Git init
authorKibum Kim <kb0929.kim@samsung.com>
Fri, 6 Jan 2012 15:48:08 +0000 (00:48 +0900)
committerKibum Kim <kb0929.kim@samsung.com>
Fri, 6 Jan 2012 15:48:08 +0000 (00:48 +0900)
304 files changed:
CMakeLists.txt [new file with mode: 0644]
COPYING [new file with mode: 0644]
LICENSE [new file with mode: 0644]
TC/_export_env.sh [new file with mode: 0755]
TC/build.sh [new file with mode: 0755]
TC/execute.sh [new file with mode: 0755]
TC/making_new_tet_scen.py [new file with mode: 0755]
TC/tet_scen [new file with mode: 0644]
TC/tetbuild.cfg [new file with mode: 0644]
TC/tetclean.cfg [new file with mode: 0644]
TC/tetexec.cfg [new file with mode: 0644]
TC/tslist.txt [new file with mode: 0644]
TC/utc/audio/Makefile [new file with mode: 0755]
TC/utc/audio/legend.sub [new file with mode: 0755]
TC/utc/audio/tslist [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_add_item_to_playlist_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_add_item_to_playlist_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_add_playlist_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_add_playlist_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_check_duplicate_insertion_in_playlist_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_check_duplicate_insertion_in_playlist_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_check_item_exist_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_check_item_exist_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_close_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_close_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_common.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_common.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_count_group_item_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_count_group_item_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_count_list_item_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_count_list_item_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_count_playlist_by_name_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_count_playlist_by_name_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_count_playlist_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_count_playlist_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_create_table_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_create_table_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_delete_all_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_delete_all_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_delete_invalid_items_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_delete_invalid_items_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_delete_item_by_path_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_delete_item_by_path_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_delete_playlist_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_delete_playlist_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_group_item_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_group_item_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_item_by_audio_id_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_item_by_audio_id_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_item_by_path_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_item_by_path_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_list_item_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_list_item_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_path_by_audio_id_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_path_by_audio_id_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_playlist_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_playlist_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_playlist_id_by_playlist_name_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_playlist_id_by_playlist_name_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_playlist_name_by_playlist_id_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_playlist_name_by_playlist_id_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_unique_playlist_name_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_get_unique_playlist_name_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_insert_item_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_insert_item_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_item_free_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_item_free_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_item_get_val_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_item_get_val_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_item_new_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_item_new_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_list_item_free_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_list_item_free_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_list_item_get_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_list_item_get_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_list_item_get_val_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_list_item_get_val_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_list_item_new_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_list_item_new_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_move_item_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_move_item_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_open_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_open_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_playlist_free_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_playlist_free_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_playlist_get_item_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_playlist_get_item_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_playlist_get_val_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_playlist_get_val_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_playlist_new_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_playlist_new_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_playlist_set_val_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_playlist_set_val_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_refresh_metadata_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_refresh_metadata_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_remove_item_from_playlist_by_audio_id_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_remove_item_from_playlist_by_audio_id_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_set_db_valid_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_set_db_valid_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_set_item_valid_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_set_item_valid_func.h [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_update_playlist_name_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_update_playlist_name_func.h [new file with mode: 0755]
TC/utc/visual/Makefile [new file with mode: 0644]
TC/utc/visual/tslist [new file with mode: 0644]
TC/utc/visual/utc_minfo_add_bookmark_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_add_bookmark_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_add_cluster_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_add_cluster_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_add_media_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_add_media_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_bookmark_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_bookmark_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_cluster_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_cluster_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_copy_media_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_copy_media_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_cp_media_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_cp_media_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_delete_bookmark_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_delete_bookmark_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_delete_cluster_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_delete_cluster_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_delete_invalid_media_records_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_delete_invalid_media_records_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_delete_media_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_delete_media_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_delete_media_id_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_delete_media_id_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_destroy_mtype_item_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_destroy_mtype_item_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_finalize_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_finalize_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_all_item_list_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_all_item_list_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_bookmark_list_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_bookmark_list_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_cluster_cnt_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_cluster_cnt_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_cluster_cover_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_cluster_cover_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_cluster_fullpath_by_id_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_cluster_fullpath_by_id_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_cluster_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_cluster_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_cluster_id_by_url_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_cluster_id_by_url_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_cluster_list_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_cluster_list_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_cluster_lock_status_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_cluster_lock_status_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_cluster_name_by_id_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_cluster_name_by_id_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_geo_item_list_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_geo_item_list_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_item_cnt_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_item_cnt_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_item_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_item_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_item_list_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_item_list_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_media_list_by_tagname_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_media_list_by_tagname_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_media_path_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_media_path_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_meta_info_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_meta_info_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_tag_list_by_media_id_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_tag_list_by_media_id_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_thumb_path_for_video_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_thumb_path_for_video_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_thumb_path_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_get_thumb_path_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_init_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_init_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_media_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_media_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_move_media_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_move_media_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_mv_media_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_mv_media_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_set_cluster_lock_status_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_set_cluster_lock_status_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_set_db_valid_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_set_db_valid_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_tag_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_tag_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_update_cluster_name_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_update_cluster_name_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_update_favorite_by_media_id_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_update_favorite_by_media_id_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_update_media_favorite_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_update_media_favorite_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_update_media_name_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_update_media_name_func.h [new file with mode: 0644]
TC/utc/visual/utc_minfo_update_video_meta_info_int_func.c [new file with mode: 0644]
TC/utc/visual/utc_minfo_update_video_meta_info_int_func.h [new file with mode: 0644]
TC/utc/visual/utc_visual_svc_common.h [new file with mode: 0644]
debian/changelog [new file with mode: 0755]
debian/compat [new file with mode: 0755]
debian/control [new file with mode: 0755]
debian/copyright [new file with mode: 0755]
debian/docs [new file with mode: 0755]
debian/libmedia-service-dev.install.in [new file with mode: 0755]
debian/libmedia-service.install.in [new file with mode: 0755]
debian/rules [new file with mode: 0755]
image/SLP_MediaSvc_PG_image001.png [new file with mode: 0755]
image/SLP_MediaSvc_PG_image002.png [new file with mode: 0755]
image/SLP_MusicSVC_PG_image001.png [new file with mode: 0755]
image/SLP_MusicSVC_PG_image002.png [new file with mode: 0755]
include/SLP_AudioSvc_PG.h [new file with mode: 0755]
include/SLP_MediaSvc_PG.h [new file with mode: 0644]
include/audio-svc-error.h [new file with mode: 0755]
include/audio-svc-types.h [new file with mode: 0755]
include/audio-svc.h [new file with mode: 0755]
include/media-info-error.h [new file with mode: 0755]
include/media-info-types.h [new file with mode: 0755]
include/media-info.h [new file with mode: 0755]
include/media-svc-error.h [new file with mode: 0755]
include/media-svc.h [new file with mode: 0755]
include/minfo-api.h [new file with mode: 0755]
include/minfo-types.h [new file with mode: 0755]
libmedia-service.pc.in [new file with mode: 0755]
license [new file with mode: 0644]
md5/md5.c [new file with mode: 0644]
md5/md5.h [new file with mode: 0644]
md5/media-svc-hash.c [new file with mode: 0644]
packaging/libmedia-service.spec [new file with mode: 0644]
src/audio/audio-svc-db-utils.c [new file with mode: 0755]
src/audio/audio-svc-music-table.c [new file with mode: 0755]
src/audio/audio-svc-playlist-table.c [new file with mode: 0755]
src/audio/audio-svc-ta.c [new file with mode: 0755]
src/audio/audio-svc-utils.c [new file with mode: 0755]
src/audio/audio-svc.c [new file with mode: 0755]
src/common/media-info-debug.c [new file with mode: 0755]
src/common/media-info-util.c [new file with mode: 0755]
src/common/media-info.c [new file with mode: 0755]
src/include/audio/audio-svc-db-utils.h [new file with mode: 0755]
src/include/audio/audio-svc-debug.h [new file with mode: 0755]
src/include/audio/audio-svc-music-table.h [new file with mode: 0755]
src/include/audio/audio-svc-playlist-table.h [new file with mode: 0755]
src/include/audio/audio-svc-ta.h [new file with mode: 0755]
src/include/audio/audio-svc-types-priv.h [new file with mode: 0755]
src/include/audio/audio-svc-utils.h [new file with mode: 0755]
src/include/audio/md5_hash.h [new file with mode: 0755]
src/include/common/media-info-debug.h [new file with mode: 0755]
src/include/common/media-info-env.h [new file with mode: 0755]
src/include/common/media-info-util.h [new file with mode: 0755]
src/include/visual/AGifFrameInfo.h [new file with mode: 0644]
src/include/visual/IfegDecodeAGIF.h [new file with mode: 0644]
src/include/visual/media-img-codec-agif.h [new file with mode: 0644]
src/include/visual/media-img-codec-common.h [new file with mode: 0644]
src/include/visual/media-img-codec-config.h [new file with mode: 0644]
src/include/visual/media-img-codec-osal.h [new file with mode: 0644]
src/include/visual/media-img-codec-parser.h [new file with mode: 0644]
src/include/visual/media-img-codec.h [new file with mode: 0644]
src/include/visual/media-svc-api.h [new file with mode: 0755]
src/include/visual/media-svc-db-util.h [new file with mode: 0755]
src/include/visual/media-svc-db.h [new file with mode: 0755]
src/include/visual/media-svc-debug.h [new file with mode: 0755]
src/include/visual/media-svc-structures.h [new file with mode: 0755]
src/include/visual/media-svc-thumb.h [new file with mode: 0755]
src/include/visual/media-svc-util.h [new file with mode: 0755]
src/include/visual/minfo-bookmark.h [new file with mode: 0755]
src/include/visual/minfo-cluster.h [new file with mode: 0755]
src/include/visual/minfo-item.h [new file with mode: 0755]
src/include/visual/minfo-meta.h [new file with mode: 0755]
src/include/visual/minfo-streaming.h [new file with mode: 0755]
src/include/visual/minfo-tag.h [new file with mode: 0755]
src/visual/IfegDecodeAGIF.c [new file with mode: 0644]
src/visual/media-img-codec-osal.c [new file with mode: 0644]
src/visual/media-img-codec-parser.c [new file with mode: 0644]
src/visual/media-img-codec.c [new file with mode: 0755]
src/visual/media-svc-api.c [new file with mode: 0755]
src/visual/media-svc-db-util.c [new file with mode: 0755]
src/visual/media-svc-db.c [new file with mode: 0755]
src/visual/media-svc-thumb.c [new file with mode: 0755]
src/visual/media-svc-util.c [new file with mode: 0755]
src/visual/minfo-api.c [new file with mode: 0755]
src/visual/minfo-bookmark.c [new file with mode: 0755]
src/visual/minfo-cluster.c [new file with mode: 0755]
src/visual/minfo-item.c [new file with mode: 0755]
src/visual/minfo-meta.c [new file with mode: 0755]
src/visual/minfo-streaming.c [new file with mode: 0755]
src/visual/minfo-tag.c [new file with mode: 0755]
test/audio/Makefile [new file with mode: 0644]
test/audio/audio_svc_test.c [new file with mode: 0755]
test/test_media_info.c [new file with mode: 0755]
test/test_visual.c [new file with mode: 0755]
uuid/COPYING [new file with mode: 0644]
uuid/clear.c [new file with mode: 0644]
uuid/compare.c [new file with mode: 0644]
uuid/copy.c [new file with mode: 0644]
uuid/gen_uuid.c [new file with mode: 0644]
uuid/isnull.c [new file with mode: 0644]
uuid/pack.c [new file with mode: 0644]
uuid/parse.c [new file with mode: 0644]
uuid/unpack.c [new file with mode: 0644]
uuid/unparse.c [new file with mode: 0644]
uuid/uuid.h [new file with mode: 0644]
uuid/uuidP.h [new file with mode: 0644]
uuid/uuid_time.c [new file with mode: 0644]
uuid/uuid_types.h [new file with mode: 0644]
uuid/uuidd.h [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..91e7c52
--- /dev/null
@@ -0,0 +1,149 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(media-service C)
+SET(VERSION_MAJOR 1)
+SET(VERSION "${VERSION_MAJOR}.0.0")
+
+SET(MEDIASERVICE-LIB "media-service")
+SET(MEDIASERVICE-HASH-LIB "media-svc-hash")
+SET(SRCS 
+       src/visual/media-svc-db.c
+       src/visual/media-svc-db-util.c
+       src/visual/media-svc-util.c
+       src/visual/media-svc-api.c
+       src/visual/media-svc-thumb.c   
+    
+       src/visual/IfegDecodeAGIF.c
+       src/visual/media-img-codec.c
+       src/visual/media-img-codec-osal.c
+       src/visual/media-img-codec-parser.c
+
+       src/visual/minfo-item.c 
+       src/visual/minfo-tag.c
+       src/visual/minfo-cluster.c
+       src/visual//minfo-bookmark.c
+       src/visual/minfo-streaming.c
+       src/visual/minfo-meta.c
+       src/visual/minfo-api.c
+
+       src/audio/audio-svc-music-table.c
+       src/audio/audio-svc-playlist-table.c
+       src/audio/audio-svc-ta.c
+       src/audio/audio-svc-utils.c
+       src/audio/audio-svc-db-utils.c
+       src/audio/audio-svc.c
+
+       uuid/clear.c
+       uuid/compare.c
+       uuid/copy.c
+       uuid/gen_uuid.c
+       uuid/isnull.c
+       uuid/pack.c
+       uuid/parse.c
+       uuid/unpack.c
+       uuid/unparse.c
+       uuid/uuid_time.c
+
+       src/common/media-info.c
+       src/common/media-info-util.c
+       src/common/media-info-debug.c   
+       )
+
+SET(HASH_SRCS
+       md5/md5.c
+       md5/media-svc-hash.c
+       )
+
+SET(TEST-SRCS test/test_media_info.c)
+SET(TEST-AUDIO-SRCS test/audio/audio_svc_test.c)
+SET(TEST-VISUAL-SRCS test/test_visual.c)
+
+SET(VENDOR "samsung")
+SET(PACKAGE ${PROJECT_NAME})
+SET(PKGNAME "com.${VENDOR}.${PACKAGE}")
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(BINDIR "${PREFIX}/bin")
+SET(DATADIR "${PREFIX}/share")
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include")
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src/include/visual ${CMAKE_SOURCE_DIR}/src/include/audio ${CMAKE_SOURCE_DIR}/src/include/common ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/uuid ${CMAKE_SOURCE_DIR}/md5)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED 
+glib-2.0 gobject-2.0 libpng libpng12 gio-2.0 gio-unix-2.0 
+dlog sqlite3 db-util mm-common  mm-fileinfo drm-service aul
+libexif gthread-2.0 vconf ecore-evas evas mmutil-imgp mmutil-jpeg dbus-1)
+
+
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2 -fPIC")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
+ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+#ADD_DEFINITIONS("-D_PERFORMANCE_CHECK_")
+#ADD_DEFINITIONS("-D_USE_LOG_FILE_")
+#ADD_DEFINITIONS("-D_USE_DBUS_")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--hash-style=both")
+CONFIGURE_FILE(libmedia-service.pc.in libmedia-service.pc @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libmedia-service.pc DESTINATION lib/pkgconfig)
+
+LINK_DIRECTORIES(lib)
+
+ADD_LIBRARY(${MEDIASERVICE-HASH-LIB} SHARED ${HASH_SRCS})
+SET_TARGET_PROPERTIES(${MEDIASERVICE-HASH-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${MEDIASERVICE-HASH-LIB} PROPERTIES VERSION ${VERSION})
+ADD_LIBRARY(${MEDIASERVICE-LIB} SHARED ${SRCS}) 
+TARGET_LINK_LIBRARIES(${MEDIASERVICE-LIB} ${pkgs_LDFLAGS} ${MEDIASERVICE-HASH-LIB} z Xrender X11 xcb expat Xau Xdmcp)
+SET_TARGET_PROPERTIES(${MEDIASERVICE-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${MEDIASERVICE-LIB} PROPERTIES VERSION ${VERSION})
+
+INSTALL(TARGETS ${MEDIASERVICE-LIB} LIBRARY DESTINATION lib)
+INSTALL(TARGETS ${MEDIASERVICE-HASH-LIB} LIBRARY DESTINATION lib)
+
+#ADD_EXECUTABLE( media_service_test ${TEST-SRCS})
+#TARGET_LINK_LIBRARIES(media_service_test ${pkgs_LDFLAGS} ${MEDIASERVICE-LIB} )
+#INSTALL(TARGETS media_service_test DESTINATION ${BINDIR})
+
+#ADD_EXECUTABLE( visual_test ${TEST-VISUAL-SRCS})
+#TARGET_LINK_LIBRARIES(visual_test ${pkgs_LDFLAGS} ${MEDIASERVICE-LIB} )
+#INSTALL(TARGETS visual_test DESTINATION ${BINDIR})
+
+#ADD_EXECUTABLE( audio_test ${TEST-AUDIO-SRCS})
+#TARGET_LINK_LIBRARIES(audio_test ${pkgs_LDFLAGS} ${MEDIASERVICE-LIB} )
+#INSTALL(TARGETS audio_test DESTINATION ${BINDIR})
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-svc.h DESTINATION include/media-service)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-svc-error.h DESTINATION include/media-service)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/minfo-api.h DESTINATION include/media-service/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/minfo-types.h DESTINATION include/media-service/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/audio-svc-error.h DESTINATION include/media-service)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/audio-svc.h DESTINATION include/media-service/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/audio-svc-types.h DESTINATION include/media-service/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-info.h DESTINATION include/media-service/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-info-error.h DESTINATION include/media-service/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-info-types.h DESTINATION include/media-service/)
+
+#INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/image/thumb_default.png DESTINATION /opt/data/gallery-beat)
+
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..8add30a
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,504 @@
+                 GNU LESSER GENERAL PUBLIC LICENSE
+                      Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+\f
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+\f
+                 GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+\f
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+\f
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+\f
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+\f
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+\f
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                           NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+\f
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..a06208b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,204 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
diff --git a/TC/_export_env.sh b/TC/_export_env.sh
new file mode 100755 (executable)
index 0000000..56e2167
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+export ARCH=target
+
+export TET_INSTALL_PATH=/usr/bin/tetware/TETware  # tetware root path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+
+export TET_ROOT=$TET_TARGET_PATH
+
+set $(pwd)
+export TET_SUITE_ROOT=$1
+
+set $(date +%s)
+FILE_NAME_EXTENSION=$1
+
diff --git a/TC/build.sh b/TC/build.sh
new file mode 100755 (executable)
index 0000000..dc464e7
--- /dev/null
@@ -0,0 +1,18 @@
+. ./_export_env.sh                              # setting environment variables
+
+echo PATH=$PATH
+echo LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+echo TET_ROOT=$TET_ROOT
+echo TET_SUITE_ROOT=$TET_SUITE_ROOT
+echo ARCH=$ARCH
+
+RESULT_DIR=results-$ARCH
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir $RESULT_DIR
+
+tcc -c -p ./                                # executing tcc, with clean option (-c)
+tcc -b -j $JOURNAL_RESULT -p ./            # executing tcc to build test cases (-b)
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT  # reporting the result
+
diff --git a/TC/execute.sh b/TC/execute.sh
new file mode 100755 (executable)
index 0000000..9de8291
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+export ARCH=target
+
+export TET_INSTALL_PATH=/mnt/nfs/tetware/TETware  # path to mount
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+
+export TET_ROOT=$TET_TARGET_PATH
+
+set $(pwd)
+export TET_SUITE_ROOT=$1
+
+set $(date +%s)
+FILE_NAME_EXTENSION=$1
+
+echo PATH=$PATH
+echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH
+echo TET_ROOT=$TET_ROOT
+echo TET_SUITE_ROOT=$TET_SUITE_ROOT
+echo ARCH=$ARCH
+
+RESULT_DIR=results-$ARCH
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT  # reporting the result
+
diff --git a/TC/making_new_tet_scen.py b/TC/making_new_tet_scen.py
new file mode 100755 (executable)
index 0000000..6c5b845
--- /dev/null
@@ -0,0 +1,69 @@
+#!/usr/bin/python
+
+#############################################
+# tet_scen  auto generator
+#
+# ** argv[1] = TC root
+#############################################
+
+import sys,string,os
+
+
+write_file = open("tet_scen", 'w')
+
+#
+# making new tet_scen
+#
+def making_tet_scen (filename):
+       #tmp_list = filename.strip().split('/')
+       n_filename = filename.replace(' ', '\\ ')
+       #print n_filename
+       #new_path = "/"+ sys.argv[1] +"/"+n_filename[2:-6]
+       new_path = "/"+n_filename[:-6]
+       #print new_path
+       file = open(filename, 'r')
+       lines = file.readlines()
+       for line in lines:
+               if len(line.strip()) > 1:
+                       list = line.strip().split('/')
+                       #print new_path + list[-1]
+                       write_file.write("\t"+new_path+list[-1]+"\n")
+
+#
+# usage()
+#
+def usage():
+       print(" ")
+       print("./making_new_tet_scen.py tc_root")
+       print("Put the Test Case's root directory.")
+       print("Do not include '/' at the end")
+       print(" ")
+
+#
+# main()
+#
+def main():
+       if len(sys.argv) < 2:
+               usage()
+               sys.exit(0)
+               
+       os.system('find '+ sys.argv[1] +' -name "tslist" > tslist.txt')
+       
+       #write_file = open("tetscen", w)
+       write_file.write("# auto generated tet_scen\n")
+       write_file.write("all\n")
+       write_file.write("\t\"Starting Full Test Suite\"\n")
+       
+       for file in open("tslist.txt", 'r'):
+               #print file.strip()
+               making_tet_scen(file.strip())
+                       
+       write_file.write("\t\"Completed Full Test Suite\"\n")
+       write_file.write("# EOF\n")
+       write_file.close()
+       print(" ")
+       print("==============================")
+       print("New tet_scen file is made~~~~")
+       print("==============================")
+       print(" ")
+main()
diff --git a/TC/tet_scen b/TC/tet_scen
new file mode 100644 (file)
index 0000000..1771392
--- /dev/null
@@ -0,0 +1,7 @@
+# auto generated tet_scen
+all
+       "Starting Full Test Suite"
+       :include:/utc/audio/tslist
+       :include:/utc/visual/tslist
+       "Completed Full Test Suite"
+# EOF
diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg
new file mode 100644 (file)
index 0000000..f7eda55
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option for build operation checking
+TET_BUILD_TOOL=make # build with using make command
+TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build
+TET_API_COMPLIANT=True # use TET API in Test Case ?
+TET_PASS_TC_NAME=True # report passed TC name in Journal file?
diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg
new file mode 100644 (file)
index 0000000..02d7030
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option
+TET_CLEAN_TOOL= make clean # clean tool
+TET_CLEAN_FILE= Makefile # file for clean
+TET_API_COMPLIANT=True # TET API useage 
+TET_PASS_TC_NAME=True # showing name , passed TC
diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg
new file mode 100644 (file)
index 0000000..ef3e452
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capturing execution or not
+TET_EXEC_TOOL=  # ex) exec : execution tool set up/ Optional
+TET_EXEC_FILE=   # ex) exectool : execution file/ Optional
+TET_API_COMPLIANT=True # Test case or Tool usesTET API?
+TET_PASS_TC_NAME=True # showing Passed TC name ?
diff --git a/TC/tslist.txt b/TC/tslist.txt
new file mode 100644 (file)
index 0000000..da39889
--- /dev/null
@@ -0,0 +1,2 @@
+utc/audio/tslist
+utc/visual/tslist
diff --git a/TC/utc/audio/Makefile b/TC/utc/audio/Makefile
new file mode 100755 (executable)
index 0000000..1342188
--- /dev/null
@@ -0,0 +1,270 @@
+ifeq ($(ARCH),target)\r
+       PKG_CONFIG_PATH=/usr/lib/pkgconfig\r
+       export PKG_CONFIG_PATH\r
+       CC=arm-linux-gcc -Wall\r
+       CXX=arm-linux-g++ -Wall\r
+else\r
+       PKG_CONFIG_PATH=/usr/lib/pkgconfig\r
+       export PKG_CONFIG_PATH\r
+       CC=gcc -Wall\r
+    CXX=gcc -Wall\r
+endif\r
+\r
+TS1=utc_audio_svc_add_item_to_playlist_func\r
+TS2=utc_audio_svc_add_playlist_func\r
+TS3=utc_audio_svc_check_duplicate_insertion_in_playlist_func\r
+TS4=utc_audio_svc_close_func\r
+TS5=utc_audio_svc_get_playlist_func\r
+TS7=utc_audio_svc_count_group_item_func\r
+TS8=utc_audio_svc_count_list_item_func\r
+TS9=utc_audio_svc_count_playlist_by_name_func\r
+TS10=utc_audio_svc_count_playlist_func\r
+TS11=utc_audio_svc_create_table_func\r
+TS12=utc_audio_svc_delete_all_func\r
+TS15=utc_audio_svc_delete_playlist_func\r
+TS17=utc_audio_svc_get_group_item_func\r
+TS18=utc_audio_svc_get_item_by_audio_id_func\r
+TS19=utc_audio_svc_get_item_by_path_func\r
+TS20=utc_audio_svc_get_list_item_func\r
+TS21=utc_audio_svc_get_playlist_name_by_playlist_id_func\r
+TS22=utc_audio_svc_get_unique_playlist_name_func\r
+TS23=utc_audio_svc_insert_item_func\r
+TS25=utc_audio_svc_item_free_func\r
+TS26=utc_audio_svc_item_get_val_func\r
+TS27=utc_audio_svc_item_new_func\r
+TS29=utc_audio_svc_list_item_free_func\r
+TS30=utc_audio_svc_list_item_get_func\r
+TS31=utc_audio_svc_list_item_get_val_func\r
+TS32=utc_audio_svc_list_item_new_func\r
+TS34=utc_audio_svc_move_item_func\r
+TS35=utc_audio_svc_open_func\r
+TS36=utc_audio_svc_playlist_free_func\r
+TS37=utc_audio_svc_playlist_get_item_func\r
+TS38=utc_audio_svc_playlist_get_val_func\r
+TS39=utc_audio_svc_playlist_new_func\r
+TS40=utc_audio_svc_playlist_set_val_func\r
+TS41=utc_audio_svc_refresh_metadata_func\r
+TS42=utc_audio_svc_remove_item_from_playlist_by_audio_id_func\r
+TS43=utc_audio_svc_set_db_valid_func\r
+TS44=utc_audio_svc_set_item_valid_func\r
+TS48=utc_audio_svc_update_playlist_name_func\r
+TS50=utc_audio_svc_get_path_by_audio_id_func\r
+TS51=utc_audio_svc_delete_item_by_path_func\r
+TS55=utc_audio_svc_delete_invalid_items_func\r
+TS56=utc_audio_svc_check_item_exist_func\r
+TS57=utc_audio_svc_get_playlist_id_by_playlist_name_func\r
+\r
+LIBS = `pkg-config --libs libmedia-info`\r
+LIBS +=-L/usr/lib/:/usr/lib/pkgconfig\r
+LIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o\r
+LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s\r
+LIBS +=-L$(TET_ROOT)/lib/tet3/ -lapi_s\r
+LIBS +=utc_audio_svc_common.o\r
+\r
+INCS = -I. `pkg-config --cflags  libmedia-info`\r
+INCS += -I$(TET_ROOT)/inc/tet3\r
+INCS += -I/usr/include\r
+\r
+CFLAGS = $(INCS)\r
+CC += $(CFLAGS)\r
+LDFLAGS = $(LIBS)\r
+\r
+TCLIST = $(TS1) $(TS2) $(TS3) $(TS4) $(TS5) $(TS7) $(TS8) $(TS9) $(TS10) $(TS11) $(TS12) $(TS15) $(TS17) $(TS18) $(TS19) $(TS20) $(TS21) $(TS22) $(TS23) $(TS25) $(TS26) $(TS27) $(TS29) $(TS30) $(TS31) $(TS32) $(TS34) $(TS35) $(TS36) $(TS37) $(TS38) $(TS39) $(TS40) $(TS41) $(TS42) $(TS43) $(TS44) $(TS48) $(TS50) $(TS51) $(TS55) $(TS56) $(TS57)\r
+\r
+#utc_audio_svc_common :\r
+#      $(CC) -c utc_audio_svc_common.c\r
+\r
+all :\r
+       $(CC) -c utc_audio_svc_common.c\r
+       for testcase in $(TCLIST) ; do \\r
+               $(CC) -o $$testcase $(UTIL_SRC) $$testcase.c  $(LDFLAGS) ; \\r
+       done\r
+\r
+utc_audio_svc_common :\r
+       $(CC) -c utc_audio_svc_common.c\r
+\r
+$(TS1): $(TS1).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS1) $(TS1).c $(LDFLAGS)\r
+\r
+$(TS2): $(TS2).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS2) $(TS2).c $(LDFLAGS)\r
+\r
+$(TS3): $(TS3).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS3) $(TS3).c $(LDFLAGS)\r
+\r
+$(TS4): $(TS4).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS4) $(TS4).c $(LDFLAGS)\r
+\r
+$(TS5): $(TS5).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS5) $(TS5).c $(LDFLAGS)\r
+\r
+$(TS7): $(TS7).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS7) $(TS7).c $(LDFLAGS)\r
+\r
+$(TS8): $(TS8).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS8) $(TS8).c $(LDFLAGS)\r
+\r
+$(TS9): $(TS9).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS9) $(TS9).c $(LDFLAGS)\r
+\r
+$(TS10): $(TS10).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS10) $(TS10).c $(LDFLAGS)\r
+\r
+$(TS11): $(TS11).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS11) $(TS11).c $(LDFLAGS)\r
+\r
+$(TS12): $(TS12).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS12) $(TS12).c $(LDFLAGS)\r
+\r
+$(TS15): $(TS15).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS15) $(TS15).c $(LDFLAGS)\r
+\r
+$(TS17): $(TS17).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS17) $(TS17).c $(LDFLAGS)\r
+\r
+$(TS18): $(TS18).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS18) $(TS18).c $(LDFLAGS)\r
+\r
+$(TS19): $(TS19).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS19) $(TS19).c $(LDFLAGS)\r
+\r
+$(TS20): $(TS20).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS20) $(TS20).c $(LDFLAGS)\r
+\r
+$(TS21): $(TS21).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS21) $(TS21).c $(LDFLAGS)\r
+\r
+$(TS22): $(TS22).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS22) $(TS22).c $(LDFLAGS)\r
+\r
+$(TS23): $(TS23).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS23) $(TS23).c $(LDFLAGS)\r
+\r
+$(TS25): $(TS25).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS25) $(TS25).c $(LDFLAGS)\r
+\r
+$(TS26): $(TS26).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS26) $(TS26).c $(LDFLAGS)\r
+\r
+$(TS27): $(TS27).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS27) $(TS27).c $(LDFLAGS)\r
+\r
+$(TS29): $(TS29).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS29) $(TS29).c $(LDFLAGS)\r
+\r
+$(TS30): $(TS30).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS30) $(TS30).c $(LDFLAGS)\r
+\r
+$(TS31): $(TS31).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS31) $(TS31).c $(LDFLAGS)\r
+\r
+$(TS32): $(TS32).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS32) $(TS32).c $(LDFLAGS)\r
+\r
+$(TS34): $(TS34).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS34) $(TS34).c $(LDFLAGS)\r
+\r
+$(TS35): $(TS35).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS35) $(TS35).c $(LDFLAGS)\r
+\r
+$(TS36): $(TS36).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS36) $(TS36).c $(LDFLAGS)\r
+\r
+$(TS37): $(TS37).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS37) $(TS37).c $(LDFLAGS)\r
+\r
+$(TS38): $(TS38).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS38) $(TS38).c $(LDFLAGS)\r
+\r
+$(TS39): $(TS39).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS39) $(TS39).c $(LDFLAGS)\r
+\r
+$(TS40): $(TS40).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS40) $(TS40).c $(LDFLAGS)\r
+\r
+$(TS41): $(TS41).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS41) $(TS41).c $(LDFLAGS)\r
+\r
+$(TS42): $(TS42).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS42) $(TS42).c $(LDFLAGS)\r
+\r
+$(TS43): $(TS43).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS43) $(TS43).c $(LDFLAGS)\r
+\r
+$(TS44): $(TS44).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS44) $(TS44).c $(LDFLAGS)\r
+\r
+$(TS48): $(TS48).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS48) $(TS48).c $(LDFLAGS)\r
+\r
+$(TS50): $(TS50).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS50) $(TS50).c $(LDFLAGS)\r
+\r
+$(TS51): $(TS51).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS51) $(TS51).c $(LDFLAGS)\r
+\r
+$(TS55): $(TS55).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS55) $(TS55).c $(LDFLAGS)\r
+\r
+$(TS56): $(TS56).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS56) $(TS56).c $(LDFLAGS)\r
+\r
+$(TS57): $(TS57).c\r
+               $(CC) -c utc_audio_svc_common.c\r
+               $(CC) -o $(TS57) $(TS57).c $(LDFLAGS)\r
+\r
+clean :\r
+       rm -rf *~ *.o $(TCLIST)\r
+\r
+\r
+\r
+clean :\r
+       rm -rf *~ *.o $(TCLIST)\r
+\r
+\r
+clean :\r
+       rm -rf *~ *.o $(TCLIST)\r
+\r
+\r
diff --git a/TC/utc/audio/legend.sub b/TC/utc/audio/legend.sub
new file mode 100755 (executable)
index 0000000..76c392c
--- /dev/null
@@ -0,0 +1,2986 @@
+1\r
+00:00:01,838 --> 00:00:03,005\r
+<i>Richard Cypher,</i>\r
+\r
+2\r
+00:00:03,006 --> 00:00:05,474\r
+<i>you are the true Seeker.</i>\r
+\r
+3\r
+00:00:07,510 --> 00:00:14,510\r
+<font color=#7FFF00> Legend of the Seeker 2x09</font>\r
+<font color=#FFFF00>Dark</font>\r
+Original Air Date on January 23, 2010\r
+\r
+4\r
+00:00:14,511 --> 00:00:19,811\r
+-- Sync, corrected by <font color=#00FF00>elderman</font> --\r
+-- <font color=#00FFFF>for addic7ed.com</font> --\r
+\r
+5\r
+00:00:29,745 --> 00:00:33,015\r
+Welcome to the Palace\r
+of the Prophets.\r
+\r
+6\r
+00:00:33,016 --> 00:00:35,168\r
+It's beautiful.\r
+\r
+7\r
+00:00:35,169 --> 00:00:37,534\r
+I searched for you\r
+for 24 years, Richard.\r
+\r
+8\r
+00:00:38,235 --> 00:00:42,798\r
+To bring you here, to my home,\r
+to be trained as a Wizard.\r
+\r
+9\r
+00:00:42,799 --> 00:00:45,319\r
+So often I thought this day\r
+would never come.\r
+\r
+10\r
+00:00:48,134 --> 00:00:51,185\r
+Well, at least we arrived before\r
+you turned me completely gray.\r
+\r
+11\r
+00:00:55,815 --> 00:00:56,920\r
+Another headache?\r
+\r
+12\r
+00:00:58,365 --> 00:01:00,708\r
+Once you're inside the palace\r
+walls the pain will go away.\r
+\r
+13\r
+00:01:00,709 --> 00:01:02,551\r
+How?\r
+\r
+14\r
+00:01:02,552 --> 00:01:04,594\r
+The palace is spelled\r
+to carry the burden\r
+\r
+15\r
+00:01:04,595 --> 00:01:07,238\r
+that young Wizards\r
+can't yet carry themselves.\r
+\r
+16\r
+00:01:07,239 --> 00:01:09,418\r
+Well, the quicker I learn\r
+to handle it on my own,\r
+\r
+17\r
+00:01:09,419 --> 00:01:11,023\r
+the quicker I can get back\r
+to my quest.\r
+\r
+18\r
+00:01:11,024 --> 00:01:12,864\r
+And my friends.\r
+\r
+19\r
+00:01:17,586 --> 00:01:20,464\r
+Where there is darkness\r
+\r
+20\r
+00:01:20,465 --> 00:01:24,747\r
+Let the light shine\r
+\r
+21\r
+00:01:24,748 --> 00:01:29,129\r
+Where there is despair\r
+\r
+22\r
+00:01:29,130 --> 00:01:32,173\r
+Let the Creator\r
+\r
+23\r
+00:01:32,174 --> 00:01:34,984\r
+Bring us hope\r
+\r
+24\r
+00:01:34,985 --> 00:01:39,298\r
+Where there is fear\r
+\r
+25\r
+00:01:39,299 --> 00:01:42,844\r
+Let the Creator\r
+\r
+26\r
+00:01:42,845 --> 00:01:46,957\r
+Inspire valor\r
+\r
+27\r
+00:01:46,958 --> 00:01:50,769\r
+Where there is loneliness\r
+\r
+28\r
+00:01:50,770 --> 00:01:53,176\r
+Let the Creator\r
+\r
+29\r
+00:01:53,177 --> 00:01:55,349\r
+Sow friendship\r
+\r
+30\r
+00:01:55,350 --> 00:01:56,285\r
+Verna.\r
+\r
+31\r
+00:01:59,965 --> 00:02:02,270\r
+Welcome home.\r
+\r
+32\r
+00:02:02,271 --> 00:02:04,376\r
+And you must be Richard.\r
+\r
+33\r
+00:02:04,377 --> 00:02:05,714\r
+Richard, this is\r
+\r
+34\r
+00:02:05,715 --> 00:02:07,787\r
+Annalina Aldurren,\r
+the Prelate,\r
+\r
+35\r
+00:02:07,788 --> 00:02:10,393\r
+our spiritual leader.\r
+\r
+36\r
+00:02:10,394 --> 00:02:13,101\r
+We have waited\r
+so long to meet you.\r
+\r
+37\r
+00:02:13,102 --> 00:02:15,039\r
+Welcome to the Palace\r
+of the Prophets.\r
+\r
+38\r
+00:02:15,040 --> 00:02:16,242\r
+Thank you.\r
+\r
+39\r
+00:02:16,243 --> 00:02:22,024\r
+We'll speak later.\r
+After devotions, yes?\r
+\r
+40\r
+00:02:22,025 --> 00:02:26,301\r
+â\99ª Strengthen me, O Creator Ã¢\99ª\r
+\r
+41\r
+00:02:26,302 --> 00:02:31,616\r
+â\99ª To defend your light Ã¢\99ª\r
+\r
+42\r
+00:02:36,361 --> 00:02:38,566\r
+Into the warmth\r
+of the Creator's light.\r
+\r
+43\r
+00:02:38,567 --> 00:02:40,538\r
+Please rise.\r
+\r
+44\r
+00:02:45,651 --> 00:02:46,585\r
+Sister Brenna?\r
+\r
+45\r
+00:03:02,557 --> 00:03:05,060\r
+Sister Brenna's weak heart\r
+finally gave out,\r
+\r
+46\r
+00:03:05,061 --> 00:03:07,933\r
+but the radiant look\r
+of peace on her face\r
+\r
+47\r
+00:03:07,934 --> 00:03:12,643\r
+can only mean\r
+she is with the Creator now.\r
+\r
+48\r
+00:03:14,347 --> 00:03:16,718\r
+Thank you, Sister Nicci.\r
+\r
+49\r
+00:03:16,719 --> 00:03:18,388\r
+Could you please prepare\r
+the funeral pyre?\r
+\r
+50\r
+00:03:18,389 --> 00:03:19,356\r
+Yes, Prelate.\r
+\r
+51\r
+00:03:25,772 --> 00:03:27,573\r
+Prelate,\r
+\r
+52\r
+00:03:27,574 --> 00:03:31,112\r
+may I leave Sister Brenna's\r
+hymn book with her?\r
+\r
+53\r
+00:03:31,113 --> 00:03:32,949\r
+She loved it so.\r
+\r
+54\r
+00:03:32,950 --> 00:03:35,086\r
+Of course, Sister Ulicia.\r
+\r
+55\r
+00:03:42,035 --> 00:03:45,541\r
+This rash.\r
+I've seen it before.\r
+\r
+56\r
+00:03:45,542 --> 00:03:47,647\r
+It's caused by a deadly poison\r
+from a rare vine\r
+\r
+57\r
+00:03:47,648 --> 00:03:48,649\r
+called creeping elder.\r
+\r
+58\r
+00:03:48,650 --> 00:03:50,552\r
+Sisters, please excuse us.\r
+\r
+59\r
+00:03:53,659 --> 00:03:55,128\r
+I should have known\r
+better than to try\r
+\r
+60\r
+00:03:55,129 --> 00:03:57,231\r
+and keep the Seeker of Truth\r
+in the dark.\r
+\r
+61\r
+00:03:57,232 --> 00:04:00,237\r
+I think Sister Brenna\r
+took her own life.\r
+\r
+62\r
+00:04:01,808 --> 00:04:03,644\r
+Perhaps with that poison\r
+you mentioned.\r
+\r
+63\r
+00:04:03,645 --> 00:04:05,513\r
+Why would she do\r
+such a thing?\r
+\r
+64\r
+00:04:05,514 --> 00:04:08,382\r
+Many months ago\r
+I sent Sister Brenna\r
+\r
+65\r
+00:04:08,383 --> 00:04:10,049\r
+on a service mission.\r
+\r
+66\r
+00:04:10,050 --> 00:04:13,251\r
+When she returned, she said\r
+that during her time away\r
+\r
+67\r
+00:04:13,252 --> 00:04:14,752\r
+she'd become\r
+troubled in her heart.\r
+\r
+68\r
+00:04:14,753 --> 00:04:19,388\r
+She witnessed fear,\r
+sickness, famine.\r
+\r
+69\r
+00:04:19,389 --> 00:04:20,722\r
+"Starving children can't survive\r
+\r
+70\r
+00:04:20,723 --> 00:04:22,090\r
+on the Creator's light,\r
+Prelate."\r
+\r
+71\r
+00:04:22,091 --> 00:04:23,024\r
+That's what she told me.\r
+\r
+72\r
+00:04:24,493 --> 00:04:26,860\r
+I was afraid she might\r
+do something like this.\r
+\r
+73\r
+00:04:26,861 --> 00:04:29,229\r
+Then why did you tell everyone\r
+her heart gave out?\r
+\r
+74\r
+00:04:29,230 --> 00:04:30,863\r
+The Sisters of the Light\r
+\r
+75\r
+00:04:30,864 --> 00:04:33,064\r
+believe suicide is an offense\r
+to the Creator.\r
+\r
+76\r
+00:04:33,065 --> 00:04:35,701\r
+I didn't want to dishonor her\r
+in front of the others.\r
+\r
+77\r
+00:04:35,702 --> 00:04:37,736\r
+How can you be sure\r
+someone didn't poison her?\r
+\r
+78\r
+00:04:37,737 --> 00:04:39,937\r
+Richard, you heard\r
+what the Prelate said.\r
+\r
+79\r
+00:04:39,938 --> 00:04:41,139\r
+Brenna wasn't well.\r
+\r
+80\r
+00:04:41,140 --> 00:04:42,907\r
+Why would she kill herself\r
+during devotions?\r
+\r
+81\r
+00:04:42,908 --> 00:04:45,276\r
+As opposed to what?\r
+Killing herself during teatime?\r
+\r
+82\r
+00:04:45,277 --> 00:04:46,846\r
+You've both had such\r
+a long journey.\r
+\r
+83\r
+00:04:46,846 --> 00:04:51,949\r
+Verna, why don't you show\r
+Richard to his quarters.\r
+\r
+84\r
+00:04:51,950 --> 00:04:55,019\r
+Your Wizard training\r
+can begin in the morning.\r
+\r
+85\r
+00:04:58,958 --> 00:05:01,392\r
+Has a Sister ever taken her life\r
+at the palace before?\r
+\r
+86\r
+00:05:01,393 --> 00:05:04,262\r
+Verna Sauventreen.\r
+\r
+87\r
+00:05:04,263 --> 00:05:07,597\r
+Sister Philomena.\r
+Welcome back, welcome back.\r
+\r
+88\r
+00:05:07,598 --> 00:05:10,133\r
+And you must be our new Wizard.\r
+\r
+89\r
+00:05:10,134 --> 00:05:11,200\r
+How terribly exciting.\r
+\r
+90\r
+00:05:11,201 --> 00:05:12,501\r
+I'm not really a Wizard--\r
+\r
+91\r
+00:05:13,869 --> 00:05:15,303\r
+Oh, forgive me.\r
+\r
+92\r
+00:05:15,304 --> 00:05:16,737\r
+I saw you put your hands up\r
+\r
+93\r
+00:05:16,738 --> 00:05:19,873\r
+and thought you were going\r
+to blast me with Wizard's Fire.\r
+\r
+94\r
+00:05:24,545 --> 00:05:25,777\r
+Are you all right?\r
+\r
+95\r
+00:05:25,778 --> 00:05:28,146\r
+We have so much to catch up on.\r
+\r
+96\r
+00:05:28,147 --> 00:05:29,780\r
+Trust no one.\r
+Yes, I'm sure we do.\r
+\r
+97\r
+00:05:29,781 --> 00:05:32,148\r
+meet me tonight when moonbeams\r
+flood the sanctuary.\r
+\r
+98\r
+00:05:32,149 --> 00:05:33,650\r
+It was-- It was good to see you.\r
+\r
+99\r
+00:05:33,651 --> 00:05:34,984\r
+Uh, Richard?\r
+\r
+100\r
+00:05:34,985 --> 00:05:37,152\r
+how unfortunate that just as you\r
+return from one mission\r
+\r
+101\r
+00:05:37,153 --> 00:05:39,119\r
+in the New World,\r
+I'm setting off on another.\r
+\r
+102\r
+00:05:39,120 --> 00:05:40,921\r
+So many poor souls\r
+\r
+103\r
+00:05:40,922 --> 00:05:42,888\r
+in need of the Creator's light,\r
+you know.\r
+\r
+104\r
+00:05:42,889 --> 00:05:45,522\r
+A sister's work is never done.\r
+\r
+105\r
+00:05:45,523 --> 00:05:46,857\r
+Speaking of a sister's work,\r
+\r
+106\r
+00:05:46,858 --> 00:05:48,825\r
+I need to see Richard\r
+to his room.\r
+\r
+107\r
+00:05:48,826 --> 00:05:51,793\r
+Young Wizard, may the Creator's\r
+light illuminate your path.\r
+\r
+108\r
+00:05:54,162 --> 00:05:56,530\r
+The Prelate's probably\r
+sending her on a mission\r
+\r
+109\r
+00:05:56,531 --> 00:05:58,031\r
+just to get rid of her.\r
+\r
+110\r
+00:05:58,032 --> 00:05:58,998\r
+Your room.\r
+\r
+111\r
+00:06:06,606 --> 00:06:09,574\r
+I'll be back in the morning\r
+to begin your training.\r
+\r
+112\r
+00:06:09,575 --> 00:06:10,908\r
+Good.\r
+\r
+113\r
+00:06:10,909 --> 00:06:12,876\r
+The sooner we start,\r
+the sooner I can get out of here\r
+\r
+114\r
+00:06:12,877 --> 00:06:13,911\r
+and get back to the New World.\r
+\r
+115\r
+00:06:31,559 --> 00:06:33,426\r
+Is something wrong?\r
+\r
+116\r
+00:06:37,163 --> 00:06:38,530\r
+I miss Richard.\r
+\r
+117\r
+00:06:38,531 --> 00:06:39,698\r
+Why?\r
+\r
+118\r
+00:06:43,835 --> 00:06:48,505\r
+Because I love him and I'm not\r
+used to being apart from him.\r
+\r
+119\r
+00:06:48,506 --> 00:06:51,541\r
+It's not necessary to feel\r
+pain over his absence.\r
+\r
+120\r
+00:06:53,343 --> 00:06:54,743\r
+Don't you feel anything?\r
+\r
+121\r
+00:06:58,981 --> 00:07:01,615\r
+Mord-Sith believe emotions\r
+must be governed.\r
+\r
+122\r
+00:07:01,616 --> 00:07:06,119\r
+Sadness, remorse, love...\r
+These feelings make you weak.\r
+\r
+123\r
+00:07:06,120 --> 00:07:11,790\r
+But anger, loyalty, pride?\r
+\r
+124\r
+00:07:11,791 --> 00:07:13,992\r
+These feelings\r
+make you powerful.\r
+\r
+125\r
+00:07:13,993 --> 00:07:17,828\r
+I can teach you how to control\r
+your emotions, if you like.\r
+\r
+126\r
+00:07:17,829 --> 00:07:21,031\r
+I'm not sure love\r
+makes a person weak, Cara.\r
+\r
+127\r
+00:07:21,032 --> 00:07:22,866\r
+Then why are you sitting\r
+on the ground\r
+\r
+128\r
+00:07:22,867 --> 00:07:24,300\r
+weeping over a sword?\r
+\r
+129\r
+00:07:27,071 --> 00:07:29,406\r
+Thank you for your advice,\r
+\r
+130\r
+00:07:29,407 --> 00:07:33,209\r
+but, uh,\r
+I think I'll be all right.\r
+\r
+131\r
+00:07:36,880 --> 00:07:39,714\r
+I hope Zedd is all right.\r
+\r
+132\r
+00:07:40,916 --> 00:07:42,350\r
+Zedd can handle himself.\r
+\r
+133\r
+00:07:42,351 --> 00:07:44,151\r
+I'm sure\r
+he'll be back soon.\r
+\r
+134\r
+00:07:54,560 --> 00:07:59,729\r
+Can I help you\r
+with something, Zeddicus?\r
+\r
+135\r
+00:07:59,730 --> 00:08:01,498\r
+You know exactly why I've come.\r
+\r
+136\r
+00:08:01,499 --> 00:08:02,566\r
+Yes.\r
+\r
+137\r
+00:08:02,667 --> 00:08:06,367\r
+Because you realize that Richard Cypher\r
+will fail at his quest.\r
+\r
+138\r
+00:08:06,470 --> 00:08:09,605\r
+And someone very wise told you\r
+that if you do not name\r
+\r
+139\r
+00:08:09,706 --> 00:08:12,040\r
+a new Seeker,\r
+the world will perish,\r
+\r
+140\r
+00:08:12,041 --> 00:08:15,143\r
+which, in your blindness\r
+and your pride,\r
+\r
+141\r
+00:08:15,144 --> 00:08:16,477\r
+you chose to ignore.\r
+\r
+142\r
+00:08:16,478 --> 00:08:18,311\r
+Are you just\r
+interested in gloating,\r
+\r
+143\r
+00:08:18,412 --> 00:08:20,380\r
+or do you have\r
+a candidate in mind?\r
+\r
+144\r
+00:08:20,381 --> 00:08:23,148\r
+As a matter of fact, I do.\r
+\r
+145\r
+00:08:23,149 --> 00:08:25,416\r
+Remember, not just anyone\r
+can be the Seeker.\r
+\r
+146\r
+00:08:25,517 --> 00:08:29,452\r
+He must be courageous, strong,\r
+compassionate, and above all,\r
+\r
+147\r
+00:08:29,453 --> 00:08:31,420\r
+relentless in the pursuit\r
+of truth.\r
+\r
+148\r
+00:08:31,421 --> 00:08:34,756\r
+Fortunately, I have glimpsed\r
+just such a man in my vision.\r
+\r
+149\r
+00:08:34,757 --> 00:08:37,291\r
+Come, let me show him to you.\r
+\r
+150\r
+00:08:38,727 --> 00:08:40,861\r
+Shota, if this turns out\r
+to be one of your tricks\r
+\r
+151\r
+00:08:40,862 --> 00:08:42,395\r
+it will be your last.\r
+\r
+152\r
+00:08:42,396 --> 00:08:43,563\r
+No tricks.\r
+\r
+153\r
+00:08:43,564 --> 00:08:46,131\r
+A new Seeker is our only hope.\r
+\r
+154\r
+00:08:55,132 --> 00:08:56,532\r
+There he is.\r
+\r
+155\r
+00:09:11,084 --> 00:09:12,285\r
+Who are you?\r
+\r
+156\r
+00:09:17,256 --> 00:09:19,390\r
+I am Sister Nicci.\r
+\r
+157\r
+00:09:19,391 --> 00:09:20,558\r
+I saw you today.\r
+\r
+158\r
+00:09:20,559 --> 00:09:22,426\r
+With the Prelate.\r
+Yes.\r
+\r
+159\r
+00:09:22,427 --> 00:09:25,463\r
+She considers me one\r
+of her closest advisers.\r
+\r
+160\r
+00:09:25,464 --> 00:09:27,164\r
+Why did you ask me here?\r
+\r
+161\r
+00:09:29,034 --> 00:09:30,835\r
+To tell you a secret\r
+that could get me killed.\r
+\r
+162\r
+00:09:30,836 --> 00:09:34,337\r
+But you must know the truth.\r
+\r
+163\r
+00:09:34,338 --> 00:09:35,939\r
+What truth?\r
+\r
+164\r
+00:09:35,940 --> 00:09:37,909\r
+How old do you think I am?\r
+\r
+165\r
+00:09:37,910 --> 00:09:39,944\r
+By the reckoning of the world\r
+\r
+166\r
+00:09:39,945 --> 00:09:41,914\r
+outside the Palace\r
+of the Prophets,\r
+\r
+167\r
+00:09:41,915 --> 00:09:44,851\r
+I am nearly\r
+300 years old.\r
+\r
+168\r
+00:09:44,852 --> 00:09:47,386\r
+How is that possible?\r
+\r
+169\r
+00:09:47,387 --> 00:09:49,122\r
+The palace is spelled.\r
+\r
+170\r
+00:09:49,123 --> 00:09:52,293\r
+For every day\r
+that passes in here,\r
+\r
+171\r
+00:09:52,294 --> 00:09:55,261\r
+ten days pass\r
+in the outside world.\r
+\r
+172\r
+00:09:55,262 --> 00:10:01,066\r
+If that's true,\r
+then if I'm here a month,\r
+\r
+173\r
+00:10:01,067 --> 00:10:03,268\r
+almost a year will\r
+go by for my friends.\r
+\r
+174\r
+00:10:03,269 --> 00:10:06,871\r
+Yes, and if your Wizard training\r
+takes only a year--\r
+\r
+175\r
+00:10:06,872 --> 00:10:08,907\r
+Ten years will pass\r
+on the outside?\r
+\r
+176\r
+00:10:08,908 --> 00:10:10,341\r
+And by that time,\r
+\r
+177\r
+00:10:10,342 --> 00:10:11,643\r
+your friends could be dead.\r
+\r
+178\r
+00:10:11,644 --> 00:10:14,212\r
+Your quest could be meaningless.\r
+\r
+179\r
+00:10:14,213 --> 00:10:17,081\r
+The Keeper could have already\r
+destroyed all life.\r
+\r
+180\r
+00:10:21,523 --> 00:10:22,923\r
+Why didn't anyone\r
+tell me this?\r
+\r
+181\r
+00:10:22,924 --> 00:10:25,892\r
+The Prelate believed you\r
+wouldn't stay if you found out\r
+\r
+182\r
+00:10:25,893 --> 00:10:28,294\r
+so she ordered the Sisters\r
+not to speak of it.\r
+\r
+183\r
+00:10:28,295 --> 00:10:30,896\r
+But you're telling me. Why?\r
+\r
+184\r
+00:10:42,573 --> 00:10:45,140\r
+Because I don't believe\r
+it's right to keep you\r
+\r
+185\r
+00:10:45,141 --> 00:10:47,842\r
+from pursuing your quest\r
+by perpetrating a lie.\r
+\r
+186\r
+00:10:47,843 --> 00:10:50,545\r
+Are the headaches\r
+a lie too?\r
+\r
+187\r
+00:10:50,546 --> 00:10:52,346\r
+No, I'm afraid\r
+those are real.\r
+\r
+188\r
+00:10:57,485 --> 00:10:59,185\r
+What are you doing?\r
+\r
+189\r
+00:10:59,186 --> 00:11:00,720\r
+Showing you your han.\r
+\r
+190\r
+00:11:00,721 --> 00:11:04,156\r
+The essence\r
+of your magic.\r
+\r
+191\r
+00:11:04,157 --> 00:11:06,825\r
+Sisters of the Light\r
+have the ability to sense it.\r
+\r
+192\r
+00:11:10,396 --> 00:11:13,330\r
+Your han is the strongest\r
+I've ever felt.\r
+\r
+193\r
+00:11:13,331 --> 00:11:16,099\r
+It's what's been\r
+causing your pain.\r
+\r
+194\r
+00:11:16,100 --> 00:11:17,200\r
+And it's also why the Prelate\r
+\r
+195\r
+00:11:17,201 --> 00:11:19,535\r
+is so intent\r
+on keeping you here.\r
+\r
+196\r
+00:11:19,536 --> 00:11:20,837\r
+Because I'd die otherwise?\r
+\r
+197\r
+00:11:20,838 --> 00:11:22,071\r
+That's only part of it.\r
+\r
+198\r
+00:11:22,072 --> 00:11:23,572\r
+What she really wants\r
+is to train\r
+\r
+199\r
+00:11:23,573 --> 00:11:25,807\r
+the most powerful wizard\r
+in 3,000 years\r
+\r
+200\r
+00:11:25,808 --> 00:11:28,176\r
+to be her disciple,\r
+to fight her enemies.\r
+\r
+201\r
+00:11:28,177 --> 00:11:30,077\r
+You mean the Keeper?\r
+No.\r
+\r
+202\r
+00:11:30,078 --> 00:11:33,580\r
+The Prelate wants to stop\r
+you from pursuing your quest.\r
+\r
+203\r
+00:11:33,581 --> 00:11:35,548\r
+Why?\r
+\r
+204\r
+00:11:35,549 --> 00:11:37,383\r
+Prophecy.\r
+\r
+205\r
+00:11:37,384 --> 00:11:39,852\r
+It is written: "In the time\r
+of the tearing of the veil,\r
+\r
+206\r
+00:11:39,853 --> 00:11:41,853\r
+"should the son of Brennidon\r
+seek the sacred stone,\r
+\r
+207\r
+00:11:41,854 --> 00:11:46,591\r
+he will find it, only to deliver\r
+it to the enemy of light."\r
+\r
+208\r
+00:11:51,563 --> 00:11:54,297\r
+The Prelate believes the enemy\r
+of the light is the Keeper\r
+\r
+209\r
+00:11:54,298 --> 00:11:55,431\r
+and that this prophecy means\r
+\r
+210\r
+00:11:55,432 --> 00:11:56,966\r
+you'll fail in your\r
+quest to defeat him.\r
+\r
+211\r
+00:11:56,967 --> 00:11:58,500\r
+You don't agree.\r
+\r
+212\r
+00:11:58,501 --> 00:11:59,834\r
+Some of us believe\r
+it's a pretense\r
+\r
+213\r
+00:11:59,835 --> 00:12:00,969\r
+for holding you here,\r
+\r
+214\r
+00:12:00,970 --> 00:12:03,037\r
+and that the beloved\r
+leader of our order\r
+\r
+215\r
+00:12:03,038 --> 00:12:05,572\r
+has become a zealot.\r
+\r
+216\r
+00:12:05,573 --> 00:12:06,806\r
+Sister Brenna thought so.\r
+\r
+217\r
+00:12:06,807 --> 00:12:09,541\r
+She argued that we should\r
+tell you the truth,\r
+\r
+218\r
+00:12:09,542 --> 00:12:12,210\r
+but she never got the chance.\r
+\r
+219\r
+00:12:12,211 --> 00:12:14,512\r
+You believe the Prelate\r
+killed her?\r
+\r
+220\r
+00:12:22,387 --> 00:12:25,055\r
+Creeping elder\r
+kills quickly.\r
+\r
+221\r
+00:12:25,056 --> 00:12:28,290\r
+The Prelate greeted me\r
+at the back of this room.\r
+\r
+222\r
+00:12:28,291 --> 00:12:31,926\r
+She didn't get close enough\r
+to Brenna to deliver the poison.\r
+\r
+223\r
+00:12:31,927 --> 00:12:34,828\r
+All I know is that Sister Brenna\r
+spoke out against the Prelate\r
+\r
+224\r
+00:12:34,829 --> 00:12:36,763\r
+and now Brenna's dead.\r
+\r
+225\r
+00:12:36,764 --> 00:12:39,133\r
+I have to get out of here.\r
+\r
+226\r
+00:12:41,972 --> 00:12:44,509\r
+Is there a way to do that\r
+without the han killing me?\r
+\r
+227\r
+00:12:44,510 --> 00:12:47,878\r
+If you wore a rada'han,\r
+it would suppress your powers,\r
+\r
+228\r
+00:12:47,879 --> 00:12:49,547\r
+and in turn,\r
+your headaches.\r
+\r
+229\r
+00:12:49,548 --> 00:12:51,315\r
+Do you have one?\r
+No.\r
+\r
+230\r
+00:12:51,316 --> 00:12:52,816\r
+But the Prelate does.\r
+\r
+231\r
+00:12:52,817 --> 00:12:55,351\r
+She keeps it locked up.\r
+\r
+232\r
+00:12:55,352 --> 00:12:57,219\r
+It may take me a few days\r
+before I have the chance,\r
+\r
+233\r
+00:12:57,220 --> 00:12:58,454\r
+but I'll try to bring\r
+it for you.\r
+\r
+234\r
+00:12:58,455 --> 00:13:00,321\r
+A few days here\r
+is a month on the outside.\r
+\r
+235\r
+00:13:00,322 --> 00:13:02,823\r
+I'll get it\r
+as soon as I can.\r
+\r
+236\r
+00:13:02,824 --> 00:13:07,460\r
+Until then, please, don't let\r
+anyone know that we've spoken.\r
+\r
+237\r
+00:13:07,461 --> 00:13:10,028\r
+It could get me killed.\r
+\r
+238\r
+00:13:22,806 --> 00:13:23,340\r
+Why did you lie to me?\r
+\r
+239\r
+00:13:25,242 --> 00:13:28,077\r
+I want the truth.\r
+\r
+240\r
+00:13:36,151 --> 00:13:38,051\r
+Come with me.\r
+\r
+241\r
+00:13:39,720 --> 00:13:41,020\r
+<i>"In the time</i>\r
+\r
+242\r
+00:13:41,021 --> 00:13:42,854\r
+<i>"of the tearing\r
+of the veil,</i>\r
+\r
+243\r
+00:13:42,855 --> 00:13:47,325\r
+"should the son of Brennidon\r
+seek the sacred stone,\r
+\r
+244\r
+00:13:47,326 --> 00:13:52,495\r
+he will find it, only to deliver\r
+it to the enemy of the light."\r
+\r
+245\r
+00:13:52,496 --> 00:13:54,797\r
+The Creator herself\r
+gives us these prophecies\r
+\r
+246\r
+00:13:54,798 --> 00:13:56,532\r
+to guide our actions.\r
+\r
+247\r
+00:13:56,533 --> 00:13:59,033\r
+Did the Creator herself\r
+tell you to lie to me?\r
+\r
+248\r
+00:13:59,034 --> 00:14:02,837\r
+No.\r
+\r
+249\r
+00:14:02,838 --> 00:14:04,306\r
+No, that was my idea.\r
+\r
+250\r
+00:14:04,307 --> 00:14:07,743\r
+While I was looking for you\r
+in the New World,\r
+\r
+251\r
+00:14:07,744 --> 00:14:09,344\r
+I learned a lot about you,\r
+\r
+252\r
+00:14:09,345 --> 00:14:11,513\r
+including how devoted\r
+you were to Kahlan\r
+\r
+253\r
+00:14:11,514 --> 00:14:12,581\r
+and your grandfather.\r
+\r
+254\r
+00:14:12,582 --> 00:14:15,183\r
+So I sent word\r
+in a Journey Book\r
+\r
+255\r
+00:14:15,184 --> 00:14:17,485\r
+suggesting the Prelate\r
+hide the truth\r
+\r
+256\r
+00:14:17,486 --> 00:14:18,986\r
+about the time difference.\r
+\r
+257\r
+00:14:18,987 --> 00:14:20,186\r
+Why?\r
+\r
+258\r
+00:14:20,187 --> 00:14:23,355\r
+Because you have\r
+a greater destiny, Richard.\r
+\r
+259\r
+00:14:23,356 --> 00:14:25,757\r
+I believe people\r
+make their own destinies.\r
+\r
+260\r
+00:14:25,758 --> 00:14:28,459\r
+Sometimes they\r
+are written for us.\r
+\r
+261\r
+00:14:33,297 --> 00:14:35,531\r
+Our scholars have interpreted\r
+this prophecy to mean\r
+\r
+262\r
+00:14:35,532 --> 00:14:38,567\r
+that you would\r
+be born in Brennidon.\r
+\r
+263\r
+00:14:38,568 --> 00:14:40,268\r
+And you were.\r
+\r
+264\r
+00:14:45,207 --> 00:14:46,874\r
+They said that\r
+this prophecy meant\r
+\r
+265\r
+00:14:46,875 --> 00:14:49,576\r
+that you would defeat\r
+an evil tyrant.\r
+\r
+266\r
+00:14:49,577 --> 00:14:51,177\r
+And you did.\r
+\r
+267\r
+00:14:52,580 --> 00:14:53,880\r
+And now they say\r
+\r
+268\r
+00:14:53,881 --> 00:14:57,550\r
+that this prophecy means\r
+that if you continue searching\r
+\r
+269\r
+00:14:57,551 --> 00:15:00,219\r
+for the Stone of Tears,\r
+you'll find it,\r
+\r
+270\r
+00:15:00,220 --> 00:15:02,887\r
+but you will give\r
+it to the Keeper\r
+\r
+271\r
+00:15:02,888 --> 00:15:05,022\r
+I would never do that.\r
+\r
+272\r
+00:15:05,023 --> 00:15:10,093\r
+And finally, the last and most\r
+important prophecy.\r
+\r
+273\r
+00:15:10,094 --> 00:15:12,128\r
+Our scholars have interpreted\r
+this one to mean\r
+\r
+274\r
+00:15:12,129 --> 00:15:15,464\r
+that the descendant\r
+of two powerful bloodlines\r
+\r
+275\r
+00:15:15,465 --> 00:15:19,334\r
+must fight a powerful new force\r
+after the Keeper is defeated.\r
+\r
+276\r
+00:15:20,870 --> 00:15:23,471\r
+That descendant is you.\r
+\r
+277\r
+00:15:23,472 --> 00:15:26,707\r
+Even if that's true,\r
+that battle will never happen\r
+\r
+278\r
+00:15:26,708 --> 00:15:28,608\r
+if I don't defeat\r
+the Keeper first.\r
+\r
+279\r
+00:15:28,609 --> 00:15:30,810\r
+You must leave that quest\r
+to a new Seeker\r
+\r
+280\r
+00:15:30,811 --> 00:15:33,112\r
+and prepare for your\r
+next challenge.\r
+\r
+281\r
+00:15:33,113 --> 00:15:36,648\r
+I'm not going to let my life\r
+be ruled by someone's\r
+\r
+282\r
+00:15:36,649 --> 00:15:38,450\r
+interpretations of some\r
+carvings on a wall.\r
+\r
+283\r
+00:15:38,451 --> 00:15:40,819\r
+Because of these carvings\r
+\r
+284\r
+00:15:40,820 --> 00:15:42,787\r
+I gave up half my life\r
+\r
+285\r
+00:15:42,788 --> 00:15:45,289\r
+just to bring you here.\r
+\r
+286\r
+00:15:45,290 --> 00:15:48,760\r
+And if I stay I'm giving up\r
+the love of my life.\r
+\r
+287\r
+00:15:48,761 --> 00:15:50,828\r
+The harder you study,\r
+\r
+288\r
+00:15:50,829 --> 00:15:53,263\r
+the faster you'll learn\r
+to use your power,\r
+\r
+289\r
+00:15:53,264 --> 00:15:56,532\r
+and the sooner you'll\r
+get back to those you love.\r
+\r
+290\r
+00:16:21,758 --> 00:16:23,592\r
+What do we do\r
+with horse thieves?\r
+\r
+291\r
+00:16:23,593 --> 00:16:26,261\r
+I'm not a horse thief,\r
+I'm a blacksmith.\r
+\r
+292\r
+00:16:28,197 --> 00:16:30,464\r
+This is the man\r
+we've spent the last month\r
+\r
+293\r
+00:16:30,465 --> 00:16:32,499\r
+crossing three rivers,\r
+\r
+294\r
+00:16:32,500 --> 00:16:33,667\r
+two mountain ranges,\r
+\r
+295\r
+00:16:33,668 --> 00:16:35,768\r
+and the great swamp\r
+of Mathragon to find.\r
+\r
+296\r
+00:16:35,769 --> 00:16:38,436\r
+This is the man I saw\r
+in Shota's vision.\r
+\r
+297\r
+00:16:38,437 --> 00:16:41,268\r
+Then why was he skulking\r
+around our horses?\r
+\r
+298\r
+00:16:41,269 --> 00:16:44,168\r
+I was going to the stream\r
+to get some water for my forge\r
+\r
+299\r
+00:16:44,169 --> 00:16:47,969\r
+when I noticed one of your\r
+horses was favoring a leg.\r
+\r
+300\r
+00:16:47,970 --> 00:16:49,470\r
+Look, if you don't\r
+get that pebble\r
+\r
+301\r
+00:16:49,471 --> 00:16:50,871\r
+out of her hoof,\r
+she'll go lame.\r
+\r
+302\r
+00:16:50,872 --> 00:16:52,773\r
+He's telling the truth.\r
+\r
+303\r
+00:16:52,774 --> 00:16:54,507\r
+Of course he's telling\r
+the truth.\r
+\r
+304\r
+00:16:54,508 --> 00:16:57,510\r
+He's the next Seeker of Truth.\r
+\r
+305\r
+00:17:02,615 --> 00:17:04,349\r
+So it's true then?\r
+\r
+306\r
+00:17:04,350 --> 00:17:06,284\r
+You knew you'd be the Seeker?\r
+\r
+307\r
+00:17:06,285 --> 00:17:08,987\r
+There's been a legend\r
+in my family for generations\r
+\r
+308\r
+00:17:08,988 --> 00:17:11,655\r
+that someday one of our line\r
+would be named.\r
+\r
+309\r
+00:17:11,656 --> 00:17:15,158\r
+My mother was always\r
+sure it would be me.\r
+\r
+310\r
+00:17:15,159 --> 00:17:16,659\r
+Did did Richard Cypher die?\r
+\r
+311\r
+00:17:16,660 --> 00:17:19,361\r
+No. He's alive.\r
+\r
+312\r
+00:17:19,362 --> 00:17:22,397\r
+He just had to take\r
+a long journey.\r
+\r
+313\r
+00:17:22,398 --> 00:17:23,932\r
+We're not sure\r
+when he'll come back.\r
+\r
+314\r
+00:17:32,541 --> 00:17:34,575\r
+<i>This is The Book\r
+of Counted Shadows.</i>\r
+\r
+315\r
+00:17:34,576 --> 00:17:38,145\r
+Only a true Seeker\r
+can read it.\r
+\r
+316\r
+00:17:42,248 --> 00:17:46,917\r
+<i>The truth of the words of\r
+The Book of Counted Shadows</i>\r
+\r
+317\r
+00:17:46,918 --> 00:17:48,985\r
+can only be insured\r
+by a Confessor.\r
+\r
+318\r
+00:17:52,823 --> 00:17:54,890\r
+Sorry about your neck.\r
+\r
+319\r
+00:17:57,493 --> 00:17:59,861\r
+Leo Dane,\r
+\r
+320\r
+00:17:59,862 --> 00:18:02,662\r
+though the road will be long\r
+and the outcome unknown,\r
+\r
+321\r
+00:18:02,663 --> 00:18:05,698\r
+will you undertake\r
+this journey?\r
+\r
+322\r
+00:18:05,699 --> 00:18:07,365\r
+I will.\r
+\r
+323\r
+00:18:07,366 --> 00:18:08,800\r
+Will you leave\r
+behind your friends\r
+\r
+324\r
+00:18:08,801 --> 00:18:10,767\r
+and all that you have known?\r
+\r
+325\r
+00:18:12,303 --> 00:18:14,003\r
+I will.\r
+\r
+326\r
+00:18:14,004 --> 00:18:15,972\r
+And though the forces\r
+of evil are sworn\r
+\r
+327\r
+00:18:15,973 --> 00:18:17,740\r
+to bring about your death,\r
+\r
+328\r
+00:18:17,741 --> 00:18:20,243\r
+still, will you go on?\r
+\r
+329\r
+00:18:20,244 --> 00:18:22,678\r
+I will.\r
+\r
+330\r
+00:18:22,679 --> 00:18:23,946\r
+And will you accept\r
+\r
+331\r
+00:18:23,947 --> 00:18:25,848\r
+the name of the Seeker?\r
+\r
+332\r
+00:18:25,849 --> 00:18:28,952\r
+I will.\r
+\r
+333\r
+00:18:42,198 --> 00:18:44,066\r
+Then I,\r
+\r
+334\r
+00:18:44,067 --> 00:18:48,070\r
+First Wizard\r
+Zeddicus Zu'l Zorander,\r
+\r
+335\r
+00:18:48,071 --> 00:18:49,538\r
+so name you.\r
+\r
+336\r
+00:19:09,461 --> 00:19:11,031\r
+Only in the hands of the Seeker\r
+\r
+337\r
+00:19:11,032 --> 00:19:12,166\r
+will the compass guide the way\r
+\r
+338\r
+00:19:12,167 --> 00:19:15,038\r
+to the Stone of Tears.\r
+\r
+339\r
+00:19:15,039 --> 00:19:16,072\r
+We head south.\r
+\r
+340\r
+00:19:20,778 --> 00:19:21,878\r
+Can I give you a hand?\r
+\r
+341\r
+00:19:26,783 --> 00:19:27,917\r
+You'll soon learn that it's we\r
+\r
+342\r
+00:19:27,918 --> 00:19:32,319\r
+who are here\r
+to help you, Seeker.\r
+\r
+343\r
+00:19:35,989 --> 00:19:38,357\r
+Trying to show chivalry\r
+to a Mord-Sith\r
+\r
+344\r
+00:19:38,358 --> 00:19:39,791\r
+is like trying\r
+to dance with a bear.\r
+\r
+345\r
+00:19:39,792 --> 00:19:41,492\r
+It's never gonna work\r
+\r
+346\r
+00:19:41,493 --> 00:19:43,962\r
+and someone will get\r
+their head bitten off.\r
+\r
+347\r
+00:19:50,868 --> 00:19:52,302\r
+Something's spooking her.\r
+\r
+348\r
+00:19:54,672 --> 00:19:56,639\r
+Easy, easy, easy.\r
+\r
+349\r
+00:20:07,816 --> 00:20:09,417\r
+Banelings.\r
+\r
+350\r
+00:21:15,047 --> 00:21:17,615\r
+Who are these people?\r
+And why did they attack us?\r
+\r
+351\r
+00:21:17,616 --> 00:21:19,548\r
+They're banelings.\r
+\r
+352\r
+00:21:19,549 --> 00:21:22,716\r
+Dead souls who bargain with\r
+the Keeper for a second life\r
+\r
+353\r
+00:21:22,717 --> 00:21:24,151\r
+in exchange for killing others.\r
+\r
+354\r
+00:21:25,620 --> 00:21:27,619\r
+How do we make sure they don't\r
+come back from the dead\r
+\r
+355\r
+00:21:27,620 --> 00:21:28,619\r
+a second time?\r
+\r
+356\r
+00:21:28,620 --> 00:21:30,217\r
+We burn them.\r
+\r
+357\r
+00:21:40,189 --> 00:21:42,188\r
+I told you you were\r
+gonna need our help.\r
+\r
+358\r
+00:21:48,729 --> 00:21:52,564\r
+The Grace represents\r
+the whole of everything.\r
+\r
+359\r
+00:21:52,565 --> 00:21:56,400\r
+Separating the world of life\r
+from the Underworld\r
+\r
+360\r
+00:21:56,401 --> 00:21:58,602\r
+is the veil.\r
+\r
+361\r
+00:21:58,603 --> 00:22:00,004\r
+Which has been torn.\r
+\r
+362\r
+00:22:00,005 --> 00:22:01,472\r
+And while the Keeper\r
+\r
+363\r
+00:22:01,473 --> 00:22:04,375\r
+is threatening\r
+to destroy all life,\r
+\r
+364\r
+00:22:04,376 --> 00:22:06,443\r
+here I am drawing shapes\r
+with sand.\r
+\r
+365\r
+00:22:06,444 --> 00:22:08,445\r
+We've been at this\r
+for three days.\r
+\r
+366\r
+00:22:08,446 --> 00:22:10,180\r
+I thought you would teach\r
+me to use my powers.\r
+\r
+367\r
+00:22:10,181 --> 00:22:11,781\r
+Patience.\r
+\r
+368\r
+00:22:11,782 --> 00:22:14,617\r
+The Grace is the foundation\r
+of everything you need to know.\r
+\r
+369\r
+00:22:14,618 --> 00:22:16,751\r
+What exactly are you\r
+trying to teach me?\r
+\r
+370\r
+00:22:16,752 --> 00:22:18,419\r
+How to be a Wizard?\r
+\r
+371\r
+00:22:18,420 --> 00:22:19,819\r
+Or how to be the Prelate's\r
+disciple?\r
+\r
+372\r
+00:22:19,820 --> 00:22:22,922\r
+Your stubborn resistance is only\r
+gonna make this take longer.\r
+\r
+373\r
+00:22:25,558 --> 00:22:26,958\r
+Excuse the interruption,\r
+\r
+374\r
+00:22:26,959 --> 00:22:28,993\r
+but I was asked to bring\r
+Richard his lunch.\r
+\r
+375\r
+00:22:28,994 --> 00:22:31,795\r
+Thank you, Sister Nicci.\r
+\r
+376\r
+00:22:36,801 --> 00:22:38,635\r
+Yes, thank you, Sister Nicci.\r
+\r
+377\r
+00:22:39,637 --> 00:22:41,104\r
+Shall we continue?\r
+\r
+378\r
+00:23:00,223 --> 00:23:01,690\r
+How can I ever thank you?\r
+\r
+379\r
+00:23:01,691 --> 00:23:03,057\r
+You must hurry.\r
+\r
+380\r
+00:23:03,058 --> 00:23:04,225\r
+It's only a matter of time\r
+\r
+381\r
+00:23:04,226 --> 00:23:06,593\r
+before the Prelate\r
+discovers it's missing.\r
+\r
+382\r
+00:23:06,594 --> 00:23:09,529\r
+Leave through the vestibule\r
+at the west end of the palace.\r
+\r
+383\r
+00:23:09,530 --> 00:23:12,665\r
+It's rarely used and far\r
+from the Sisters' quarters.\r
+\r
+384\r
+00:23:12,666 --> 00:23:14,967\r
+Will you be all right?\r
+\r
+385\r
+00:23:14,968 --> 00:23:18,136\r
+We'll all be better off\r
+once you're back on your quest.\r
+\r
+386\r
+00:23:18,137 --> 00:23:19,804\r
+Now, go.\r
+\r
+387\r
+00:23:50,834 --> 00:23:53,100\r
+You're not going anywhere.\r
+\r
+388\r
+00:24:31,496 --> 00:24:32,763\r
+How did you get the rada'han?\r
+\r
+389\r
+00:24:36,500 --> 00:24:38,167\r
+I'm the Seeker.\r
+\r
+390\r
+00:24:38,168 --> 00:24:39,635\r
+I find things.\r
+\r
+391\r
+00:24:39,636 --> 00:24:42,503\r
+The only way you could have\r
+known I even had a rada'han\r
+\r
+392\r
+00:24:42,504 --> 00:24:44,572\r
+is if one of the Sisters\r
+told you.\r
+\r
+393\r
+00:24:44,573 --> 00:24:46,240\r
+How did you find me?\r
+\r
+394\r
+00:24:46,241 --> 00:24:48,775\r
+I'm 600 years old, Richard.\r
+\r
+395\r
+00:24:48,776 --> 00:24:50,976\r
+Not much gets past me.\r
+\r
+396\r
+00:24:50,977 --> 00:24:52,878\r
+I discovered the rada'han\r
+was missing\r
+\r
+397\r
+00:24:52,879 --> 00:24:55,014\r
+and I told the Prelate\r
+right away.\r
+\r
+398\r
+00:24:55,015 --> 00:24:56,582\r
+I erected a magical barrier\r
+\r
+399\r
+00:24:56,583 --> 00:24:58,483\r
+over every exit in the palace.\r
+\r
+400\r
+00:24:58,484 --> 00:25:00,151\r
+So now I'm your prisoner?\r
+\r
+401\r
+00:25:00,152 --> 00:25:01,718\r
+You've read the Prophecy\r
+for yourself.\r
+\r
+402\r
+00:25:01,719 --> 00:25:03,355\r
+You've seen it with\r
+your own eyes.\r
+\r
+403\r
+00:25:03,356 --> 00:25:05,157\r
+Well, I must have missed\r
+the part that said,\r
+\r
+404\r
+00:25:05,158 --> 00:25:07,493\r
+"Richard Cypher will be held\r
+in the Palace of the Prophets\r
+\r
+405\r
+00:25:07,494 --> 00:25:08,694\r
+against his will."\r
+\r
+406\r
+00:25:08,695 --> 00:25:11,830\r
+Richard, I want to show\r
+you the ugly truth\r
+\r
+407\r
+00:25:11,831 --> 00:25:14,065\r
+about whichever Sister\r
+is helping you.\r
+\r
+408\r
+00:25:14,066 --> 00:25:15,566\r
+What are you talking about?\r
+\r
+409\r
+00:25:20,072 --> 00:25:23,941\r
+Each candle represents\r
+one Sister in the palace.\r
+\r
+410\r
+00:25:23,942 --> 00:25:27,612\r
+As the soul seeks the dark,\r
+so does the flame.\r
+\r
+411\r
+00:25:31,013 --> 00:25:33,813\r
+The green flames represent\r
+the sisters of the Dark.\r
+\r
+412\r
+00:25:34,718 --> 00:25:36,618\r
+Who secretly serve the Keeper.\r
+\r
+413\r
+00:25:36,619 --> 00:25:40,120\r
+One of them is obviously\r
+pretending to be your friend.\r
+\r
+414\r
+00:25:40,121 --> 00:25:42,455\r
+Why would these Sisters\r
+of the Dark do that?\r
+\r
+415\r
+00:25:42,456 --> 00:25:44,089\r
+Because they want you\r
+to leave the palace,\r
+\r
+416\r
+00:25:44,090 --> 00:25:46,258\r
+find the Stone of Tears\r
+and deliver it to the Keeper,\r
+\r
+417\r
+00:25:46,259 --> 00:25:47,993\r
+just as the Prophecy\r
+says you will.\r
+\r
+418\r
+00:25:49,863 --> 00:25:50,796\r
+Nicci?\r
+\r
+419\r
+00:25:56,569 --> 00:25:57,502\r
+Yes, Prelate?\r
+\r
+420\r
+00:26:00,038 --> 00:26:03,339\r
+Please see Richard\r
+to his room.\r
+\r
+421\r
+00:26:03,340 --> 00:26:05,442\r
+Make sure he doesn't\r
+get any uninvited guests.\r
+\r
+422\r
+00:26:17,084 --> 00:26:18,818\r
+Whose side are you on?\r
+\r
+423\r
+00:26:18,819 --> 00:26:20,586\r
+I tried to help you.\r
+\r
+424\r
+00:26:20,587 --> 00:26:22,921\r
+So I can get back on my quest,\r
+find the sacred stone\r
+\r
+425\r
+00:26:22,922 --> 00:26:24,322\r
+and give it to the enemy\r
+of the light?\r
+\r
+426\r
+00:26:24,323 --> 00:26:27,256\r
+Are the Prelate's\r
+powers of persuasion\r
+\r
+427\r
+00:26:27,257 --> 00:26:28,924\r
+so compelling that even\r
+the Seeker of Truth\r
+\r
+428\r
+00:26:28,925 --> 00:26:31,660\r
+will succumb\r
+to her manipulations?\r
+\r
+429\r
+00:26:31,661 --> 00:26:34,195\r
+How do I know she's the one\r
+manipulating me?\r
+\r
+430\r
+00:26:36,130 --> 00:26:38,831\r
+All she had to do was turn one\r
+word from "light" to "dark"\r
+\r
+431\r
+00:26:38,832 --> 00:26:41,567\r
+and claim there's\r
+a conspiracy against her,\r
+\r
+432\r
+00:26:41,568 --> 00:26:44,002\r
+and you-- You believed her?\r
+\r
+433\r
+00:26:44,003 --> 00:26:46,871\r
+And you stopped\r
+believing in yourself.\r
+\r
+434\r
+00:26:46,872 --> 00:26:48,640\r
+I believe in myself, Nicci.\r
+\r
+435\r
+00:26:48,641 --> 00:26:50,308\r
+It's you I'm not sure about.\r
+\r
+436\r
+00:26:50,309 --> 00:26:52,676\r
+I risked my life for you.\r
+\r
+437\r
+00:26:52,677 --> 00:26:54,010\r
+Where are you going?\r
+\r
+438\r
+00:26:54,011 --> 00:26:56,912\r
+If the Prelate is going\r
+to accuse anyone\r
+\r
+439\r
+00:26:56,913 --> 00:26:59,814\r
+who disagrees with her\r
+of serving the Keeper,\r
+\r
+440\r
+00:26:59,815 --> 00:27:02,248\r
+then it's far more\r
+dangerous than I thought.\r
+\r
+441\r
+00:27:02,249 --> 00:27:03,916\r
+Who-- Who will she\r
+accuse next?\r
+\r
+442\r
+00:27:03,917 --> 00:27:05,784\r
+The cook because\r
+the roast was burnt?\r
+\r
+443\r
+00:27:05,785 --> 00:27:10,425\r
+Or the groundskeeper because\r
+he trimmed the hedges too low?\r
+\r
+444\r
+00:27:10,426 --> 00:27:13,898\r
+If I stay here, I will\r
+end up like Sister Brenna.\r
+\r
+445\r
+00:27:17,903 --> 00:27:19,202\r
+Is there another way\r
+to get out?\r
+\r
+446\r
+00:27:29,579 --> 00:27:30,712\r
+There might be.\r
+\r
+447\r
+00:27:30,713 --> 00:27:31,780\r
+Tell me.\r
+\r
+448\r
+00:27:33,716 --> 00:27:36,784\r
+Aside from being able\r
+to sense someone's han,\r
+\r
+449\r
+00:27:36,785 --> 00:27:39,685\r
+the Sisters of Light\r
+can also take it.\r
+\r
+450\r
+00:27:39,686 --> 00:27:41,853\r
+Take it how?\r
+\r
+451\r
+00:27:41,854 --> 00:27:44,857\r
+We can kill someone\r
+with the Dacra,\r
+\r
+452\r
+00:27:44,858 --> 00:27:46,694\r
+and use it to absorb their han,\r
+\r
+453\r
+00:27:46,695 --> 00:27:49,629\r
+or accept the gift from\r
+someone who chooses\r
+\r
+454\r
+00:27:49,630 --> 00:27:51,731\r
+to relinquish it willingly.\r
+\r
+455\r
+00:27:51,732 --> 00:27:53,698\r
+Why didn't you\r
+tell me this before?\r
+\r
+456\r
+00:27:53,699 --> 00:27:55,733\r
+Because the rada'han\r
+was a safer way.\r
+\r
+457\r
+00:27:55,734 --> 00:27:58,068\r
+Taking someone's han\r
+could kill me.\r
+\r
+458\r
+00:27:59,804 --> 00:28:01,271\r
+It could also make you\r
+very powerful.\r
+\r
+459\r
+00:28:03,842 --> 00:28:06,644\r
+Yes.\r
+\r
+460\r
+00:28:06,645 --> 00:28:09,547\r
+Powerful enough to break through\r
+the Prelate's barriers\r
+\r
+461\r
+00:28:09,548 --> 00:28:11,215\r
+and help you escape.\r
+\r
+462\r
+00:28:11,216 --> 00:28:14,985\r
+How do I know this wasn't\r
+your plan all along?\r
+\r
+463\r
+00:28:14,986 --> 00:28:17,254\r
+Slowly gain my trust\r
+and then steal my power.\r
+\r
+464\r
+00:28:19,190 --> 00:28:22,192\r
+I told you,\r
+\r
+465\r
+00:28:22,193 --> 00:28:23,393\r
+if I wanted your power\r
+\r
+466\r
+00:28:23,394 --> 00:28:25,762\r
+I could just kill you\r
+and take it.\r
+\r
+467\r
+00:28:28,933 --> 00:28:31,734\r
+I have to go before\r
+they catch me talking to you.\r
+\r
+468\r
+00:28:36,238 --> 00:28:37,338\r
+The choice is yours.\r
+\r
+469\r
+00:28:37,339 --> 00:28:41,173\r
+Trust me and escape\r
+\r
+470\r
+00:28:41,174 --> 00:28:44,240\r
+or stay here until\r
+they decide to let you out.\r
+\r
+471\r
+00:28:58,418 --> 00:29:01,086\r
+Sister Philomena\r
+sent word by Journey Book.\r
+\r
+472\r
+00:29:01,087 --> 00:29:02,454\r
+She's crossed to the New World\r
+\r
+473\r
+00:29:02,455 --> 00:29:04,889\r
+and she's already\r
+on the new Seeker's trail.\r
+\r
+474\r
+00:29:04,890 --> 00:29:06,890\r
+He'll be dead before\r
+he's gripped the Sword of Truth\r
+\r
+475\r
+00:29:06,891 --> 00:29:08,958\r
+long enough to warm its hilt.\r
+\r
+476\r
+00:29:08,959 --> 00:29:11,461\r
+Very good, Ulicia.\r
+\r
+477\r
+00:29:11,462 --> 00:29:12,495\r
+And Richard?\r
+\r
+478\r
+00:29:14,498 --> 00:29:16,699\r
+It's only a matter of time\r
+\r
+479\r
+00:29:16,700 --> 00:29:18,500\r
+before he's begging me\r
+to take his power,\r
+\r
+480\r
+00:29:18,501 --> 00:29:22,237\r
+and once I have it,\r
+I'll free him from the palace\r
+\r
+481\r
+00:29:22,238 --> 00:29:26,707\r
+and return him\r
+to his quest...\r
+\r
+482\r
+00:29:26,708 --> 00:29:28,675\r
+of failure.\r
+\r
+483\r
+00:29:28,676 --> 00:29:32,112\r
+And the Sisters of the Light?\r
+\r
+484\r
+00:29:32,113 --> 00:29:34,581\r
+I'll kill the Prelate.\r
+\r
+485\r
+00:29:34,582 --> 00:29:36,985\r
+The rest of the Sisters\r
+will be given a choice:\r
+\r
+486\r
+00:29:36,986 --> 00:29:40,689\r
+convert to the dark\r
+and serve the Keeper, or die.\r
+\r
+487\r
+00:29:42,725 --> 00:29:46,495\r
+Although there\r
+is one small problem.\r
+\r
+488\r
+00:29:46,496 --> 00:29:50,099\r
+I've felt the strength\r
+of Richard's han.\r
+\r
+489\r
+00:29:50,100 --> 00:29:53,769\r
+It's far greater\r
+than I anticipated.\r
+\r
+490\r
+00:29:53,770 --> 00:29:56,872\r
+If I try to absorb it,\r
+\r
+491\r
+00:29:56,873 --> 00:29:59,107\r
+the power may overwhelm me.\r
+\r
+492\r
+00:29:59,108 --> 00:30:03,278\r
+You should increase your\r
+strength before you take his.\r
+\r
+493\r
+00:30:03,279 --> 00:30:07,982\r
+Kill another Sister.\r
+Take her han.\r
+\r
+494\r
+00:30:07,983 --> 00:30:12,486\r
+Sisters of the Dark\r
+think alike, Ulicia.\r
+\r
+495\r
+00:30:34,166 --> 00:30:37,768\r
+I'll take over your watch\r
+so you can get some sleep.\r
+\r
+496\r
+00:30:37,769 --> 00:30:39,470\r
+I'm not tired.\r
+\r
+497\r
+00:30:39,471 --> 00:30:42,673\r
+Considering how easy it was for\r
+me to sneak up on you just now,\r
+\r
+498\r
+00:30:42,674 --> 00:30:44,141\r
+obviously you need some rest.\r
+\r
+499\r
+00:30:44,142 --> 00:30:47,579\r
+It would be impossible\r
+for you to sneak up on me.\r
+\r
+500\r
+00:30:56,787 --> 00:30:58,287\r
+So,\r
+\r
+501\r
+00:30:58,288 --> 00:30:59,989\r
+Cara.\r
+\r
+502\r
+00:30:59,990 --> 00:31:02,590\r
+Yes, Leo?\r
+\r
+503\r
+00:31:05,861 --> 00:31:07,428\r
+Do you like animals?\r
+\r
+504\r
+00:31:07,429 --> 00:31:09,329\r
+Ones that taste good.\r
+\r
+505\r
+00:31:09,330 --> 00:31:11,998\r
+I meant,\r
+do you like pets?\r
+\r
+506\r
+00:31:14,334 --> 00:31:16,802\r
+I once had a dog.\r
+\r
+507\r
+00:31:16,803 --> 00:31:18,003\r
+I like dogs.\r
+\r
+508\r
+00:31:19,239 --> 00:31:21,406\r
+I trained it to attack\r
+on command.\r
+\r
+509\r
+00:31:23,042 --> 00:31:25,843\r
+I could see how that\r
+could be useful.\r
+\r
+510\r
+00:31:27,512 --> 00:31:29,713\r
+Could you train a chipmunk?\r
+\r
+511\r
+00:31:32,182 --> 00:31:33,549\r
+What are you talking about?\r
+\r
+512\r
+00:31:33,550 --> 00:31:36,518\r
+To obey your orders?\r
+Attack people?\r
+\r
+513\r
+00:31:37,954 --> 00:31:40,588\r
+It's probably too hard, right?\r
+\r
+514\r
+00:31:40,589 --> 00:31:43,457\r
+Ah, the mighty chipmunk.\r
+\r
+515\r
+00:31:43,458 --> 00:31:44,825\r
+It's fearless.\r
+\r
+516\r
+00:31:44,826 --> 00:31:45,859\r
+Cunning.\r
+\r
+517\r
+00:31:45,860 --> 00:31:47,393\r
+Stalwart.\r
+\r
+518\r
+00:31:47,394 --> 00:31:48,728\r
+And sworn enemy\r
+of the Mord-Sith.\r
+\r
+519\r
+00:31:48,729 --> 00:31:51,363\r
+Not even the touch of the Agiel\r
+\r
+520\r
+00:31:51,364 --> 00:31:54,065\r
+can break its tiny\r
+but heroic heart.\r
+\r
+521\r
+00:31:55,634 --> 00:31:58,469\r
+So you do have\r
+a sense of humor.\r
+\r
+522\r
+00:32:01,039 --> 00:32:02,472\r
+You were right.\r
+\r
+523\r
+00:32:02,473 --> 00:32:03,640\r
+What about?\r
+\r
+524\r
+00:32:03,641 --> 00:32:05,275\r
+If I'm laughing at your\r
+ridiculous jokes,\r
+\r
+525\r
+00:32:05,276 --> 00:32:07,544\r
+I must be tired.\r
+\r
+526\r
+00:32:07,545 --> 00:32:09,412\r
+I should get some sleep.\r
+\r
+527\r
+00:32:09,413 --> 00:32:10,746\r
+Sleep well.\r
+\r
+528\r
+00:32:10,747 --> 00:32:12,614\r
+And don't worry.\r
+\r
+529\r
+00:32:12,615 --> 00:32:14,215\r
+I'll protect you\r
+from the chipmunks.\r
+\r
+530\r
+00:32:19,819 --> 00:32:22,154\r
+I've never heard you\r
+laugh before.\r
+\r
+531\r
+00:32:24,123 --> 00:32:26,124\r
+Aren't you supposed\r
+to be asleep?\r
+\r
+532\r
+00:32:40,236 --> 00:32:43,004\r
+Well, I'm glad to see you\r
+at devotions.\r
+\r
+533\r
+00:32:43,005 --> 00:32:45,806\r
+Having the Creator on your side\r
+certainly can't hurt\r
+\r
+534\r
+00:32:45,807 --> 00:32:48,008\r
+when it comes to learning\r
+to use your gift.\r
+\r
+535\r
+00:32:50,011 --> 00:32:53,413\r
+In time, I'm confident\r
+you'll learn to appreciate\r
+\r
+536\r
+00:32:53,414 --> 00:32:55,749\r
+the Palace of the Prophets\r
+as much as I do.\r
+\r
+537\r
+00:32:55,750 --> 00:32:58,984\r
+Maybe so.\r
+\r
+538\r
+00:33:01,689 --> 00:33:04,858\r
+It is customary to kiss\r
+the star before opening it.\r
+\r
+539\r
+00:33:27,276 --> 00:33:28,310\r
+Ready for your lesson?\r
+\r
+540\r
+00:33:28,311 --> 00:33:29,844\r
+The lessons are over.\r
+\r
+541\r
+00:33:32,447 --> 00:33:35,082\r
+A Sister of the Dark\r
+has agreed to absorb my han,\r
+\r
+542\r
+00:33:35,083 --> 00:33:37,950\r
+use the power to blast\r
+through the Prelate's barrier,\r
+\r
+543\r
+00:33:37,951 --> 00:33:39,051\r
+and set me free.\r
+\r
+544\r
+00:33:45,893 --> 00:33:47,059\r
+Is this a joke?\r
+\r
+545\r
+00:33:47,060 --> 00:33:49,628\r
+Oh, I'm very serious.\r
+\r
+546\r
+00:33:49,629 --> 00:33:51,830\r
+Who's helping you?\r
+\r
+547\r
+00:33:51,831 --> 00:33:53,665\r
+All I can say is that\r
+once this is done,\r
+\r
+548\r
+00:33:53,666 --> 00:33:57,935\r
+the person I'm leaving behind\r
+will be very powerful.\r
+\r
+549\r
+00:33:57,936 --> 00:34:01,070\r
+She'll probably kill all\r
+the Sisters of the Light.\r
+\r
+550\r
+00:34:01,071 --> 00:34:04,140\r
+How kind of you to warn me.\r
+\r
+551\r
+00:34:05,809 --> 00:34:07,409\r
+But I'm afraid\r
+I can't let you do this.\r
+\r
+552\r
+00:34:07,410 --> 00:34:09,477\r
+Looking for this?\r
+\r
+553\r
+00:34:09,478 --> 00:34:11,946\r
+The choice is yours:\r
+\r
+554\r
+00:34:11,947 --> 00:34:13,847\r
+help me with what I need to do\r
+to prevent this woman\r
+\r
+555\r
+00:34:13,848 --> 00:34:15,082\r
+from killing everyone,\r
+\r
+556\r
+00:34:15,083 --> 00:34:18,284\r
+or stay here gagged and tied up\r
+while I escape anyway.\r
+\r
+557\r
+00:34:18,285 --> 00:34:21,854\r
+Either way, I'm getting free.\r
+\r
+558\r
+00:34:21,855 --> 00:34:25,357\r
+In one instance\r
+the Sisters will be safe.\r
+\r
+559\r
+00:34:25,358 --> 00:34:27,993\r
+In the other,\r
+they'll probably be slaughtered.\r
+\r
+560\r
+00:34:30,963 --> 00:34:33,765\r
+I've gotten\r
+to know you Richard.\r
+\r
+561\r
+00:34:33,766 --> 00:34:36,167\r
+You would never leave innocent\r
+women at the mercy of a monster.\r
+\r
+562\r
+00:34:36,168 --> 00:34:39,536\r
+I'd hardly call the Sisters\r
+of the Light innocent women.\r
+\r
+563\r
+00:34:39,537 --> 00:34:42,371\r
+You've lied to me,\r
+held me captive,\r
+\r
+564\r
+00:34:42,372 --> 00:34:45,706\r
+and separated me from the people\r
+I love most in the world.\r
+\r
+565\r
+00:34:47,608 --> 00:34:49,041\r
+But worst of all,\r
+\r
+566\r
+00:34:49,042 --> 00:34:51,943\r
+you've used your piety\r
+as an excuse\r
+\r
+567\r
+00:34:51,944 --> 00:34:53,478\r
+to take away my freedom.\r
+\r
+568\r
+00:34:53,479 --> 00:34:56,814\r
+Everything I've done, I've done\r
+with the best intentions.\r
+\r
+569\r
+00:34:56,815 --> 00:34:59,849\r
+I don't need training to tell\r
+you Wizard's Second Rule:\r
+\r
+570\r
+00:34:59,850 --> 00:35:04,320\r
+the greatest harm can result\r
+from the best intentions.\r
+\r
+571\r
+00:35:32,578 --> 00:35:36,179\r
+Is the air putting up\r
+much of a fight?\r
+\r
+572\r
+00:35:36,180 --> 00:35:39,015\r
+Well, I could use\r
+a sparring partner.\r
+\r
+573\r
+00:35:39,016 --> 00:35:41,150\r
+Mord-Siths don't spar.\r
+\r
+574\r
+00:35:41,151 --> 00:35:44,987\r
+When we fight,\r
+we fight to inflict pain.\r
+\r
+575\r
+00:35:48,892 --> 00:35:50,626\r
+Someone just tried to kill you.\r
+\r
+576\r
+00:36:10,881 --> 00:36:13,049\r
+Who are you and why are you\r
+trying to kill me?\r
+\r
+577\r
+00:36:13,050 --> 00:36:14,716\r
+I'm not telling you anything.\r
+\r
+578\r
+00:36:14,717 --> 00:36:16,617\r
+Feeling a little shy today?\r
+\r
+579\r
+00:36:16,618 --> 00:36:18,951\r
+I can help you\r
+find your courage.\r
+\r
+580\r
+00:36:22,021 --> 00:36:23,922\r
+What's going on here?\r
+\r
+581\r
+00:36:23,923 --> 00:36:26,358\r
+This woman just tried\r
+to kill Leo.\r
+\r
+582\r
+00:36:26,359 --> 00:36:28,794\r
+Perhaps you can compel her\r
+to explain why.\r
+\r
+583\r
+00:36:47,543 --> 00:36:51,478\r
+Can you bring her back\r
+with the Breath of Life?\r
+\r
+584\r
+00:36:54,982 --> 00:36:57,383\r
+No.\r
+\r
+585\r
+00:36:57,384 --> 00:36:58,784\r
+She's severed her windpipe.\r
+\r
+586\r
+00:36:58,785 --> 00:37:02,486\r
+Why would a Sister of the Light\r
+want to kill Leo?\r
+\r
+587\r
+00:37:02,487 --> 00:37:04,522\r
+Something must be terribly wrong\r
+within their order.\r
+\r
+588\r
+00:37:07,125 --> 00:37:09,625\r
+Richard's with them.\r
+\r
+589\r
+00:37:09,626 --> 00:37:10,626\r
+He could be in danger.\r
+\r
+590\r
+00:37:10,627 --> 00:37:12,128\r
+I have to find him.\r
+\r
+591\r
+00:37:12,129 --> 00:37:13,829\r
+I'll go with you.\r
+\r
+592\r
+00:37:13,830 --> 00:37:15,731\r
+What about the Stone of Tears?\r
+\r
+593\r
+00:37:15,732 --> 00:37:17,799\r
+He's right.\r
+\r
+594\r
+00:37:17,800 --> 00:37:19,801\r
+We shouldn't all go.\r
+\r
+595\r
+00:37:19,802 --> 00:37:21,002\r
+I'll stay with Leo.\r
+\r
+596\r
+00:37:21,003 --> 00:37:23,204\r
+You try to pick up\r
+Richard's trail.\r
+\r
+597\r
+00:37:25,340 --> 00:37:27,040\r
+Are you sure you\r
+want to do this?\r
+\r
+598\r
+00:37:27,041 --> 00:37:28,842\r
+Yes.\r
+\r
+599\r
+00:37:30,811 --> 00:37:32,077\r
+Place your palms on mine,\r
+\r
+600\r
+00:37:34,947 --> 00:37:36,515\r
+close your eyes,\r
+\r
+601\r
+00:37:38,117 --> 00:37:39,651\r
+and surrender yourself to me.\r
+\r
+602\r
+00:37:54,387 --> 00:37:56,354\r
+Say the words with me:\r
+\r
+603\r
+00:38:47,932 --> 00:38:50,968\r
+Now the Sisters won't be able\r
+to follow you.\r
+\r
+604\r
+00:38:53,137 --> 00:38:55,037\r
+All that power.\r
+\r
+605\r
+00:38:55,038 --> 00:38:56,038\r
+Useless.\r
+\r
+606\r
+00:38:56,039 --> 00:38:58,273\r
+Richard, help me.\r
+\r
+607\r
+00:38:58,274 --> 00:38:59,808\r
+You are a Sister of the Dark,\r
+Nicci.\r
+\r
+608\r
+00:38:59,809 --> 00:39:00,809\r
+And so is Ulicia.\r
+\r
+609\r
+00:39:00,810 --> 00:39:02,210\r
+That's not true.\r
+\r
+610\r
+00:39:02,211 --> 00:39:03,545\r
+At first I wasn't sure,\r
+\r
+611\r
+00:39:03,546 --> 00:39:04,980\r
+but then I realized:\r
+\r
+612\r
+00:39:04,981 --> 00:39:06,982\r
+<i>you're the one who passes\r
+out the hymn books.</i>\r
+\r
+613\r
+00:39:06,983 --> 00:39:08,651\r
+You killed Sister Brenna\r
+\r
+614\r
+00:39:08,652 --> 00:39:10,453\r
+by rubbing\r
+creeping elder on hers.\r
+\r
+615\r
+00:39:10,454 --> 00:39:12,554\r
+<i>She was poisoned\r
+when she kissed it.</i>\r
+\r
+616\r
+00:39:12,555 --> 00:39:14,055\r
+Why would I kill Brenna?\r
+\r
+617\r
+00:39:14,056 --> 00:39:16,490\r
+To make me suspicious\r
+of the Prelate.\r
+\r
+618\r
+00:39:16,491 --> 00:39:18,424\r
+That's absurd.\r
+Ulicia put the hymn book\r
+\r
+619\r
+00:39:18,425 --> 00:39:21,093\r
+<i>with the body so the poison\r
+wouldn't be discovered.</i>\r
+\r
+620\r
+00:39:21,094 --> 00:39:24,660\r
+She also alerted the Prelate\r
+that the rada'han was missing\r
+\r
+621\r
+00:39:24,661 --> 00:39:25,760\r
+so I'd be captured.\r
+\r
+622\r
+00:39:25,761 --> 00:39:28,030\r
+If we wanted you\r
+out of the palace,\r
+\r
+623\r
+00:39:28,031 --> 00:39:29,767\r
+why would we\r
+want you captured?\r
+\r
+624\r
+00:39:29,768 --> 00:39:32,103\r
+Because you needed me to believe\r
+that the only way out\r
+\r
+625\r
+00:39:32,104 --> 00:39:34,639\r
+was to let you take my powers.\r
+\r
+626\r
+00:39:41,779 --> 00:39:43,180\r
+Get him.\r
+\r
+627\r
+00:39:49,753 --> 00:39:52,421\r
+Your han isn't as strong\r
+as the woman\r
+\r
+628\r
+00:39:52,422 --> 00:39:53,788\r
+who put up this barrier.\r
+\r
+629\r
+00:39:53,789 --> 00:39:55,657\r
+You can't take\r
+it down so easily.\r
+\r
+630\r
+00:39:55,658 --> 00:39:59,660\r
+Richard, don't go.\r
+\r
+631\r
+00:39:59,661 --> 00:40:02,963\r
+Don't you see, you'll only\r
+be serving the Keeper?\r
+\r
+632\r
+00:40:02,964 --> 00:40:06,365\r
+I don't believe\r
+in prophecies.\r
+\r
+633\r
+00:40:06,366 --> 00:40:09,001\r
+You're a lost soul if you have\r
+nothing to believe in, Richard.\r
+\r
+634\r
+00:40:10,369 --> 00:40:12,403\r
+I believe in myself.\r
+\r
+635\r
+00:40:12,404 --> 00:40:13,671\r
+And the people I love.\r
+\r
+636\r
+00:40:33,180 --> 00:40:35,473\r
+Well, it's only a matter of time\r
+before he finds the stone\r
+\r
+637\r
+00:40:35,474 --> 00:40:36,539\r
+and gives it to the Keeper.\r
+\r
+638\r
+00:40:36,540 --> 00:40:39,765\r
+Just like the Prophecy says.\r
+\r
+639\r
+00:40:39,766 --> 00:40:42,666\r
+I wouldn't underestimate him\r
+if I were you.\r
+\r
+640\r
+00:40:42,667 --> 00:40:44,568\r
+He's full of surprises.\r
+\r
+641\r
+00:41:05,287 --> 00:41:06,718\r
+Sister, what's happening?\r
+\r
+642\r
+00:41:11,356 --> 00:41:14,191\r
+A new prophecy.\r
+\r
+643\r
+00:41:14,192 --> 00:41:17,127\r
+That hasn't happened\r
+in a thousand years.\r
+\r
+644\r
+00:41:19,530 --> 00:41:22,866\r
+"As long as the Mother\r
+Confessor's pure heart beats,\r
+\r
+645\r
+00:41:22,867 --> 00:41:27,103\r
+the Keeper is doomed to fail."\r
+\r
+646\r
+00:41:39,047 --> 00:41:40,614\r
+Lesson Number 88, Seeker:\r
+\r
+647\r
+00:41:40,615 --> 00:41:44,583\r
+"Growling bellies make for\r
+unhappy traveling companions."\r
+\r
+648\r
+00:41:44,584 --> 00:41:46,117\r
+You want to stop and eat?\r
+\r
+649\r
+00:41:48,487 --> 00:41:49,820\r
+Kahlan.\r
+\r
+650\r
+00:41:49,821 --> 00:41:50,988\r
+Cara.\r
+\r
+651\r
+00:41:50,989 --> 00:41:52,255\r
+What are you doing here?\r
+\r
+652\r
+00:41:52,256 --> 00:41:53,523\r
+We were heading south,\r
+\r
+653\r
+00:41:53,524 --> 00:41:56,859\r
+but then the compass\r
+suddenly changed direction\r
+\r
+654\r
+00:41:56,860 --> 00:41:57,993\r
+and it led us here.\r
+\r
+655\r
+00:41:57,994 --> 00:42:00,229\r
+If the compass led you to us,\r
+\r
+656\r
+00:42:00,230 --> 00:42:03,465\r
+and we're traveling\r
+towards Richard, then--\r
+\r
+657\r
+00:42:06,236 --> 00:42:08,470\r
+Then the compass must\r
+be guiding us all back to him.\r
+\r
+658\r
+00:42:10,780 --> 00:42:15,414\r
+-- Sync, corrected by <font color=#00FF00>elderman</font> --\r
+-- <font color=#00FFFF>for addic7ed.com</font> --\r
+\r
diff --git a/TC/utc/audio/tslist b/TC/utc/audio/tslist
new file mode 100755 (executable)
index 0000000..a15691b
--- /dev/null
@@ -0,0 +1,43 @@
+/utc/audio/utc_audio_svc_add_item_to_playlist_func
+/utc/audio/utc_audio_svc_add_playlist_func
+/utc/audio/utc_audio_svc_check_duplicate_insertion_in_playlist_func
+/utc/audio/utc_audio_svc_close_func
+/utc/audio/utc_audio_svc_count_group_item_func
+/utc/audio/utc_audio_svc_count_list_item_func
+/utc/audio/utc_audio_svc_count_playlist_by_name_func
+/utc/audio/utc_audio_svc_count_playlist_func
+/utc/audio/utc_audio_svc_create_table_func
+/utc/audio/utc_audio_svc_delete_all_func
+/utc/audio/utc_audio_svc_delete_item_by_path_func
+/utc/audio/utc_audio_svc_delete_playlist_func
+/utc/audio/utc_audio_svc_get_group_item_func
+/utc/audio/utc_audio_svc_get_item_by_audio_id_func
+/utc/audio/utc_audio_svc_get_item_by_path_func
+/utc/audio/utc_audio_svc_get_list_item_func
+/utc/audio/utc_audio_svc_get_path_by_audio_id_func
+/utc/audio/utc_audio_svc_get_playlist_name_by_playlist_id_func
+/utc/audio/utc_audio_svc_get_playlist_func
+/utc/audio/utc_audio_svc_get_unique_playlist_name_func
+/utc/audio/utc_audio_svc_insert_item_func
+/utc/audio/utc_audio_svc_item_free_func
+/utc/audio/utc_audio_svc_item_get_val_func
+/utc/audio/utc_audio_svc_item_new_func
+/utc/audio/utc_audio_svc_list_item_free_func
+/utc/audio/utc_audio_svc_list_item_get_func
+/utc/audio/utc_audio_svc_list_item_get_val_func
+/utc/audio/utc_audio_svc_list_item_new_func
+/utc/audio/utc_audio_svc_move_item_func
+/utc/audio/utc_audio_svc_open_func
+/utc/audio/utc_audio_svc_playlist_free_func
+/utc/audio/utc_audio_svc_playlist_get_item_func
+/utc/audio/utc_audio_svc_playlist_get_val_func
+/utc/audio/utc_audio_svc_playlist_new_func
+/utc/audio/utc_audio_svc_playlist_set_val_func
+/utc/audio/utc_audio_svc_refresh_metadata_func
+/utc/audio/utc_audio_svc_remove_item_from_playlist_by_audio_id_func
+/utc/audio/utc_audio_svc_set_db_valid_func
+/utc/audio/utc_audio_svc_set_item_valid_func
+/utc/audio/utc_audio_svc_update_playlist_name_func
+/utc/audio/utc_audio_svc_delete_invalid_items_func
+/utc/audio/utc_audio_svc_check_item_exist_func
+/utc/audio/utc_audio_svc_get_playlist_id_by_playlist_name_func
diff --git a/TC/utc/audio/utc_audio_svc_add_item_to_playlist_func.c b/TC/utc/audio/utc_audio_svc_add_item_to_playlist_func.c
new file mode 100755 (executable)
index 0000000..72a6893
--- /dev/null
@@ -0,0 +1,104 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_add_item_to_playlist_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_add_playlist API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_add_item_to_playlist_func.h"\r
+\r
+\r
+\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_add_playlist() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_add_item_to_playlist_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_add_item_to_playlist_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       int playlist_id = 0;\r
+       char audio_id[AUDIO_SVC_UUID_SIZE+1] = {0, };\r
+\r
+       retval = get_playlist_id(&playlist_id);\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_default_playlist_exist","fail to check default playlist.");\r
+       }\r
+       \r
+       retval = get_item_audio_id(audio_id);\r
+       if(!retval)\r
+       {\r
+               dts_fail("get_item_audio_id","fail to get audio_id.");\r
+       }\r
+       \r
+       ret = audio_svc_add_item_to_playlist(playlist_id, audio_id);\r
+       dts_check_eq("audio_svc_add_item_to_playlist", ret, AUDIO_SVC_ERROR_NONE, "unable to add item to playlist.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_add_playlist() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_add_item_to_playlist_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_add_item_to_playlist_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       int plst_index = -1;\r
+       char * audio_id = "550e8400-e29b-41d4-a716-446655440000";\r
+\r
+       ret = audio_svc_add_item_to_playlist(plst_index, audio_id);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_add_item_to_playlist","abnormal condition test for invalid parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_add_item_to_playlist","add item to playlist should be failed because of the invalid parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_add_item_to_playlist_func.h b/TC/utc/audio/utc_audio_svc_add_item_to_playlist_func.h
new file mode 100755 (executable)
index 0000000..cbd2a2b
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_add_item_to_playlist_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_add_playlist API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_ADD_ITEM_TO_PLAYLIST_FUNC_H_\r
+#define __UTS_AUDIO_SVC_ADD_ITEM_TO_PLAYLIST_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_add_item_to_playlist_func_01();\r
+void utc_audio_svc_add_item_to_playlist_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_add_item_to_playlist_func_01, 1},\r
+       {utc_audio_svc_add_item_to_playlist_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_ADD_ITEM_TO_PLAYLIST_FUNC_H_  \r
diff --git a/TC/utc/audio/utc_audio_svc_add_playlist_func.c b/TC/utc/audio/utc_audio_svc_add_playlist_func.c
new file mode 100755 (executable)
index 0000000..5fe3d58
--- /dev/null
@@ -0,0 +1,90 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_insert_playlist_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_add_playlist API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_add_playlist_func.h"\r
+\r
+\r
+\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_add_playlist() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_insert_playlist_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_insert_playlist_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       const char *playlist_name = "plst_test_00";\r
+       int playlist_id = 0;\r
+       \r
+       ret = audio_svc_add_playlist(playlist_name, &playlist_id);\r
+       dts_check_eq("audio_svc_add_playlist", ret, AUDIO_SVC_ERROR_NONE, "unable to insert playlist.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_add_playlist() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_insert_playlist_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success \r
+*/\r
+void utc_audio_svc_insert_playlist_func_02()\r
+{      \r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+\r
+       ret = audio_svc_add_playlist(NULL, NULL);\r
+       \r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_add_playlist","abnormal condition test for invalid parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_add_playlist","Inserting playlist should be failed because of the NULL out parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_add_playlist_func.h b/TC/utc/audio/utc_audio_svc_add_playlist_func.h
new file mode 100755 (executable)
index 0000000..e8d113c
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_insert_playlist_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_add_playlist API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_INSERT_PLAYLIST_FUNC_H_\r
+#define __UTS_AUDIO_SVC_INSERT_PLAYLIST_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_insert_playlist_func_01();\r
+void utc_audio_svc_insert_playlist_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_insert_playlist_func_01, 1},\r
+       {utc_audio_svc_insert_playlist_func_02, 2},     \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_INSERT_PLAYLIST_FUNC_H_       \r
diff --git a/TC/utc/audio/utc_audio_svc_check_duplicate_insertion_in_playlist_func.c b/TC/utc/audio/utc_audio_svc_check_duplicate_insertion_in_playlist_func.c
new file mode 100755 (executable)
index 0000000..d161291
--- /dev/null
@@ -0,0 +1,111 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_check_duplicate_insertion_in_playlist_playlist_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_add_playlist API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_check_duplicate_insertion_in_playlist_func.h"\r
+\r
+\r
+\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_add_playlist() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_check_duplicate_insertion_in_playlist_playlist_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_check_duplicate_insertion_in_playlist_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       int playlist_id = 0;\r
+       char audio_id[AUDIO_SVC_UUID_SIZE+1] = {0, };\r
+       int count = -1;\r
+\r
+       retval = get_playlist_id(&playlist_id);\r
+       if(!retval)\r
+       {\r
+               dts_fail("get_playlist_id","fail to get playlist id.");\r
+       }\r
+\r
+       retval = check_default_item_exist();\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_default_item_exist","fail to check default item.");\r
+       }\r
+\r
+       retval = get_item_audio_id(audio_id);\r
+       if(!retval)\r
+       {\r
+               dts_fail("get_item_audio_id","fail to get audio_id.");\r
+       }\r
+       \r
+       ret = audio_svc_check_duplicate_insertion_in_playlist(playlist_id, audio_id, &count);\r
+       dts_check_eq("audio_svc_check_duplicate_insertion_in_playlist", ret, AUDIO_SVC_ERROR_NONE, "unable to check duplicate insertion.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_add_playlist() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_check_duplicate_insertion_in_playlist_playlist_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_check_duplicate_insertion_in_playlist_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       int playlist_id = 1;\r
+       char * audio_id = "550e8400-e29b-41d4-a716-446655440000";\r
+\r
+       ret = audio_svc_check_duplicate_insertion_in_playlist(playlist_id, audio_id, NULL);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_check_duplicate_insertion_in_playlist","abnormal condition test for invalid parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_check_duplicate_insertion_in_playlist","check insertion should be failed because of the NULL parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_check_duplicate_insertion_in_playlist_func.h b/TC/utc/audio/utc_audio_svc_check_duplicate_insertion_in_playlist_func.h
new file mode 100755 (executable)
index 0000000..27ab7df
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_check_duplicate_insertion_in_playlist_playlist_func.h\r
+* @author\r
+* @brief       This is the implementaion file for the test case of audio_svc_add_playlist API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_CHECK_DUPLICATE_INSERT_PLAYLIST_FUNC_H_\r
+#define __UTS_AUDIO_SVC_CHECK_DUPLICATE_INSERT_PLAYLIST_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_check_duplicate_insertion_in_playlist_func_01();\r
+void utc_audio_svc_check_duplicate_insertion_in_playlist_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_check_duplicate_insertion_in_playlist_func_01, 1},\r
+       {utc_audio_svc_check_duplicate_insertion_in_playlist_func_02, 2},\r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_CHECK_DUPLICATE_INSERT_PLAYLIST_FUNC_H_\r
diff --git a/TC/utc/audio/utc_audio_svc_check_item_exist_func.c b/TC/utc/audio/utc_audio_svc_check_item_exist_func.c
new file mode 100755 (executable)
index 0000000..c715bf8
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file                utc_audio_svc_check_item_exist_func.c
+* @brief       This is a suit of unit test cases to test audio_svc_check_item_exist API function
+* @author
+* @version     Initial Creation Version 0.1
+* @date        2011-03-07
+*/
+#include "utc_audio_svc_check_item_exist_func.h"
+
+
+void startup()
+{
+       UTC_AUDIO_SVC_OPEN();
+}
+
+
+void cleanup()
+{
+       UTC_AUDIO_SVC_CLOSE();
+}
+
+/**
+* @brief       This tests int audio_svc_check_item_exist() API with valid parameter
+* @par ID      utc_audio_svc_check_item_exist_func_01
+* @param       [in] storage_type       storage type to delete invalid item
+*                      [in]    path                    the file path
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_audio_svc_check_item_exist_func_01()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       ret = audio_svc_check_item_exist(DEFAULT_FILE);
+       if(ret ==  AUDIO_SVC_ERROR_INVALID_PARAMETER)
+       {
+               dts_fail("audio_svc_check_item_exist","fail to check item.");
+       }
+       else
+       {
+               dts_pass("audio_svc_check_item_exist","Success to check item.");
+       }
+}
+
+
+/**
+* @brief       This tests int audio_svc_check_item_exist() API with invalid parameter
+* @par ID      utc_audio_svc_check_item_exist_func_02
+* @param       [in] storage_type       storage type to delete invalid item
+*                      [in]    path                    the file path
+* @return      error code on success
+*/
+void utc_audio_svc_check_item_exist_func_02()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       ret = audio_svc_check_item_exist(NULL);
+       if (ret ==  AUDIO_SVC_ERROR_INVALID_PARAMETER)
+       {
+               dts_pass("audio_svc_check_item_exist","abnormal condition test for invalid path parameter.");
+       }
+       else
+       {
+               dts_fail("audio_svc_check_item_exist","this API should be failed because of the invalid path parameter.");
+       }
+
+       return ;
+}
+
diff --git a/TC/utc/audio/utc_audio_svc_check_item_exist_func.h b/TC/utc/audio/utc_audio_svc_check_item_exist_func.h
new file mode 100755 (executable)
index 0000000..d91c072
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file                utc_audio_svc_check_item_exist_func.h
+* @author      
+* @brief       This is the implementaion file for the test case of audio_svc_check_item_exist API function
+* @version     Initial Creation Version 0.1
+* @date                2011-03-07
+*/
+
+#ifndef __UTS_AUDIO_SVC_CHECK_ITEM_EXIST_FUNC_H_
+#define __UTS_AUDIO_SVC_CHECK_ITEM_EXIST_FUNC_H_
+
+
+#include "utc_audio_svc_common.h"
+
+void startup();
+void cleanup();
+
+/* Initialize TCM data structures */
+void (*tet_startup)() = startup;
+void (*tet_cleanup)() = cleanup;
+
+void utc_audio_svc_check_item_exist_func_01();
+void utc_audio_svc_check_item_exist_func_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_audio_svc_check_item_exist_func_01, 1},
+       {utc_audio_svc_check_item_exist_func_02, 2},    
+       {NULL, 0}
+};
+
+
+#endif //__UTS_AUDIO_SVC_CHECK_ITEM_EXIST_FUNC_H_
+
diff --git a/TC/utc/audio/utc_audio_svc_close_func.c b/TC/utc/audio/utc_audio_svc_close_func.c
new file mode 100755 (executable)
index 0000000..28e3297
--- /dev/null
@@ -0,0 +1,81 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_close_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_close API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_close_func.h"\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_close() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_close_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_close_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+\r
+       ret = audio_svc_close();\r
+       dts_check_eq("audio_svc_close", ret, AUDIO_SVC_ERROR_NONE, "fail to close music db.");\r
+\r
+}\r
+\r
+#if 0\r
+/**\r
+* @brief               This tests int audio_svc_close() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_close_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success \r
+*/\r
+void utc_audio_svc_close_func_02()\r
+{      \r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       UTC_AUDIO_SVC_OPEN();\r
+       ret = audio_svc_close();\r
+       if (!ret)\r
+       {\r
+               UTC_MM_LOG("abnormal condition test for null, error code->%x", ret);\r
+               tet_result(TET_PASS);\r
+       }\r
+       else\r
+       {\r
+               UTC_MM_LOG("Closing music db should be failed because of the NULL out parameter.");\r
+               tet_result(TET_FAIL);\r
+       }\r
+\r
+       return ;\r
+}\r
+#endif\r
diff --git a/TC/utc/audio/utc_audio_svc_close_func.h b/TC/utc/audio/utc_audio_svc_close_func.h
new file mode 100755 (executable)
index 0000000..d48ad70
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_close_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_close API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_CLOSE_FUNC_H_\r
+#define __UTS_AUDIO_SVC_CLOSE_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+\r
+void startup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = NULL;\r
+\r
+void utc_audio_svc_close_func_01();\r
+//void utc_audio_svc_close_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_close_func_01, 1},\r
+//     {utc_audio_svc_close_func_02, 2},       \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_CLOSE_FUNC_H_ \r
diff --git a/TC/utc/audio/utc_audio_svc_common.c b/TC/utc/audio/utc_audio_svc_common.c
new file mode 100755 (executable)
index 0000000..70fefd8
--- /dev/null
@@ -0,0 +1,355 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+bool copy_file(const char* srcPath, const char* destPath);\r
+\r
+bool copy_file(const char* srcPath, const char* destPath)\r
+{\r
+       FILE* fs = NULL;\r
+       FILE* fd = NULL;\r
+       char buff[4096] = {0};\r
+       int n = 0;\r
+       int m = 0;\r
+       bool result = FALSE;\r
+       bool remove_dest = FALSE;\r
+\r
+       fs=fopen(srcPath, "rb");\r
+       if(fs == NULL)\r
+       {\r
+               dts_message("fopen", "failed to open source file: %s", srcPath);\r
+               return FALSE;\r
+       }\r
+\r
+\r
+       fd=fopen(destPath, "wb");\r
+       if(fd == NULL)\r
+       {\r
+               dts_message("fopen", "ailed to open dest file: %s", destPath);\r
+\r
+               fclose(fs);\r
+               return FALSE;\r
+       }\r
+\r
+\r
+       while (1)\r
+       {\r
+               result = feof(fs);\r
+               if (!result)\r
+               {\r
+                       n = fread(buff, sizeof(char), sizeof(buff), fs);\r
+                       if(n > 0 && n <= sizeof(buff))\r
+                       {\r
+                               m = fwrite(buff, sizeof(char), n, fd);\r
+                               if (m <= 0)\r
+                               {\r
+                                       dts_message("fwrite", "fwrite = %d \n", m);\r
+\r
+                                       result = FALSE;\r
+                                       remove_dest = TRUE;\r
+                                       goto CATCH;\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               dts_message("fread", "fread = %d \n", n);\r
+                               result = TRUE;\r
+                               goto CATCH;\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       result = TRUE;\r
+                       goto CATCH;\r
+               }\r
+\r
+\r
+       }\r
+\r
+CATCH:\r
+       fflush(fd);\r
+       fsync(fileno(fd));\r
+       fclose(fd);\r
+       fclose(fs);\r
+\r
+       if(remove_dest)\r
+       {\r
+               remove(destPath);\r
+               sync();\r
+       }\r
+\r
+       dts_message("copy_file", "copying file is successful\n");\r
+       return result;\r
+}\r
+\r
+bool get_item_audio_id(char * audio_id_val)\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       AudioHandleType *item;\r
+       char * audio_id = NULL;\r
+       int size = 0;\r
+\r
+       retval = check_default_item_exist();\r
+       if(!retval)\r
+       {\r
+               dts_message("check_default_item_exist","fail to check default item exist.");\r
+               return FALSE;\r
+       }\r
+\r
+       ret = audio_svc_item_new(&item);\r
+       if(ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_message("audio_svc_item_new","fail to audio_svc_item_new.");\r
+               return FALSE;\r
+       }\r
+       \r
+       ret = audio_svc_get_item_by_path(DEFAULT_FILE, item);\r
+       if(ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_item_free(item);\r
+               dts_message("audio_svc_get_item_by_path","fail to audio_svc_get_item_by_path.");\r
+               return FALSE;\r
+       }\r
+       \r
+       ret = audio_svc_item_get_val(item, AUDIO_SVC_TRACK_DATA_AUDIO_ID, &audio_id, &size, -1);\r
+       if(ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_item_free(item);\r
+               dts_message("audio_svc_item_get_val","fail to audio_svc_item_get_val.");\r
+               return FALSE;\r
+       }\r
+\r
+       if(audio_id == NULL)\r
+       {\r
+               audio_svc_item_free(item);\r
+               dts_message("audio_svc_item_get_val","wrong audio_id.");\r
+               return FALSE;\r
+       }\r
+       \r
+       _strncpy_safe(audio_id_val, audio_id, AUDIO_SVC_UUID_SIZE+1);\r
+\r
+       ret = audio_svc_item_free(item);\r
+       if(ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_message("audio_svc_item_free","fail to audio_svc_item_free.");\r
+               return FALSE;\r
+       }\r
+       \r
+       return TRUE;\r
+       \r
+}\r
+\r
+bool get_playlist_id(int * playlist_id)\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       AudioHandleType*playlists = NULL;\r
+       int count = -1;\r
+       int plst_id = 0;\r
+       \r
+       retval = check_default_playlist_exist();\r
+       if(!retval)\r
+       {\r
+               dts_message("check_default_playlist_exist","fail to check default playlist exist.");\r
+               return FALSE;\r
+       }\r
+\r
+       ret = audio_svc_count_playlist("", "", &count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_message("audio_svc_count_playlist","unable to get playlist.");\r
+               return FALSE;\r
+       }\r
+       \r
+       ret = audio_svc_playlist_new(&playlists, count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_message("audio_svc_count_playlist","there is no playlist.");\r
+               return FALSE;\r
+       }\r
+       \r
+       //get all the playlists in db.\r
+       ret = audio_svc_get_playlist(\r
+                               NULL, //filter_string,\r
+                               NULL, //filter_string2,\r
+                               0, //offset,\r
+                               count,\r
+                               playlists);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_playlist_free(playlists);\r
+               dts_message("audio_svc_get_playlist","unable to get playlist.");\r
+               return FALSE;\r
+       }\r
+       \r
+       //get the playlist id and playlist name of each playlist\r
+       ret = audio_svc_playlist_get_val(playlists, 0, AUDIO_SVC_PLAYLIST_ID, &plst_id, -1);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_playlist_free(playlists);\r
+               dts_message("audio_svc_get_playlist","unable to get value for playlist.");\r
+               return FALSE;\r
+       }\r
+\r
+       if(plst_id < 1)\r
+       {\r
+               audio_svc_playlist_free(playlists);\r
+               dts_message("audio_svc_get_playlist","unable to get value for playlist.");\r
+               return FALSE;\r
+       }\r
+       \r
+       *playlist_id = plst_id;\r
+\r
+       ret = audio_svc_playlist_free(playlists);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_message("audio_svc_playlist_free","unable to audio_svc_playlist_free.");\r
+               return FALSE;\r
+       }\r
+       \r
+       return TRUE;\r
+}      \r
+\r
+bool check_default_item_exist()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       audio_svc_storage_type_e storage = AUDIO_SVC_STORAGE_PHONE;\r
+\r
+       ret = audio_svc_check_item_exist(DEFAULT_FILE);\r
+       if(ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               ret = audio_svc_insert_item(storage, DEFAULT_FILE, AUDIO_SVC_CATEGORY_MUSIC);\r
+               if (ret != AUDIO_SVC_ERROR_NONE)\r
+               {\r
+                       dts_message("audio_svc_insert_item","fail to insert item.");\r
+                       return FALSE;\r
+               }\r
+       }\r
+       \r
+       return TRUE;\r
+}\r
+\r
+bool check_temp_item_file_exist()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+\r
+       ret = audio_svc_check_item_exist(TEST_FILE);\r
+       if(ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               copy_file(DEFAULT_FILE, TEST_FILE);\r
+       }\r
+       else\r
+       {\r
+               ret = audio_svc_delete_item_by_path(TEST_FILE);\r
+               if (ret != AUDIO_SVC_ERROR_NONE)\r
+               {\r
+                       dts_message("audio_svc_delete_item_by_path","fail to delete item.");\r
+                       return FALSE;\r
+               }\r
+       }\r
+\r
+       return TRUE;\r
+}\r
+\r
+bool check_default_playlist_exist()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       int count = -1;\r
+\r
+       ret = audio_svc_count_playlist("", "", &count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_message("audio_svc_count_playlist","unable to get playlist.");\r
+               return FALSE;\r
+       }\r
+\r
+       if(count < 1)\r
+       {\r
+               int playlist_id = 0;\r
+               ret = audio_svc_add_playlist("plst_test", &playlist_id);\r
+               if (ret != AUDIO_SVC_ERROR_NONE)\r
+               {\r
+                       dts_message("audio_svc_add_playlist","fail to add playlist");\r
+                       return FALSE;\r
+               }\r
+               \r
+               ret = audio_svc_count_playlist( "", "", &count);\r
+               if (ret != AUDIO_SVC_ERROR_NONE)\r
+               {\r
+                       dts_message("audio_svc_count_playlist","unable to get playlist.");\r
+                       return FALSE;\r
+               }\r
+               if(count < 1)\r
+               {\r
+                       dts_message("audio_svc_count_playlist","there is no playlist");\r
+                       return FALSE;\r
+               }\r
+       }\r
+       \r
+       return TRUE;\r
+}\r
+\r
+bool check_playlist_has_item(int * playlist_id, char * audio_id_val)\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       int playlist_idx = 0;\r
+       char audio_id[AUDIO_SVC_UUID_SIZE+1] = {0, };\r
+       int count = -1;\r
+       \r
+       retval = get_playlist_id(&playlist_idx);\r
+       if(!retval)\r
+       {\r
+               dts_message("get_playlist_id","fail to get playlist id.");\r
+               return FALSE;\r
+       }\r
+\r
+       retval = get_item_audio_id(audio_id);\r
+       if(!retval)\r
+       {\r
+               dts_message("get_item_audio_id","fail to get item audio_id.");\r
+               return FALSE;\r
+       }\r
+\r
+       ret = audio_svc_check_duplicate_insertion_in_playlist(playlist_idx, audio_id, &count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_message("audio_svc_count_playlist","unable to get playlist.");\r
+               return FALSE;\r
+       }\r
+\r
+       if(count < 1)\r
+       {\r
+               ret = audio_svc_add_item_to_playlist(playlist_idx, audio_id);\r
+               if (ret != AUDIO_SVC_ERROR_NONE)\r
+               {\r
+                       dts_message("audio_svc_add_item_to_playlist","unable to audio_svc_add_item_to_playlist.");\r
+                       return FALSE;\r
+               }\r
+       }\r
+\r
+       *playlist_id = playlist_idx;\r
+       _strncpy_safe(audio_id_val, audio_id, AUDIO_SVC_UUID_SIZE+1);\r
+       \r
+       return TRUE;\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_common.h b/TC/utc/audio/utc_audio_svc_common.h
new file mode 100755 (executable)
index 0000000..db9d1b5
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+* @file                uts_mmf_player_common.h
+* @author      
+* @brief       This is the implementaion file for the test case of mmfplayer_common 
+* @version     Initial Creation Version 0.1
+* @date        2010-09-13
+*/
+
+#ifndef __UTS_AUDIO_SVC_COMMON_H_
+#define __UTS_AUDIO_SVC_COMMON_H_
+
+#include <audio-svc.h>
+#include <audio-svc-error.h>
+#include <string.h>
+#include <tet_api.h>
+#include <unistd.h>
+#include <glib.h>
+#include <stdbool.h>
+
+#define MAX_STRING_LEN 256
+
+#define UTC_MM_LOG(fmt, args...)       tet_printf("[%s(L%d)]:"fmt"\n", __FUNCTION__, __LINE__, ##args)
+
+#define UTC_AUDIO_SVC_OPEN() \
+do \
+{ \
+       int ret = AUDIO_SVC_ERROR_NONE; \
+       ret = audio_svc_open(); \
+       if (ret != AUDIO_SVC_ERROR_NONE) \
+       { \
+               dts_fail("audio_svc_open", "fail to open music db"); \
+       } \
+} \
+while(0);
+
+#define UTC_AUDIO_SVC_CLOSE() \
+do \
+{ \
+       int ret = AUDIO_SVC_ERROR_NONE; \
+       ret = audio_svc_close(); \
+       if (ret != AUDIO_SVC_ERROR_NONE) \
+       { \
+               dts_fail("audio_svc_close", "fail to close music db"); \
+       } \
+} \
+while(0);
+
+#define        DEFAULT_FILE            "/opt/media/Sounds and music/Music/Over the horizon.mp3"
+#define        TEST_FILE                       "/opt/media/Sounds and music/test.mp3"
+
+bool get_item_audio_id(char * audio_id_val);
+bool get_playlist_id(int * playlist_id);
+bool check_default_item_exist();
+bool check_temp_item_file_exist();
+bool check_default_playlist_exist();
+bool check_playlist_has_item(int * playlist_id, char * audio_id_val);
+
+#endif //__UTS_AUDIO_SVC_COMMON_H_
+
diff --git a/TC/utc/audio/utc_audio_svc_count_group_item_func.c b/TC/utc/audio/utc_audio_svc_count_group_item_func.c
new file mode 100755 (executable)
index 0000000..55da7c7
--- /dev/null
@@ -0,0 +1,85 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_count_group_item_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_count_group_item API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_count_group_item_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_count_group_item() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_count_group_item_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_count_group_item_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       int count = -1;\r
+       ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ARTIST, "", "", "", "", &count);\r
+       dts_check_eq("audio_svc_count_group_item", ret, AUDIO_SVC_ERROR_NONE, "failed to get groups.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_count_group_item() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_count_group_item_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success \r
+*/\r
+void utc_audio_svc_count_group_item_func_02()\r
+{      \r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       int count = -1;\r
+       ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ARTIST_ALBUM, NULL, "", "", "", &count);\r
+       \r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_count_group_item","abnormal condition test for invalid limit string parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_count_group_item","Counting groups should be failed because of the NULL limit string parameter.");\r
+       }\r
\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_count_group_item_func.h b/TC/utc/audio/utc_audio_svc_count_group_item_func.h
new file mode 100755 (executable)
index 0000000..ca55680
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_count_group_item_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_count_group_item API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_COUNT_GROUPS_FUNC_H_\r
+#define __UTS_AUDIO_SVC_COUNT_GROUPS_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_count_group_item_func_01();\r
+void utc_audio_svc_count_group_item_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_count_group_item_func_01, 1},\r
+       {utc_audio_svc_count_group_item_func_02, 2},    \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_COUNT_GROUPS_FUNC_H_  \r
diff --git a/TC/utc/audio/utc_audio_svc_count_list_item_func.c b/TC/utc/audio/utc_audio_svc_count_list_item_func.c
new file mode 100755 (executable)
index 0000000..8896334
--- /dev/null
@@ -0,0 +1,84 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_count_list_item_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_count_list_item API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_count_list_item_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_count_list_item() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_count_list_item_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_count_list_item_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       int count = -1;\r
+       ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
+       dts_check_eq("audio_svc_count_list_item", ret, AUDIO_SVC_ERROR_NONE, "failed to count items.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_count_list_item() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_count_list_item_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success \r
+*/\r
+void utc_audio_svc_count_list_item_func_02()\r
+{      \r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", NULL);\r
+       \r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_count_list_item","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_count_list_item","Counting items should be failed because of the NULL parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_count_list_item_func.h b/TC/utc/audio/utc_audio_svc_count_list_item_func.h
new file mode 100755 (executable)
index 0000000..dd9f532
--- /dev/null
@@ -0,0 +1,53 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_audio_svc_count_list_item_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_count_list_item API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_COUNT_ITEMS_FUNC_H_\r
+#define __UTS_AUDIO_SVC_COUNT_ITEMS_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_count_list_item_func_01();\r
+void utc_audio_svc_count_list_item_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_count_list_item_func_01, 1},\r
+       {utc_audio_svc_count_list_item_func_02, 2},     \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_COUNT_ITEMS_FUNC_H_   \r
diff --git a/TC/utc/audio/utc_audio_svc_count_playlist_by_name_func.c b/TC/utc/audio/utc_audio_svc_count_playlist_by_name_func.c
new file mode 100755 (executable)
index 0000000..bc6f703
--- /dev/null
@@ -0,0 +1,85 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_count_playlists_by_name_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_count_playlists API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_count_playlist_by_name_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_count_playlist_by_name() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_count_playlist_by_name_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_count_playlist_by_name_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       int count = -1;\r
+       ret = audio_svc_count_playlist_by_name("plst 001", &count);\r
+       dts_check_eq("audio_svc_count_playlist_by_name", ret, AUDIO_SVC_ERROR_NONE, "failed to get playlists count.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_count_playlist_by_name() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_count_playlist_by_name_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_count_playlist_by_name_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       int count = -1;\r
+       ret = audio_svc_count_playlist_by_name(NULL, &count);\r
+\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_count_playlist_by_name","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_count_playlist_by_name","Counting playlists should be failed because of the NULL parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_count_playlist_by_name_func.h b/TC/utc/audio/utc_audio_svc_count_playlist_by_name_func.h
new file mode 100755 (executable)
index 0000000..e1c7cd9
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_count_playlist_by_name_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_count_playlist_by_name API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_COUNT_PLAYLISTS_BY_NAME_FUNC_H_\r
+#define __UTS_AUDIO_SVC_COUNT_PLAYLISTS_BY_NAME_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_count_playlist_by_name_func_01();\r
+void utc_audio_svc_count_playlist_by_name_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_count_playlist_by_name_func_01, 1},\r
+       {utc_audio_svc_count_playlist_by_name_func_02, 2},      \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_COUNT_PLAYLISTS_BY_NAME_FUNC_H_       \r
diff --git a/TC/utc/audio/utc_audio_svc_count_playlist_func.c b/TC/utc/audio/utc_audio_svc_count_playlist_func.c
new file mode 100755 (executable)
index 0000000..7bbd17d
--- /dev/null
@@ -0,0 +1,84 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_count_playlist_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_count_playlist API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_count_playlist_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_count_playlist() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_count_playlist_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_count_playlist_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       int count = -1;\r
+       ret = audio_svc_count_playlist("", "", &count);\r
+       dts_check_eq("audio_svc_count_playlist", ret, AUDIO_SVC_ERROR_NONE, "failed to get playlists count.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_count_playlist() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_count_playlist_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_count_playlist_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       ret = audio_svc_count_playlist("", "", NULL);\r
+\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_count_playlist","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_count_playlist","Counting playlists should be failed because of the NULL parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_count_playlist_func.h b/TC/utc/audio/utc_audio_svc_count_playlist_func.h
new file mode 100755 (executable)
index 0000000..92049fd
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_count_playlist_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_count_playlist API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_COUNT_PLAYLISTS_FUNC_H_\r
+#define __UTS_AUDIO_SVC_COUNT_PLAYLISTS_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_count_playlist_func_01();\r
+void utc_audio_svc_count_playlist_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_count_playlist_func_01, 1},\r
+       {utc_audio_svc_count_playlist_func_02, 2},      \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_COUNT_PLAYLISTS_FUNC_H_       \r
diff --git a/TC/utc/audio/utc_audio_svc_create_table_func.c b/TC/utc/audio/utc_audio_svc_create_table_func.c
new file mode 100755 (executable)
index 0000000..05eba10
--- /dev/null
@@ -0,0 +1,84 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_create_table_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_create_table API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_create_table_func.h"\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_create_table() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_create_table_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_create_table_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       \r
+       ret = audio_svc_create_table();\r
+       dts_check_eq("audio_svc_create_table", ret, AUDIO_SVC_ERROR_NONE, "unable to create music phone table.");\r
+\r
+}\r
+\r
+#if 0\r
+/**\r
+* @brief       This tests int audio_svc_create_table() API with invalid parameter\r
+*              Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_create_table_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success \r
+*/\r
+void utc_audio_svc_create_table_func_02()\r
+{      \r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       \r
+       ret = audio_svc_create_table();\r
+       \r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_create_table","abnormal condition test for invalid storage type parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_create_table","create music table should be failed because of the invalid storage type.");\r
+       }\r
+\r
+}\r
+#endif\r
diff --git a/TC/utc/audio/utc_audio_svc_create_table_func.h b/TC/utc/audio/utc_audio_svc_create_table_func.h
new file mode 100755 (executable)
index 0000000..af0b93d
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_create_table_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_create_table API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_CREATE_TABLE_FUNC_H_\r
+#define __UTS_AUDIO_SVC_CREATE_TABLE_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_create_table_func_01();\r
+//void utc_audio_svc_create_table_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_create_table_func_01, 1},\r
+//     {utc_audio_svc_create_table_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_CREATE_TABLE_FUNC_H_  \r
diff --git a/TC/utc/audio/utc_audio_svc_delete_all_func.c b/TC/utc/audio/utc_audio_svc_delete_all_func.c
new file mode 100755 (executable)
index 0000000..9b34b8a
--- /dev/null
@@ -0,0 +1,85 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_delete_all_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_delete_all API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_delete_all_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_delete_all() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_delete_all_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_delete_all_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       \r
+       ret = audio_svc_delete_all(AUDIO_SVC_STORAGE_PHONE);\r
+       dts_check_eq("audio_svc_delete_all", ret, AUDIO_SVC_ERROR_NONE, "failed to get groups.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_delete_all() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_delete_all_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success \r
+*/\r
+void utc_audio_svc_delete_all_func_02()\r
+{      \r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+\r
+       ret = audio_svc_delete_all(100);\r
+\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_delete_all","abnormal condition test for invalid storage type.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_delete_all","Deleting all should be failed because of the storage type parameter.");\r
+       }\r
+       \r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_delete_all_func.h b/TC/utc/audio/utc_audio_svc_delete_all_func.h
new file mode 100755 (executable)
index 0000000..e3f6a4b
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_delete_all_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_delete_all API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_DELETE_ALL_FUNC_H_\r
+#define __UTS_AUDIO_SVC_DELETE_ALL_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_delete_all_func_01();\r
+void utc_audio_svc_delete_all_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_delete_all_func_01, 1},\r
+       {utc_audio_svc_delete_all_func_02, 2},  \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_DELETE_ALL_FUNC_H_    \r
diff --git a/TC/utc/audio/utc_audio_svc_delete_invalid_items_func.c b/TC/utc/audio/utc_audio_svc_delete_invalid_items_func.c
new file mode 100755 (executable)
index 0000000..9586b03
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file                utc_audio_svc_delete_invalid_items_func.c
+* @brief       This is a suit of unit test cases to test utc_audio_svc_delete_invalid_items_func API function
+* @author
+* @version     Initial Creation Version 0.1
+* @date        2011-03-07
+*/
+#include "utc_audio_svc_delete_invalid_items_func.h"
+
+
+void startup()
+{
+       UTC_AUDIO_SVC_OPEN();
+}
+
+
+void cleanup()
+{
+       UTC_AUDIO_SVC_CLOSE();
+}
+
+/**
+* @brief       This tests int audio_svc_delete_invalid_items() API with valid parameter
+* @par ID      utc_audio_svc_list_item_get_val_func_01
+* @param       [in] storage_type       storage type to delete invalid item
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_audio_svc_delete_invalid_items_func_01()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       audio_svc_storage_type_e storage = AUDIO_SVC_STORAGE_PHONE;
+
+       ret = audio_svc_delete_invalid_items(storage);
+       dts_check_eq("audio_svc_delete_invalid_items", ret, AUDIO_SVC_ERROR_NONE, "failed to delete invalid items.");
+}
+
+/**
+* @brief       This tests int audio_svc_delete_invalid_items() API with invalid parameter
+* @par ID      utc_audio_svc_list_item_get_val_func_02
+* @param       [in] storage_type       storage type to delete invalid item
+* @return      error code on success
+*/
+void utc_audio_svc_delete_invalid_items_func_02()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       audio_svc_storage_type_e storage = 3;
+
+       ret = audio_svc_delete_invalid_items(storage);
+       if (ret !=  AUDIO_SVC_ERROR_NONE)
+       {
+               dts_pass("audio_svc_delete_invalid_items","abnormal condition test for invalid storage parameter.");
+       }
+       else
+       {
+               dts_fail("audio_svc_delete_invalid_items","this API should be failed because of the invalid storage parameter.");
+       }
+
+       return ;
+}
+
diff --git a/TC/utc/audio/utc_audio_svc_delete_invalid_items_func.h b/TC/utc/audio/utc_audio_svc_delete_invalid_items_func.h
new file mode 100755 (executable)
index 0000000..d4be1f4
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file                utc_audio_svc_delete_invalid_items_func.h
+* @author      
+* @brief       This is the implementaion file for the test case of audio_svc_delete_invalid_items API function
+* @version     Initial Creation Version 0.1
+* @date                2011-03-07
+*/
+
+#ifndef __UTS_AUDIO_SVC_DELETE_INVALID_ITEMS_FUNC_H_
+#define __UTS_AUDIO_SVC_DELETE_INVALID_ITEMS_FUNC_H_
+
+
+#include "utc_audio_svc_common.h"
+
+void startup();
+void cleanup();
+
+/* Initialize TCM data structures */
+void (*tet_startup)() = startup;
+void (*tet_cleanup)() = cleanup;
+
+void utc_audio_svc_delete_invalid_items_func_01();
+void utc_audio_svc_delete_invalid_items_func_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_audio_svc_delete_invalid_items_func_01, 1},
+       {utc_audio_svc_delete_invalid_items_func_02, 2},        
+       {NULL, 0}
+};
+
+
+#endif //__UTS_AUDIO_SVC_DELETE_INVALID_ITEMS_FUNC_H_
+
diff --git a/TC/utc/audio/utc_audio_svc_delete_item_by_path_func.c b/TC/utc/audio/utc_audio_svc_delete_item_by_path_func.c
new file mode 100755 (executable)
index 0000000..462219d
--- /dev/null
@@ -0,0 +1,93 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_delete_item_by_path_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_delete_item_by_path API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_delete_item_by_path_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_delete_item_by_path() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_delete_item_by_path_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_delete_item_by_path_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+\r
+       retval = check_default_item_exist();\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_default_item_exist","fail to check default item.");\r
+       }\r
+       \r
+       ret = audio_svc_delete_item_by_path(DEFAULT_FILE);\r
+       dts_check_eq("audio_svc_delete_item_by_path", ret, AUDIO_SVC_ERROR_NONE, "failed to delete item by path.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_delete_item_by_path() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_delete_item_by_path_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_delete_item_by_path_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       const char * path = NULL;\r
+\r
+       ret = audio_svc_delete_item_by_path(path);\r
+\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_delete_item_by_path","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_delete_item_by_path","Getting item by path should be failed because of the invalid parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_delete_item_by_path_func.h b/TC/utc/audio/utc_audio_svc_delete_item_by_path_func.h
new file mode 100755 (executable)
index 0000000..85b6f52
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_get_item_by_path_func.h\r
+* @author\r
+* @brief       This is the implementaion file for the test case of audio_svc_get_item_by_path API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_GET_ITEM_BY_PATH_FUNC_H_\r
+#define __UTS_AUDIO_SVC_GET_ITEM_BY_PATH_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_delete_item_by_path_func_01();\r
+void utc_audio_svc_delete_item_by_path_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_delete_item_by_path_func_01, 1},\r
+       {utc_audio_svc_delete_item_by_path_func_02, 2},\r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_GET_ITEM_BY_PATH_FUNC_H_\r
diff --git a/TC/utc/audio/utc_audio_svc_delete_playlist_func.c b/TC/utc/audio/utc_audio_svc_delete_playlist_func.c
new file mode 100755 (executable)
index 0000000..e9b3aec
--- /dev/null
@@ -0,0 +1,97 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_delete_playlist_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_delete_playlist API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_delete_playlist_func.h"\r
+\r
+\r
+\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_delete_playlist() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_delete_playlist_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_delete_playlist_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       int playlist_id = 0;\r
+\r
+       retval = get_playlist_id(&playlist_id);\r
+       if(!retval)\r
+       {\r
+               dts_fail("get_playlist_id","fail to get playlist id.");\r
+       }\r
+       \r
+       ret = audio_svc_delete_playlist(playlist_id);\r
+       dts_check_eq("audio_svc_delete_playlist", ret, AUDIO_SVC_ERROR_NONE, "failed to delete playlist.");\r
+       \r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_delete_playlist() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_delete_playlist_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success \r
+*/\r
+void utc_audio_svc_delete_playlist_func_02()\r
+{      \r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       int playlist_id = -1;\r
+       \r
+       ret = audio_svc_delete_playlist(playlist_id);\r
+       \r
+       if (ret  != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_delete_playlist","abnormal condition test for invalid parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_delete_playlist","deleting playlist should be failed because of the invalid parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_delete_playlist_func.h b/TC/utc/audio/utc_audio_svc_delete_playlist_func.h
new file mode 100755 (executable)
index 0000000..4a9db6a
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_delete_playlist_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_delete_playlist API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_DELETE_PLAYLIST_FUNC_H_\r
+#define __UTS_AUDIO_SVC_DELETE_PLAYLIST_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_delete_playlist_func_01();\r
+void utc_audio_svc_delete_playlist_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_delete_playlist_func_01, 1},\r
+       {utc_audio_svc_delete_playlist_func_02, 2},     \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_DELETE_PLAYLIST_FUNC_H_       \r
diff --git a/TC/utc/audio/utc_audio_svc_get_group_item_func.c b/TC/utc/audio/utc_audio_svc_get_group_item_func.c
new file mode 100755 (executable)
index 0000000..0c08b89
--- /dev/null
@@ -0,0 +1,117 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_get_group_item_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_get_group_item API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_get_group_item_func.h"\r
+\r
+\r
+\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_get_group_item() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_get_group_item_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_get_group_item_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       AudioHandleType *result_records = NULL;\r
+       int count = -1;\r
+\r
+       retval = check_default_item_exist();\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_default_item_exist","fail to check default item.");\r
+       }\r
+       \r
+       ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Breakaway", "", "", "", &count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_count_group_item","unable to count.");\r
+       }\r
+\r
+       ret = audio_svc_list_item_new(&result_records, count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_list_item_new","unable to new records.");\r
+       }\r
+\r
+       ret = audio_svc_get_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Breakaway", "", "", "", 0, count, result_records);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_list_item_free(result_records);\r
+               dts_fail("audio_svc_get_group_item","unable to get records.");\r
+       }\r
+\r
+       ret = audio_svc_list_item_free(result_records);\r
+       dts_check_eq("audio_svc_list_item_free", ret, AUDIO_SVC_ERROR_NONE, "fail to free memory.");\r
+       \r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_get_group_item() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_get_group_item_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_get_group_item_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *result_records = NULL;\r
+       \r
+       ret = audio_svc_get_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Breakaway", "", "", "", 0, ret, result_records);\r
+\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_get_group_item","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_get_group_item","Getting groups should be failed because of the NULL out parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_get_group_item_func.h b/TC/utc/audio/utc_audio_svc_get_group_item_func.h
new file mode 100755 (executable)
index 0000000..d393366
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_get_group_item_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_get_group_item API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_GET_GROUPS_FUNC_H_\r
+#define __UTS_AUDIO_SVC_GET_GROUPS_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_get_group_item_func_01();\r
+void utc_audio_svc_get_group_item_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_get_group_item_func_01, 1},\r
+       {utc_audio_svc_get_group_item_func_02, 2},      \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif // __UTS_AUDIO_SVC_GET_GROUPS_FUNC_H_\r
diff --git a/TC/utc/audio/utc_audio_svc_get_item_by_audio_id_func.c b/TC/utc/audio/utc_audio_svc_get_item_by_audio_id_func.c
new file mode 100755 (executable)
index 0000000..3bb0fb4
--- /dev/null
@@ -0,0 +1,127 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_get_item_by_audio_id_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_get_item_by_audio_id API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_get_item_by_audio_id_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_get_item_by_audio_id() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_get_item_by_audio_id_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_get_item_by_audio_id_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       char audio_id[AUDIO_SVC_UUID_SIZE+1] = {0, };\r
+       AudioHandleType *item = NULL;\r
+       int count = -1;\r
+\r
+       retval = check_default_item_exist();\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_default_item_exist","fail to check default item.");\r
+       }\r
+       \r
+       ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_count_list_item","failed to count items.");\r
+       }\r
+\r
+       if(count < 1)\r
+       {\r
+               dts_fail("audio_svc_insert_item","there is no item.");\r
+       }\r
+\r
+       ret = audio_svc_item_new(&item);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_item_new","failed to malloc.");\r
+       }\r
+\r
+       retval = get_item_audio_id(audio_id);\r
+       if(!retval)\r
+       {\r
+               dts_fail("get_item_audio_id","fail to get audio_id.");\r
+       }\r
+       \r
+       ret = audio_svc_get_item_by_audio_id(audio_id, item);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_item_free(item);\r
+               dts_fail("audio_svc_get_item_by_audio_id","failed to get item by audio_id.");\r
+       }\r
+\r
+       ret = audio_svc_item_free(item);\r
+       dts_check_eq("audio_svc_item_free", ret, AUDIO_SVC_ERROR_NONE, "fail to free memory.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_get_item_by_audio_id() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_get_item_by_audio_id_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_get_item_by_audio_id_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *item = NULL;\r
+       char * audio_id = "550e8400-e29b-41d4-a716-446655440000";\r
+\r
+       ret = audio_svc_get_item_by_audio_id(audio_id, item);\r
+\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_get_item_by_audio_id","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_get_item_by_audio_id","Getting item by path should be failed because of the null parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_get_item_by_audio_id_func.h b/TC/utc/audio/utc_audio_svc_get_item_by_audio_id_func.h
new file mode 100755 (executable)
index 0000000..0e89558
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_get_item_by_audio_id_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_get_item_by_audio_id API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_GET_ITEM_BY_AUDIO_ID_FUNC_H_\r
+#define __UTS_AUDIO_SVC_GET_ITEM_BY_AUDIO_ID_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_get_item_by_audio_id_func_01();\r
+void utc_audio_svc_get_item_by_audio_id_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_get_item_by_audio_id_func_01, 1},\r
+       {utc_audio_svc_get_item_by_audio_id_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_GET_ITEM_BY_AUDIO_ID_FUNC_H_  \r
diff --git a/TC/utc/audio/utc_audio_svc_get_item_by_path_func.c b/TC/utc/audio/utc_audio_svc_get_item_by_path_func.c
new file mode 100755 (executable)
index 0000000..97e2974
--- /dev/null
@@ -0,0 +1,114 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_get_item_by_path_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_get_item_by_path API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_get_item_by_path_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_get_item_by_path() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_get_item_by_path_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_get_item_by_path_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       AudioHandleType *item = NULL;\r
+\r
+       retval = check_default_item_exist();\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_default_item_exist","fail to check default item.");\r
+       }\r
+       \r
+       ret = audio_svc_item_new(&item);\r
+       if (ret  != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_item_new","failed to malloc.");\r
+       }\r
+\r
+       ret = audio_svc_get_item_by_path(DEFAULT_FILE, item);\r
+       if (ret  != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_item_free(item);\r
+               dts_fail("audio_svc_get_item_by_path","failed to get item by path.");\r
+       }\r
+\r
+       ret = audio_svc_item_free(item);\r
+       dts_check_eq("audio_svc_item_free", ret, AUDIO_SVC_ERROR_NONE, "fail to free memory.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_get_item_by_path() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_get_item_by_path_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_get_item_by_path_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *item = NULL;\r
+\r
+       ret = audio_svc_item_new(&item);\r
+       if (ret  != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_item_new","failed to malloc.");\r
+       }\r
+       \r
+       ret = audio_svc_get_item_by_path(NULL, item);\r
+       if (ret  != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_item_free(item);\r
+               dts_pass("audio_svc_get_item_by_path","abnormal condition test for invalid path.");\r
+       }\r
+       else\r
+       {\r
+               audio_svc_item_free(item);\r
+               dts_fail("audio_svc_get_item_by_path","Getting item by path should be failed because of the invalid path parameter.");\r
+       }\r
+       \r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_get_item_by_path_func.h b/TC/utc/audio/utc_audio_svc_get_item_by_path_func.h
new file mode 100755 (executable)
index 0000000..f63753c
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_get_item_by_path_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_get_item_by_path API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_GET_ITEM_BY_PATH_FUNC_H_\r
+#define __UTS_AUDIO_SVC_GET_ITEM_BY_PATH_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_get_item_by_path_func_01();\r
+void utc_audio_svc_get_item_by_path_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_get_item_by_path_func_01, 1},\r
+       {utc_audio_svc_get_item_by_path_func_02, 2},    \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_GET_ITEM_BY_PATH_FUNC_H_      \r
diff --git a/TC/utc/audio/utc_audio_svc_get_list_item_func.c b/TC/utc/audio/utc_audio_svc_get_list_item_func.c
new file mode 100755 (executable)
index 0000000..425a46f
--- /dev/null
@@ -0,0 +1,120 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_get_list_item_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_get_list_item API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_get_list_item_func.h"\r
+\r
+\r
+\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_get_list_item() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_get_list_item_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_get_list_item_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       AudioHandleType *result_records = NULL;\r
+       int count = -1;\r
+\r
+       retval = check_default_item_exist();\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_default_item_exist","fail to check default item.");\r
+       }\r
+       \r
+       ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_count_list_item","failed to count items.");\r
+       }\r
+\r
+       if(count < 1)\r
+       {\r
+               dts_fail("audio_svc_insert_item","there is no item.");\r
+       }\r
+       \r
+       ret = audio_svc_list_item_new(&result_records, count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_list_item_new","unable to make list item.");\r
+       }\r
+       \r
+       ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", 0, count, result_records);\r
+       if (ret != AUDIO_SVC_ERROR_NONE) {\r
+               audio_svc_list_item_free(result_records);\r
+               dts_fail("audio_svc_get_list_item","failed to get items.");\r
+       }\r
+       \r
+       ret = audio_svc_list_item_free(result_records);\r
+       dts_check_eq("audio_svc_list_item_free", ret, AUDIO_SVC_ERROR_NONE, "fail to free memory.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_get_list_item() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_get_list_item_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_get_list_item_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *result_records = NULL;\r
+       ret = audio_svc_get_list_item(AUDIO_SVC_GROUP_BY_ALBUM, "Breakaway", "", "", "", 0, ret, result_records);\r
+\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_get_list_item","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_get_list_item","Getting items should be failed because of the NULL out parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_get_list_item_func.h b/TC/utc/audio/utc_audio_svc_get_list_item_func.h
new file mode 100755 (executable)
index 0000000..e87d736
--- /dev/null
@@ -0,0 +1,53 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_audio_svc_get_list_item_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_get_list_item API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_GET_ITEMS_FUNC_H_\r
+#define __UTS_AUDIO_SVC_GET_ITEMS_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_get_list_item_func_01();\r
+void utc_audio_svc_get_list_item_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_get_list_item_func_01, 1},\r
+       {utc_audio_svc_get_list_item_func_02, 2},       \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_GET_ITEMS_FUNC_H_     \r
diff --git a/TC/utc/audio/utc_audio_svc_get_path_by_audio_id_func.c b/TC/utc/audio/utc_audio_svc_get_path_by_audio_id_func.c
new file mode 100755 (executable)
index 0000000..b43f3af
--- /dev/null
@@ -0,0 +1,97 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_get_path_by_audio_id_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_get_path_by_audio_id API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_get_path_by_audio_id_func.h"\r
+\r
+\r
+\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_get_path_by_audio_id() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_get_path_by_audio_id_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_get_path_by_audio_id_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       char pathname[AUDIO_SVC_PATHNAME_SIZE] = {0,};\r
+       char audio_id[AUDIO_SVC_UUID_SIZE+1] = {0, };\r
+\r
+       retval = get_item_audio_id(audio_id);\r
+       if(!retval)\r
+       {\r
+               dts_fail("get_item_audio_id","fail to get audio_id.");\r
+       }\r
+       //retrieve the file path by track audio_id.\r
+       ret = audio_svc_get_path_by_audio_id(audio_id, pathname, AUDIO_SVC_PATHNAME_SIZE);\r
+       dts_check_eq("audio_svc_get_path_by_audio_id", ret, AUDIO_SVC_ERROR_NONE, "failed to get path.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_get_path_by_audio_id() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_get_path_by_audio_id_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_get_path_by_audio_id_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       char * audio_id = "550e8400-e29b-41d4-a716-446655440000";\r
+\r
+       ret = audio_svc_get_path_by_audio_id(audio_id, NULL, AUDIO_SVC_PATHNAME_SIZE);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_get_path_by_audio_id","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_get_path_by_audio_id","Getting items should be failed because of the NULL out parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_get_path_by_audio_id_func.h b/TC/utc/audio/utc_audio_svc_get_path_by_audio_id_func.h
new file mode 100755 (executable)
index 0000000..5938386
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_get_path_by_audio_id_func.h\r
+* @author\r
+* @brief       This is the implementaion file for the test case of audio_svc_get_path_by_audio_id API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_GET_PATH_BY_AUDIO_ID_FUNC_H_\r
+#define __UTS_AUDIO_SVC_GET_PATH_BY_AUDIO_ID_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_get_path_by_audio_id_func_01();\r
+void utc_audio_svc_get_path_by_audio_id_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_get_path_by_audio_id_func_01, 1},\r
+       {utc_audio_svc_get_path_by_audio_id_func_02, 2},\r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_GET_ITEMS_FUNC_H_\r
diff --git a/TC/utc/audio/utc_audio_svc_get_playlist_func.c b/TC/utc/audio/utc_audio_svc_get_playlist_func.c
new file mode 100755 (executable)
index 0000000..6a86e30
--- /dev/null
@@ -0,0 +1,117 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_get_playlist_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_get_playlist API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_get_playlist_func.h"\r
+\r
+\r
+\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_get_playlist() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_get_playlist_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_get_playlist_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       AudioHandleType *result_records = NULL;\r
+       int count = -1;\r
+\r
+       retval = check_default_playlist_exist();\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_default_playlist_exist","fail to check default playlist.");\r
+       }\r
+\r
+       ret = audio_svc_count_playlist("", "", &count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_count_playlist","unable to get playlist.");\r
+       }\r
+       \r
+       ret = audio_svc_playlist_new(&result_records, count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_playlist_new","unable to create playlist.");\r
+       }\r
+       \r
+       ret = audio_svc_get_playlist("", "", 0, count, result_records);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_playlist_free(result_records);\r
+               dts_fail("audio_svc_get_playlist","unable to get playlist.");\r
+       }\r
+\r
+       ret = audio_svc_playlist_free(result_records);\r
+       dts_check_eq("audio_svc_playlist_free", ret, AUDIO_SVC_ERROR_NONE, "failed to free list memory.");\r
+       \r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_get_playlist() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_get_playlist_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_get_playlist_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *result_records = NULL;\r
+       \r
+       ret = audio_svc_get_playlist( "", "", 0, ret, result_records);\r
+\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_get_playlist","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_get_playlist","Getting playlists should be failed because of the NULL out parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_get_playlist_func.h b/TC/utc/audio/utc_audio_svc_get_playlist_func.h
new file mode 100755 (executable)
index 0000000..9ca738f
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_get_playlist_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_get_playlist API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_GET_PLAYLISTS_FUNC_H_\r
+#define __UTS_AUDIO_SVC_GET_PLAYLISTS_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_get_playlist_func_01();\r
+void utc_audio_svc_get_playlist_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_get_playlist_func_01, 1},\r
+       {utc_audio_svc_get_playlist_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_GET_PLAYLISTS_FUNC_H_ \r
diff --git a/TC/utc/audio/utc_audio_svc_get_playlist_id_by_playlist_name_func.c b/TC/utc/audio/utc_audio_svc_get_playlist_id_by_playlist_name_func.c
new file mode 100755 (executable)
index 0000000..f90e01a
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+* @file                utc_audio_svc_get_playlist_id_by_playlist_name_func.c
+* @brief       This is a suit of unit test cases to test utc_audio_svc_get_playlist_id_by_playlist_name_func API function
+* @author
+* @version     Initial Creation Version 0.1
+* @date        2011-03-07
+*/
+#include "utc_audio_svc_get_playlist_id_by_playlist_name_func.h"
+
+
+void startup()
+{
+       UTC_AUDIO_SVC_OPEN();
+}
+
+
+void cleanup()
+{
+       UTC_AUDIO_SVC_CLOSE();
+}
+
+/**
+* @brief       This tests int audio_svc_get_playlist_id_by_playlist_name() API with valid parameter
+* @par ID      utc_audio_svc_get_playlist_id_by_playlist_name_func_01
+* @param       [in]    playlist_name   playlist name for find playlist index
+                       [out]   playlist_id             the unique playlist id
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_audio_svc_get_playlist_id_by_playlist_name_func_01()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       bool retval = FALSE;
+       int playlist_id = -1;
+       int count = -1;
+       AudioHandleType*playlists = NULL;
+       char *p = NULL;
+       int size = -1;
+       int i = 0;
+
+       retval = check_default_playlist_exist();
+       if(!retval)
+       {
+               dts_fail("check_default_playlist_exist","fail to check default playlist.");
+       }
+
+       ret = audio_svc_count_playlist("", "", &count);
+       if (ret != AUDIO_SVC_ERROR_NONE)
+       {
+               dts_fail("audio_svc_count_playlists","unable to get playlist.");
+       }
+       
+       ret = audio_svc_playlist_new(&playlists, count);
+       if (ret != AUDIO_SVC_ERROR_NONE)
+       {
+               dts_fail("audio_svc_count_playlists","there is no playlist.");
+       }
+       
+       //get all the playlists in db.
+       ret = audio_svc_get_playlist(
+                               NULL, //filter_string,
+                               NULL, //filter_string2,
+                               0, //offset,
+                               count,
+                               playlists);
+       if (ret != AUDIO_SVC_ERROR_NONE)
+       {
+               audio_svc_playlist_free(playlists);
+               dts_fail("audio_svc_get_playlist","unable to get playlist.");
+       }
+       
+       //get the playlist id and playlist name of each playlist
+       ret = audio_svc_playlist_get_val(playlists, i, AUDIO_SVC_PLAYLIST_NAME, &p, &size, -1);
+       if (ret != AUDIO_SVC_ERROR_NONE)
+       {
+               audio_svc_playlist_free(playlists);
+               dts_fail("audio_svc_playlist_get_val","unable to get value for playlist.");
+       }
+       if(p == NULL)
+       {
+               audio_svc_playlist_free(playlists);
+               dts_fail("audio_svc_playlists_get_val","unable to get name of playlist.");
+       }
+       
+       ret = audio_svc_get_playlist_id_by_playlist_name(p, &playlist_id);
+       if (ret != AUDIO_SVC_ERROR_NONE)
+       {
+               audio_svc_playlist_free(playlists);
+               dts_fail("audio_svc_get_playlist_id_by_playlist_name","unable to get playlist id.");
+       }
+       
+       ret = audio_svc_playlist_free(playlists);
+       dts_check_eq("audio_svc_playlist_free", ret, AUDIO_SVC_ERROR_NONE, "failed to free list memory.");
+
+}
+
+
+/**
+* @brief       This tests int audio_svc_get_playlist_id_by_playlist_name() API with invalid parameter
+* @par ID      utc_audio_svc_get_playlist_id_by_playlist_name_func_02
+* @param       [in]    playlist_name   playlist name for find playlist index
+                       [out]   playlist_id             the unique playlist id
+* @return      error code on success
+*/
+void utc_audio_svc_get_playlist_id_by_playlist_name_func_02()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int playlist_id = -1;
+       
+       ret = audio_svc_get_playlist_id_by_playlist_name(NULL, &playlist_id);
+       if (ret !=  AUDIO_SVC_ERROR_NONE)
+       {
+               dts_pass("audio_svc_get_playlist_id_by_playlist_name","abnormal condition test for invalid playlist name parameter.");
+       }
+       else
+       {
+               dts_fail("audio_svc_get_playlist_id_by_playlist_name","this API should be failed because of the invalid playlist name parameter.");
+       }
+
+       return ;
+}
+
diff --git a/TC/utc/audio/utc_audio_svc_get_playlist_id_by_playlist_name_func.h b/TC/utc/audio/utc_audio_svc_get_playlist_id_by_playlist_name_func.h
new file mode 100755 (executable)
index 0000000..845fb56
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+* @file                utc_audio_svc_get_playlist_id_by_playlist_name_func.h
+* @author      
+* @brief       This is the implementaion file for the test case of audio_svc_get_playlist_id_by_playlist_name API function
+* @version     Initial Creation Version 0.1
+* @date                2011-03-07
+*/
+
+#ifndef __UTS_AUDIO_SVC_GET_PLAYLIST_ID_BY_PLAYLIST_NAME_FUNC_H_
+#define __UTS_AUDIO_SVC_GET_PLAYLIST_ID_BY_PLAYLIST_NAME_FUNC_H_
+
+
+#include "utc_audio_svc_common.h"
+
+void startup();
+void cleanup();
+
+/* Initialize TCM data structures */
+void (*tet_startup)() = startup;
+void (*tet_cleanup)() = cleanup;
+
+void utc_audio_svc_get_playlist_id_by_playlist_name_func_01();
+void utc_audio_svc_get_playlist_id_by_playlist_name_func_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_audio_svc_get_playlist_id_by_playlist_name_func_01, 1},
+       {utc_audio_svc_get_playlist_id_by_playlist_name_func_02, 2},    
+       {NULL, 0}
+};
+
+
+#endif //__UTS_AUDIO_SVC_GET_PLAYLIST_ID_BY_PLAYLIST_NAME_FUNC_H_
+
diff --git a/TC/utc/audio/utc_audio_svc_get_playlist_name_by_playlist_id_func.c b/TC/utc/audio/utc_audio_svc_get_playlist_name_by_playlist_id_func.c
new file mode 100755 (executable)
index 0000000..4a0cfb5
--- /dev/null
@@ -0,0 +1,97 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file        utc_audio_svc_get_playlist_name_by_playlist_id_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_add_playlist API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_get_playlist_name_by_playlist_id_func.h"\r
+\r
+\r
+\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_add_playlist() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_get_playlist_name_by_playlist_id_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_get_playlist_name_by_playlist_id_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       char playlist_name[AUDIO_SVC_PLAYLIST_NAME_SIZE] = {0};\r
+       int playlist_id = 0;\r
+\r
+       retval = get_playlist_id(&playlist_id);\r
+       if(!retval)\r
+       {\r
+               dts_fail("get_playlist_id","fail to get playlist id.");\r
+       }\r
+       \r
+       ret = audio_svc_get_playlist_name_by_playlist_id(playlist_id, playlist_name, AUDIO_SVC_PLAYLIST_NAME_SIZE);\r
+       dts_check_eq("audio_svc_get_playlist_name_by_playlist_id", ret, AUDIO_SVC_ERROR_NONE, "failed to get playlist name.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_add_playlist() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_get_playlist_name_by_playlist_id_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_get_playlist_name_by_playlist_id_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       char playlist_name[AUDIO_SVC_PLAYLIST_NAME_SIZE] = {0};\r
+       int playlist_id = -1;\r
+\r
+       ret = audio_svc_get_playlist_name_by_playlist_id(playlist_id, playlist_name, AUDIO_SVC_PLAYLIST_NAME_SIZE);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_get_playlist_name_by_playlist_id","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_get_playlist_name_by_playlist_id","get playlist should be failed because of the NULL parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_get_playlist_name_by_playlist_id_func.h b/TC/utc/audio/utc_audio_svc_get_playlist_name_by_playlist_id_func.h
new file mode 100755 (executable)
index 0000000..04b7c41
--- /dev/null
@@ -0,0 +1,53 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_audio_svc_get_playlist_name_by_playlist_id_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_add_playlist API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_GET_PLST_NAME_BY_IDX_FUNC_H_\r
+#define __UTS_AUDIO_SVC_GET_PLST_NAME_BY_IDX_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_get_playlist_name_by_playlist_id_func_01();\r
+void utc_audio_svc_get_playlist_name_by_playlist_id_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_get_playlist_name_by_playlist_id_func_01, 1},\r
+       {utc_audio_svc_get_playlist_name_by_playlist_id_func_02, 2},    \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_GET_PLST_NAME_BY_IDX_FUNC_H_  \r
diff --git a/TC/utc/audio/utc_audio_svc_get_unique_playlist_name_func.c b/TC/utc/audio/utc_audio_svc_get_unique_playlist_name_func.c
new file mode 100755 (executable)
index 0000000..a3cba66
--- /dev/null
@@ -0,0 +1,91 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file        utc_audio_svc_get_unique_playlist_name_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_add_playlist API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_get_unique_playlist_name_func.h"\r
+\r
+\r
+\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_add_playlist() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_get_unique_playlist_name_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_get_unique_playlist_name_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       const char orig_name[AUDIO_SVC_PLAYLIST_NAME_SIZE] = "plst_test";\r
+       char unique_name[AUDIO_SVC_PLAYLIST_NAME_SIZE] = {0};\r
+\r
+       ret = audio_svc_get_unique_playlist_name(orig_name, unique_name, AUDIO_SVC_PLAYLIST_NAME_SIZE);\r
+       dts_check_eq("audio_svc_get_unique_playlist_name", ret, AUDIO_SVC_ERROR_NONE, "failed to get playlist name.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_add_playlist() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_get_unique_playlist_name_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_get_unique_playlist_name_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       char *orig_name = NULL;\r
+       char unique_name[AUDIO_SVC_PLAYLIST_NAME_SIZE] = {0};\r
+\r
+       ret = audio_svc_get_unique_playlist_name(orig_name, unique_name, AUDIO_SVC_PLAYLIST_NAME_SIZE);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_get_unique_playlist_name","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_get_unique_playlist_name","get playlist should be failed because of the NULL parameter.");\r
+       }\r
+\r
+       return ;\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_get_unique_playlist_name_func.h b/TC/utc/audio/utc_audio_svc_get_unique_playlist_name_func.h
new file mode 100755 (executable)
index 0000000..9307c2d
--- /dev/null
@@ -0,0 +1,53 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_audio_svc_get_unique_playlist_name_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_add_playlist API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_GET_UNIQUE_PLAYLIST_NAME_FUNC_H_\r
+#define __UTS_AUDIO_SVC_GET_UNIQUE_PLAYLIST_NAME_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_get_unique_playlist_name_func_01();\r
+void utc_audio_svc_get_unique_playlist_name_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_get_unique_playlist_name_func_01, 1},\r
+       {utc_audio_svc_get_unique_playlist_name_func_02, 2},    \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_GET_UNIQUE_PLAYLIST_NAME_FUNC_H_      \r
diff --git a/TC/utc/audio/utc_audio_svc_insert_item_func.c b/TC/utc/audio/utc_audio_svc_insert_item_func.c
new file mode 100755 (executable)
index 0000000..9c89c97
--- /dev/null
@@ -0,0 +1,99 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file        utc_audio_svc_insert_item_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_insert_item_ex API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_insert_item_func.h"\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_insert_item_ex() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_insert_item_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_insert_item_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       int category = AUDIO_SVC_CATEGORY_MUSIC;\r
+\r
+       retval = check_default_item_exist();\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_default_item_exist","fail to check default item.");\r
+       }\r
+\r
+       ret = audio_svc_delete_item_by_path(DEFAULT_FILE);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_delete_item_by_path","failed to delete item by path.");\r
+       }\r
+       \r
+       ret = audio_svc_insert_item(AUDIO_SVC_STORAGE_PHONE, DEFAULT_FILE, category);\r
+       dts_check_eq("audio_svc_insert_item", ret, AUDIO_SVC_ERROR_NONE, "failed to insert item.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_insert_item_ex() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_insert_item_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_insert_item_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       const char *path = NULL; // invalid value\r
+       int category = AUDIO_SVC_CATEGORY_MUSIC;\r
+\r
+       ret = audio_svc_insert_item(AUDIO_SVC_STORAGE_PHONE, path, category);\r
+\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_insert_item","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_insert_item","Inserting item should be failed because of invalid path parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_insert_item_func.h b/TC/utc/audio/utc_audio_svc_insert_item_func.h
new file mode 100755 (executable)
index 0000000..e9f692c
--- /dev/null
@@ -0,0 +1,53 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_audio_svc_insert_item_ex_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_insert_item_ex API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_INSERT_ITEM_FUNC_H_\r
+#define __UTS_AUDIO_SVC_INSERT_ITEM_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_insert_item_func_01();\r
+void utc_audio_svc_insert_item_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_insert_item_func_01, 1},\r
+       {utc_audio_svc_insert_item_func_02, 2}, \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_INSERT_ITEM_EX_FUNC_H_        \r
diff --git a/TC/utc/audio/utc_audio_svc_item_free_func.c b/TC/utc/audio/utc_audio_svc_item_free_func.c
new file mode 100755 (executable)
index 0000000..a0b900c
--- /dev/null
@@ -0,0 +1,91 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file        utc_audio_svc_item_free_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_item_free API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+#include "utc_audio_svc_item_free_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_item_free() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_item_free_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_item_free_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+\r
+       //create svc item object, object number is count.\r
+       ret = audio_svc_item_new(&handle);\r
+       if (ret  != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_item_new","failed to allocate service item.");\r
+       }\r
+\r
+       //free the svc item object.\r
+       ret = audio_svc_item_free(handle);\r
+       dts_check_eq("audio_svc_item_free", ret, AUDIO_SVC_ERROR_NONE, "fail to free memory.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_item_free() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_item_free_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_item_free_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+\r
+       ret = audio_svc_item_free(handle);\r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_item_free","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_item_free","free item should be failed because of the null parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_item_free_func.h b/TC/utc/audio/utc_audio_svc_item_free_func.h
new file mode 100755 (executable)
index 0000000..f058f8c
--- /dev/null
@@ -0,0 +1,53 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+/**\r
+* @file                utc_audio_svc_item_free_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_item_free API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_ITEM_FREE_FUNC_H_\r
+#define __UTS_AUDIO_SVC_ITEM_FREE_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_item_free_func_01();\r
+void utc_audio_svc_item_free_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_item_free_func_01, 1},\r
+       {utc_audio_svc_item_free_func_02, 2},   \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_ITEM_FREE_FUNC_H_     \r
diff --git a/TC/utc/audio/utc_audio_svc_item_get_val_func.c b/TC/utc/audio/utc_audio_svc_item_get_val_func.c
new file mode 100755 (executable)
index 0000000..9941069
--- /dev/null
@@ -0,0 +1,173 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file        utc_audio_svc_item_get_val_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_list_item_get_val API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+#include "utc_audio_svc_item_get_val_func.h"\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_list_item_get_val() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_item_get_val_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_item_get_val_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       int count = -1;\r
+       AudioHandleType *tracks = NULL;\r
+       AudioHandleType *item = NULL;\r
+       char *audio_id = NULL, *title = NULL, *album = NULL, *artist = NULL, *thumbname = NULL;\r
+       int i = 0;\r
+       int size = -1;\r
+\r
+       retval = check_default_item_exist();\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_default_item_exist","fail to check default item.");\r
+       }\r
+       \r
+       ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_count_list_item","unable to get count.");\r
+       }\r
+\r
+       if(count < 1)\r
+       {\r
+               dts_fail("audio_svc_insert_item","there is no item.");\r
+       }\r
+\r
+       ret = audio_svc_list_item_new(&tracks, count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_list_item_new","unable to make list item.");\r
+       }\r
+\r
+       //get all tracks from db.\r
+       ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,\r
+               NULL, //type_string,\r
+               NULL, //type_string2,\r
+               NULL, //filter_string,\r
+               NULL, //filter_string2,\r
+               0, //offset,\r
+               count,\r
+               tracks\r
+               );\r
+\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_list_item_free(tracks);\r
+               dts_fail("audio_svc_get_list_item","unable to get items.");\r
+       }\r
+\r
+       ret = audio_svc_item_new(&item);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_list_item_free(tracks);\r
+               dts_fail("audio_svc_item_new","unable to malloc.");     \r
+       }\r
+       \r
+       //get the track audio_id with index "i" in tracks array.\r
+       ret = audio_svc_list_item_get_val(tracks, i, AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, &size, -1);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_list_item_free(tracks);\r
+               dts_fail("audio_svc_list_item_get_val","unable to get count.");\r
+       }\r
+       \r
+       ret = audio_svc_get_item_by_audio_id(audio_id, item);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_list_item_free(tracks);\r
+               dts_fail("audio_svc_get_item_by_audio_id","unable to get audio_id.");\r
+       }\r
+\r
+       //get the property value of svc item\r
+       ret = audio_svc_item_get_val(item,\r
+               AUDIO_SVC_TRACK_DATA_AUDIO_ID, &audio_id, &size,\r
+               AUDIO_SVC_TRACK_DATA_TITLE, &title, &size,\r
+               AUDIO_SVC_TRACK_DATA_ALBUM, &album, &size,\r
+               AUDIO_SVC_TRACK_DATA_ARTIST, &artist, &size,\r
+               AUDIO_SVC_TRACK_DATA_THUMBNAIL_PATH, &thumbname, &size,\r
+               -1);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_list_item_free(tracks);\r
+               dts_fail("audio_svc_item_get_val","unable to get value for item.");\r
+       }\r
+\r
+       ret = audio_svc_list_item_free(tracks);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_item_free(item);\r
+               dts_fail("audio_svc_list_item_free","unable to free.");\r
+       }\r
+       \r
+       ret = audio_svc_item_free(item);\r
+       dts_check_eq("audio_svc_item_free", ret, AUDIO_SVC_ERROR_NONE, "fail to free memory.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_item_get_val() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_item_get_val_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_item_get_val_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+       int i = 0;\r
+       char * audio_id = NULL;\r
+\r
+       ret = audio_svc_item_get_val(handle, i, AUDIO_SVC_TRACK_DATA_AUDIO_ID, &audio_id, -1);\r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_item_get_val","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_item_get_val","Svc item get value should be failed because of the null parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_item_get_val_func.h b/TC/utc/audio/utc_audio_svc_item_get_val_func.h
new file mode 100755 (executable)
index 0000000..0208634
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_audio_svc_item_get_val_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_item_get_val API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_ITEM_GET_VAL_FUNC_H_\r
+#define __UTS_AUDIO_SVC_ITEM_GET_VAL_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_item_get_val_func_01();\r
+void utc_audio_svc_item_get_val_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_item_get_val_func_01, 1},\r
+       {utc_audio_svc_item_get_val_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_ITEM_GET_VAL_FUNC_H_  \r
diff --git a/TC/utc/audio/utc_audio_svc_item_new_func.c b/TC/utc/audio/utc_audio_svc_item_new_func.c
new file mode 100755 (executable)
index 0000000..9d9192a
--- /dev/null
@@ -0,0 +1,87 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_playlist_new_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_playlist_new API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+#include "utc_audio_svc_playlist_new_func.h"\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_playlist_new() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_playlist_new_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_playlist_new_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+       int count = 5;\r
+\r
+       //create playlists\r
+       ret = audio_svc_playlist_new(&handle, count);\r
+       dts_check_eq("audio_svc_playlist_new", ret, AUDIO_SVC_ERROR_NONE, "failed to create playlist.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_playlist_new() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_playlist_new_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_playlist_new_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+       int count = 0;\r
+\r
+       //create playlists\r
+       ret = audio_svc_playlist_new(&handle, count);\r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_item_get_val","abnormal condition test for invalid count parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_playlist_new","Creating playlist should be failed because of the invalid count parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_item_new_func.h b/TC/utc/audio/utc_audio_svc_item_new_func.h
new file mode 100755 (executable)
index 0000000..8c1488d
--- /dev/null
@@ -0,0 +1,55 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_playlist_new_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_playlist_new API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_PLAYLIST_NEW_FUNC_H_\r
+#define __UTS_AUDIO_SVC_PLAYLIST_NEW_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_playlist_new_func_01();\r
+void utc_audio_svc_playlist_new_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_playlist_new_func_01, 1},\r
+       {utc_audio_svc_playlist_new_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_PLAYLIST_NEW_FUNC_H_  \r
diff --git a/TC/utc/audio/utc_audio_svc_list_item_free_func.c b/TC/utc/audio/utc_audio_svc_list_item_free_func.c
new file mode 100755 (executable)
index 0000000..db754c2
--- /dev/null
@@ -0,0 +1,93 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_list_item_free_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_list_item_free API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+#include "utc_audio_svc_list_item_free_func.h"\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_list_item_free() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_list_item_free_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_list_item_free_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+       int count = 5;\r
+\r
+       //allocate the memory of type list item with count\r
+       ret = audio_svc_list_item_new(&handle, count);\r
+       if (ret  != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_list_item_new","failed to allocate handle.");\r
+       }\r
+\r
+       //free the list item memory.\r
+       ret = audio_svc_list_item_free(handle);\r
+       dts_check_eq("audio_svc_list_item_free", ret, AUDIO_SVC_ERROR_NONE, "fail to free memory.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_list_item_free() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_list_item_free_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_list_item_free_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+\r
+       ret = audio_svc_list_item_free(handle);\r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_list_item_free","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_list_item_free","free list item should be failed because of the null parameter.");\r
+       }\r
+\r
+       return ;\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_list_item_free_func.h b/TC/utc/audio/utc_audio_svc_list_item_free_func.h
new file mode 100755 (executable)
index 0000000..1554b91
--- /dev/null
@@ -0,0 +1,55 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_list_item_free_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_list_item_new API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_LIST_ITEM_FREE_FUNC_H_\r
+#define __UTS_AUDIO_SVC_LIST_ITEM_FREE_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_list_item_free_func_01();\r
+void utc_audio_svc_list_item_free_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_list_item_free_func_01, 1},\r
+       {utc_audio_svc_list_item_free_func_02, 2},      \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_LIST_ITEM_FREE_FUNC_H_        \r
diff --git a/TC/utc/audio/utc_audio_svc_list_item_get_func.c b/TC/utc/audio/utc_audio_svc_list_item_get_func.c
new file mode 100755 (executable)
index 0000000..84edbb4
--- /dev/null
@@ -0,0 +1,138 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_list_item_get_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_list_item_get API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+#include "utc_audio_svc_list_item_get_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_list_item_get() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_list_item_get_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_list_item_get_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       int count = -1;\r
+       int i = 0;\r
+       AudioHandleType *tracks = NULL; \r
+       AudioHandleType *item = NULL;\r
+\r
+\r
+       retval = check_default_item_exist();\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_default_item_exist","fail to check default item.");\r
+       }\r
+       \r
+       ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_count_list_item","unable to get count.");\r
+       }\r
+\r
+       if(count < 1)\r
+       {\r
+               dts_fail("audio_svc_insert_item","there is no item.");\r
+       }\r
+\r
+       ret = audio_svc_list_item_new(&tracks, count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_list_item_new","unable to make list item.");\r
+       }\r
+       \r
+       //get the all tracks item.\r
+       ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,\r
+               NULL, //type_string,\r
+               NULL, //type_string2,\r
+               NULL, //filter_string,\r
+               NULL, //filter_string2,\r
+               0, //offset,\r
+               count,\r
+               tracks\r
+               );\r
+\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_list_item_free(tracks);\r
+               dts_fail("audio_svc_get_list_item","unable to get items.");     \r
+       }\r
+\r
+       //get the list item with index "i"\r
+       ret = audio_svc_list_item_get(tracks, i, &item);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_list_item_get","unable to get svc item.");\r
+       }\r
+\r
+       ret = audio_svc_list_item_free(tracks);\r
+       dts_check_eq("audio_svc_list_item_free", ret, AUDIO_SVC_ERROR_NONE, "fail to free memory.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_list_item_get() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_list_item_get_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_list_item_get_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+       AudioHandleType *list_item = NULL;\r
+\r
+       ret = audio_svc_list_item_get(handle, 0, &list_item);\r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_list_item_get","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_list_item_get","Getting list item should be failed because of the null parameter.");\r
+       }\r
+\r
+       return ;\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_list_item_get_func.h b/TC/utc/audio/utc_audio_svc_list_item_get_func.h
new file mode 100755 (executable)
index 0000000..a285852
--- /dev/null
@@ -0,0 +1,55 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_list_item_get_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_list_item_get API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_LIST_ITEM_GET_FUNC_H_\r
+#define __UTS_AUDIO_SVC_LIST_ITEM_GET_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_list_item_get_func_01();\r
+void utc_audio_svc_list_item_get_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_list_item_get_func_01, 1},\r
+       {utc_audio_svc_list_item_get_func_02, 2},       \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_LIST_ITEM_GET_FUNC_H_ \r
diff --git a/TC/utc/audio/utc_audio_svc_list_item_get_val_func.c b/TC/utc/audio/utc_audio_svc_list_item_get_val_func.c
new file mode 100755 (executable)
index 0000000..ef2cc7f
--- /dev/null
@@ -0,0 +1,140 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_list_item_get_val_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_list_item_new API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+#include "utc_audio_svc_list_item_get_val_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_list_item_get_val() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_list_item_get_val_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_list_item_get_val_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       int count = -1;\r
+       AudioHandleType *tracks = NULL;\r
+       int i = 0;\r
+       char * audio_id = NULL;\r
+       int size = 0;\r
+\r
+       retval = check_default_item_exist();\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_default_item_exist","fail to check default item.");\r
+       }\r
+       \r
+       ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_count_list_item","unable to get count.");\r
+       }\r
+\r
+       if(count < 1)\r
+       {\r
+               dts_fail("audio_svc_insert_item","there is no item.");\r
+       }\r
+       \r
+       ret = audio_svc_list_item_new(&tracks, count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_list_item_new","unable to make list item.");\r
+       }\r
+       \r
+       //get the all track items.\r
+       ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,\r
+               NULL, //type_string,\r
+               NULL, //type_string2,\r
+               NULL, //filter_string,\r
+               NULL, //filter_string2,\r
+               0, //offset,\r
+               count,\r
+               tracks\r
+               );\r
+\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_list_item_free(tracks);\r
+               dts_fail("audio_svc_get_list_item","failed to get service list items.");\r
+       }\r
+       \r
+       //get the audio_id of each track in "tracks"\r
+       ret = audio_svc_list_item_get_val(tracks, i, AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, &size, -1);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_list_item_free(tracks);\r
+               dts_fail("audio_svc_list_item_get_val","unable to get value for svc list item.");\r
+       }\r
+\r
+       ret = audio_svc_list_item_free(tracks);\r
+       dts_check_eq("audio_svc_list_item_free", ret, AUDIO_SVC_ERROR_NONE, "fail to free memory.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_list_item_get_val() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_list_item_get_val_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_list_item_get_val_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+       int i = 0;\r
+       char *audio_id = NULL;\r
+\r
+       ret = audio_svc_list_item_get_val(handle, i, AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, -1);\r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_list_item_get_val","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_list_item_get_val","Svc list get value should be failed because of the null parameter.");\r
+       }\r
+\r
+       return ;\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_list_item_get_val_func.h b/TC/utc/audio/utc_audio_svc_list_item_get_val_func.h
new file mode 100755 (executable)
index 0000000..00b0ef0
--- /dev/null
@@ -0,0 +1,55 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_list_item_get_val_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_list_item_new API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_SVC_LIST_GET_VAL_FUNC_H_\r
+#define __UTS_AUDIO_SVC_SVC_LIST_GET_VAL_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_list_item_get_val_func_01();\r
+void utc_audio_svc_list_item_get_val_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_list_item_get_val_func_01, 1},\r
+       {utc_audio_svc_list_item_get_val_func_02, 2},   \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_SVC_LIST_GET_VAL_FUNC_H_      \r
diff --git a/TC/utc/audio/utc_audio_svc_list_item_new_func.c b/TC/utc/audio/utc_audio_svc_list_item_new_func.c
new file mode 100755 (executable)
index 0000000..2eecdbc
--- /dev/null
@@ -0,0 +1,89 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_list_item_new_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_list_item_new API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+#include "utc_audio_svc_list_item_new_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_list_item_new() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_list_item_new_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_list_item_new_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+       int count = 5;\r
+\r
+       //create svc list\r
+       ret = audio_svc_list_item_new(&handle, count);\r
+       dts_check_eq("audio_svc_list_item_new", ret, AUDIO_SVC_ERROR_NONE, "failed to create svc list.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_list_item_new() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_list_item_new_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_list_item_new_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+       int count = 0;\r
+\r
+       //create svc list\r
+       ret = audio_svc_list_item_new(&handle, count);\r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_list_item_new","abnormal condition test for invalid count parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_list_item_new","Creating playlist should be failed because of the invalid count parameter.");\r
+       }\r
+\r
+       return ;\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_list_item_new_func.h b/TC/utc/audio/utc_audio_svc_list_item_new_func.h
new file mode 100755 (executable)
index 0000000..47daa13
--- /dev/null
@@ -0,0 +1,55 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_list_item_new_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_list_item_new API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_LIST_ITEM_NEWFUNC_H_\r
+#define __UTS_AUDIO_SVC_LIST_ITEM_NEWFUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_list_item_new_func_01();\r
+void utc_audio_svc_list_item_new_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_list_item_new_func_01, 1},\r
+       {utc_audio_svc_list_item_new_func_02, 2},       \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_LIST_ITEM_NEWFUNC_H_  \r
diff --git a/TC/utc/audio/utc_audio_svc_move_item_func.c b/TC/utc/audio/utc_audio_svc_move_item_func.c
new file mode 100755 (executable)
index 0000000..cc41354
--- /dev/null
@@ -0,0 +1,95 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_move_item_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_move_item API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_move_item_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_move_item() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_move_item_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_move_item_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       audio_svc_storage_type_e storage = AUDIO_SVC_STORAGE_PHONE;\r
+       \r
+       retval = check_default_item_exist();\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_default_item_exist","fail to check default item.");\r
+       }\r
+\r
+       ret = audio_svc_move_item(storage, DEFAULT_FILE, storage, TEST_FILE);\r
+       dts_check_eq("audio_svc_move_item", ret, AUDIO_SVC_ERROR_NONE, "failed to move item.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_move_item() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_move_item_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_move_item_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       audio_svc_storage_type_e storage = AUDIO_SVC_STORAGE_PHONE;\r
+       const char *src_path = NULL;\r
+\r
+       ret = audio_svc_move_item(storage, src_path, storage, TEST_FILE);\r
+\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_move_item","abnormal condition test for invalid NULL src path parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_move_item","Moving item should be failed because of NULL parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_move_item_func.h b/TC/utc/audio/utc_audio_svc_move_item_func.h
new file mode 100755 (executable)
index 0000000..723b474
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_move_item_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_move_item API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_MOVE_ITEM_FUNC_H_\r
+#define __UTS_AUDIO_SVC_MOVE_ITEM_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_move_item_func_01();\r
+void utc_audio_svc_move_item_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_move_item_func_01, 1},\r
+       {utc_audio_svc_move_item_func_02, 2},   \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_MOVE_ITEM_FUNC_H_     \r
diff --git a/TC/utc/audio/utc_audio_svc_open_func.c b/TC/utc/audio/utc_audio_svc_open_func.c
new file mode 100755 (executable)
index 0000000..8aa266a
--- /dev/null
@@ -0,0 +1,81 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_open_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_open API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+#include "utc_audio_svc_open_func.h"\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_open() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_open_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_open_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+\r
+       ret = audio_svc_open();\r
+       dts_check_eq("audio_svc_open", ret, AUDIO_SVC_ERROR_NONE, "failed to open music db.");\r
+\r
+}\r
+\r
+#if 0          //there is no abnormal case\r
+/**\r
+* @brief               This tests int audio_svc_open() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_open_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success \r
+*/\r
+void utc_audio_svc_open_func_02()\r
+{      \r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+\r
+       ret = audio_svc_open();\r
+       \r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               UTC_MM_LOG("abnormal condition test for null, error code->%d", ret);\r
+               tet_result(TET_PASS);\r
+       }\r
+       else\r
+       {\r
+               UTC_MM_LOG("Open music db should be failed because of the NULL out parameter.");\r
+               tet_result(TET_FAIL);\r
+       }\r
+\r
+       return ;\r
+}\r
+#endif\r
diff --git a/TC/utc/audio/utc_audio_svc_open_func.h b/TC/utc/audio/utc_audio_svc_open_func.h
new file mode 100755 (executable)
index 0000000..a1fdfdd
--- /dev/null
@@ -0,0 +1,53 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_audio_svc_open_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_open API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_OPEN_FUNC_H_\r
+#define __UTS_AUDIO_SVC_OPEN_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = NULL;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_open_func_01();\r
+//void utc_audio_svc_open_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_open_func_01, 1},\r
+//     {utc_audio_svc_open_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_OPEN_FUNC_H_  \r
diff --git a/TC/utc/audio/utc_audio_svc_playlist_free_func.c b/TC/utc/audio/utc_audio_svc_playlist_free_func.c
new file mode 100755 (executable)
index 0000000..6f380ec
--- /dev/null
@@ -0,0 +1,91 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file        utc_audio_svc_playlist_free_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_playlist_free API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+#include "utc_audio_svc_playlist_free_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_playlist_free() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_playlist_free_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_playlist_free_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+       int count = 5;\r
+\r
+       //create playlists\r
+       ret = audio_svc_playlist_new(&handle, count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_playlist_new","unable to create playlist.");\r
+       }\r
+\r
+       ret = audio_svc_playlist_free(handle);\r
+       dts_check_eq("audio_svc_playlist_free", ret, AUDIO_SVC_ERROR_NONE, "failed to free list memory.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_playlist_free() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_playlist_free_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_playlist_free_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+\r
+       ret = audio_svc_playlist_free(handle);\r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_playlist_free","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_playlist_free","free playlist should be failed because of the null parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_playlist_free_func.h b/TC/utc/audio/utc_audio_svc_playlist_free_func.h
new file mode 100755 (executable)
index 0000000..fe998b3
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_audio_svc_playlist_free_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_playlist_new API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_PLAYLIST_FREE_FUNC_H_\r
+#define __UTS_AUDIO_SVC_PLAYLIST_FREE_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_playlist_free_func_01();\r
+void utc_audio_svc_playlist_free_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_playlist_free_func_01, 1},\r
+       {utc_audio_svc_playlist_free_func_02, 2},       \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_PLAYLIST_FREE_FUNC_H_ \r
diff --git a/TC/utc/audio/utc_audio_svc_playlist_get_item_func.c b/TC/utc/audio/utc_audio_svc_playlist_get_item_func.c
new file mode 100755 (executable)
index 0000000..c94626e
--- /dev/null
@@ -0,0 +1,130 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file        utc_audio_svc_playlist_get_item_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_playlist_get_item API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+#include "utc_audio_svc_playlist_get_item_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_playlist_get_item() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_playlist_get_item_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_playlist_get_item_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       int count = -1;\r
+       AudioHandleType*playlists = NULL;\r
+       int i = 0;\r
+\r
+       retval = check_default_playlist_exist();\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_default_playlist_exist","fail to check default playlist.");\r
+       }\r
+\r
+       ret = audio_svc_count_playlist("", "", &count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_count_playlist","unable to get playlist.");\r
+       }\r
+       \r
+       ret = audio_svc_playlist_new(&playlists, count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_playlist_new","unable to make list item."); \r
+       }\r
+\r
+       ret = audio_svc_get_playlist(\r
+                               NULL, //filter_string,\r
+                               NULL, //filter_string2,\r
+                               0, //offset,\r
+                               count, \r
+                               playlists);\r
+\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_playlist_free(playlists);\r
+               dts_fail("audio_svc_get_playlist","unable to get playlist.");\r
+       }\r
+       \r
+       for (i = 0; i < count; i++) {\r
+               AudioHandleType *plst = NULL;\r
+               //get the playlist object with index "i"\r
+               ret = audio_svc_playlist_get_item(playlists, i, &plst);\r
+               if (ret != AUDIO_SVC_ERROR_NONE)\r
+               {\r
+                       audio_svc_playlist_free(playlists);\r
+                       dts_fail("audio_svc_playlist_get_item","unable to create playlist.");\r
+               }\r
+       }\r
+\r
+       ret = audio_svc_playlist_free(playlists);\r
+       dts_check_eq("audio_svc_playlist_free", ret, AUDIO_SVC_ERROR_NONE, "failed to free list memory.");\r
+\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_playlist_get_item() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_playlist_get_item_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_playlist_get_item_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+       AudioHandleType *plst = NULL;\r
+\r
+       ret = audio_svc_playlist_get_item(handle, 0, &plst);\r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_playlist_get_item","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_playlist_get_item","Getting playlist item should be failed because of the null parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_playlist_get_item_func.h b/TC/utc/audio/utc_audio_svc_playlist_get_item_func.h
new file mode 100755 (executable)
index 0000000..9bc757c
--- /dev/null
@@ -0,0 +1,53 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_audio_svc_playlist_get_item_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_playlist_get_item API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_PLAYLIST_GET_ITEM_FUNC_H_\r
+#define __UTS_AUDIO_SVC_PLAYLIST_GET_ITEM_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_playlist_get_item_func_01();\r
+void utc_audio_svc_playlist_get_item_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_playlist_get_item_func_01, 1},\r
+       {utc_audio_svc_playlist_get_item_func_02, 2},   \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_PLAYLIST_GET_ITEM_FUNC_H_     \r
diff --git a/TC/utc/audio/utc_audio_svc_playlist_get_val_func.c b/TC/utc/audio/utc_audio_svc_playlist_get_val_func.c
new file mode 100755 (executable)
index 0000000..18d21db
--- /dev/null
@@ -0,0 +1,130 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file        utc_audio_svc_playlist_get_val_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_playlist_new API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+#include "utc_audio_svc_playlist_get_val_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_playlist_new() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_playlist_get_val_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_playlist_get_val_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       int count = -1;\r
+       AudioHandleType*playlists = NULL;\r
+       char *p = NULL;\r
+       int plst_id = -1;\r
+       int size = -1;\r
+       int i = 0;\r
+\r
+       retval = check_default_playlist_exist();\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_default_playlist_exist","fail to check default playlist.");\r
+       }\r
+\r
+       ret = audio_svc_count_playlist("", "", &count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_count_playlist","unable to get playlist.");\r
+       }\r
+       \r
+       ret = audio_svc_playlist_new(&playlists, count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_count_playlist","there is no playlist.");\r
+       }\r
+       \r
+       //get all the playlists in db.\r
+       ret = audio_svc_get_playlist(\r
+                               NULL, //filter_string,\r
+                               NULL, //filter_string2,\r
+                               0, //offset,\r
+                               count,\r
+                               playlists);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_playlist_free(playlists);\r
+               dts_fail("audio_svc_get_playlist","unable to get playlist.");\r
+       }\r
+       \r
+       //get the playlist id and playlist name of each playlist\r
+       ret = audio_svc_playlist_get_val(playlists, i, AUDIO_SVC_PLAYLIST_ID, &plst_id, AUDIO_SVC_PLAYLIST_NAME, &p, &size, -1);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_playlist_free(playlists);\r
+               dts_fail("audio_svc_get_playlist","unable to get value for playlist.");\r
+       }\r
+\r
+       ret = audio_svc_playlist_free(playlists);\r
+       dts_check_eq("audio_svc_playlist_free", ret, AUDIO_SVC_ERROR_NONE, "failed to free list memory.");\r
+       \r
+}\r
+\r
+/**\r
+* @brief               This tests int audio_svc_playlist_new() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_playlist_get_val_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_playlist_get_val_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+       int i = 0;\r
+       int size;\r
+       char *name;\r
+\r
+       ret = audio_svc_playlist_get_val(handle, i, AUDIO_SVC_PLAYLIST_NAME, &name, &size, -1);\r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_playlist_get_val","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_playlist_get_val","Playlist get value should be failed because of the null parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_playlist_get_val_func.h b/TC/utc/audio/utc_audio_svc_playlist_get_val_func.h
new file mode 100755 (executable)
index 0000000..7cf13b9
--- /dev/null
@@ -0,0 +1,53 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_audio_svc_playlist_get_val_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_playlist_new API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_PLAYLIST_GET_VAL_FUNC_H_\r
+#define __UTS_AUDIO_SVC_PLAYLIST_GET_VAL_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_playlist_get_val_func_01();\r
+void utc_audio_svc_playlist_get_val_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_playlist_get_val_func_01, 1},\r
+       {utc_audio_svc_playlist_get_val_func_02, 2},    \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_PLAYLIST_GET_VAL_FUNC_H_      \r
diff --git a/TC/utc/audio/utc_audio_svc_playlist_new_func.c b/TC/utc/audio/utc_audio_svc_playlist_new_func.c
new file mode 100755 (executable)
index 0000000..01bc9f3
--- /dev/null
@@ -0,0 +1,87 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file        utc_audio_svc_playlist_new_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_playlist_new API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+#include "utc_audio_svc_playlist_new_func.h"\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_playlist_new() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_playlist_new_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_playlist_new_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+       int count = 5;\r
+\r
+       //create playlists\r
+       ret = audio_svc_playlist_new(&handle, count);\r
+       dts_check_eq("audio_svc_playlist_new", ret, AUDIO_SVC_ERROR_NONE, "failed to create playlist.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_playlist_new() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_playlist_new_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_playlist_new_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+       int count = 0;\r
+\r
+       //create playlists\r
+       ret = audio_svc_playlist_new(&handle, count);\r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_playlist_new","abnormal condition test for invalid count parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_playlist_new","Creating playlist should be failed because of the invalid count parameter.");\r
+       }\r
+\r
+       return ;\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_playlist_new_func.h b/TC/utc/audio/utc_audio_svc_playlist_new_func.h
new file mode 100755 (executable)
index 0000000..9b29cf6
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_audio_svc_playlist_new_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_playlist_new API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_PLAYLIST_NEW_FUNC_H_\r
+#define __UTS_AUDIO_SVC_PLAYLIST_NEW_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_playlist_new_func_01();\r
+void utc_audio_svc_playlist_new_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_playlist_new_func_01, 1},\r
+       {utc_audio_svc_playlist_new_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_PLAYLIST_NEW_FUNC_H_  \r
diff --git a/TC/utc/audio/utc_audio_svc_playlist_set_val_func.c b/TC/utc/audio/utc_audio_svc_playlist_set_val_func.c
new file mode 100755 (executable)
index 0000000..812d716
--- /dev/null
@@ -0,0 +1,127 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file        utc_audio_svc_playlist_set_val_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_playlist_new API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+#include "utc_audio_svc_playlist_set_val_func.h"\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_playlist_new() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_playlist_set_val_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_playlist_set_val_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       int count = -1;\r
+       AudioHandleType*playlists = NULL;\r
+       int size = AUDIO_SVC_METADATA_LEN_MAX;\r
+       int i = 0;\r
+\r
+       retval = check_default_playlist_exist();\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_default_playlist_exist","fail to check default playlist.");\r
+       }\r
+\r
+       ret = audio_svc_count_playlist("", "", &count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_count_playlist","unable to get playlist.");\r
+       }\r
+       \r
+       ret = audio_svc_playlist_new(&playlists, count);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail("audio_svc_playlist_new","unable to make list item.");\r
+       }\r
+\r
+       //get all the playlists.\r
+       ret = audio_svc_get_playlist(\r
+                               NULL, //filter_string,\r
+                               NULL, //filter_string2,\r
+                               0, //offset,\r
+                               count,\r
+                               playlists);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_playlist_free(playlists);\r
+               dts_fail("audio_svc_get_playlist","unable to get playlist.");\r
+       }\r
+       \r
+       //set the name of first playlist to "playlist_test_name"\r
+       ret = audio_svc_playlist_set_val(playlists, i, AUDIO_SVC_PLAYLIST_NAME, "playlist_test_name", size, -1);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               audio_svc_playlist_free(playlists);\r
+               dts_fail("audio_svc_playlist_set_val","unable to set value for playlist.");\r
+       }\r
+\r
+       ret = audio_svc_playlist_free(playlists);\r
+       dts_check_eq("audio_svc_playlist_free", ret, AUDIO_SVC_ERROR_NONE, "failed to free list memory.");\r
+       \r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_playlist_new() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_playlist_set_val_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_playlist_set_val_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       AudioHandleType *handle = NULL;\r
+       int i = 0;\r
+       int size = AUDIO_SVC_METADATA_LEN_MAX;\r
+\r
+       ret = audio_svc_playlist_set_val(handle, i, AUDIO_SVC_PLAYLIST_NAME, "playlist_test_name", size, -1);\r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_playlist_set_val","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_playlist_set_val","Playlist set value should be failed because of the null parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_playlist_set_val_func.h b/TC/utc/audio/utc_audio_svc_playlist_set_val_func.h
new file mode 100755 (executable)
index 0000000..c8f53e5
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_audio_svc_playlist_set_val_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_playlist_new API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_PLAYLIST_SET_VAL_FUNC_H_\r
+#define __UTS_AUDIO_SVC_PLAYLIST_SET_VAL_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_playlist_set_val_func_01();\r
+void utc_audio_svc_playlist_set_val_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_playlist_set_val_func_01, 1},\r
+       {utc_audio_svc_playlist_set_val_func_02, 2},    \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_PLAYLIST_SET_VAL_FUNC_H_      \r
diff --git a/TC/utc/audio/utc_audio_svc_refresh_metadata_func.c b/TC/utc/audio/utc_audio_svc_refresh_metadata_func.c
new file mode 100755 (executable)
index 0000000..da53b7e
--- /dev/null
@@ -0,0 +1,89 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file        utc_audio_svc_refresh_metadata_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_refresh_metadata API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+#include "utc_audio_svc_refresh_metadata_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_refresh_metadata() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_refresh_metadata_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_refresh_metadata_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       char audio_id[AUDIO_SVC_UUID_SIZE+1] = {0, };\r
+\r
+       retval = get_item_audio_id(audio_id);\r
+       if(!retval)\r
+       {\r
+               dts_fail("get_item_audio_id","fail to get audio_id.");\r
+       }\r
+       \r
+       ret = audio_svc_refresh_metadata(audio_id);\r
+       dts_check_eq("audio_svc_refresh_metadata", ret, AUDIO_SVC_ERROR_NONE, "failed to refresh metadata.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_refresh_metadata() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_refresh_metadata_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_refresh_metadata_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+\r
+       ret = audio_svc_refresh_metadata(NULL);\r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_playlist_set_val","abnormal condition test for invalid audio_id parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_refresh_metadata","Refresh metadata should be failed because of the invalid parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_refresh_metadata_func.h b/TC/utc/audio/utc_audio_svc_refresh_metadata_func.h
new file mode 100755 (executable)
index 0000000..794cd05
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_audio_svc_refresh_metadata_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_refresh_metadata API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_REFRESH_METADATA_FUNC_H_\r
+#define __UTS_AUDIO_SVC_REFRESH_METADATA_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_refresh_metadata_func_01();\r
+void utc_audio_svc_refresh_metadata_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_refresh_metadata_func_01, 1},\r
+       {utc_audio_svc_refresh_metadata_func_02, 2},    \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_REFRESH_METADATA_FUNC_H_      \r
diff --git a/TC/utc/audio/utc_audio_svc_remove_item_from_playlist_by_audio_id_func.c b/TC/utc/audio/utc_audio_svc_remove_item_from_playlist_by_audio_id_func.c
new file mode 100755 (executable)
index 0000000..d5a4deb
--- /dev/null
@@ -0,0 +1,97 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file        utc_audio_svc_remove_item_from_playlist_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_add_playlist API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_remove_item_from_playlist_by_audio_id_func.h"\r
+\r
+\r
+\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_add_playlist() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_remove_item_from_playlist_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_remove_item_from_playlist_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       int playlist_id = 0;\r
+       char audio_id[AUDIO_SVC_UUID_SIZE+1] = {0, };\r
+\r
+       retval =  check_playlist_has_item(&playlist_id, audio_id);\r
+       if(!retval)\r
+       {\r
+               dts_fail("check_playlist_has_item","fail to check_playlist_has_item.");\r
+       }\r
+       \r
+       ret = audio_svc_remove_item_from_playlist_by_audio_id(playlist_id, audio_id);\r
+       dts_check_eq("audio_svc_remove_item_from_playlist", ret, AUDIO_SVC_ERROR_NONE, "failed to  remove item.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_add_playlist() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_remove_item_from_playlist_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_remove_item_from_playlist_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       char * audio_id = "550e8400-e29b-41d4-a716-446655440000";\r
+       int playlist_id = -1;\r
+\r
+       ret = audio_svc_remove_item_from_playlist_by_audio_id(playlist_id, audio_id);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_remove_item_from_playlist","abnormal condition test for invalid playlist index parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_remove_item_from_playlist","get playlist should be failed because of the invalid parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_remove_item_from_playlist_by_audio_id_func.h b/TC/utc/audio/utc_audio_svc_remove_item_from_playlist_by_audio_id_func.h
new file mode 100755 (executable)
index 0000000..863a9d9
--- /dev/null
@@ -0,0 +1,53 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_audio_svc_remove_item_from_playlist_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_add_playlist API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_REMOVE_ITEM_FROM_PLAYLIST_FUNC_H_\r
+#define __UTS_AUDIO_SVC_REMOVE_ITEM_FROM_PLAYLIST_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_remove_item_from_playlist_func_01();\r
+void utc_audio_svc_remove_item_from_playlist_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_remove_item_from_playlist_func_01, 1},\r
+       {utc_audio_svc_remove_item_from_playlist_func_02, 2},   \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_REMOVE_ITEM_FROM_PLAYLIST_FUNC_H_     \r
diff --git a/TC/utc/audio/utc_audio_svc_set_db_valid_func.c b/TC/utc/audio/utc_audio_svc_set_db_valid_func.c
new file mode 100755 (executable)
index 0000000..9058037
--- /dev/null
@@ -0,0 +1,87 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_set_db_valid_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_set_db_valid API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+#include "utc_audio_svc_set_db_valid_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_set_db_valid() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_set_db_valid_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_set_db_valid_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       int storage = AUDIO_SVC_STORAGE_PHONE;\r
+       int valid = 1;\r
+\r
+       ret = audio_svc_set_db_valid(storage, valid);\r
+       dts_check_eq("audio_svc_set_db_valid", ret, AUDIO_SVC_ERROR_NONE, "failed to set db valid.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_set_db_valid() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_set_db_valid_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_set_db_valid_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       int valid = 1;\r
+\r
+       ret = audio_svc_set_db_valid(100, valid);\r
+\r
+\r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_remove_item_from_playlist","abnormal condition test for invalid storage type parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_set_db_valid","Open music db should be failed because of the invalid parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_set_db_valid_func.h b/TC/utc/audio/utc_audio_svc_set_db_valid_func.h
new file mode 100755 (executable)
index 0000000..24b56b7
--- /dev/null
@@ -0,0 +1,55 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_set_db_valid_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_set_db_valid API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_SET_DB_VALID_FUNC_H_\r
+#define __UTS_AUDIO_SVC_SET_DB_VALID_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_set_db_valid_func_01();\r
+void utc_audio_svc_set_db_valid_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_set_db_valid_func_01, 1},\r
+       {utc_audio_svc_set_db_valid_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_SET_DB_VALID_FUNC_H_  \r
diff --git a/TC/utc/audio/utc_audio_svc_set_item_valid_func.c b/TC/utc/audio/utc_audio_svc_set_item_valid_func.c
new file mode 100755 (executable)
index 0000000..cc50fe9
--- /dev/null
@@ -0,0 +1,84 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_set_item_valid_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_set_item_valid API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+#include "utc_audio_svc_set_item_valid_func.h"\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+/**\r
+* @brief       This tests int audio_svc_set_item_valid() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_set_item_valid_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_set_item_valid_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       int valid = 1;\r
+\r
+       ret = audio_svc_set_item_valid(DEFAULT_FILE, valid);\r
+       dts_check_eq("audio_svc_set_item_valid", ret, AUDIO_SVC_ERROR_NONE, "failed to set item valid.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_set_item_valid() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_set_item_valid_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_set_item_valid_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       int valid = 1;\r
+\r
+       ret = audio_svc_set_item_valid(NULL, valid);\r
+       if (ret !=  AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_set_item_valid","abnormal condition test for invalid path parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_set_item_valid","Setting item valid should be failed because of the invalid path parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_set_item_valid_func.h b/TC/utc/audio/utc_audio_svc_set_item_valid_func.h
new file mode 100755 (executable)
index 0000000..a36f9dc
--- /dev/null
@@ -0,0 +1,55 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_audio_svc_set_item_valid_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_set_item_valid API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_SET_ITEM_VALID_FUNC_H_\r
+#define __UTS_AUDIO_SVC_SET_ITEM_VALID_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_set_item_valid_func_01();\r
+void utc_audio_svc_set_item_valid_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_set_item_valid_func_01, 1},\r
+       {utc_audio_svc_set_item_valid_func_02, 2},      \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_SET_ITEM_VALID_FUNC_H_        \r
diff --git a/TC/utc/audio/utc_audio_svc_update_playlist_name_func.c b/TC/utc/audio/utc_audio_svc_update_playlist_name_func.c
new file mode 100755 (executable)
index 0000000..01a0ae6
--- /dev/null
@@ -0,0 +1,96 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_audio_svc_update_playlist_name_func.c\r
+* @brief       This is a suit of unit test cases to test audio_svc_add_playlist API function\r
+* @author\r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-09-13\r
+*/\r
+\r
+#include "utc_audio_svc_update_playlist_name_func.h"\r
+\r
+\r
+\r
+\r
+\r
+void startup()\r
+{\r
+       UTC_AUDIO_SVC_OPEN();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       UTC_AUDIO_SVC_CLOSE();\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int audio_svc_add_playlist() API with valid parameter\r
+*              Create a player handle with valid parameter & Test the handle by playing\r
+* @par ID      utc_audio_svc_update_playlist_name_func_01\r
+* @param       [in] &player = handle of player to be populated\r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_audio_svc_update_playlist_name_func_01()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       bool retval = FALSE;\r
+       int playlist_id = 0;\r
+\r
+       retval = get_playlist_id(&playlist_id);\r
+       if(!retval)\r
+       {\r
+               dts_fail("get_playlist_id","fail to get playlist id.");\r
+       }\r
+       \r
+       ret = audio_svc_update_playlist_name(playlist_id, "new name");\r
+       dts_check_eq("audio_svc_update_playlist_name", ret, AUDIO_SVC_ERROR_NONE, "failed to update playlist name.");\r
+\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int audio_svc_add_playlist() API with invalid parameter\r
+*                      Create a player handle with a NULL out param\r
+* @par ID      utc_audio_svc_update_playlist_name_func_02\r
+* @param       [in] &player = NULL\r
+* @return      error code on success\r
+*/\r
+void utc_audio_svc_update_playlist_name_func_02()\r
+{\r
+       int ret = AUDIO_SVC_ERROR_NONE;\r
+       int playlist_id = 1;\r
+\r
+       ret = audio_svc_update_playlist_name(playlist_id, NULL);\r
+       if (ret != AUDIO_SVC_ERROR_NONE)\r
+       {\r
+               dts_pass("audio_svc_update_playlist_name","abnormal condition test for invalid NULL parameter.");\r
+       }\r
+       else\r
+       {\r
+               dts_fail("audio_svc_update_playlist_name","update playlist should be failed because of the null parameter.");\r
+       }\r
+\r
+}\r
diff --git a/TC/utc/audio/utc_audio_svc_update_playlist_name_func.h b/TC/utc/audio/utc_audio_svc_update_playlist_name_func.h
new file mode 100755 (executable)
index 0000000..042db0e
--- /dev/null
@@ -0,0 +1,53 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_audio_svc_update_playlist_name_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of audio_svc_add_playlist API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-09-13\r
+*/\r
+\r
+#ifndef __UTS_AUDIO_SVC_UPDATE_PLAYLIST_NAME_FUNC_H_\r
+#define __UTS_AUDIO_SVC_UPDATE_PLAYLIST_NAME_FUNC_H_\r
+\r
+\r
+#include "utc_audio_svc_common.h"\r
+\r
+void startup();\r
+void cleanup();\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_audio_svc_update_playlist_name_func_01();\r
+void utc_audio_svc_update_playlist_name_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_audio_svc_update_playlist_name_func_01, 1},\r
+       {utc_audio_svc_update_playlist_name_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_AUDIO_SVC_UPDATE_PLAYLIST_NAME_FUNC_H_  \r
diff --git a/TC/utc/visual/Makefile b/TC/utc/visual/Makefile
new file mode 100644 (file)
index 0000000..d86aee6
--- /dev/null
@@ -0,0 +1,219 @@
+ifeq ($(ARCH),target)\r
+       PKG_CONFIG_PATH=/usr/lib/pkgconfig\r
+       export PKG_CONFIG_PATH\r
+       CC=arm-linux-gcc -Wall\r
+       CXX=arm-linux-g++ -Wall\r
+else\r
+       PKG_CONFIG_PATH=/usr/lib/pkgconfig\r
+       export PKG_CONFIG_PATH\r
+       CC=gcc -Wall\r
+    CXX=gcc -Wall\r
+endif\r
+\r
+TS10=utc_minfo_finalize_func\r
+TS11=utc_minfo_destroy_mtype_item_func\r
+TS13=utc_minfo_get_bookmark_list_func\r
+TS14=utc_minfo_get_cluster_cnt_func\r
+TS15=utc_minfo_get_cluster_cover_func\r
+TS16=utc_minfo_get_cluster_func\r
+TS17=utc_minfo_get_cluster_list_func\r
+TS18=utc_minfo_get_cluster_id_by_url_func\r
+TS19=utc_minfo_get_geo_item_list_func\r
+TS20=utc_minfo_get_item_cnt_func\r
+TS21=utc_minfo_get_item_func\r
+TS22=utc_minfo_get_item_list_func\r
+TS25=utc_minfo_get_meta_info_func\r
+TS26=utc_minfo_get_thumb_path_func\r
+TS27=utc_minfo_init_func\r
+TS28=utc_minfo_move_media_func\r
+TS29=utc_minfo_mv_media_func\r
+TS30=utc_minfo_update_cluster_name_func\r
+TS31=utc_minfo_update_favorite_by_media_id_func\r
+TS32=utc_minfo_update_media_favorite_func\r
+TS33=utc_minfo_update_media_name_func\r
+TS34=utc_minfo_set_cluster_lock_status_func\r
+TS35=utc_minfo_get_cluster_lock_status_func\r
+TS36=utc_minfo_bookmark_func\r
+TS37=utc_minfo_cluster_func\r
+TS38=utc_minfo_media_func\r
+TS39=utc_minfo_get_all_item_list_func\r
+TS40=utc_minfo_update_video_meta_info_int_func\r
+TS41=utc_minfo_get_thumb_path_for_video_func\r
+TS42=utc_minfo_get_cluster_name_by_id_func\r
+TS43=utc_minfo_get_media_path_func\r
+TS44=utc_minfo_tag_func\r
+TS45=utc_minfo_get_media_list_by_tagname_func\r
+TS46=utc_minfo_get_tag_list_by_media_id_func\r
+TS47=utc_minfo_set_db_valid_func\r
+TS48=utc_minfo_delete_invalid_media_records_func\r
+TS49=utc_minfo_get_cluster_fullpath_by_id_func\r
+\r
+\r
+LIBS = `pkg-config --libs libmedia-info`\r
+LIBS +=-L/usr/lib/:/usr/lib/pkgconfig\r
+LIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o\r
+LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s\r
+LIBS +=-L$(TET_ROOT)/lib/tet3/ -lapi_s\r
+\r
+INCS = -I. `pkg-config --cflags  libmedia-info`\r
+INCS += -I$(TET_ROOT)/inc/tet3\r
+INCS += -I/usr/include\r
+\r
+CFLAGS = $(INCS) \r
+CC += $(CFLAGS)\r
+LDFLAGS = $(LIBS)\r
+\r
+all : $(TS10) $(TS11) $(TS12) $(TS13) $(TS14) $(TS15) $(TS16) $(TS17) $(TS18) $(TS19) $(TS20) $(TS21) $(TS22) $(TS23) $(TS24) $(TS25) $(TS26) $(TS27) $(TS28) $(TS29) $(TS30) $(TS31) $(TS32) $(TS33) $(TS34) $(TS35) $(TS36) $(TS37) $(TS38) $(TS39) $(TS40) $(TS41) $(TS42) $(TS43) $(TS44) $(TS45) $(TS46) $(TS47) $(TS48) $(TS49)\r
+\r
+$(TS1): $(TS1).c\r
+       $(CC) -o $(TS1) $(TS1).c $(LDFLAGS)\r
+\r
+$(TS2): $(TS2).c\r
+       $(CC) -o $(TS2) $(TS2).c $(LDFLAGS)\r
+       \r
+$(TS3): $(TS3).c\r
+       $(CC) -o $(TS3) $(TS3).c $(LDFLAGS)\r
+\r
+$(TS4): $(TS4).c\r
+       $(CC) -o $(TS4) $(TS4).c $(LDFLAGS)\r
+\r
+$(TS5): $(TS5).c\r
+       $(CC) -o $(TS5) $(TS5).c $(LDFLAGS)\r
+       \r
+$(TS6): $(TS6).c\r
+       $(CC) -o $(TS6) $(TS6).c $(LDFLAGS)\r
+\r
+$(TS7): $(TS7).c\r
+       $(CC) -o $(TS7) $(TS7).c $(LDFLAGS)\r
+\r
+$(TS8): $(TS8).c\r
+       $(CC) -o $(TS8) $(TS8).c $(LDFLAGS)\r
+\r
+$(TS9): $(TS9).c\r
+       $(CC) -o $(TS9) $(TS9).c $(LDFLAGS)\r
+\r
+$(TS10): $(TS10).c\r
+       $(CC) -o $(TS10) $(TS10).c $(LDFLAGS)\r
+\r
+$(TS11): $(TS11).c\r
+       $(CC) -o $(TS11) $(TS11).c $(LDFLAGS)\r
+\r
+$(TS12): $(TS12).c\r
+       $(CC) -o $(TS12) $(TS12).c $(LDFLAGS)\r
+\r
+$(TS13): $(TS13).c\r
+       $(CC) -o $(TS13) $(TS13).c $(LDFLAGS)\r
+\r
+$(TS14): $(TS14).c\r
+       $(CC) -o $(TS14) $(TS14).c $(LDFLAGS)\r
+\r
+$(TS15): $(TS15).c\r
+       $(CC) -o $(TS15) $(TS15).c $(LDFLAGS)\r
+\r
+$(TS16): $(TS16).c\r
+       $(CC) -o $(TS16) $(TS16).c $(LDFLAGS)\r
+\r
+$(TS17): $(TS17).c\r
+       $(CC) -o $(TS17) $(TS17).c $(LDFLAGS)\r
+\r
+$(TS18): $(TS18).c\r
+       $(CC) -o $(TS18) $(TS18).c $(LDFLAGS)\r
+\r
+$(TS19): $(TS19).c\r
+       $(CC) -o $(TS19) $(TS19).c $(LDFLAGS)\r
+\r
+$(TS20): $(TS20).c\r
+       $(CC) -o $(TS20) $(TS20).c $(LDFLAGS)\r
+\r
+$(TS21): $(TS21).c\r
+       $(CC) -o $(TS21) $(TS21).c $(LDFLAGS)\r
+\r
+$(TS22): $(TS22).c\r
+       $(CC) -o $(TS22) $(TS22).c $(LDFLAGS)\r
+\r
+$(TS23): $(TS23).c\r
+       $(CC) -o $(TS23) $(TS23).c $(LDFLAGS)\r
+\r
+$(TS24): $(TS24).c\r
+       $(CC) -o $(TS24) $(TS24).c $(LDFLAGS)\r
+\r
+$(TS25): $(TS25).c\r
+       $(CC) -o $(TS25) $(TS25).c $(LDFLAGS)\r
+\r
+$(TS26): $(TS26).c\r
+       $(CC) -o $(TS26) $(TS26).c $(LDFLAGS)\r
+\r
+$(TS27): $(TS27).c\r
+       $(CC) -o $(TS27) $(TS27).c $(LDFLAGS)\r
+\r
+$(TS28): $(TS28).c\r
+       $(CC) -o $(TS28) $(TS28).c $(LDFLAGS)\r
+\r
+$(TS29): $(TS29).c\r
+       $(CC) -o $(TS29) $(TS29).c $(LDFLAGS)\r
+\r
+$(TS30): $(TS30).c\r
+       $(CC) -o $(TS30) $(TS30).c $(LDFLAGS)\r
+\r
+$(TS31): $(TS31).c\r
+       $(CC) -o $(TS31) $(TS31).c $(LDFLAGS)\r
+\r
+$(TS32): $(TS32).c\r
+       $(CC) -o $(TS32) $(TS32).c $(LDFLAGS)\r
+\r
+$(TS33): $(TS33).c\r
+       $(CC) -o $(TS33) $(TS33).c $(LDFLAGS)\r
+\r
+$(TS34): $(TS34).c\r
+       $(CC) -o $(TS34) $(TS34).c $(LDFLAGS)\r
+\r
+$(TS35): $(TS35).c\r
+       $(CC) -o $(TS35) $(TS35).c $(LDFLAGS)\r
+\r
+$(TS36): $(TS36).c\r
+       $(CC) -o $(TS36) $(TS36).c $(LDFLAGS)\r
+\r
+$(TS37): $(TS37).c\r
+       $(CC) -o $(TS37) $(TS37).c $(LDFLAGS)\r
+\r
+$(TS38): $(TS38).c\r
+       $(CC) -o $(TS38) $(TS38).c $(LDFLAGS)\r
+\r
+$(TS39): $(TS39).c\r
+       $(CC) -o $(TS39) $(TS39).c $(LDFLAGS)\r
+\r
+$(TS40): $(TS40).c\r
+       $(CC) -o $(TS40) $(TS40).c $(LDFLAGS)\r
+\r
+$(TS41): $(TS41).c\r
+       $(CC) -o $(TS41) $(TS41).c $(LDFLAGS)\r
+\r
+$(TS42): $(TS42).c\r
+       $(CC) -o $(TS42) $(TS42).c $(LDFLAGS)\r
+\r
+$(TS43): $(TS43).c\r
+       $(CC) -o $(TS43) $(TS43).c $(LDFLAGS)\r
+\r
+$(TS44): $(TS44).c\r
+       $(CC) -o $(TS44) $(TS44).c $(LDFLAGS)\r
+\r
+$(TS45): $(TS45).c\r
+       $(CC) -o $(TS45) $(TS45).c $(LDFLAGS)\r
+\r
+$(TS46): $(TS46).c\r
+       $(CC) -o $(TS46) $(TS46).c $(LDFLAGS)\r
+\r
+$(TS47): $(TS47).c\r
+       $(CC) -o $(TS47) $(TS47).c $(LDFLAGS)\r
+\r
+$(TS48): $(TS48).c\r
+       $(CC) -o $(TS48) $(TS48).c $(LDFLAGS)\r
+\r
+$(TS49): $(TS49).c\r
+       $(CC) -o $(TS49) $(TS49).c $(LDFLAGS)\r
+\r
+clean:\r
+       rm -rf *~ *.o $(TS10) $(TS11) $(TS12) $(TS13) $(TS14) $(TS15) $(TS16) $(TS17) $(TS18) $(TS19) $(TS20) $(TS21) $(TS22) $(TS23) $(TS24) $(TS25) $(TS26) $(TS27) $(TS28) $(TS29) $(TS30) $(TS31) $(TS32) $(TS33) $(TS34) $(TS35) $(TS36) $(TS37) $(TS38) $(TS39) $(TS40) $(TS41) $(TS42) $(TS43) $(TS44) $(TS45) $(TS46) $(TS47) $(TS48) $(TS49)\r
+       \r
+\r
+\r
diff --git a/TC/utc/visual/tslist b/TC/utc/visual/tslist
new file mode 100644 (file)
index 0000000..6f77723
--- /dev/null
@@ -0,0 +1,37 @@
+/utc/visual/utc_minfo_init_func\r
+/utc/visual/utc_minfo_bookmark_func\r
+/utc/visual/utc_minfo_cluster_func\r
+/utc/visual/utc_minfo_media_func\r
+/utc/visual/utc_minfo_tag_func\r
+/utc/visual/utc_minfo_delete_invalid_media_records_func\r
+/utc/visual/utc_minfo_destroy_mtype_item_func\r
+/utc/visual/utc_minfo_get_bookmark_list_func\r
+/utc/visual/utc_minfo_get_cluster_cnt_func\r
+/utc/visual/utc_minfo_get_cluster_cover_func\r
+/utc/visual/utc_minfo_get_cluster_func\r
+/utc/visual/utc_minfo_get_cluster_id_by_url_func\r
+/utc/visual/utc_minfo_get_cluster_list_func\r
+/utc/visual/utc_minfo_get_cluster_lock_status_func\r
+/utc/visual/utc_minfo_get_cluster_name_by_id_func\r
+/utc/visual/utc_minfo_get_cluster_fullpath_by_id_func\r
+/utc/visual/utc_minfo_get_geo_item_list_func\r
+/utc/visual/utc_minfo_get_item_cnt_func\r
+/utc/visual/utc_minfo_get_item_func\r
+/utc/visual/utc_minfo_get_item_list_func\r
+/utc/visual/utc_minfo_get_all_item_list_func\r
+/utc/visual/utc_minfo_get_meta_info_func\r
+/utc/visual/utc_minfo_get_media_list_by_tagname_func\r
+/utc/visual/utc_minfo_set_cluster_lock_status_func\r
+/utc/visual/utc_minfo_set_db_valid_func\r
+/utc/visual/utc_minfo_update_cluster_name_func\r
+/utc/visual/utc_minfo_update_favorite_by_media_id_func\r
+/utc/visual/utc_minfo_update_media_favorite_func\r
+/utc/visual/utc_minfo_update_media_name_func\r
+/utc/visual/utc_minfo_update_video_meta_info_int_func\r
+/utc/visual/utc_minfo_get_thumb_path_func\r
+/utc/visual/utc_minfo_get_thumb_path_for_video_func\r
+/utc/visual/utc_minfo_get_media_path_func\r
+/utc/visual/utc_minfo_get_tag_list_by_media_id_func\r
+/utc/visual/utc_minfo_move_media_func\r
+/utc/visual/utc_minfo_mv_media_func\r
+/utc/visual/utc_minfo_finalize_func\r
diff --git a/TC/utc/visual/utc_minfo_add_bookmark_func.c b/TC/utc/visual/utc_minfo_add_bookmark_func.c
new file mode 100644 (file)
index 0000000..f306742
--- /dev/null
@@ -0,0 +1,103 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_add_bookmark_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_add_bookmark API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_add_bookmark_func.h"\r
+\r
+\r
+/**\r
+* @brief       This tests int minfo_add_bookmark() API with valid parameter\r
+*              add a bookmark to a media file.\r
+* @par ID      utc_minfo_add_bookmark_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_add_bookmark_func_01()\r
+{\r
+       int ret = -1;\r
+        \r
+       int position = 2346;\r
+       int media_id = 1;\r
+       char *thumb_path = "tmp1";\r
+\r
+       UTC_MINFO_INIT()\r
+\r
+       ret = minfo_add_bookmark(media_id, position, thumb_path);\r
+       \r
+       if (ret < MB_SVC_ERROR_NONE)\r
+       {\r
+               UTC_MM_LOG( "unable to add a bookmark to a media file. error code->%d", ret);\r
+       UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+               return;\r
+       } else {\r
+       UTC_MINFO_FINALIZE()\r
+               tet_result(TET_PASS);\r
+       }\r
+       \r
+       \r
+       return;\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_add_bookmark() API with invalid parameter\r
+*                      add a bookmark to a media file.\r
+* @par ID      utc_minfo_add_bookmark_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_add_bookmark_func_02()\r
+{      \r
+        int ret = -1;\r
+        \r
+        int position = 2346;\r
+        int media_id = 1;\r
+        char *thumb_path = NULL;\r
+\r
+        UTC_MINFO_INIT()\r
+\r
+        ret = minfo_add_bookmark(media_id,position,thumb_path);\r
+\r
+       if (ret<0)\r
+       {\r
+               UTC_MM_LOG("abnormal condition test for null, error code->%d", ret);\r
+       UTC_MINFO_FINALIZE()\r
+               tet_result(TET_PASS);\r
+       }\r
+       else\r
+       {\r
+               UTC_MM_LOG("add a bookmark to a media file should be failed because of the media_id parameter -1.");\r
+       UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+       }\r
+\r
+\r
+       return ;\r
+}\r
diff --git a/TC/utc/visual/utc_minfo_add_bookmark_func.h b/TC/utc/visual/utc_minfo_add_bookmark_func.h
new file mode 100644 (file)
index 0000000..f385105
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_add_bookmark_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_add_bookmark_ API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_add_bookmark__FUNC_H_\r
+#define __UTS_minfo_add_bookmark__FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = NULL;\r
+void (*tet_cleanup)() = NULL;\r
+\r
+void utc_minfo_add_bookmark_func_01();\r
+void utc_minfo_add_bookmark_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_add_bookmark_func_01, 1},\r
+       {utc_minfo_add_bookmark_func_02, 2},    \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_add_bookmark__FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_add_cluster_func.c b/TC/utc/visual/utc_minfo_add_cluster_func.c
new file mode 100644 (file)
index 0000000..5cf72e1
--- /dev/null
@@ -0,0 +1,97 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_add_cluster_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_add_cluster API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_add_cluster_func.h"\r
+\r
+\r
+/**\r
+* @brief       This tests int minfo_add_cluster() API with valid parameter\r
+*              add a cluser record content in folder table.\r
+* @par ID      utc_minfo_add_cluster_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_add_cluster_func_01()\r
+{\r
+       int ret = -1;\r
+       char *cluster_url = "/opt/media/Images and videos/ForTC";\r
+       int id = 0;\r
+       \r
+       UTC_MINFO_INIT()\r
+       ret = minfo_add_cluster(cluster_url, &id);\r
+\r
+       if (ret < MB_SVC_ERROR_NONE)\r
+       {\r
+               UTC_MM_LOG( "failed to add a cluser record content in folder table. error code->%d", ret);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+               return;\r
+       }\r
+       \r
+       UTC_MINFO_FINALIZE()\r
+       tet_result(TET_PASS);\r
+       \r
+       return;\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_add_cluster() API with invalid parameter\r
+*                      add a cluser record content in folder table.\r
+* @par ID      utc_minfo_add_cluster_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_add_cluster_func_02()\r
+{\r
+       int ret = -1;\r
+       char *cluster_url = NULL; /*= "/opt/media/Images/Wallpapers_1";*/\r
+       int id = 0;\r
+       \r
+       UTC_MINFO_INIT()\r
+       ret = minfo_add_cluster(cluster_url, &id);\r
+\r
+               \r
+       if (ret<0)\r
+       {\r
+               UTC_MM_LOG("abnormal condition test for null, error code->%d", ret);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_PASS);\r
+       }\r
+       else\r
+       {\r
+               UTC_MM_LOG("add a cluser record content in folder table should be failed because of the cluster_url NULL.");\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+       }\r
+\r
+\r
+       return ;\r
+}\r
diff --git a/TC/utc/visual/utc_minfo_add_cluster_func.h b/TC/utc/visual/utc_minfo_add_cluster_func.h
new file mode 100644 (file)
index 0000000..6d3f5d0
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_add_cluster_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_add_cluster API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_add_cluster_FUNC_H_\r
+#define __UTS_minfo_add_cluster_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = NULL;\r
+void (*tet_cleanup)() = NULL;\r
+\r
+void utc_minfo_add_cluster_func_01();\r
+void utc_minfo_add_cluster_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_add_cluster_func_01, 1},\r
+       {utc_minfo_add_cluster_func_02, 2},     \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_add_cluster_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_add_media_func.c b/TC/utc/visual/utc_minfo_add_media_func.c
new file mode 100644 (file)
index 0000000..ff5d382
--- /dev/null
@@ -0,0 +1,96 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_free_glist_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_add_media API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_add_media_func.h"\r
+\r
+\r
+/**\r
+* @brief       This tests int minfo_add_media() API with valid parameter\r
+*              Add a media content to media table.\r
+* @par ID      utc_minfo_add_media_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_add_media_func_01()\r
+{\r
+       int err = -1;\r
+       char *file_url = "/opt/media/Images and videos/Wallpapers/Home_01.png";\r
+       int type = 1;\r
+\r
+       UTC_MINFO_INIT()\r
+\r
+       err = minfo_add_media(file_url, type);\r
+\r
+       if (err < MB_SVC_ERROR_NONE)\r
+       {\r
+               UTC_MM_LOG( "unable to Add a media content to media table. error code->%d", err);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+               return;\r
+       }\r
+       \r
+       UTC_MINFO_FINALIZE()\r
+       tet_result(TET_PASS);\r
+       \r
+       return;\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_add_media() API with invalid parameter\r
+*                      Add a media content to media table.\r
+* @par ID      utc_minfo_add_media_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_add_media_func_02()\r
+{      \r
+       int err = -1;\r
+       char *file_url = NULL; /*= "/opt/media/Images/Wallpapers/Home_01.png";*/\r
+       int type = 1;\r
+\r
+       UTC_MINFO_INIT()\r
+       err = minfo_add_media(file_url, type);  \r
+               \r
+       if (err<0)\r
+       {\r
+               UTC_MM_LOG("abnormal condition test for null, error code->%d", err);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_PASS);\r
+       }\r
+       else\r
+       {\r
+               UTC_MM_LOG("Add a media content to media table should be failed because of the file_url NULL.");\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+       }\r
+\r
+       return ;\r
+}\r
diff --git a/TC/utc/visual/utc_minfo_add_media_func.h b/TC/utc/visual/utc_minfo_add_media_func.h
new file mode 100644 (file)
index 0000000..1a2cf94
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_add_media_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_add_media API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_add_media_FUNC_H_\r
+#define __UTS_minfo_add_media_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = NULL;\r
+void (*tet_cleanup)() = NULL;\r
+\r
+void utc_minfo_add_media_func_01();\r
+void utc_minfo_add_media_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_add_media_func_01, 1},\r
+       {utc_minfo_add_media_func_02, 2},       \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_add_media_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_bookmark_func.c b/TC/utc/visual/utc_minfo_bookmark_func.c
new file mode 100644 (file)
index 0000000..68847c6
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_bookmark_func.c
+* @brief       This is a suit of unit test cases to test minfo_add_bookmark and minfo_delete_bookmark API functions
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_bookmark_func.h"
+
+/**
+* @brief       This tests int minfo_add_bookmark() API with valid parameter
+*              add a bookmark to a media file.
+* @par ID      utc_minfo_add_bookmark_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_add_bookmark_func_01()
+{
+       int ret = -1;
+        
+       int position = 2346;
+       const char *media_id = "2f08863e-52fd-eaf8-269c-3d0798e7aa0e";
+       char *thumb_path = "tmp1";
+
+       ret = minfo_add_bookmark(media_id, position, thumb_path);
+       
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to add a bookmark to a media file. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_add_bookmark() API with invalid parameter
+*                      add a bookmark to a media file.
+* @par ID      utc_minfo_add_bookmark_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_add_bookmark_func_02()
+{      
+        int ret = -1;
+        
+        int position = 2346;
+        const char *media_id = "2f08863e-52fd-eaf8-269c-3d0798e7aa0e";
+        char *thumb_path = NULL;
+
+        ret = minfo_add_bookmark(media_id,position,thumb_path);
+
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "add a bookmark to a media file should be failed because of the media_id parameter -1.");
+}
+
+/**
+* @brief       This tests int minfo_delete_bookmark() API with valid parameter
+*              delete a bookmark to a media file.
+* @par ID      utc_minfo_delete_bookmark_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_delete_bookmark_func_01()
+{
+       int ret = -1;
+        
+       int bookmark_id = 1;
+       ret = minfo_delete_bookmark(bookmark_id);
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to delete a bookmark to a media file. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_delete_bookmark() API with invalid parameter
+*                      delete a bookmark to a media file.
+* @par ID      utc_minfo_delete_bookmark_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_delete_bookmark_func_02()
+{      
+       int ret = -1;
+        
+       int bookmark_id = -1;
+       ret = minfo_delete_bookmark(bookmark_id);
+       
+
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "delete a bookmark to a media file should be failed because of the bookmark_id parameter -1.");
+}
diff --git a/TC/utc/visual/utc_minfo_bookmark_func.h b/TC/utc/visual/utc_minfo_bookmark_func.h
new file mode 100644 (file)
index 0000000..418babd
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file                utc_minfo_bookmark_func.h
+* @author      
+* @brief       This is the implementaion file for the test case of minfo_add_bookmark and minfo_delete_bookmark API functions
+* @version     Initial Creation Version 0.1
+* @date                2010-10-13
+*/
+
+#ifndef __UTS_minfo_bookmark__FUNC_H_
+#define __UTS_minfo_bookmark__FUNC_H_
+
+
+#include "utc_visual_svc_common.h"
+
+/* Initialize TCM data structures */
+void (*tet_startup)() = startup;
+void (*tet_cleanup)() = cleanup;
+
+void utc_minfo_add_bookmark_func_01();
+void utc_minfo_add_bookmark_func_02();
+void utc_minfo_delete_bookmark_func_01();
+void utc_minfo_delete_bookmark_func_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_minfo_add_bookmark_func_01, 1},
+       {utc_minfo_delete_bookmark_func_01, 1},
+       {utc_minfo_add_bookmark_func_02, 2},    
+       {utc_minfo_delete_bookmark_func_02, 2}, 
+       {NULL, 0}
+};
+
+
+#endif //__UTS_minfo_bookmark__FUNC_H_
diff --git a/TC/utc/visual/utc_minfo_cluster_func.c b/TC/utc/visual/utc_minfo_cluster_func.c
new file mode 100644 (file)
index 0000000..d66bd50
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_cluster_func.c
+* @brief       This is a suit of unit test cases to test minfo_add_cluster and minfo_delete_cluster API functions
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_cluster_func.h"
+
+int _get_id_by_url(const char *url, char *id)
+{
+       char cluster_id[256] = {0,};
+
+       if( minfo_get_cluster_id_by_url(url, cluster_id, sizeof(cluster_id)) < 0 )
+       {
+               return -1;
+       }
+
+       strncpy(id, cluster_id, 256);
+
+       return 0;
+}
+
+
+/**
+* @brief       This tests int minfo_add_cluster() API with valid parameter
+*              add a cluser record content in folder table.
+* @par ID      utc_minfo_add_cluster_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_add_cluster_func_01()
+{
+       int ret = -1;
+       char *cluster_url = "/opt/media/Images and videos/ForTC";
+       char cluster_id[256] = {0,};
+       
+       ret = minfo_add_cluster(cluster_url, cluster_id, sizeof(cluster_id));
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to add a cluser record content in folder table. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_add_cluster() API with invalid parameter
+*                      add a cluser record content in folder table.
+* @par ID      utc_minfo_add_cluster_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_add_cluster_func_02()
+{
+       int ret = -1;
+       char *cluster_url = NULL; /*= "/opt/media/Images/Wallpapers_1";*/
+       char cluster_id[256] = {0,};
+       
+       ret = minfo_add_cluster(cluster_url, cluster_id, sizeof(cluster_id));
+
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "add a cluser record content in folder table should be failed because of the cluster_url NULL.");
+}
+
+
+/**
+* @brief       This tests int minfo_delete_cluster() API with valid parameter
+*              delete a cluster/folder identified by folder id.
+* @par ID      utc_minfo_delete_cluster_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_delete_cluster_func_01()
+{
+       int ret = -1;
+
+       char cluster_id[256] = {0,};
+        _get_id_by_url("/opt/media/Images and videos/ForTC", cluster_id);
+       ret = minfo_delete_cluster(cluster_id);
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to delete a cluster/folder identified by folder id. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_delete_cluster() API with invalid parameter
+*                      delete a cluster/folder identified by folder id.
+* @par ID      utc_minfo_delete_cluster_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_delete_cluster_func_02()
+{
+       int ret = -1;
+        
+       const char *cluster_id = NULL;
+       ret = minfo_delete_cluster(cluster_id);
+               
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "delete a cluster/folder identified by folder id should be failed because of the cluster_id -1.");
+}
diff --git a/TC/utc/visual/utc_minfo_cluster_func.h b/TC/utc/visual/utc_minfo_cluster_func.h
new file mode 100644 (file)
index 0000000..ef7317c
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file                utc_minfo_cluster_func.h
+* @author      
+* @brief       This is the implementaion file for the test case of minfo_add_cluster and minfo_del_cluster API functions
+* @version     Initial Creation Version 0.1
+* @date                2010-10-13
+*/
+
+#ifndef __UTS_minfo_cluster_FUNC_H_
+#define __UTS_minfo_cluster_FUNC_H_
+
+
+#include "utc_visual_svc_common.h"
+
+/* Initialize TCM data structures */
+void (*tet_startup)() = startup;
+void (*tet_cleanup)() = cleanup;
+
+void utc_minfo_add_cluster_func_01();
+void utc_minfo_add_cluster_func_02();
+void utc_minfo_delete_cluster_func_01();
+void utc_minfo_delete_cluster_func_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_minfo_add_cluster_func_01, 1},
+       {utc_minfo_delete_cluster_func_01, 1},
+       {utc_minfo_add_cluster_func_02, 2},     
+       {utc_minfo_delete_cluster_func_02, 2},  
+       {NULL, 0}
+};
+
+
+#endif //__UTS_minfo_cluster_FUNC_H_
diff --git a/TC/utc/visual/utc_minfo_copy_media_func.c b/TC/utc/visual/utc_minfo_copy_media_func.c
new file mode 100644 (file)
index 0000000..d7041ff
--- /dev/null
@@ -0,0 +1,98 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_copy_media_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_copy_media API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_copy_media_func.h"\r
+\r
+\r
+/**\r
+* @brief       This tests int minfo_copy_media() API with valid parameter\r
+*              Copy a media content from media table.\r
+* @par ID      utc_minfo_copy_media_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_copy_media_func_01()\r
+{\r
+       int err = -1;\r
+       char *old_file_url = "/opt/media/Images and videos/Wallpapers/Home_default.png";\r
+       char *new_file_url = "/opt/media/Images and videos/Wallpapers/Home_default_1.png";\r
+       int type = 1;\r
+\r
+       UTC_MINFO_INIT()\r
+       err = minfo_copy_media(old_file_url, new_file_url, type);\r
+\r
+       if (err < MB_SVC_ERROR_NONE)\r
+       {\r
+               UTC_MM_LOG( "unable to Copy a media content from media table.. error code->%d", err);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+               return;\r
+       }\r
+\r
+       UTC_MINFO_FINALIZE()\r
+       tet_result(TET_PASS);\r
+       \r
+       return;\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_copy_media() API with invalid parameter\r
+*                      Copy a media content from media table.\r
+* @par ID      utc_minfo_copy_media_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_copy_media_func_02()\r
+{      \r
+       int err = -1;\r
+       char *old_file_url = NULL; /*= "/opt/media/Images and videos/Wallpapers/Home_default.png";*/\r
+       char *new_file_url = "/opt/media/Images and videos/Wallpapers/Home_default_1.png";\r
+       int type = 1;\r
+\r
+       UTC_MINFO_INIT()\r
+       err = minfo_copy_media(old_file_url, new_file_url, type);\r
+               \r
+       if (err<0)\r
+       {\r
+               UTC_MM_LOG("abnormal condition test for null, error code->%d", err);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_PASS);\r
+       }\r
+       else\r
+       {\r
+               UTC_MM_LOG("Copy a media content from media table should be failed because of the file_url NULL.");\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+       }\r
+\r
+       return ;\r
+}\r
+\r
diff --git a/TC/utc/visual/utc_minfo_copy_media_func.h b/TC/utc/visual/utc_minfo_copy_media_func.h
new file mode 100644 (file)
index 0000000..ca25e00
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_copy_media_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_copy_media API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_copy_media_FUNC_H_\r
+#define __UTS_minfo_copy_media_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = NULL;\r
+void (*tet_cleanup)() = NULL;\r
+\r
+void utc_minfo_copy_media_func_01();\r
+void utc_minfo_copy_media_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_copy_media_func_01, 1},\r
+       {utc_minfo_copy_media_func_02, 2},      \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_copy_media_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_cp_media_func.c b/TC/utc/visual/utc_minfo_cp_media_func.c
new file mode 100644 (file)
index 0000000..1c3bd31
--- /dev/null
@@ -0,0 +1,150 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_cp_media_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_cp_media API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_cp_media_func.h"\r
+\r
+static int _ite_fn( Mitem* item, void* user_data) \r
+{\r
+       GList** list = (GList**) user_data;\r
+       *list = g_list_append( *list, item );\r
+\r
+       return 0;\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int minfo_cp_media() API with valid parameter\r
+*              copy a record identified by media id to destination folder identified by folder id.\r
+* @par ID      utc_minfo_cp_media_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_cp_media_func_01()\r
+{\r
+       int ret = -1;\r
+       \r
+       char *file_url = "/opt/media/Images and videos/Wallpapers/Home_default.png";\r
+       int src_media_id = 1;\r
+       int src_cluster_id = 2;\r
+       int dst_cluster_id = 2;\r
+       Mitem* item = NULL;\r
+       UTC_MINFO_INIT()\r
+\r
+       ret = minfo_get_item( file_url, &item );\r
+       if (ret < MB_SVC_ERROR_NONE)\r
+       {\r
+               UTC_MM_LOG( "unable to get a media content from media table. error code->%d", ret);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+               return;\r
+       }\r
+\r
+       src_media_id = item->_id;\r
+       src_cluster_id = item->cluster_id;\r
+       dst_cluster_id = item->cluster_id + 1;\r
+\r
+       minfo_destroy_mtype_item(item); \r
+\r
+       ret = minfo_cp_media(src_media_id, dst_cluster_id);\r
+\r
+       if (ret < MB_SVC_ERROR_NONE)\r
+       {\r
+               UTC_MM_LOG( "failed to copy a record identified by media id to destination folder identified by folder id. error code->%d", ret);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+               return;\r
+       }\r
+       \r
+       GList *p_list = NULL;\r
+       minfo_item_filter item_filter = {MINFO_ITEM_ALL,MINFO_MEDIA_SORT_BY_NONE,-1,-1,false,false};\r
+       Mitem* dest_item = NULL;\r
+\r
+       ret = minfo_get_item_list(dst_cluster_id, item_filter, _ite_fn, &p_list);\r
+       \r
+       if (ret < MB_SVC_ERROR_NONE)\r
+       {\r
+               UTC_MM_LOG( "unable to get media records. error code->%d", ret);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+               return;\r
+       }\r
+\r
+       int len = g_list_length( p_list );\r
+       dest_item = (Mitem*)g_list_nth_data(p_list, len-1);\r
+       ret = minfo_delete_media_id( dest_item->_id );\r
+\r
+       if (ret < MB_SVC_ERROR_NONE)\r
+       {\r
+               UTC_MM_LOG( "unable to delete media records. error code->%d", ret);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+               return;\r
+       }\r
+\r
+       minfo_destroy_mtype_item(dest_item);    \r
+\r
+       UTC_MINFO_FINALIZE()\r
+       tet_result(TET_PASS);\r
+\r
+       return;\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_cp_media() API with invalid parameter\r
+*                      copy a record identified by media id to destination folder identified by folder id.\r
+* @par ID      utc_minfo_cp_media_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_cp_media_func_02()\r
+{\r
+       int ret = -1;\r
+       \r
+       int src_media_id = -1;\r
+       int dst_cluster_id = 2;\r
+       UTC_MINFO_INIT()\r
+       ret = minfo_cp_media(src_media_id, dst_cluster_id);\r
+               \r
+       if (ret<0)\r
+       {\r
+               UTC_MM_LOG("abnormal condition test for null, error code->%d", ret);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_PASS);\r
+       }\r
+       else\r
+       {\r
+               UTC_MM_LOG("copy a record identified by media id to destination folder identified by folder id should be failed because of the src_media_id -1.");\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+       }\r
+\r
+       return ;\r
+}\r
diff --git a/TC/utc/visual/utc_minfo_cp_media_func.h b/TC/utc/visual/utc_minfo_cp_media_func.h
new file mode 100644 (file)
index 0000000..bb64eb8
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_cp_media_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_cp_media API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_cp_media_func_FUNC_H_\r
+#define __UTS_minfo_cp_media_func_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = NULL;\r
+void (*tet_cleanup)() = NULL;\r
+\r
+void utc_minfo_cp_media_func_01();\r
+void utc_minfo_cp_media_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_cp_media_func_01, 1},\r
+       {utc_minfo_cp_media_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_cp_media_func_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_delete_bookmark_func.c b/TC/utc/visual/utc_minfo_delete_bookmark_func.c
new file mode 100644 (file)
index 0000000..17e9c1f
--- /dev/null
@@ -0,0 +1,94 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_delete_bookmark_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_delete_bookmark API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_delete_bookmark_func.h"\r
+\r
+\r
+/**\r
+* @brief       This tests int minfo_delete_bookmark() API with valid parameter\r
+*              delete a bookmark to a media file.\r
+* @par ID      utc_minfo_delete_bookmark_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_delete_bookmark_func_01()\r
+{\r
+       int ret = -1;\r
+        \r
+       int bookmark_id = 1;\r
+       UTC_MINFO_INIT()\r
+       ret = minfo_delete_bookmark(bookmark_id);\r
+       \r
+       if (ret < MB_SVC_ERROR_NONE)\r
+       {\r
+               UTC_MM_LOG( "unable to delete a bookmark to a media file. error code->%d", ret);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+               return;\r
+       }\r
+       \r
+       UTC_MINFO_FINALIZE()\r
+       tet_result(TET_PASS);\r
+       \r
+       return;\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_delete_bookmark() API with invalid parameter\r
+*                      delete a bookmark to a media file.\r
+* @par ID      utc_minfo_delete_bookmark_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_delete_bookmark_func_02()\r
+{      \r
+       int ret = -1;\r
+        \r
+       int bookmark_id = -1;\r
+       UTC_MINFO_INIT()\r
+       ret = minfo_delete_bookmark(bookmark_id);\r
+       \r
+\r
+       if (ret<0)\r
+       {\r
+               UTC_MM_LOG("abnormal condition test for null, error code->%d", ret);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_PASS);\r
+       }\r
+       else\r
+       {\r
+               UTC_MM_LOG("delete a bookmark to a media file should be failed because of the bookmark_id parameter -1.");\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+       }\r
+\r
+       return ;\r
+}\r
diff --git a/TC/utc/visual/utc_minfo_delete_bookmark_func.h b/TC/utc/visual/utc_minfo_delete_bookmark_func.h
new file mode 100644 (file)
index 0000000..a6dcc86
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file                utc_minfo_delete_bookmark_func.h
+* @author      
+* @brief       This is the implementaion file for the test case of minfo_delete_bookmark API function
+* @version     Initial Creation Version 0.1
+* @date                2010-10-13
+*/
+
+#ifndef __UTS_minfo_delete_bookmark_FUNC_H_
+#define __UTS_minfo_delete_bookmark_FUNC_H_
+
+
+#include "utc_visual_svc_common.h"
+
+/* Initialize TCM data structures */
+void (*tet_startup)() = NULL;
+void (*tet_cleanup)() = NULL;
+
+void utc_minfo_delete_bookmark_func_01();
+void utc_minfo_delete_bookmark_func_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_minfo_delete_bookmark_func_01, 1},
+       {utc_minfo_delete_bookmark_func_02, 2}, 
+       {NULL, 0}
+};
+
+
+#endif //__UTS_minfo_delete_bookmark_FUNC_H_
diff --git a/TC/utc/visual/utc_minfo_delete_cluster_func.c b/TC/utc/visual/utc_minfo_delete_cluster_func.c
new file mode 100644 (file)
index 0000000..ecebd25
--- /dev/null
@@ -0,0 +1,106 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_delete_cluster_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_delete_cluster API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_delete_cluster_func.h"\r
+\r
+int _get_id_by_url(const char* url)\r
+{\r
+       int id;\r
+       if( minfo_get_cluster_id_by_url(url, &id) < 0 )\r
+       {\r
+               UTC_MM_LOG("minfo_get_cluster_id_by_url failed");\r
+               return -1;\r
+       }\r
+\r
+       return id;\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int minfo_delete_cluster() API with valid parameter\r
+*              delete a cluster/folder identified by folder id.\r
+* @par ID      utc_minfo_delete_cluster_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_delete_cluster_func_01()\r
+{\r
+       int ret = -1;\r
+\r
+       UTC_MINFO_INIT()\r
+        \r
+       int cluster_id = _get_id_by_url("/opt/media/Images and videos/ForTC");\r
+       ret = minfo_delete_cluster(cluster_id);\r
+\r
+       if (ret < MB_SVC_ERROR_NONE)\r
+       {\r
+               UTC_MM_LOG( "failed to delete a cluster/folder identified by folder id. error code->%d", ret);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+               return;\r
+       }\r
+       \r
+       UTC_MINFO_FINALIZE()\r
+       tet_result(TET_PASS);\r
+\r
+       return;\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_delete_cluster() API with invalid parameter\r
+*                      delete a cluster/folder identified by folder id.\r
+* @par ID      utc_minfo_delete_cluster_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_delete_cluster_func_02()\r
+{\r
+       int ret = -1;\r
+        \r
+       int cluster_id = -1;\r
+       UTC_MINFO_INIT()\r
+       ret = minfo_delete_cluster(cluster_id);\r
+               \r
+       if (ret<0)\r
+       {\r
+               UTC_MM_LOG("abnormal condition test for null, error code->%d", ret);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_PASS);\r
+       }\r
+       else\r
+       {\r
+               UTC_MM_LOG("delete a cluster/folder identified by folder id should be failed because of the cluster_id -1.");\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+       }\r
+\r
+       return ;\r
+}\r
diff --git a/TC/utc/visual/utc_minfo_delete_cluster_func.h b/TC/utc/visual/utc_minfo_delete_cluster_func.h
new file mode 100644 (file)
index 0000000..e4e8068
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_delete_cluster_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_delete_cluster API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_delete_cluster_func_FUNC_H_\r
+#define __UTS_minfo_delete_cluster_func_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = NULL;\r
+void (*tet_cleanup)() = NULL;\r
+\r
+void utc_minfo_delete_cluster_func_01();\r
+void utc_minfo_delete_cluster_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_delete_cluster_func_01, 1},\r
+       {utc_minfo_delete_cluster_func_02, 2},  \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_delete_cluster_func_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_delete_invalid_media_records_func.c b/TC/utc/visual/utc_minfo_delete_invalid_media_records_func.c
new file mode 100644 (file)
index 0000000..f8064f4
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_delete_invalid_media_records.c
+* @brief       This is a suit of unit test cases to test minfo_delete_invalid_media_records API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_delete_invalid_media_records_func.h"
+
+
+/**
+* @brief       This tests int minfo_delete_invalid_media_records() API with valid parameter
+*                      Set status for lock to DB
+* @par ID      utc_minfo_delete_invalid_media_records_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_delete_invalid_media_records_func_01()
+{
+       int ret = -1;
+       minfo_store_type storage_type = MINFO_PHONE;
+
+    ret = minfo_delete_invalid_media_records(storage_type );
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to delete invalid records. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_delete_invalid_media_records() API with invalid parameter
+*                      Set status for lock to DB
+* @par ID      utc_minfo_delete_invalid_media_records_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_delete_invalid_media_records_func_02()
+{
+       int ret = -1;
+       minfo_store_type storage_type = MINFO_SYSTEM;
+
+    ret = minfo_delete_invalid_media_records(storage_type);
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "deleting invalid records should be failed because of the status is invalid.");
+}
+
diff --git a/TC/utc/visual/utc_minfo_delete_invalid_media_records_func.h b/TC/utc/visual/utc_minfo_delete_invalid_media_records_func.h
new file mode 100644 (file)
index 0000000..33f6625
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file                utc_minfo_delete_invalid_media_records_func.h
+* @author      
+* @brief       This is the implementaion file for the test case of minfo_delete_invalid_media_records API function
+* @version     Initial Creation Version 0.1
+* @date                2010-10-13
+*/
+
+#ifndef __UTS_minfo_delete_invalid_media_records_FUNC_H_
+#define __UTS_minfo_delete_invalid_media_records_FUNC_H_
+
+
+#include "utc_visual_svc_common.h"
+
+/* Initialize TCM data structures */
+void (*tet_startup)() = startup;
+void (*tet_cleanup)() = cleanup;
+
+void utc_minfo_delete_invalid_media_records_func_01();
+void utc_minfo_delete_invalid_media_records_func_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_minfo_delete_invalid_media_records_func_01, 1},
+       {utc_minfo_delete_invalid_media_records_func_02, 2},    
+       {NULL, 0}
+};
+
+
+#endif //__UTS_minfo_delete_invalid_media_records_FUNC_H_
diff --git a/TC/utc/visual/utc_minfo_delete_media_func.c b/TC/utc/visual/utc_minfo_delete_media_func.c
new file mode 100644 (file)
index 0000000..de115ec
--- /dev/null
@@ -0,0 +1,93 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_delete_media_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_delete_media API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_delete_media_func.h"\r
+\r
+\r
+/**\r
+* @brief       This tests int minfo_delete_media() API with valid parameter\r
+*              Delete a media content from media table.\r
+* @par ID      utc_minfo_delete_media_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_delete_media_func_01()\r
+{\r
+       int err = -1;\r
+       char *file_url = "/opt/media/Images and videos/Wallpapers/Home_01.png";\r
+\r
+       UTC_MINFO_INIT()\r
+       err = minfo_delete_media(file_url);\r
+\r
+       if (err < MB_SVC_ERROR_NONE)\r
+       {\r
+               UTC_MM_LOG( "unable to Add a media content to media table. error code->%d", err);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+               return;\r
+       }\r
+       \r
+       UTC_MINFO_FINALIZE()\r
+       tet_result(TET_PASS);\r
+       \r
+       return;\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_delete_media() API with invalid parameter\r
+*                      Delete a media content from media table.\r
+* @par ID      utc_minfo_delete_media_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_delete_media_func_02()\r
+{      \r
+       int err = -1;\r
+       char *file_url = NULL; /*= "/opt/media/Images/Wallpapers/Home_01.png";*/\r
+\r
+       UTC_MINFO_INIT()\r
+       err = minfo_delete_media(file_url);\r
+               \r
+       if (err<0)\r
+       {\r
+               UTC_MM_LOG("abnormal condition test for null, error code->%d", err);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_PASS);\r
+       }\r
+       else\r
+       {\r
+               UTC_MM_LOG("Delete a media content from media table should be failed because of the file_url NULL.");\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+       }\r
+\r
+       return ;\r
+}\r
diff --git a/TC/utc/visual/utc_minfo_delete_media_func.h b/TC/utc/visual/utc_minfo_delete_media_func.h
new file mode 100644 (file)
index 0000000..9db8a5d
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_delete_media_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_delete_media API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_delete_media_FUNC_H_\r
+#define __UTS_minfo_delete_media_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = NULL;\r
+void (*tet_cleanup)() = NULL;\r
+\r
+void utc_minfo_delete_media_func_01();\r
+void utc_minfo_delete_media_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_delete_media_func_01, 1},\r
+       {utc_minfo_delete_media_func_02, 2},    \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_delete_media_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_delete_media_id_func.c b/TC/utc/visual/utc_minfo_delete_media_id_func.c
new file mode 100644 (file)
index 0000000..263e050
--- /dev/null
@@ -0,0 +1,108 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_delete_media_id_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_delete_media_id API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_delete_media_id_func.h"\r
+\r
+int _get_id_by_url(const char* url)\r
+{\r
+       int id;\r
+       int ret;\r
+       Mitem* item = NULL;\r
+\r
+       ret = minfo_get_item( url, &item );\r
+       if( ret < 0 ) {\r
+               UTC_MM_LOG("minfo_get_item failed : %d", ret );\r
+               return -1;\r
+       }\r
+\r
+       return item->_id;\r
+}\r
+       \r
+\r
+/**\r
+* @brief       This tests int minfo_delete_media_id() API with valid parameter\r
+*              delete a record identified by media id from 'media' table.\r
+* @par ID      utc_minfo_delete_media_id_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_delete_media_id_func_01()\r
+{\r
+       int ret = -1;\r
+       \r
+       UTC_MINFO_INIT()\r
+       int media_id = _get_id_by_url("/opt/media/Images and videos/Wallpapers/Home_default_1.png");\r
+       ret = minfo_delete_media_id(media_id);\r
+\r
+       if (ret < MB_SVC_ERROR_NONE)\r
+       {\r
+               UTC_MM_LOG( "failed to delete a record identified by media id from 'media' table. error code->%d", ret);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+               return;\r
+       }\r
+       \r
+       UTC_MINFO_FINALIZE()\r
+       tet_result(TET_PASS);\r
+\r
+       return;\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_delete_media_id() API with invalid parameter\r
+*                      delete a record identified by media id from 'media' table.\r
+* @par ID      utc_minfo_delete_media_id_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_delete_media_id_func_02()\r
+{\r
+       int ret = -1;\r
+       \r
+       int media_id = -1;\r
+       UTC_MINFO_INIT()\r
+       ret = minfo_delete_media_id(media_id);\r
+               \r
+       if (ret<0)\r
+       {\r
+               UTC_MM_LOG("abnormal condition test for null, error code->%d", ret);\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_PASS);\r
+       }\r
+       else\r
+       {\r
+               UTC_MM_LOG("delete a record identified by media id from 'media' table should be failed because of the media_id -1.");\r
+               UTC_MINFO_FINALIZE()\r
+               tet_result(TET_FAIL);\r
+       }\r
+\r
+       return ;\r
+}\r
diff --git a/TC/utc/visual/utc_minfo_delete_media_id_func.h b/TC/utc/visual/utc_minfo_delete_media_id_func.h
new file mode 100644 (file)
index 0000000..792af3f
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_delete_media_id_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_delete_media_id API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_delete_media_id_FUNC_H_\r
+#define __UTS_minfo_delete_media_id_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = NULL;\r
+void (*tet_cleanup)() = NULL;\r
+\r
+void utc_minfo_delete_media_id_func_01();\r
+void utc_minfo_delete_media_id_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_delete_media_id_func_01, 1},\r
+       {utc_minfo_delete_media_id_func_02, 2}, \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_delete_media_id_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_destroy_mtype_item_func.c b/TC/utc/visual/utc_minfo_destroy_mtype_item_func.c
new file mode 100644 (file)
index 0000000..207441d
--- /dev/null
@@ -0,0 +1,95 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_destroy_mtype_item_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_destroy_mtype_item_func API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_destroy_mtype_item_func.h"\r
+\r
+static int _cluster_ite_fn( Mcluster* cluster, void* user_data)\r
+{\r
+       GList** list = (GList**) user_data;\r
+       *list = g_list_append( *list, cluster );\r
+       return 0;\r
+}\r
+\r
+/**\r
+* @brief       This tests int minfo_destroy_mtype_item_func() API with valid parameter\r
+*              free glist of media clusters.\r
+* @par ID      utc_minfo_destroy_mtype_item_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_destroy_mtype_item_func_01()\r
+{\r
+       int ret = -1;\r
+       int i = 0;\r
+       GList *p_list = NULL;\r
+       void* p = NULL;\r
+\r
+    minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,0,5};\r
+       ret = minfo_get_cluster_list(cluster_filter, _cluster_ite_fn, &p_list);\r
+\r
+       if( ret < MB_SVC_ERROR_NONE ) {\r
+               dts_fail(API_NAME, "unable to get list of clusters.  error code->%d", ret);\r
+               return;\r
+       }\r
+\r
+       for( i = 0; i < g_list_length(p_list); i++ ) \r
+       {\r
+               p = g_list_nth_data(p_list, i);\r
+               minfo_destroy_mtype_item(p);    \r
+\r
+               if (ret < MB_SVC_ERROR_NONE)\r
+               {\r
+                       dts_fail(API_NAME, "unable to destroy item of mtype.  error code->%d", ret);\r
+                       return;\r
+               }\r
+       }\r
+\r
+       dts_pass(API_NAME, "utc_minfo_destroy_mtype_item_func_01 succeeded");\r
+       \r
+       return;\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_destroy_mtype_item() API with invalid parameter\r
+*                      free glist of media clusters.\r
+* @par ID      utc_minfo_destroy_mtype_item_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_destroy_mtype_item_func_02()\r
+{      \r
+       int ret = -1;\r
+       void* p = NULL;\r
+\r
+       ret = minfo_destroy_mtype_item(p);      \r
+\r
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"destroying item of mtype should be failed because of the p_list NULL.");\r
+}\r
diff --git a/TC/utc/visual/utc_minfo_destroy_mtype_item_func.h b/TC/utc/visual/utc_minfo_destroy_mtype_item_func.h
new file mode 100644 (file)
index 0000000..cc85821
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_destroy_mtype_item_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_destroy_mtype_item API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_destroy_mtype_item_FUNC_H_\r
+#define __UTS_minfo_destroy_mtype_item_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_destroy_mtype_item_func_01();\r
+void utc_minfo_destroy_mtype_item_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_destroy_mtype_item_func_01, 1},\r
+       {utc_minfo_destroy_mtype_item_func_02, 2},      \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_destroy_mtype_item_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_finalize_func.c b/TC/utc/visual/utc_minfo_finalize_func.c
new file mode 100644 (file)
index 0000000..25373f6
--- /dev/null
@@ -0,0 +1,66 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_finalize_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_finalize API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_finalize_func.h"\r
+\r
+\r
+/**\r
+* @brief       This tests int minfo_init() API with valid parameter\r
+*              Close media database file.\r
+* @par ID      utc_minfo_finalize_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_finalize_func_01()\r
+{\r
+       int ret = 0;\r
+\r
+       UTC_MINFO_INIT();\r
+       \r
+       ret = minfo_finalize();\r
+       \r
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to close media db. error code->%d", ret);\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_finalize() API with invalid parameter\r
+*                      Close media database file.\r
+* @par ID      utc_minfo_finalize_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_finalize_func_02()\r
+{      \r
+       int ret = 0;\r
+\r
+       ret = minfo_finalize();\r
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"Closing media db should be failed because it's not open yet.");\r
+}\r
diff --git a/TC/utc/visual/utc_minfo_finalize_func.h b/TC/utc/visual/utc_minfo_finalize_func.h
new file mode 100644 (file)
index 0000000..936a7ed
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_finalize_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_finalize API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_MINFO_FINALIZE_FUNC_H_\r
+#define __UTS_MINFO_FINALIZE_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = NULL;\r
+void (*tet_cleanup)() = NULL;\r
+\r
+void utc_minfo_finalize_func_01();\r
+void utc_minfo_finalize_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_finalize_func_01, 1},\r
+       {utc_minfo_finalize_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_MINFO_FINALIZE_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_get_all_item_list_func.c b/TC/utc/visual/utc_minfo_get_all_item_list_func.c
new file mode 100644 (file)
index 0000000..d772088
--- /dev/null
@@ -0,0 +1,84 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_get_all_item_list_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_get_all_item_list API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-10\r
+*/\r
+\r
+#include "utc_minfo_get_all_item_list_func.h"\r
+\r
+static int _ite_fn( Mitem* item, void* user_data) \r
+{\r
+       GList** list = (GList**) user_data;\r
+       *list = g_list_append( *list, item );\r
+\r
+       return 0;\r
+}\r
+\r
+/**\r
+* @brief       This tests int minfo_get_all_item_list() API with valid parameter\r
+*              Get glist including Mitem members.\r
+* @par ID      utc_minfo_get_all_item_list_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_get_all_item_list_func_01()\r
+{\r
+       int ret = 0;\r
+\r
+       GList *p_list = NULL;\r
+       minfo_folder_type cluster_type = MINFO_CLUSTER_TYPE_LOCAL_ALL;\r
+       minfo_item_filter item_filter = {MINFO_ITEM_ALL,MINFO_MEDIA_SORT_BY_DATE_ASC,0,5,true,MINFO_MEDIA_FAV_ALL};\r
+\r
+       ret = minfo_get_all_item_list(cluster_type, item_filter, _ite_fn, &p_list);\r
+\r
+       if (ret == MB_SVC_ERROR_DB_NO_RECORD) {\r
+               dts_pass(API_NAME, "No record. This is normal operation");\r
+       }\r
+\r
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get media records. error code->%d", ret);\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_get_all_item_list() API with invalid parameter\r
+*                      Get glist including Mitem members.\r
+* @par ID      utc_minfo_get_all_item_list_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_get_all_item_list_func_02()\r
+{      \r
+       int ret = 0;\r
+\r
+       GList *p_list = NULL;\r
+       minfo_folder_type cluster_type = MINFO_CLUSTER_TYPE_LOCAL_ALL;\r
+       minfo_item_filter item_filter = {MINFO_ITEM_ALL,MINFO_MEDIA_SORT_BY_DATE_ASC,0,5,true,MINFO_MEDIA_FAV_ALL};\r
+\r
+       ret = minfo_get_all_item_list(cluster_type, item_filter, NULL, &p_list);\r
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"getting media records should be failed because of the item_filter parameter.");\r
+}\r
+\r
diff --git a/TC/utc/visual/utc_minfo_get_all_item_list_func.h b/TC/utc/visual/utc_minfo_get_all_item_list_func.h
new file mode 100644 (file)
index 0000000..eb66750
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_get_all_item_list_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_get_all_item_list API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_all_item_list_FUNC_H_\r
+#define __UTS_minfo_get_all_item_list_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_get_all_item_list_func_01();\r
+void utc_minfo_get_all_item_list_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_get_all_item_list_func_01, 1},\r
+       {utc_minfo_get_all_item_list_func_02, 2},       \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_all_item_list_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_get_bookmark_list_func.c b/TC/utc/visual/utc_minfo_get_bookmark_list_func.c
new file mode 100644 (file)
index 0000000..f256744
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_get_bookmark_list_func.c
+* @brief       This is a suit of unit test cases to test minfo_get_bookmark_list API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_get_bookmark_list_func.h"
+
+static int _minfo_bm_ite_fn( Mbookmark *bookmark, void *user_data )
+{
+       GList** list = (GList**) user_data;
+       *list = g_list_append( *list, bookmark );
+
+       return 0;
+}
+
+/**
+* @brief       This tests int minfo_get_bookmark_list() API with valid parameter
+*              get all of bookmark for a media content.
+* @par ID      utc_minfo_get_bookmark_list_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_bookmark_list_func_01()
+{
+       int ret = -1;
+
+       const char *media_uuid = "2f08863e-52fd-eaf8-269c-3d0798e7aa0e";
+       GList *p_list = NULL;
+
+       ret = minfo_get_bookmark_list(media_uuid, _minfo_bm_ite_fn, &p_list);
+
+       if (ret == MB_SVC_ERROR_DB_NO_RECORD) {
+               dts_pass(API_NAME, "No record. This is normal operation");
+       }
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to get all of bookmark for a media content. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_get_bookmark_list() API with invalid parameter
+*                      get all of bookmark for a media content.
+* @par ID      utc_minfo_get_bookmark_list_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_get_bookmark_list_func_02()
+{
+       int ret = -1;
+
+       const char *media_uuid = NULL;
+       GList *p_list = NULL;
+
+       ret = minfo_get_bookmark_list(media_uuid, NULL, &p_list);
+               
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"get all of bookmark for a media content should be failed because of the p_list non-NULL.");
+}
diff --git a/TC/utc/visual/utc_minfo_get_bookmark_list_func.h b/TC/utc/visual/utc_minfo_get_bookmark_list_func.h
new file mode 100644 (file)
index 0000000..6262796
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_get_bookmark_list_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_get_bookmark_list API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_bookmark_list_FUNC_H_\r
+#define __UTS_minfo_get_bookmark_list_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_get_bookmark_list_func_01();\r
+void utc_minfo_get_bookmark_list_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_get_bookmark_list_func_01, 1},\r
+       {utc_minfo_get_bookmark_list_func_02, 2},       \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_bookmark_list_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_get_cluster_cnt_func.c b/TC/utc/visual/utc_minfo_get_cluster_cnt_func.c
new file mode 100644 (file)
index 0000000..46a94ce
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_get_cluster_cnt_func.c
+* @brief       This is a suit of unit test cases to test minfo_get_cluster_cnt API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_get_cluster_cnt_func.h"
+
+
+/**
+* @brief       This tests int minfo_get_cluster_cnt() API with valid parameter
+*              Get count of media clusters.
+* @par ID      utc_minfo_get_cluster_cnt_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_cluster_cnt_func_01()
+{
+       int ret = 0;
+       int cnt = 0;
+
+       minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,-1,10};
+       ret = minfo_get_cluster_cnt(cluster_filter, &cnt);
+       
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get count of media clusters. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_get_cluster_cnt() API with invalid parameter
+*                      Get count of media clusters.
+* @par ID      utc_minfo_get_cluster_cnt_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_get_cluster_cnt_func_02()
+{      
+       int ret = 0;
+       int *cnt = NULL;
+
+       minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,-1,10};
+       ret = minfo_get_cluster_cnt(cluster_filter, cnt);
+       
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"getting count of media clusters should be failed because of the item_filter parameter.");
+}
diff --git a/TC/utc/visual/utc_minfo_get_cluster_cnt_func.h b/TC/utc/visual/utc_minfo_get_cluster_cnt_func.h
new file mode 100644 (file)
index 0000000..9a114ee
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_get_cluster_cnt_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_get_cluster_cnt API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_cluster_cnt_FUNC_H_\r
+#define __UTS_minfo_get_cluster_cnt_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_get_cluster_cnt_func_01();\r
+void utc_minfo_get_cluster_cnt_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_get_cluster_cnt_func_01, 1},\r
+       {utc_minfo_get_cluster_cnt_func_02, 2}, \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_cluster_cnt_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_get_cluster_cover_func.c b/TC/utc/visual/utc_minfo_get_cluster_cover_func.c
new file mode 100644 (file)
index 0000000..6498c3b
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_get_cluster_cover_func.c
+* @brief       This is a suit of unit test cases to test minfo_get_cluster_cover API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_get_cluster_cover_func.h"
+
+static int _cover_ite_fn( char* thumb_path, void* user_data)
+{
+       GList** list = (GList**) user_data;
+       *list = g_list_append( *list, thumb_path );
+
+       return 0;
+}
+
+/**
+* @brief       This tests int minfo_get_cluster_cover() API with valid parameter
+*              get cover of a cluster/folder.
+* @par ID      utc_minfo_get_cluster_cover_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_cluster_cover_func_01()
+{
+       int ret = -1;
+       
+       GList *p_list = NULL;
+       int img_cnt = 5;
+       const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+       
+       ret = minfo_get_cluster_cover(cluster_uuid, img_cnt, _cover_ite_fn, &p_list);
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to get cover of a cluster/folder. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_get_cluster_cover() API with invalid parameter
+*                      get cover of a cluster/folder.
+* @par ID      utc_minfo_get_cluster_cover_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_get_cluster_cover_func_02()
+{
+       int ret = -1;
+       
+       GList *p_list = NULL;
+       int img_cnt = 5;
+       const char *cluster_uuid = NULL;
+       
+       ret = minfo_get_cluster_cover(cluster_uuid, img_cnt, NULL, &p_list);
+               
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"get cover of a cluster/folder should be failed because of the p_list non-NULL.");
+}
diff --git a/TC/utc/visual/utc_minfo_get_cluster_cover_func.h b/TC/utc/visual/utc_minfo_get_cluster_cover_func.h
new file mode 100644 (file)
index 0000000..93109bb
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_get_cluster_cover_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_get_cluster_cover API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_cluster_cover_FUNC_H_\r
+#define __UTS_minfo_get_cluster_cover_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_get_cluster_cover_func_01();\r
+void utc_minfo_get_cluster_cover_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_get_cluster_cover_func_01, 1},\r
+       {utc_minfo_get_cluster_cover_func_02, 2},       \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_cluster_cover_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_get_cluster_fullpath_by_id_func.c b/TC/utc/visual/utc_minfo_get_cluster_fullpath_by_id_func.c
new file mode 100644 (file)
index 0000000..7ba4000
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_get_cluster_fullpath_by_id.c
+* @brief       This is a suit of unit test cases to test minfo_get_cluster_fullpath_by_id API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_get_cluster_fullpath_by_id_func.h"
+
+
+/**
+* @brief       This tests int minfo_get_cluster_fullpath_by_id() API with valid parameter
+*                      Gets status for lock from DB
+* @par ID      utc_minfo_get_cluster_fullpath_by_id_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_cluster_fullpath_by_id_func_01()
+{
+       int ret = -1;
+       const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+       int size = 256;
+       char fullpath[256] = {'\0'};
+
+    ret = minfo_get_cluster_fullpath_by_id(cluster_uuid, fullpath, size);
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get cluster fullpath by id. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_get_cluster_fullpath_by_id() API with invalid parameter
+*                      Gets status for lock from DB
+* @par ID      utc_minfo_get_cluster_fullpath_by_id_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_get_cluster_fullpath_by_id_func_02()
+{
+       int ret = -1;
+       const char *cluster_uuid = NULL;
+       int size = 256;
+       char fullpath[256] = {'\0'};
+
+    ret = minfo_get_cluster_fullpath_by_id(cluster_uuid, fullpath, size);
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"Getting cluster fullpath by id should be failed because the passed status is NULL.");
+}
+
diff --git a/TC/utc/visual/utc_minfo_get_cluster_fullpath_by_id_func.h b/TC/utc/visual/utc_minfo_get_cluster_fullpath_by_id_func.h
new file mode 100644 (file)
index 0000000..2f0c64b
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file                utc_minfo_get_cluster_fullpath_by_id_func.h
+* @author      
+* @brief       This is the implementaion file for the test case of minfo_get_cluster_fullpath_by_id API function
+* @version     Initial Creation Version 0.1
+* @date                2010-10-13
+*/
+
+#ifndef __UTS_minfo_get_cluster_fullpath_by_id_FUNC_H_
+#define __UTS_minfo_get_cluster_fullpath_by_id_FUNC_H_
+
+
+#include "utc_visual_svc_common.h"
+
+/* Initialize TCM data structures */
+void (*tet_startup)() = startup;
+void (*tet_cleanup)() = cleanup;
+
+void utc_minfo_get_cluster_fullpath_by_id_func_01();
+void utc_minfo_get_cluster_fullpath_by_id_func_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_minfo_get_cluster_fullpath_by_id_func_01, 1},
+       {utc_minfo_get_cluster_fullpath_by_id_func_02, 2},      
+       {NULL, 0}
+};
+
+
+#endif //__UTS_minfo_get_cluster_fullpath_by_id_FUNC_H_
diff --git a/TC/utc/visual/utc_minfo_get_cluster_func.c b/TC/utc/visual/utc_minfo_get_cluster_func.c
new file mode 100644 (file)
index 0000000..4256935
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_get_cluster_func.c
+* @brief       This is a suit of unit test cases to test minfo_get_cluster API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_get_cluster_func.h"
+
+
+/**
+* @brief       This tests int minfo_get_cluster() API with valid parameter
+*              get a cluster/folder record from folder table with Mcluster type.
+* @par ID      utc_minfo_get_cluster_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_cluster_func_01()
+{
+       int ret = -1;
+
+    Mcluster *mc = NULL;
+    char *cluster_url = "/opt/media/Images and videos/Wallpapers";
+
+    ret = minfo_get_cluster(cluster_url, 0, &mc);
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to get a cluster/folder record from folder table with Mcluster type. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_get_cluster() API with invalid parameter
+*                      get a cluster/folder record from folder table with Mcluster type.
+* @par ID      utc_minfo_get_cluster_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_get_cluster_func_02()
+{
+       int ret = -1;
+
+    Mcluster *mc = NULL;
+    char *cluster_url = NULL; /*= "/opt/media/Images/Wallpapers";*/
+
+    ret = minfo_get_cluster(cluster_url, 0, &mc);
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "get a cluster/folder record from folder table with Mcluster type should be failed because of mc NULL.");
+}
diff --git a/TC/utc/visual/utc_minfo_get_cluster_func.h b/TC/utc/visual/utc_minfo_get_cluster_func.h
new file mode 100644 (file)
index 0000000..fa87d9f
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_get_cluster_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_get_cluster API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_cluster_FUNC_H_\r
+#define __UTS_minfo_get_cluster_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_get_cluster_func_01();\r
+void utc_minfo_get_cluster_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_get_cluster_func_01, 1},\r
+       {utc_minfo_get_cluster_func_02, 2},     \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_cluster_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_get_cluster_id_by_url_func.c b/TC/utc/visual/utc_minfo_get_cluster_id_by_url_func.c
new file mode 100644 (file)
index 0000000..1c53c70
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_get_cluster_id_by_url_func.c
+* @brief       This is a suit of unit test cases to test minfo_get_cluster_id_by_url API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_get_cluster_id_by_url_func.h"
+
+
+/**
+* @brief       This tests int minfo_get_cluster_id_by_url() API with valid parameter
+*              get folder id using it's full name.
+* @par ID      utc_minfo_get_cluster_id_by_url_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_cluster_id_by_url_func_01()
+{
+       int ret = -1;
+        
+       char cluster_uuid[256] = {0,};
+       char *folder_full_path = "/opt/media/Images and videos/Wallpapers";
+       ret = minfo_get_cluster_id_by_url(folder_full_path, cluster_uuid, sizeof(cluster_uuid));
+       
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get folder id using it's full name. error code->%d", ret);
+
+}
+
+
+/**
+* @brief               This tests int minfo_get_cluster_id_by_url() API with invalid parameter
+*                      get folder id using it's full name.
+* @par ID      utc_minfo_get_cluster_id_by_url_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_get_cluster_id_by_url_func_02()
+{      
+       int ret = -1;
+        
+       char *cluster_uuid = NULL;
+       char *folder_full_path = NULL; /*= "/opt/media/Images/Wallpapers";*/
+
+       ret = minfo_get_cluster_id_by_url(folder_full_path, cluster_uuid, sizeof(cluster_uuid));
+
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"get folder id using it's full name should be failed because of the folder_full_path parameter NULL.");
+}
diff --git a/TC/utc/visual/utc_minfo_get_cluster_id_by_url_func.h b/TC/utc/visual/utc_minfo_get_cluster_id_by_url_func.h
new file mode 100644 (file)
index 0000000..3080669
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_get_cluster_id_by_url_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_get_cluster_id_by_url API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_cluster_id_by_url_FUNC_H_\r
+#define __UTS_minfo_get_cluster_id_by_url_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_get_cluster_id_by_url_func_01();\r
+void utc_minfo_get_cluster_id_by_url_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_get_cluster_id_by_url_func_01, 1},\r
+       {utc_minfo_get_cluster_id_by_url_func_02, 2},   \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_cluster_id_by_url_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_get_cluster_list_func.c b/TC/utc/visual/utc_minfo_get_cluster_list_func.c
new file mode 100644 (file)
index 0000000..ff551fb
--- /dev/null
@@ -0,0 +1,78 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_get_cluster_list_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_get_cluster_list API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_get_cluster_list_func.h"\r
+\r
+static int _cluster_ite_fn( Mcluster* cluster, void* user_data)\r
+{\r
+       GList** list = (GList**) user_data;\r
+       *list = g_list_append( *list, cluster );\r
+       return 0;\r
+}\r
+\r
+\r
+/**\r
+* @brief       This tests int minfo_get_cluster_list() API with valid parameter\r
+*              Get glist including media clusters.\r
+* @par ID      utc_minfo_get_cluster_list_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_get_cluster_list_func_01()\r
+{\r
+       int ret = -1;\r
+\r
+       GList *p_list = NULL;\r
+\r
+    minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,0,10};\r
+       ret = minfo_get_cluster_list(cluster_filter, _cluster_ite_fn, &p_list);\r
+       \r
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get glist including media clusters. error code->%d", ret);\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_get_cluster_list() API with invalid parameter\r
+*                      Get glist including media clusters.\r
+* @par ID      utc_minfo_get_cluster_list_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_get_cluster_list_func_02()\r
+{      \r
+       int ret = -1;\r
+\r
+       GList *p_list = NULL;\r
+\r
+    minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,0,10};\r
+       ret = minfo_get_cluster_list(cluster_filter, NULL, &p_list);\r
+       \r
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"getting glist including media clusters should be failed because of the item_filter parameter.");\r
+}\r
diff --git a/TC/utc/visual/utc_minfo_get_cluster_list_func.h b/TC/utc/visual/utc_minfo_get_cluster_list_func.h
new file mode 100644 (file)
index 0000000..b4ac397
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_get_cluster_list_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_get_cluster_list API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_cluster_list_FUNC_H_\r
+#define __UTS_minfo_get_cluster_list_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_get_cluster_list_func_01();\r
+void utc_minfo_get_cluster_list_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_get_cluster_list_func_01, 1},\r
+       {utc_minfo_get_cluster_list_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_cluster_list_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_get_cluster_lock_status_func.c b/TC/utc/visual/utc_minfo_get_cluster_lock_status_func.c
new file mode 100644 (file)
index 0000000..15d04a0
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_get_cluster_lock_status.c
+* @brief       This is a suit of unit test cases to test minfo_get_cluster_lock_status API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_get_cluster_lock_status_func.h"
+
+
+/**
+* @brief       This tests int minfo_get_cluster_lock_status() API with valid parameter
+*                      Gets status for lock from DB
+* @par ID      utc_minfo_get_cluster_lock_status_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_cluster_lock_status_func_01()
+{
+       int ret = -1;
+       int status = 0;
+       const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+
+    ret = minfo_get_cluster_lock_status(cluster_uuid, &status);
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to varify password to lock/unlock.  error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_get_cluster_lock_status() API with invalid parameter
+*                      Gets status for lock from DB
+* @par ID      utc_minfo_get_cluster_lock_status_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_get_cluster_lock_status_func_02()
+{
+       int ret = -1;
+       const char *cluster_uuid = NULL;
+       int status = 0;
+
+    ret = minfo_get_cluster_lock_status(cluster_uuid, &status);
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"Get status for lock should be failed because the passed status is NULL.");
+}
+
diff --git a/TC/utc/visual/utc_minfo_get_cluster_lock_status_func.h b/TC/utc/visual/utc_minfo_get_cluster_lock_status_func.h
new file mode 100644 (file)
index 0000000..8dcf0be
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+* @file                utc_minfo_get_cluster_lock_status_func.h
+* @author      
+* @brief       This is the implementaion file for the test case of minfo_get_cluster_lock_status API function
+* @version     Initial Creation Version 0.1
+* @date                2010-10-13
+*/
+
+#ifndef __UTS_minfo_get_cluster_lock_status_FUNC_H_
+#define __UTS_minfo_get_cluster_lock_status_FUNC_H_
+
+
+#include "utc_visual_svc_common.h"
+
+/* Initialize TCM data structures */
+void (*tet_startup)() = startup;
+void (*tet_cleanup)() = cleanup;
+
+void utc_minfo_get_cluster_lock_status_func_01();
+void utc_minfo_get_cluster_lock_status_func_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_minfo_get_cluster_lock_status_func_01, 1},
+       {utc_minfo_get_cluster_lock_status_func_02, 2}, 
+       {NULL, 0}
+};
+
+
+#endif //__UTS_minfo_get_cluster_lock_status_FUNC_H_
diff --git a/TC/utc/visual/utc_minfo_get_cluster_name_by_id_func.c b/TC/utc/visual/utc_minfo_get_cluster_name_by_id_func.c
new file mode 100644 (file)
index 0000000..ca59b71
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_get_cluster_name_by_id.c
+* @brief       This is a suit of unit test cases to test minfo_get_cluster_name_by_id API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_get_cluster_name_by_id_func.h"
+
+
+/**
+* @brief       This tests int minfo_get_cluster_name_by_id() API with valid parameter
+*                      Gets status for lock from DB
+* @par ID      utc_minfo_get_cluster_name_by_id_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_cluster_name_by_id_func_01()
+{
+       int ret = -1;
+       const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+       int size = 256;
+       char cluster_name[256] = {'\0'};
+
+    ret = minfo_get_cluster_name_by_id(cluster_uuid, cluster_name, size);
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get cluster name by id. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_get_cluster_name_by_id() API with invalid parameter
+*                      Gets status for lock from DB
+* @par ID      utc_minfo_get_cluster_name_by_id_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_get_cluster_name_by_id_func_02()
+{
+       int ret = -1;
+       const char *cluster_uuid = NULL;
+       int size = 256;
+       char cluster_name[256] = {'\0'};
+
+    ret = minfo_get_cluster_name_by_id(cluster_uuid, cluster_name, size);
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"Getting cluster name by id should be failed because the passed status is NULL.");
+}
+
diff --git a/TC/utc/visual/utc_minfo_get_cluster_name_by_id_func.h b/TC/utc/visual/utc_minfo_get_cluster_name_by_id_func.h
new file mode 100644 (file)
index 0000000..1482512
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file                utc_minfo_get_cluster_name_by_id_func.h
+* @author      
+* @brief       This is the implementaion file for the test case of minfo_get_cluster_name_by_id API function
+* @version     Initial Creation Version 0.1
+* @date                2010-10-13
+*/
+
+#ifndef __UTS_minfo_get_cluster_name_by_id_FUNC_H_
+#define __UTS_minfo_get_cluster_name_by_id_FUNC_H_
+
+
+#include "utc_visual_svc_common.h"
+
+/* Initialize TCM data structures */
+void (*tet_startup)() = startup;
+void (*tet_cleanup)() = cleanup;
+
+void utc_minfo_get_cluster_name_by_id_func_01();
+void utc_minfo_get_cluster_name_by_id_func_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_minfo_get_cluster_name_by_id_func_01, 1},
+       {utc_minfo_get_cluster_name_by_id_func_02, 2},  
+       {NULL, 0}
+};
+
+
+#endif //__UTS_minfo_get_cluster_name_by_id_FUNC_H_
diff --git a/TC/utc/visual/utc_minfo_get_geo_item_list_func.c b/TC/utc/visual/utc_minfo_get_geo_item_list_func.c
new file mode 100644 (file)
index 0000000..1875874
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_get_geo_item_list_func.c
+* @brief       This is a suit of unit test cases to test minfo_get_geo_item_list API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_get_geo_item_list_func.h"
+
+static int _ite_fn( Mitem* item, void* user_data) 
+{
+       GList** list = (GList**) user_data;
+       *list = g_list_append( *list, item );
+
+       return 0;
+}
+
+/**
+* @brief       This tests int minfo_get_geo_item_list() API with valid parameter
+*              get all of Mitem which pass the filter and meanwhile position where the longitude and latitude are specified.
+* @par ID      utc_minfo_get_geo_item_list_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_geo_item_list_func_01()
+{
+       int ret = -1;
+
+       const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+       int min_longitude = 120.0;
+       int max_longitude = 123.0;
+       int min_latitude = 19.0;
+       int max_latitude = 24.0;
+       GList *p_list = NULL;
+       minfo_item_filter filter = {MINFO_ITEM_ALL,MINFO_MEDIA_SORT_BY_NONE,-1,-1,true,MINFO_MEDIA_FAV_ALL};
+       //minfo_store_type store_type = MINFO_CLUSTER_TYPE_LOCAL_ALL;
+       minfo_store_type store_type = MINFO_CLUSTER_TYPE_ALL;
+
+       ret = minfo_get_geo_item_list(cluster_uuid, 
+                                               store_type,
+                                   filter, 
+                                   min_longitude, 
+                                   max_longitude, 
+                                   min_latitude, 
+                                   max_latitude,
+                                               _ite_fn,
+                                   &p_list);
+
+       if (ret == MB_SVC_ERROR_DB_NO_RECORD) {
+               dts_pass(API_NAME, "No record. This is normal operation");
+       }
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to get all of Mitem which pass the filter and meanwhile position where the longitude and latitude are specified. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_get_geo_item_list() API with invalid parameter
+*                      get all of Mitem which pass the filter and meanwhile position where the longitude and latitude are specified.
+* @par ID      utc_minfo_get_geo_item_list_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_get_geo_item_list_func_02()
+{
+       int ret = -1; 
+
+       const char *cluster_uuid = NULL;
+       int min_longitude = 220.0;
+       int max_longitude = 223.0;
+       int min_latitude = 119.0;
+       int max_latitude = 24.0;
+       GList *p_list = NULL;
+       minfo_item_filter filter = {MINFO_ITEM_ALL,MINFO_MEDIA_SORT_BY_NONE,-1,-1,true,MINFO_MEDIA_FAV_ALL};
+       minfo_store_type store_type = MINFO_CLUSTER_TYPE_ALL;
+
+       ret = minfo_get_geo_item_list(cluster_uuid, 
+                                               store_type,
+                                   filter, 
+                                   min_longitude, 
+                                   max_longitude, 
+                                   min_latitude, 
+                                   max_latitude,
+                                               _ite_fn,
+                                   &p_list);
+               
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"get all of Mitem which pass the filter and meanwhile position where the longitude and latitude are specified should be failed because of the p_list non-NULL.");
+}
diff --git a/TC/utc/visual/utc_minfo_get_geo_item_list_func.h b/TC/utc/visual/utc_minfo_get_geo_item_list_func.h
new file mode 100644 (file)
index 0000000..1a1c8a6
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_get_geo_item_list_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_get_geo_item_list API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_geo_item_list_FUNC_H_\r
+#define __UTS_minfo_get_geo_item_list_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_get_geo_item_list_func_01();\r
+void utc_minfo_get_geo_item_list_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_get_geo_item_list_func_01, 1},\r
+       {utc_minfo_get_geo_item_list_func_02, 2},       \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_geo_item_list_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_get_item_cnt_func.c b/TC/utc/visual/utc_minfo_get_item_cnt_func.c
new file mode 100644 (file)
index 0000000..2b9e08e
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+* @file        utc_minfo_get_item_cnt_func.c
+* @brief       This is a suit of unit test cases to test minfo_get_item_cnt API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_get_item_cnt_func.h"
+
+
+/**
+* @brief       This tests int minfo_get_item_cnt() API with valid parameter
+*              Get count of including Mitem members.
+* @par ID      utc_minfo_get_item_cnt_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_item_cnt_func_01()
+{
+       int ret = 0;
+       const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+
+
+       int cnt = 0;
+       minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,0,5,true,true};
+
+       ret = minfo_get_item_cnt(cluster_uuid, item_filter, &cnt);
+       
+       if (ret == MB_SVC_ERROR_DB_NO_RECORD) {
+               dts_pass(API_NAME, "No record. This is normal operation");
+       }
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get media records. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_get_item_cnt() API with invalid parameter
+*                      Get count of including Mitem members.
+* @par ID      utc_minfo_get_item_cnt_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_get_item_cnt_func_02()
+{      
+       int ret = 0;
+       const char *cluster_uuid = NULL;
+
+       int *cnt = NULL;
+       minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,0,5,true,true};
+
+       ret = minfo_get_item_cnt(cluster_uuid, item_filter, cnt);
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "getting media records should be failed because of the item_filter parameter.");
+}
diff --git a/TC/utc/visual/utc_minfo_get_item_cnt_func.h b/TC/utc/visual/utc_minfo_get_item_cnt_func.h
new file mode 100644 (file)
index 0000000..61043c7
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_get_item_cnt_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_get_item_cnt API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_item_cnt_FUNC_H_\r
+#define __UTS_minfo_get_item_cnt_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_get_item_cnt_func_01();\r
+void utc_minfo_get_item_cnt_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_get_item_cnt_func_01, 1},\r
+       {utc_minfo_get_item_cnt_func_02, 2},    \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_item_cnt_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_get_item_func.c b/TC/utc/visual/utc_minfo_get_item_func.c
new file mode 100644 (file)
index 0000000..77e4cd0
--- /dev/null
@@ -0,0 +1,71 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file        utc_minfo_get_item_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_get_item API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_get_item_func.h"\r
+\r
+\r
+/**\r
+* @brief       This tests int minfo_get_item() API with valid parameter\r
+*              get a item record from media table with Mitem type.\r
+* @par ID      utc_minfo_get_item_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_get_item_func_01()\r
+{\r
+       int ret = -1;\r
+       \r
+       Mitem *mi = NULL;\r
+       char* file_url = "/opt/media/Images and videos/Wallpapers/Home_default.png";\r
+\r
+       ret = minfo_get_item(file_url, &mi);\r
+\r
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to get a item record from media table with Mitem type . error code->%d", ret);\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_get_item() API with invalid parameter\r
+*                      get a item record from media table with Mitem type.\r
+* @par ID      utc_minfo_get_item_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_get_item_func_02()\r
+{\r
+       int ret = -1;\r
+       \r
+       Mitem *mi = NULL;\r
+       char* file_url = NULL;/*= "/opt/media/Images/Wallpapers/Home_01.png";*/\r
+\r
+       ret = minfo_get_item(file_url, &mi);\r
+               \r
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "get a item record from media table with Mitem type should be failed because of the file_url NULL.");\r
+\r
+}\r
diff --git a/TC/utc/visual/utc_minfo_get_item_func.h b/TC/utc/visual/utc_minfo_get_item_func.h
new file mode 100644 (file)
index 0000000..f51a127
--- /dev/null
@@ -0,0 +1,50 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_minfo_get_item_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_get_item API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_item_FUNC_H_\r
+#define __UTS_minfo_get_item_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_get_item_func_01();\r
+void utc_minfo_get_item_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_get_item_func_01, 1},\r
+       {utc_minfo_get_item_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_item_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_get_item_list_func.c b/TC/utc/visual/utc_minfo_get_item_list_func.c
new file mode 100644 (file)
index 0000000..7e0141b
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_get_item_list_func.c
+* @brief       This is a suit of unit test cases to test minfo_get_item_list API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-10
+*/
+
+#include "utc_minfo_get_item_list_func.h"
+
+static int _ite_fn( Mitem* item, void* user_data) 
+{
+       GList** list = (GList**) user_data;
+       *list = g_list_append( *list, item );
+
+       return 0;
+}
+
+/**
+* @brief       This tests int minfo_get_item_list() API with valid parameter
+*              Get glist including Mitem members.
+* @par ID      utc_minfo_get_item_list_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_item_list_func_01()
+{
+       int ret = 0;
+       const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+
+       GList *p_list = NULL;
+       minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,0,5,true, MINFO_MEDIA_FAV_ALL};
+
+       ret = minfo_get_item_list(cluster_uuid, item_filter, _ite_fn, &p_list);
+
+       if (ret == MB_SVC_ERROR_DB_NO_RECORD) {
+               dts_pass(API_NAME, "No record. This is normal operation");
+       }
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get media records. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_get_item_list() API with invalid parameter
+*                      Get glist including Mitem members.
+* @par ID      utc_minfo_get_item_list_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_get_item_list_func_02()
+{      
+       int ret = 0;
+       const char *cluster_uuid = NULL;
+
+       GList *p_list = NULL;
+       minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,0,5,true,MINFO_MEDIA_FAV_ALL};
+
+       ret = minfo_get_item_list(cluster_uuid, item_filter, NULL, &p_list);
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"getting media records should be failed because of the item_filter parameter.");
+}
+
diff --git a/TC/utc/visual/utc_minfo_get_item_list_func.h b/TC/utc/visual/utc_minfo_get_item_list_func.h
new file mode 100644 (file)
index 0000000..dd2bdb2
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_get_item_list_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_get_item_list API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_item_list_FUNC_H_\r
+#define __UTS_minfo_get_item_list_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_get_item_list_func_01();\r
+void utc_minfo_get_item_list_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_get_item_list_func_01, 1},\r
+       {utc_minfo_get_item_list_func_02, 2},   \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_item_list_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_get_media_list_by_tagname_func.c b/TC/utc/visual/utc_minfo_get_media_list_by_tagname_func.c
new file mode 100644 (file)
index 0000000..cfb02b8
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_get_media_list_by_tagname_func.c
+* @brief       This is a suit of unit test cases to test minfo_get_media_list_by_tagname API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-10
+*/
+
+#include "utc_minfo_get_media_list_by_tagname_func.h"
+
+static int _ite_fn( Mitem* item, void* user_data) 
+{
+       GList** list = (GList**) user_data;
+       *list = g_list_append( *list, item );
+
+       return 0;
+}
+
+/**
+* @brief       This tests int minfo_get_media_list_by_tagname() API with valid parameter
+*              Get glist including Mitem members.
+* @par ID      utc_minfo_get_media_list_by_tagname_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_media_list_by_tagname_func_01()
+{
+       int ret = 0;
+       const char* tag = "Family";
+       GList *p_list = NULL;
+       ret = minfo_get_media_list_by_tagname(tag, FALSE, _ite_fn, &p_list);
+
+       if (ret == MB_SVC_ERROR_DB_NO_RECORD) {
+               dts_pass(API_NAME, "No record. This is normal operation");
+       }
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get media records. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_get_media_list_by_tagname() API with invalid parameter
+*                      Get glist including Mitem members.
+* @par ID      utc_minfo_get_media_list_by_tagname_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_get_media_list_by_tagname_func_02()
+{      
+       int ret = 0;
+       const char* tag = "Family";
+       GList *p_list = NULL;
+       ret = minfo_get_media_list_by_tagname(tag, FALSE, NULL, &p_list);
+
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"getting media records should be failed because of the item_filter parameter.");
+}
diff --git a/TC/utc/visual/utc_minfo_get_media_list_by_tagname_func.h b/TC/utc/visual/utc_minfo_get_media_list_by_tagname_func.h
new file mode 100644 (file)
index 0000000..7722b97
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_get_media_list_by_tagname_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_get_media_list_by_tagname API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_media_list_by_tagname_FUNC_H_\r
+#define __UTS_minfo_get_media_list_by_tagname_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_get_media_list_by_tagname_func_01();\r
+void utc_minfo_get_media_list_by_tagname_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_get_media_list_by_tagname_func_01, 1},\r
+       {utc_minfo_get_media_list_by_tagname_func_02, 2},       \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_media_list_by_tagname_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_get_media_path_func.c b/TC/utc/visual/utc_minfo_get_media_path_func.c
new file mode 100644 (file)
index 0000000..e1b1a6a
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+* @file        utc_minfo_get_media_path.c
+* @brief       This is a suit of unit test cases to test minfo_get_media_path API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_get_media_path_func.h"
+
+
+/**
+* @brief       This tests int minfo_get_media_path() API with valid parameter
+*                      Gets status for lock from DB
+* @par ID      utc_minfo_get_media_path_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_media_path_func_01()
+{
+       int ret = -1;
+       int size = 256;
+       char media_path[256] = {'\0'};
+       minfo_store_type store_type = MINFO_PHONE;
+
+    ret = minfo_get_media_path(store_type, media_path, size);
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get cluster name by id. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_get_media_path() API with invalid parameter
+*                      Gets status for lock from DB
+* @par ID      utc_minfo_get_media_path_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_get_media_path_func_02()
+{
+       int ret = -1;
+       int size = 256;
+       char *media_path = NULL;
+       minfo_store_type store_type = MINFO_PHONE;
+
+    ret = minfo_get_media_path(store_type, media_path, size);
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"Getting cluster name by id should be failed because the passed status is NULL.");
+}
+
diff --git a/TC/utc/visual/utc_minfo_get_media_path_func.h b/TC/utc/visual/utc_minfo_get_media_path_func.h
new file mode 100644 (file)
index 0000000..60448ab
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file                utc_minfo_get_media_path_func.h
+* @author      
+* @brief       This is the implementaion file for the test case of minfo_get_media_path API function
+* @version     Initial Creation Version 0.1
+* @date                2010-10-13
+*/
+
+#ifndef __UTS_minfo_get_media_path_FUNC_H_
+#define __UTS_minfo_get_media_path_FUNC_H_
+
+
+#include "utc_visual_svc_common.h"
+
+/* Initialize TCM data structures */
+void (*tet_startup)() = startup;
+void (*tet_cleanup)() = cleanup;
+
+void utc_minfo_get_media_path_func_01();
+void utc_minfo_get_media_path_func_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_minfo_get_media_path_func_01, 1},
+       {utc_minfo_get_media_path_func_02, 2},  
+       {NULL, 0}
+};
+
+
+#endif //__UTS_minfo_get_media_path_FUNC_H_
diff --git a/TC/utc/visual/utc_minfo_get_meta_info_func.c b/TC/utc/visual/utc_minfo_get_meta_info_func.c
new file mode 100644 (file)
index 0000000..8341410
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_get_cluster_list_func.c
+* @brief       This is a suit of unit test cases to test minfo_get_meta_info API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_get_meta_info_func.h"
+
+
+/**
+* @brief       This tests int minfo_get_meta_info() API with valid parameter
+*              Get meta record of media Mitem.
+* @par ID      utc_minfo_get_cluster_list_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_meta_info_func_01()
+{
+       int ret = -1;
+       Mmeta* mt = NULL;
+       const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";
+
+
+       ret = minfo_get_meta_info(media_uuid, &mt);
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get meta record of media Mitem. error code->%d", ret);
+       minfo_destroy_mtype_item(mt);
+}
+
+
+/**
+* @brief               This tests int minfo_get_meta_info() API with invalid parameter
+*                      Get meta record of media Mitem.
+* @par ID      utc_minfo_get_meta_info_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_get_meta_info_func_02()
+{      
+       int ret = -1;
+       Mmeta* mt = NULL;
+       const char *media_uuid = NULL;
+
+       ret = minfo_get_meta_info(media_uuid, &mt);
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"getting meta record of media Mitem should be failed because of the media_id parameter.");
+}
diff --git a/TC/utc/visual/utc_minfo_get_meta_info_func.h b/TC/utc/visual/utc_minfo_get_meta_info_func.h
new file mode 100644 (file)
index 0000000..b513a5b
--- /dev/null
@@ -0,0 +1,50 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_minfo_get_meta_info_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_get_meta_info API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_meta_info_FUNC_H_\r
+#define __UTS_minfo_get_meta_info_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_get_meta_info_func_01();\r
+void utc_minfo_get_meta_info_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_get_meta_info_func_01, 1},\r
+       {utc_minfo_get_meta_info_func_02, 2},   \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_meta_info_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_get_tag_list_by_media_id_func.c b/TC/utc/visual/utc_minfo_get_tag_list_by_media_id_func.c
new file mode 100644 (file)
index 0000000..87eb38d
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_get_tag_list_by_media_id_func.c
+* @brief       This is a suit of unit test cases to test minfo_get_tag_list_by_media_id API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-10
+*/
+
+#include "utc_minfo_get_tag_list_by_media_id_func.h"
+
+static int _ite_fn( Mtag* item, void* user_data) 
+{
+       GList** list = (GList**) user_data;
+       *list = g_list_append( *list, item );
+
+       return 0;
+}
+
+/**
+* @brief       This tests int minfo_get_tag_list_by_media_id() API with valid parameter
+*              Get glist including Mitem members.
+* @par ID      utc_minfo_get_tag_list_by_media_id_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_tag_list_by_media_id_func_01()
+{
+       int ret = 0;
+       const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";
+       GList *p_list = NULL;
+       ret = minfo_get_tag_list_by_media_id( media_uuid, _ite_fn, &p_list);
+
+       if (ret == MB_SVC_ERROR_DB_NO_RECORD) {
+               dts_pass(API_NAME, "No record. This is normal operation");
+       }
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get tag list. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_get_tag_list_by_media_id() API with invalid parameter
+*                      Get glist including Mitem members.
+* @par ID      utc_minfo_get_tag_list_by_media_id_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_get_tag_list_by_media_id_func_02()
+{      
+       int ret = 0;
+       const char *media_uuid = NULL;
+       GList *p_list = NULL;
+       ret = minfo_get_tag_list_by_media_id( media_uuid, NULL, &p_list);
+
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"getting tag list should be failed because of the item_filter parameter.");
+}
diff --git a/TC/utc/visual/utc_minfo_get_tag_list_by_media_id_func.h b/TC/utc/visual/utc_minfo_get_tag_list_by_media_id_func.h
new file mode 100644 (file)
index 0000000..89fd2f8
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_get_tag_list_by_media_id_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_get_tag_list_by_media_id API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_tag_list_by_media_id_FUNC_H_\r
+#define __UTS_minfo_get_tag_list_by_media_id_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_get_tag_list_by_media_id_func_01();\r
+void utc_minfo_get_tag_list_by_media_id_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_get_tag_list_by_media_id_func_01, 1},\r
+       {utc_minfo_get_tag_list_by_media_id_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_tag_list_by_media_id_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_get_thumb_path_for_video_func.c b/TC/utc/visual/utc_minfo_get_thumb_path_for_video_func.c
new file mode 100644 (file)
index 0000000..35f6a9a
--- /dev/null
@@ -0,0 +1,72 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_get_thumb_path_for_video_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_get_thumb_path_for_video API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_get_thumb_path_for_video_func.h"\r
+\r
+\r
+/**\r
+* @brief       This tests int minfo_get_thumb_path_for_video() API with valid parameter\r
+*              get thumbnail pathname for a media content.\r
+* @par ID      utc_minfo_get_thumb_path_for_video_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_get_thumb_path_for_video_func_01()\r
+{\r
+       int ret = -1;\r
+       int size = 256;\r
+       \r
+       char thumb_path_for_video[256] = {'\0'};\r
+       char *file_url = "/opt/media/Images and videos/My video clips/Helicopter.mp4";\r
+\r
+       ret = minfo_get_thumb_path_for_video(file_url,thumb_path_for_video, size);\r
+\r
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to get thumbnail pathname for a media content. error code->%d", ret);\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_get_thumb_path_for_video() API with invalid parameter\r
+*                      get thumbnail pathname for a media content.\r
+* @par ID      utc_minfo_get_thumb_path_for_video_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_get_thumb_path_for_video_func_02()\r
+{\r
+       int ret = -1;\r
+       int size = 20;\r
+       \r
+       char thumb_path_for_video[256] = {'\0'};\r
+       char *file_url = NULL;/* = "/opt/media/Images/Wallpapers/Home_01.png";*/\r
+\r
+       ret = minfo_get_thumb_path_for_video(file_url,thumb_path_for_video, size);\r
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "get thumbnail pathname for a media content should be failed because of the file_url NULL.");\r
+}\r
diff --git a/TC/utc/visual/utc_minfo_get_thumb_path_for_video_func.h b/TC/utc/visual/utc_minfo_get_thumb_path_for_video_func.h
new file mode 100644 (file)
index 0000000..c5d471f
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_get_thumb_path_for_video_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_get_thumb_path_for_video API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_thumb_path_for_video_FUNC_H_\r
+#define __UTS_minfo_get_thumb_path_for_video_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_get_thumb_path_for_video_func_01();\r
+void utc_minfo_get_thumb_path_for_video_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_get_thumb_path_for_video_func_01, 1},\r
+       {utc_minfo_get_thumb_path_for_video_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_thumb_path_for_video_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_get_thumb_path_func.c b/TC/utc/visual/utc_minfo_get_thumb_path_func.c
new file mode 100644 (file)
index 0000000..070da91
--- /dev/null
@@ -0,0 +1,72 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_get_thumb_path_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_get_thumb_path API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_get_thumb_path_func.h"\r
+\r
+\r
+/**\r
+* @brief       This tests int minfo_get_thumb_path() API with valid parameter\r
+*              get thumbnail pathname for a media content.\r
+* @par ID      utc_minfo_get_thumb_path_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_get_thumb_path_func_01()\r
+{\r
+       int ret = -1;\r
+       int size = 256;\r
+       \r
+       char thumb_path[256] = {'\0'};\r
+       char *file_url = "/opt/media/Images and videos/Wallpapers/Home_default.png";\r
+\r
+       ret = minfo_get_thumb_path(file_url,thumb_path, size);\r
+\r
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to get thumbnail pathname for a media content. error code->%d", ret);\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_get_thumb_path() API with invalid parameter\r
+*                      get thumbnail pathname for a media content.\r
+* @par ID      utc_minfo_get_thumb_path_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_get_thumb_path_func_02()\r
+{\r
+       int ret = -1;\r
+       int size = 20;\r
+       \r
+       char thumb_path[256] = {'\0'};\r
+       char *file_url = NULL;/* = "/opt/media/Images/Wallpapers/Home_01.png";*/\r
+\r
+       ret = minfo_get_thumb_path(file_url,thumb_path, size);\r
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "get thumbnail pathname for a media content should be failed because of the file_url NULL.");\r
+}\r
diff --git a/TC/utc/visual/utc_minfo_get_thumb_path_func.h b/TC/utc/visual/utc_minfo_get_thumb_path_func.h
new file mode 100644 (file)
index 0000000..b89af40
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_get_thumb_path_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_get_thumb_path API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_thumb_path_FUNC_H_\r
+#define __UTS_minfo_get_thumb_path_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_get_thumb_path_func_01();\r
+void utc_minfo_get_thumb_path_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_get_thumb_path_func_01, 1},\r
+       {utc_minfo_get_thumb_path_func_02, 2},  \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_thumb_path_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_init_func.c b/TC/utc/visual/utc_minfo_init_func.c
new file mode 100644 (file)
index 0000000..c8b0d2c
--- /dev/null
@@ -0,0 +1,52 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_init_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_init API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_init_func.h"\r
+\r
+\r
+/**\r
+* @brief       This tests int minfo_init() API with valid parameter\r
+*              Open media, metadata, etc, database tables.\r
+* @par ID      utc_minfo_init_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_init_func_01()\r
+{\r
+       int ret = 0;\r
+       \r
+       ret = minfo_init();\r
+       \r
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to open media db. error code->%d", ret);\r
+       \r
+       return;\r
+}\r
+\r
+\r
diff --git a/TC/utc/visual/utc_minfo_init_func.h b/TC/utc/visual/utc_minfo_init_func.h
new file mode 100644 (file)
index 0000000..11aa791
--- /dev/null
@@ -0,0 +1,49 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_init_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_init API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_MINFO_INIT_FUNC_H_\r
+#define __UTS_MINFO_INIT_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = NULL;\r
+void (*tet_cleanup)() = NULL;\r
+\r
+void utc_minfo_init_func_01();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_init_func_01, 1},\r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_MINFO_INIT_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_media_func.c b/TC/utc/visual/utc_minfo_media_func.c
new file mode 100644 (file)
index 0000000..57ad960
--- /dev/null
@@ -0,0 +1,289 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_free_glist_func.c
+* @brief       This is a suit of unit test cases to test minfo_add_media, minfo_copy_media, minfo_cp_media, minfo_delete_media, minfo_delete_media_id API functions
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_media_func.h"
+
+static int _ite_fn( Mitem* item, void* user_data) 
+{
+       GList** list = (GList**) user_data;
+       *list = g_list_append( *list, item );
+
+       return 0;
+}
+
+int _get_id_by_url(const char* url, char *id)
+{
+       int ret;
+       Mitem* item = NULL;
+
+       ret = minfo_get_item( url, &item );
+       if( ret < 0 ) {
+               dts_message(API_NAME, "minfo_get_item fail");
+               return -1;
+       }
+
+       strncpy(id, item->uuid, 256);
+
+       return 0;
+}
+
+
+/**
+* @brief       This tests int minfo_add_media() API with valid parameter
+*              Add a media content to media table.
+* @par ID      utc_minfo_add_media_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_add_media_func_01()
+{
+       int err = -1;
+       char *file_url = "/opt/media/Images and videos/Wallpapers/Home_01.png";
+       int type = 1;
+
+       err = minfo_add_media(file_url, type);
+
+       dts_check_ge(API_NAME, err, MB_SVC_ERROR_NONE, "unable to Add a media content to media table. error code->%d", err);
+}
+
+
+/**
+* @brief               This tests int minfo_add_media() API with invalid parameter
+*                      Add a media content to media table.
+* @par ID      utc_minfo_add_media_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_add_media_func_02()
+{      
+       int err = -1;
+       char *file_url = NULL; /*= "/opt/media/Images/Wallpapers/Home_01.png";*/
+       int type = 1;
+
+       err = minfo_add_media(file_url, type);  
+               
+       dts_check_lt(API_NAME, err, MB_SVC_ERROR_NONE,"Add a media content to media table should be failed because of the file_url NULL.");
+}
+
+/**
+* @brief       This tests int minfo_copy_media() API with valid parameter
+*              Copy a media content from media table.
+* @par ID      utc_minfo_copy_media_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_copy_media_func_01()
+{
+       int err = -1;
+       char *old_file_url = "/opt/media/Images and videos/Wallpapers/Home_default.png";
+       char *new_file_url = "/opt/media/Images and videos/Wallpapers/Home_default_1.png";
+       int type = 1;
+
+       err = minfo_copy_media(old_file_url, new_file_url, type);
+
+       dts_check_ge(API_NAME, err, MB_SVC_ERROR_NONE, "unable to Copy a media content from media table.. error code->%d", err);
+
+}
+
+
+/**
+* @brief               This tests int minfo_copy_media() API with invalid parameter
+*                      Copy a media content from media table.
+* @par ID      utc_minfo_copy_media_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_copy_media_func_02()
+{      
+       int err = -1;
+       char *old_file_url = NULL; /*= "/opt/media/Images and videos/Wallpapers/Home_default.png";*/
+       char *new_file_url = "/opt/media/Images and videos/Wallpapers/Home_default_1.png";
+       int type = 1;
+
+       err = minfo_copy_media(old_file_url, new_file_url, type);
+               
+       dts_check_lt(API_NAME, err, MB_SVC_ERROR_NONE, "Copy a media content from media table should be failed because of the file_url NULL.");
+}
+
+
+/**
+* @brief       This tests int minfo_cp_media() API with valid parameter
+*              copy a record identified by media id to destination folder identified by folder id.
+* @par ID      utc_minfo_cp_media_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_cp_media_func_01()
+{
+       int ret = -1;
+       
+       char *file_url = "/opt/media/Images and videos/Wallpapers/Home_default.png";
+       char src_media_uuid[256] = {0,};
+       char src_cluster_uuid[256] = {0,};
+       char *dst_cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+
+       Mitem* item = NULL;
+
+       ret = minfo_get_item( file_url, &item );
+       if (ret < MB_SVC_ERROR_NONE)
+       {
+               dts_fail( API_NAME, "unable to get a media content from media table. error code->%d", ret);
+               return;
+       }
+
+       strncpy(src_media_uuid, item->uuid, sizeof(src_media_uuid));
+       strncpy(src_cluster_uuid, item->cluster_uuid, sizeof(src_cluster_uuid));
+
+       minfo_destroy_mtype_item(item); 
+
+       ret = minfo_cp_media(src_media_uuid, dst_cluster_uuid);
+
+       if (ret < MB_SVC_ERROR_NONE)
+       {
+               dts_fail(API_NAME, "failed to copy a record identified by media id to destination folder identified by folder id. error code->%d", ret);
+               return;
+       }
+       
+       GList *p_list = NULL;
+       minfo_item_filter item_filter = {MINFO_ITEM_ALL,MINFO_MEDIA_SORT_BY_NONE,-1,-1,false,false};
+       Mitem* dest_item = NULL;
+
+       ret = minfo_get_item_list(dst_cluster_uuid, item_filter, _ite_fn, &p_list);
+       
+       if (ret < MB_SVC_ERROR_NONE)
+       {
+               dts_fail(API_NAME, "unable to get media records. error code->%d", ret);
+       }
+
+       int len = g_list_length( p_list );
+       dest_item = (Mitem*)g_list_nth_data(p_list, len-1);
+       ret = minfo_delete_media_id( dest_item->uuid );
+
+       if (ret < MB_SVC_ERROR_NONE)
+       {
+               dts_fail(API_NAME, "unable to delete media records. error code->%d", ret);
+       }
+
+       minfo_destroy_mtype_item(dest_item);    
+
+       dts_pass(API_NAME, "minfo_cp_media succeeded");
+
+       return;
+}
+
+/**
+* @brief               This tests int minfo_cp_media() API with invalid parameter
+*                      copy a record identified by media id to destination folder identified by folder id.
+* @par ID      utc_minfo_cp_media_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_cp_media_func_02()
+{
+       int ret = -1;
+       
+       char *src_media_uuid = NULL;
+       char *dst_cluster_uuid = NULL;
+
+       ret = minfo_cp_media(src_media_uuid, dst_cluster_uuid);
+               
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"copy a record identified by media id to destination folder identified by folder id should be failed because of the src_media_id -1.");
+}
+
+/**
+* @brief       This tests int minfo_delete_media() API with valid parameter
+*              Delete a media content from media table.
+* @par ID      utc_minfo_delete_media_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_delete_media_func_01()
+{
+       int err = -1;
+       char *file_url = "/opt/media/Images and videos/Wallpapers/Home_01.png";
+
+       err = minfo_delete_media(file_url);
+
+       dts_check_ge(API_NAME, err, MB_SVC_ERROR_NONE, "unable to Add a media content to media table. error code->%d", err);
+}
+
+
+/**
+* @brief               This tests int minfo_delete_media() API with invalid parameter
+*                      Delete a media content from media table.
+* @par ID      utc_minfo_delete_media_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_delete_media_func_02()
+{      
+       int err = -1;
+       char *file_url = NULL; /*= "/opt/media/Images/Wallpapers/Home_01.png";*/
+
+       err = minfo_delete_media(file_url);
+       dts_check_lt(API_NAME, err, MB_SVC_ERROR_NONE,"Delete a media content from media table should be failed because of the file_url NULL.");
+}
+
+
+/**
+* @brief       This tests int minfo_delete_media_id() API with valid parameter
+*              delete a record identified by media id from 'media' table.
+* @par ID      utc_minfo_delete_media_id_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_delete_media_id_func_01()
+{
+       int ret = -1;
+       char media_uuid[256] = {0,};
+       
+       _get_id_by_url("/opt/media/Images and videos/Wallpapers/Home_default_1.png", media_uuid);
+       ret = minfo_delete_media_id(media_uuid);
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to delete a record identified by media id from 'media' table. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_delete_media_id() API with invalid parameter
+*                      delete a record identified by media id from 'media' table.
+* @par ID      utc_minfo_delete_media_id_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_delete_media_id_func_02()
+{
+       int ret = -1;
+       
+       char *media_uuid = NULL;
+       ret = minfo_delete_media_id(media_uuid);
+
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "delete a record identified by media id from 'media' table should be failed because of the media_id -1.");
+}
diff --git a/TC/utc/visual/utc_minfo_media_func.h b/TC/utc/visual/utc_minfo_media_func.h
new file mode 100644 (file)
index 0000000..45fa683
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file                utc_minfo_media_func.h
+* @author      
+* @brief       This is the implementaion file for the test case of minfo_add_media, minfo_copy_media, minfo_cp_media, minfo_delete_media, minfo_delete_media_id API functions
+* @version     Initial Creation Version 0.1
+* @date                2010-10-13
+*/
+
+#ifndef __UTS_minfo_media_FUNC_H_
+#define __UTS_minfo_media_FUNC_H_
+
+
+#include "utc_visual_svc_common.h"
+
+/* Initialize TCM data structures */
+void (*tet_startup)() = startup;
+void (*tet_cleanup)() = cleanup;
+
+void utc_minfo_add_media_func_01();
+void utc_minfo_add_media_func_02();
+void utc_minfo_copy_media_func_01();
+void utc_minfo_copy_media_func_02();
+void utc_minfo_cp_media_func_01();
+void utc_minfo_cp_media_func_02();
+void utc_minfo_delete_media_func_01();
+void utc_minfo_delete_media_func_02();
+void utc_minfo_delete_media_id_func_01();
+void utc_minfo_delete_media_id_func_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_minfo_add_media_func_01, 1},
+       {utc_minfo_copy_media_func_01, 1},
+       {utc_minfo_cp_media_func_01, 1},
+       {utc_minfo_delete_media_func_01, 1},
+       {utc_minfo_delete_media_id_func_01, 1},
+       {utc_minfo_add_media_func_02, 2},       
+       {utc_minfo_copy_media_func_02, 2},      
+       {utc_minfo_cp_media_func_02, 2},        
+       {utc_minfo_delete_media_func_02, 2},    
+       {utc_minfo_delete_media_id_func_02, 2}, 
+       {NULL, 0}
+};
+
+
+#endif //__UTS_minfo_media_FUNC_H_
diff --git a/TC/utc/visual/utc_minfo_move_media_func.c b/TC/utc/visual/utc_minfo_move_media_func.c
new file mode 100644 (file)
index 0000000..e0f33a7
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_move_media_func.c
+* @brief       This is a suit of unit test cases to test minfo_move_media API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_move_media_func.h"
+
+
+/**
+* @brief       This tests int minfo_move_media() API with valid parameter
+*              Move a media content from media table.
+* @par ID      utc_minfo_move_media_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_move_media_func_01()
+{
+       int err = -1;
+       char *old_file_url = "/opt/media/Images and videos/Wallpapers/Home_default.png";
+       char *new_file_url = "/opt/media/Images and videos/Wallpapers/Home_default_2.png";
+       int type = 1;
+
+       err = minfo_move_media(old_file_url, new_file_url, type);
+
+       if (err < MB_SVC_ERROR_NONE)
+       {
+               dts_fail(API_NAME, "unable to Move a media content from media table. error code->%d", err);
+       }
+
+       err = minfo_move_media(new_file_url, old_file_url, type);
+       if (err < MB_SVC_ERROR_NONE)
+       {
+               dts_fail(API_NAME, "unable to Move a media content from media table. error code->%d", err);
+       }
+       
+       dts_pass(API_NAME, "utc_minfo_move_media_func_01 succeeded");
+       
+       return;
+}
+
+
+/**
+* @brief               This tests int minfo_move_media() API with invalid parameter
+*                      Move a media content from media table.
+* @par ID      utc_minfo_move_media_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_move_media_func_02()
+{      
+       int err = -1;
+       char *old_file_url = NULL; /*= "/opt/media/Images/Wallpapers/Home_01.png";*/
+       char *new_file_url = "/opt/media/Images/Wallpapers/Home_01_1.png";
+       int type = 1;
+
+       err = minfo_move_media(old_file_url, new_file_url, type);
+       dts_check_lt(API_NAME, err, MB_SVC_ERROR_NONE,"Move a media content from media table should be failed because of the file_url NULL.");
+}
diff --git a/TC/utc/visual/utc_minfo_move_media_func.h b/TC/utc/visual/utc_minfo_move_media_func.h
new file mode 100644 (file)
index 0000000..74fbf80
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_move_media_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_move_media API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_move_media_FUNC_H_\r
+#define __UTS_minfo_move_media_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_move_media_func_01();\r
+void utc_minfo_move_media_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_move_media_func_01, 1},\r
+       {utc_minfo_move_media_func_02, 2},      \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_move_media_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_mv_media_func.c b/TC/utc/visual/utc_minfo_mv_media_func.c
new file mode 100644 (file)
index 0000000..5a2e4c8
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_mv_media_func.c
+* @brief       This is a suit of unit test cases to test minfo_mv_media API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_mv_media_func.h"
+
+
+/**
+* @brief       This tests int minfo_mv_media() API with valid parameter
+*              move a record identified by media id to destination folder identified by folder id.
+* @par ID      utc_minfo_mv_media_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_mv_media_func_01()
+{
+       int ret = -1;
+       
+       char *file_url = "/opt/media/Images and videos/Wallpapers/Home_default.png";
+       char src_media_uuid[256] = {0,};
+       char src_cluster_uuid[256] = {0,};
+       char *dst_cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+       Mitem* item = NULL;
+
+
+       ret = minfo_get_item( file_url, &item );
+       if (ret < MB_SVC_ERROR_NONE)
+       {
+               dts_fail(API_NAME, "unable to get a media content from media table. error code->%d", ret);
+       }
+
+       strncpy(src_media_uuid, item->uuid, sizeof(src_media_uuid));
+       strncpy(src_cluster_uuid, item->cluster_uuid, sizeof(src_cluster_uuid));
+
+       ret = minfo_mv_media(src_media_uuid, dst_cluster_uuid);
+
+       if (ret < MB_SVC_ERROR_NONE)
+       {
+               dts_fail(API_NAME, "failed to move a record identified by media id to destination folder identified by folder id. error code->%d", ret);
+       }
+
+       ret = minfo_mv_media(src_media_uuid, src_cluster_uuid);
+
+       if (ret < MB_SVC_ERROR_NONE)
+       {
+               dts_fail(API_NAME, "failed to move a record identified by media id to destination folder identified by folder id. error code->%d", ret);
+       }
+       
+       dts_pass(API_NAME, "utc_minfo_mv_media_func_01 succeeded");
+       return;
+}
+
+
+/**
+* @brief               This tests int minfo_mv_media() API with invalid parameter
+*                      move a record identified by media id to destination folder identified by folder id.
+* @par ID      utc_minfo_mv_media_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_mv_media_func_02()
+{
+       int ret = -1;
+       
+       char *src_media_uuid = NULL;
+       char *dst_cluster_uuid = NULL;
+
+       ret = minfo_mv_media(src_media_uuid, dst_cluster_uuid);
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"move a record identified by media id to destination folder identified by folder id should be failed because of the src_media_id -1.");
+}
diff --git a/TC/utc/visual/utc_minfo_mv_media_func.h b/TC/utc/visual/utc_minfo_mv_media_func.h
new file mode 100644 (file)
index 0000000..590de4e
--- /dev/null
@@ -0,0 +1,50 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_minfo_mv_media_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_mv_media API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_mv_media_FUNC_H_\r
+#define __UTS_minfo_mv_media_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_mv_media_func_01();\r
+void utc_minfo_mv_media_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_mv_media_func_01, 1},\r
+       {utc_minfo_mv_media_func_02, 2},        \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_mv_media_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_set_cluster_lock_status_func.c b/TC/utc/visual/utc_minfo_set_cluster_lock_status_func.c
new file mode 100644 (file)
index 0000000..b75e679
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_set_cluster_lock_status.c
+* @brief       This is a suit of unit test cases to test minfo_set_cluster_lock_status API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_set_cluster_lock_status_func.h"
+
+
+/**
+* @brief       This tests int minfo_set_cluster_lock_status() API with valid parameter
+*                      Set status for lock to DB
+* @par ID      utc_minfo_set_cluster_lock_status_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_set_cluster_lock_status_func_01()
+{
+       int ret = -1;
+       const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+       int status = 1;
+
+    ret = minfo_set_cluster_lock_status(cluster_uuid, status);
+
+       if (ret < MB_SVC_ERROR_NONE)
+       {
+               dts_fail(API_NAME, "unable to set status to lock the album.  error code->%d", ret);
+       }
+
+    ret = minfo_set_cluster_lock_status(cluster_uuid, 0);
+
+       if (ret < MB_SVC_ERROR_NONE)
+       {
+               dts_fail(API_NAME, "unable to set status to unlock the album.  error code->%d", ret);
+       }
+       
+       dts_pass(API_NAME, "utc_minfo_set_cluster_lock_status_func_01 succeeded");
+       
+       return;
+}
+
+
+/**
+* @brief               This tests int minfo_set_cluster_lock_status() API with invalid parameter
+*                      Set status for lock to DB
+* @par ID      utc_minfo_set_cluster_lock_status_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_set_cluster_lock_status_func_02()
+{
+       int ret = -1;
+       const char *cluster_uuid = NULL;
+       int status = 2;
+
+    ret = minfo_set_cluster_lock_status(cluster_uuid, status);
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "Setting lock status to the album should be failed because of the status is invalid.");
+}
+
diff --git a/TC/utc/visual/utc_minfo_set_cluster_lock_status_func.h b/TC/utc/visual/utc_minfo_set_cluster_lock_status_func.h
new file mode 100644 (file)
index 0000000..ffe14a2
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file                utc_minfo_set_cluster_lock_status_func.h
+* @author      
+* @brief       This is the implementaion file for the test case of minfo_set_cluster_lock_status API function
+* @version     Initial Creation Version 0.1
+* @date                2010-10-13
+*/
+
+#ifndef __UTS_minfo_set_cluster_lock_status_FUNC_H_
+#define __UTS_minfo_set_cluster_lock_status_FUNC_H_
+
+
+#include "utc_visual_svc_common.h"
+
+/* Initialize TCM data structures */
+void (*tet_startup)() = startup;
+void (*tet_cleanup)() = cleanup;
+
+void utc_minfo_set_cluster_lock_status_func_01();
+void utc_minfo_set_cluster_lock_status_func_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_minfo_set_cluster_lock_status_func_01, 1},
+       {utc_minfo_set_cluster_lock_status_func_02, 2}, 
+       {NULL, 0}
+};
+
+
+#endif //__UTS_minfo_set_cluster_lock_status_FUNC_H_
diff --git a/TC/utc/visual/utc_minfo_set_db_valid_func.c b/TC/utc/visual/utc_minfo_set_db_valid_func.c
new file mode 100644 (file)
index 0000000..bbf424b
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+* @file        utc_minfo_set_db_valid.c
+* @brief       This is a suit of unit test cases to test minfo_set_db_valid API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_set_db_valid_func.h"
+
+
+/**
+* @brief       This tests int minfo_set_db_valid() API with valid parameter
+*                      Set status for lock to DB
+* @par ID      utc_minfo_set_db_valid_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_set_db_valid_func_01()
+{
+       int ret = -1;
+       int valid = 1;
+
+       minfo_store_type storage_type = MINFO_PHONE;
+
+    ret = minfo_set_db_valid(storage_type, valid);
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to set value of valid. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_set_db_valid() API with invalid parameter
+*                      Set status for lock to DB
+* @par ID      utc_minfo_set_db_valid_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_set_db_valid_func_02()
+{
+       int ret = -1;
+       int valid = 2;
+
+       minfo_store_type storage_type = MINFO_PHONE;
+
+    ret = minfo_set_db_valid(storage_type, valid);
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "Setting value of valid should be failed because of the status is invalid.");
+}
+
diff --git a/TC/utc/visual/utc_minfo_set_db_valid_func.h b/TC/utc/visual/utc_minfo_set_db_valid_func.h
new file mode 100644 (file)
index 0000000..d550879
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+* @file                utc_minfo_set_db_valid_func.h
+* @author      
+* @brief       This is the implementaion file for the test case of minfo_set_db_valid API function
+* @version     Initial Creation Version 0.1
+* @date                2010-10-13
+*/
+
+#ifndef __UTS_minfo_set_db_valid_FUNC_H_
+#define __UTS_minfo_set_db_valid_FUNC_H_
+
+
+#include "utc_visual_svc_common.h"
+
+/* Initialize TCM data structures */
+void (*tet_startup)() = startup;
+void (*tet_cleanup)() = cleanup;
+
+void utc_minfo_set_db_valid_func_01();
+void utc_minfo_set_db_valid_func_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_minfo_set_db_valid_func_01, 1},
+       {utc_minfo_set_db_valid_func_02, 2},    
+       {NULL, 0}
+};
+
+
+#endif //__UTS_minfo_set_db_valid_FUNC_H_
diff --git a/TC/utc/visual/utc_minfo_tag_func.c b/TC/utc/visual/utc_minfo_tag_func.c
new file mode 100644 (file)
index 0000000..476c113
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+* @file        utc_minfo_tag_func.c
+* @brief       This is a suit of unit test cases to test minfo_add_tag and minfo_delete_tag API functions
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_tag_func.h"
+
+/**
+* @brief       This tests int minfo_add_tag() API with valid parameter
+*              add a cluser record content in folder table.
+* @par ID      utc_minfo_add_tag_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_add_tag_func_01()
+{
+       int ret = -1;
+       const char *tag = "Family";
+       const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";
+       
+       ret = minfo_add_tag(media_uuid, tag);
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to add a tag. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_add_tag() API with invalid parameter
+*                      add a cluser record content in folder table.
+* @par ID      utc_minfo_add_tag_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_add_tag_func_02()
+{
+       int ret = -1;
+       const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";
+       const char *tag = NULL;
+       
+       ret = minfo_add_tag(media_uuid, tag);
+
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "Adding a tag should be failed because of the cluster_url NULL.");
+}
+
+
+/**
+* @brief       This tests int minfo_delete_tag() API with valid parameter
+*              delete a cluster/folder identified by folder id.
+* @par ID      utc_minfo_delete_tag_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_delete_tag_func_01()
+{
+       int ret = -1;
+       const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";
+       const char *tag = "Family";
+
+       ret = minfo_delete_tag(media_uuid, tag);
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to delete a tag. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_delete_tag() API with invalid parameter
+*                      delete a cluster/folder identified by folder id.
+* @par ID      utc_minfo_delete_tag_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_delete_tag_func_02()
+{
+       int ret = -1;
+       const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";
+       const char *tag = NULL;
+
+       ret = minfo_delete_tag(media_uuid, tag);
+        
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "deleting a tag should be failed because of the cluster_id -1.");
+}
diff --git a/TC/utc/visual/utc_minfo_tag_func.h b/TC/utc/visual/utc_minfo_tag_func.h
new file mode 100644 (file)
index 0000000..49fd018
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+* @file                utc_minfo_tag_func.h
+* @author      
+* @brief       This is the implementaion file for the test case of minfo_add_tag and minfo_delete_tag API functions
+* @version     Initial Creation Version 0.1
+* @date                2010-10-13
+*/
+
+#ifndef __UTS_minfo_tag_FUNC_H_
+#define __UTS_minfo_tag_FUNC_H_
+
+
+#include "utc_visual_svc_common.h"
+
+/* Initialize TCM data structures */
+void (*tet_startup)() = startup;
+void (*tet_cleanup)() = cleanup;
+
+void utc_minfo_add_tag_func_01();
+void utc_minfo_add_tag_func_02();
+void utc_minfo_delete_tag_func_01();
+void utc_minfo_delete_tag_func_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_minfo_add_tag_func_01, 1},
+       {utc_minfo_delete_tag_func_01, 1},
+       {utc_minfo_add_tag_func_02, 2}, 
+       {utc_minfo_delete_tag_func_02, 2},      
+       {NULL, 0}
+};
+
+
+#endif //__UTS_minfo_tag_FUNC_H_
diff --git a/TC/utc/visual/utc_minfo_update_cluster_name_func.c b/TC/utc/visual/utc_minfo_update_cluster_name_func.c
new file mode 100644 (file)
index 0000000..d6ca296
--- /dev/null
@@ -0,0 +1,92 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_update_cluster_name_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_update_cluster_name API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_update_cluster_name_func.h"\r
+\r
+\r
+/**\r
+* @brief       This tests int minfo_update_cluster_name() API with valid parameter\r
+*              Update a cluster name.\r
+* @par ID      utc_minfo_update_cluster_name_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_update_cluster_name_func_01()\r
+{\r
+       int ret = -1;\r
+       \r
+       const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";\r
+       char *new_name = "newfolder";\r
+       char origin_name[256];\r
+       memset( origin_name, 0x00, 256 );\r
+\r
+       ret = minfo_get_cluster_name_by_id(cluster_uuid, origin_name, 256); \r
+       if (ret < MB_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail(API_NAME, "unable to get a cluster name. error code->%d", ret);\r
+       }\r
+\r
+       ret = minfo_update_cluster_name(cluster_uuid,new_name);\r
+\r
+       if (ret < MB_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail(API_NAME, "unable to get a cluster name. error code->%d", ret);\r
+       }\r
+       \r
+       ret = minfo_update_cluster_name(cluster_uuid, origin_name);\r
+\r
+       if (ret < MB_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail(API_NAME, "unable to Reupdate a cluster name. error code->%d", ret);\r
+       }\r
+\r
+       dts_pass(API_NAME, "utc_minfo_update_cluster_name_func_01 succeeded");\r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_update_cluster_name() API with invalid parameter\r
+*                      Update a cluster name.\r
+* @par ID      utc_minfo_update_cluster_name_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_update_cluster_name_func_02()\r
+{      \r
+       int ret = -1;\r
+       \r
+       const char *cluster_uuid = NULL;\r
+       char *new_name = NULL; /*= "newfolder";*/\r
+\r
+       ret = minfo_update_cluster_name(cluster_uuid, new_name);\r
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"Update a cluster name should be failed because of the new_name parameter NULL.");\r
+       \r
+}\r
+\r
diff --git a/TC/utc/visual/utc_minfo_update_cluster_name_func.h b/TC/utc/visual/utc_minfo_update_cluster_name_func.h
new file mode 100644 (file)
index 0000000..81dc27d
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_update_cluster_name_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_update_cluster_name API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_get_item_list_FUNC_H_\r
+#define __UTS_minfo_get_item_list_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_update_cluster_name_func_01();\r
+void utc_minfo_update_cluster_name_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_update_cluster_name_func_01, 1},\r
+       {utc_minfo_update_cluster_name_func_02, 2},     \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_get_item_list_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_update_favorite_by_media_id_func.c b/TC/utc/visual/utc_minfo_update_favorite_by_media_id_func.c
new file mode 100644 (file)
index 0000000..bf6c4ae
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_update_favorite_by_media_id_func.c
+* @brief       This is a suit of unit test cases to test minfo_update_favorite_by_media_id API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_update_favorite_by_media_id_func.h"
+
+
+/**
+* @brief       This tests int minfo_update_favorite_by_media_id() API with valid parameter
+*              update favorite field for media file.
+* @par ID      utc_minfo_update_favorite_by_media_id_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_update_favorite_by_media_id_func_01()
+{
+       int ret = -1;
+       
+       const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";
+
+       int favorite = 0;
+
+       ret = minfo_update_media_favorite(media_uuid, favorite);
+
+       dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to update favorite field for media file. error code->%d", ret);
+}
+
+
+/**
+* @brief               This tests int minfo_update_favorite_by_media_id() API with invalid parameter
+*                      update favorite field for media file.
+* @par ID      utc_minfo_update_favorite_by_media_id_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_update_favorite_by_media_id_func_02()
+{      
+       int ret = -1;
+       
+       const char *media_uuid = NULL;
+       int favorite = 2;
+
+       ret = minfo_update_media_favorite(media_uuid, favorite);
+       
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "update favorite field for media file should be failed because of the media_id parameter -1.");
+}
diff --git a/TC/utc/visual/utc_minfo_update_favorite_by_media_id_func.h b/TC/utc/visual/utc_minfo_update_favorite_by_media_id_func.h
new file mode 100644 (file)
index 0000000..28e35a6
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_update_favorite_by_media_id_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_update_favorite_by_media_id API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_update_favorite_by_media_id_FUNC_H_\r
+#define __UTS_minfo_update_favorite_by_media_id_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_update_favorite_by_media_id_func_01();\r
+void utc_minfo_update_favorite_by_media_id_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_update_favorite_by_media_id_func_01, 1},\r
+       {utc_minfo_update_favorite_by_media_id_func_02, 2},     \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_update_favorite_by_media_id_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_update_media_favorite_func.c b/TC/utc/visual/utc_minfo_update_media_favorite_func.c
new file mode 100644 (file)
index 0000000..2366018
--- /dev/null
@@ -0,0 +1,81 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file        utc_minfo_update_media_favorite_func.c\r
+* @brief       This is a suit of unit test cases to test minfo_update_media_favorite API function\r
+* @author              \r
+* @version     Initial Creation Version 0.1\r
+* @date        2010-10-13\r
+*/\r
+\r
+#include "utc_minfo_update_media_favorite_func.h"\r
+\r
+\r
+/**\r
+* @brief       This tests int minfo_update_media_favorite() API with valid parameter\r
+*              update 'favorite' feild of a media content in media table.\r
+* @par ID      utc_minfo_update_media_name_func_01\r
+* @param       [in] \r
+* @return      This function returns zero on success, or negative value with error code\r
+*/\r
+void utc_minfo_update_media_favorite_func_01()\r
+{\r
+       int ret = -1;\r
+       const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";\r
+       int favorite_level = 1;\r
+\r
+    ret = minfo_update_media_favorite(media_uuid, favorite_level);\r
+\r
+       if (ret < MB_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail(API_NAME, "unable to update 'favorite' feild of a media content in media table. error code->%d", ret);\r
+       }\r
+       \r
+    ret = minfo_update_media_favorite(media_uuid, 0);\r
+\r
+       if (ret < MB_SVC_ERROR_NONE)\r
+       {\r
+               dts_fail(API_NAME, "unable to reupdate 'favorite' feild of a media content in media table. error code->%d", ret);\r
+       }\r
+\r
+       dts_pass(API_NAME, "utc_minfo_update_media_favorite_func_01 succeeded");\r
+       \r
+}\r
+\r
+\r
+/**\r
+* @brief               This tests int minfo_update_media_favorite() API with invalid parameter\r
+*                      update 'favorite' feild of a media content in media table.\r
+* @par ID      utc_minfo_update_media_name_func_02\r
+* @param       [in] \r
+* @return      error code on success \r
+*/\r
+void utc_minfo_update_media_favorite_func_02()\r
+{\r
+       int ret = -1;\r
+       const char *media_uuid = NULL;\r
+       int favorite_level = 1;\r
+\r
+    ret = minfo_update_media_favorite(media_uuid, favorite_level);\r
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "update 'favorite' feild of a media content in media table should be failed because of the new_name NULL.");\r
+}\r
diff --git a/TC/utc/visual/utc_minfo_update_media_favorite_func.h b/TC/utc/visual/utc_minfo_update_media_favorite_func.h
new file mode 100644 (file)
index 0000000..fd7f701
--- /dev/null
@@ -0,0 +1,50 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+* @file                utc_minfo_update_media_favorite_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_update_media_favorite API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_update_media_favorite_FUNC_H_\r
+#define __UTS_minfo_update_media_favorite_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_update_media_favorite_func_01();\r
+void utc_minfo_update_media_favorite_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_update_media_favorite_func_01, 1},\r
+       {utc_minfo_update_media_favorite_func_01, 2},   \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_update_media_favorite_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_update_media_name_func.c b/TC/utc/visual/utc_minfo_update_media_name_func.c
new file mode 100644 (file)
index 0000000..3acaf51
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_update_media_name_func.c
+* @brief       This is a suit of unit test cases to test minfo_update_media_name API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_update_media_name_func.h"
+
+
+/**
+* @brief       This tests int minfo_update_media_name() API with valid parameter
+*              Rename a media content from media table.
+* @par ID      utc_minfo_update_media_name_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_update_media_name_func_01()
+{
+       int ret = -1;
+       char *file_url = "/opt/media/Images and videos/Wallpapers/Home_default.png";
+       char origin_name[256];
+       char *new_name = "Home_01.png";
+       Mitem* item = NULL;
+       memset( origin_name, 0x00, 256 );
+
+
+       ret = minfo_get_item( file_url, &item );
+       if (ret < MB_SVC_ERROR_NONE)
+       {
+               dts_fail(API_NAME, "unable to get a media content from media table. error code->%d", ret);
+       }
+
+       if( item ) {
+               strncpy( origin_name, item->display_name, sizeof( origin_name ) );
+       ret = minfo_update_media_name(item->uuid, new_name);
+
+               if (ret < MB_SVC_ERROR_NONE)
+               {
+                       dts_fail(API_NAME, "unable to Rename a media content from media table. error code->%d", ret);
+               }
+
+       ret = minfo_update_media_name(item->uuid, origin_name);
+
+               if (ret < MB_SVC_ERROR_NONE)
+               {
+                       dts_fail(API_NAME, "unable to Rename a media content from media table. error code->%d", ret);
+               }
+       }
+               
+       dts_pass(API_NAME, "utc_minfo_update_media_name_func_01 succeeded");
+}
+
+
+/**
+* @brief               This tests int minfo_update_media_name() API with invalid parameter
+*                      Rename a media content from media table.
+* @par ID      utc_minfo_update_media_name_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_update_media_name_func_02()
+{
+       int ret = -1;
+       const char *media_uuid = NULL;
+       char *new_name = NULL;/*= "Home_01.png";*/
+
+    ret = minfo_update_media_name(media_uuid, new_name);
+               
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"Rename a media content from media table should be failed because of the new_name NULL.");
+}
diff --git a/TC/utc/visual/utc_minfo_update_media_name_func.h b/TC/utc/visual/utc_minfo_update_media_name_func.h
new file mode 100644 (file)
index 0000000..d55edc6
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_update_media_name_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_update_media_name API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_update_media_name_FUNC_H_\r
+#define __UTS_minfo_update_media_name_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_update_media_name_func_01();\r
+void utc_minfo_update_media_name_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_update_media_name_func_01, 1},\r
+       {utc_minfo_update_media_name_func_02, 2},       \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_update_media_name_FUNC_H_\r
diff --git a/TC/utc/visual/utc_minfo_update_video_meta_info_int_func.c b/TC/utc/visual/utc_minfo_update_video_meta_info_int_func.c
new file mode 100644 (file)
index 0000000..45d9e56
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file        utc_minfo_update_video_meta_info_int_func.c
+* @brief       This is a suit of unit test cases to test minfo_update_video_meta_info_int API function
+* @author              
+* @version     Initial Creation Version 0.1
+* @date        2010-10-13
+*/
+
+#include "utc_minfo_update_video_meta_info_int_func.h"
+
+
+/**
+* @brief       This tests int minfo_update_video_meta_info_int() API with valid parameter
+*              Rename a media content from media table.
+* @par ID      utc_minfo_update_video_meta_info_int_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_update_video_meta_info_int_func_01()
+{
+       int ret = -1;
+       char *file_url = "/opt/media/Images and videos/My video clips/Helicopter.mp4";
+       char origin_name[256];
+       Mitem* item = NULL;
+       memset( origin_name, 0x00, 256 );
+
+
+       ret = minfo_get_item( file_url, &item );
+       if (ret < MB_SVC_ERROR_NONE)
+       {
+               dts_fail(API_NAME, "unable to get a media content from media table. error code->%d", ret);
+       }
+
+       if( item ) {
+               strncpy( origin_name, item->display_name, sizeof( origin_name ) );
+       ret = minfo_update_video_meta_info_int(item->uuid, MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED, 3000);
+
+               if (ret < MB_SVC_ERROR_NONE)
+               {
+                       dts_fail(API_NAME, "unable to update a media content from media table. error code->%d", ret);
+               }
+
+       ret = minfo_update_video_meta_info_int(item->uuid, MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED, 0);
+
+               if (ret < MB_SVC_ERROR_NONE)
+               {
+                       dts_fail(API_NAME, "unable to reupdate a media content from media table. error code->%d", ret);
+               }
+       }
+               
+       dts_pass(API_NAME, "utc_minfo_update_video_meta_info_int_func_01 succeeded");
+}
+
+
+/**
+* @brief               This tests int minfo_update_video_meta_info_int() API with invalid parameter
+*                      Rename a media content from media table.
+* @par ID      utc_minfo_update_video_meta_info_int_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_minfo_update_video_meta_info_int_func_02()
+{
+       int ret = -1;
+       const char *media_uuid = NULL;
+       minfo_video_meta_field_t meta_field = MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED;
+
+    ret = minfo_update_video_meta_info_int(media_uuid, meta_field, 3000);
+               
+       dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"update a media content from media table should be failed because of the new_name NULL.");
+}
diff --git a/TC/utc/visual/utc_minfo_update_video_meta_info_int_func.h b/TC/utc/visual/utc_minfo_update_video_meta_info_int_func.h
new file mode 100644 (file)
index 0000000..37c294a
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+/**\r
+* @file                utc_minfo_update_video_meta_info_int_func.h\r
+* @author      \r
+* @brief       This is the implementaion file for the test case of minfo_update_video_meta_info_int API function\r
+* @version     Initial Creation Version 0.1\r
+* @date                2010-10-13\r
+*/\r
+\r
+#ifndef __UTS_minfo_update_video_meta_info_int_FUNC_H_\r
+#define __UTS_minfo_update_video_meta_info_int_FUNC_H_\r
+\r
+\r
+#include "utc_visual_svc_common.h"\r
+\r
+/* Initialize TCM data structures */\r
+void (*tet_startup)() = startup;\r
+void (*tet_cleanup)() = cleanup;\r
+\r
+void utc_minfo_update_video_meta_info_int_func_01();\r
+void utc_minfo_update_video_meta_info_int_func_02();\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+       {utc_minfo_update_video_meta_info_int_func_01, 1},\r
+       {utc_minfo_update_video_meta_info_int_func_02, 2},      \r
+       {NULL, 0}\r
+};\r
+\r
+\r
+#endif //__UTS_minfo_update_video_meta_info_int_FUNC_H_\r
diff --git a/TC/utc/visual/utc_visual_svc_common.h b/TC/utc/visual/utc_visual_svc_common.h
new file mode 100644 (file)
index 0000000..4e5c533
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file                utc_visual_svc_common.h
+* @author      
+* @brief       This is the implementaion file for the test case of media service
+
+* @version     Initial Creation Version 0.1
+* @date                2010-10-13
+*/
+
+#ifndef __UTS_MINFO_SVC_COMMON_H_
+#define __UTS_MINFO_SVC_COMMON_H_
+
+#include <media-svc.h>
+#include <string.h>
+#include <tet_api.h>
+#include <unistd.h>
+#include <glib.h>
+
+#define MAX_STRING_LEN 256
+
+#define UTC_MM_LOG(fmt, args...)       tet_printf("[%s(L%d)]:"fmt"\n", __FUNCTION__, __LINE__, ##args)
+#define API_NAME "libmedia-info"
+
+#define UTC_MINFO_INIT() \
+do \
+{ \
+       int ret = 0; \
+       ret = minfo_init(); \
+       if (ret < MB_SVC_ERROR_NONE) \
+       { \
+               UTC_MM_LOG( "unable to open media db. error code->%d", ret); \
+               tet_result(TET_FAIL); \
+               return; \
+       } \
+} \
+while(0);
+
+#define UTC_MINFO_FINALIZE() \
+do \
+{ \
+       int ret = 0; \
+       ret = minfo_finalize(); \
+       if (ret < MB_SVC_ERROR_NONE) \
+       { \
+               UTC_MM_LOG( "unable to close media db. error code->%d", ret); \
+               tet_result(TET_FAIL); \
+               return; \
+       } \
+} \
+while(0);
+
+void startup()
+{
+       UTC_MINFO_INIT()
+}
+
+void cleanup()
+{
+       UTC_MINFO_FINALIZE()
+}
+
+
+#endif //__UTS_MINFO_SVC_COMMON_H_
diff --git a/debian/changelog b/debian/changelog
new file mode 100755 (executable)
index 0000000..15a41aa
--- /dev/null
@@ -0,0 +1,24 @@
+libmedia-service (0.2.0-2) unstable; urgency=low
+
+  * Remove libmedia-thumbnail dependancy
+  * Git : pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.2.0-2
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 5 Jan 2011 18:30:00 +0900
+
+libmedia-service (0.2.0-1) unstable; urgency=low
+
+  * Remove md5 codes
+  * Git : pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.2.0-1
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 3 Jan 2011 18:30:00 +0900
+
+libmedia-service (0.2.0-0) unstable; urgency=low
+
+  * Initial Release
+  * Git : pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.2.0-0
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Wed, 07 Dec 2011 12:35:23 +0900
+
diff --git a/debian/compat b/debian/compat
new file mode 100755 (executable)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100755 (executable)
index 0000000..6a5cd6a
--- /dev/null
@@ -0,0 +1,37 @@
+Source: libmedia-service
+Section: libs
+Priority: extra
+Maintainer: Hyunjun Ko<zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>, Byungwook Jang <bw.jang@samsung.com>
+Uploaders: Hyunjun Ko<zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+Build-Depends: debhelper (>= 5), libglib2.0-dev,
+               dlog-dev,
+               libslp-db-util-dev,
+               libsqlite3-dev, 
+               libmm-fileinfo-dev, 
+               libmm-utility-dev, 
+               drm-service-dev,
+               libexif-dev,
+               libevas-dev,
+               libecore-dev,
+               libaul-1-dev
+Standards-Version: 0.1
+Homepage: N/A
+
+Package: libmedia-service
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Media information service library for multimedia applications.
+
+Package: libmedia-service-dev
+Section: libdevel
+Architecture: any
+Depends: libmedia-service (= ${Source-Version}), libsqlite3-dev, libslp-db-util-dev, libmm-common-dev, libmm-fileinfo-dev, libmm-utility-dev, libglib2.0-dev, libxext-dev, dlog-dev, drm-service-dev, libevas-dev, libecore-dev, libexif-dev, libaul-1-dev
+Description: Media information service library for multimedia applications. (development)
+
+Package: libmedia-service-dbg
+Section: debug
+Architecture: any
+Depends:  ${misc:Depends}, libmedia-service (= ${Source-Version})
+Description: Media information service library for multimedia applications. (unstripped)
+
diff --git a/debian/copyright b/debian/copyright
new file mode 100755 (executable)
index 0000000..8eb7553
--- /dev/null
@@ -0,0 +1,17 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
diff --git a/debian/docs b/debian/docs
new file mode 100755 (executable)
index 0000000..a0f0008
--- /dev/null
@@ -0,0 +1 @@
+CMakeLists.txt
diff --git a/debian/libmedia-service-dev.install.in b/debian/libmedia-service-dev.install.in
new file mode 100755 (executable)
index 0000000..bb9b916
--- /dev/null
@@ -0,0 +1,2 @@
+@PREFIX@/lib/pkgconfig/*
+@PREFIX@/include/*
diff --git a/debian/libmedia-service.install.in b/debian/libmedia-service.install.in
new file mode 100755 (executable)
index 0000000..636e09d
--- /dev/null
@@ -0,0 +1 @@
+@PREFIX@/lib/libmedia-*.so*
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..41d28dc
--- /dev/null
@@ -0,0 +1,112 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+CFLAGS += -Wall -g
+LDFLAGS +=
+PREFIX ?= /usr
+DATADIR ?= /usr/share
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0 -fPIC
+else
+       CFLAGS += -O2 -fPIC
+endif
+
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed -Wl,--hash-style=both
+
+CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+       # Add here commands to configure the package.
+       mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && \
+       CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX="$(PREFIX)"
+
+       touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp 
+       dh_testdir
+
+       # Add here commands to compile the package.
+       cd $(CMAKE_BUILD_DIR) && $(MAKE)
+
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               cat $$f > $${f%.in}; \
+               sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+               sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+       done
+
+       touch $@
+
+clean:
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp configure-stamp
+
+       # Add here commands to clean up after the build process.
+       rm -rf $(CMAKE_BUILD_DIR)
+
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               rm -f $${f%.in}; \
+       done
+
+       dh_clean 
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k 
+       dh_installdirs
+
+       # Add here commands to install the package into debian/wavplayer.
+       cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs 
+       dh_installdocs
+       dh_installexamples
+       dh_install --sourcedir=debian/tmp
+#      dh_installmenu
+#      dh_installdebconf       
+#      dh_installlogrotate
+#      dh_installemacsen
+#      dh_installpam
+#      dh_installmime
+#      dh_python
+#      dh_installinit
+#      dh_installcron
+#      dh_installinfo
+       dh_installman
+       dh_link
+       dh_strip --dbg-package=libmedia-service-dbg
+       dh_compress
+       dh_fixperms
+#      dh_perl
+       dh_makeshlibs
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/image/SLP_MediaSvc_PG_image001.png b/image/SLP_MediaSvc_PG_image001.png
new file mode 100755 (executable)
index 0000000..d120338
Binary files /dev/null and b/image/SLP_MediaSvc_PG_image001.png differ
diff --git a/image/SLP_MediaSvc_PG_image002.png b/image/SLP_MediaSvc_PG_image002.png
new file mode 100755 (executable)
index 0000000..5edce77
Binary files /dev/null and b/image/SLP_MediaSvc_PG_image002.png differ
diff --git a/image/SLP_MusicSVC_PG_image001.png b/image/SLP_MusicSVC_PG_image001.png
new file mode 100755 (executable)
index 0000000..fbb7cc4
Binary files /dev/null and b/image/SLP_MusicSVC_PG_image001.png differ
diff --git a/image/SLP_MusicSVC_PG_image002.png b/image/SLP_MusicSVC_PG_image002.png
new file mode 100755 (executable)
index 0000000..7d783be
Binary files /dev/null and b/image/SLP_MusicSVC_PG_image002.png differ
diff --git a/include/SLP_AudioSvc_PG.h b/include/SLP_AudioSvc_PG.h
new file mode 100755 (executable)
index 0000000..ad50c90
--- /dev/null
@@ -0,0 +1,728 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+ *
+ * @defgroup   AUDIO_SVC_PG Audio Service
+    @ingroup SLP_PG
+    @{
+
+
+<h1 class="pg">Introduction</h1>
+<h2 class="pg">Purpose</h2>
+
+The purpose of this document is to give the application developer detailed information to access  music database using the Audio Service API's.
+
+
+<h2 class="pg">Scope</h2>
+
+The scope of this document is limited to Samsung platform Audio Service API usage.
+
+<h2 class="pg">Abbreviations</h2>
+
+       <table>
+               <tr>
+                       <td>
+                       API
+                       </td>
+                       <td>
+                       Application Programming Interface
+                       </td>
+               </tr>
+               <tr>
+                       <td>
+                         Group
+                       </td>
+                       <td>
+                        a collection of related audio or music tracks like Album, Artist, Genre,  Year, Composer
+                       </td>
+               </tr>
+               <tr>
+                       <td>
+                         Playlist
+                       </td>
+                       <td>
+                       a simple list of songs
+                       </td>
+               </tr>
+               <tr>
+                       <td>
+                         Extractor
+                       </td>
+                       <td>
+                         Extracts metadata associated with a particular media format from a file or records in the databases.
+                       </td>
+               </tr>
+               <tr>
+                       <td>
+                         File manager service
+                       </td>
+                       <td>
+                         Detect and manage all of file system chagnes.
+                       </td>
+               </tr>
+       </table>
+
+<h1 class="pg">Audio Service Architecture</h1>
+
+
+Audio Service is designed to provide easy to use services for accessing music library database based on an embedded Linux platform.
+Media Service is used to maintain music content in SQLite database. The content stored in database consists of music items from both MMC and Phone flash, playlist, and playlist elements.
+
+
+<h2 class="pg">Features</h2>
+You can use Audio Service to organize your digital music collection.
+You can do a number of things with them, including playing music, extract metadata, creating playlists.
+
+- Add items to the Music library
+       - File manager service automatically searches certain default folders on your phone     and MMC for music files, and then adds those files to your library. If you ever add or remove files from these
+       folders, File manager service automatically updates the library accordingly.
+
+- Delete items from the Music library
+       - You can delete a music file from the library, and the song will be removed forever in your device.
+
+- Find items in the Music library
+       - Audio Service provides smart search for you to find items in the music library. To ensure that you can easily find items in the library, it is important that files have accurate and complete media information.
+You can also find files those were recently added / recently played / Most played in the library.
+
+- Using playlists
+       - Playlists are a great way to control how you use the files in your Music library. By creating a playlist, you can group any songs into a list that you can then quickly
+       play. Favorite playlist(playlist_id = 0) is default folder for you.
+
+<h2 class="pg">Architecture diagram</h2>
+
+
+<b>Modules</b>
+
+- Database Manager
+
+Database Manager component is responsible for database manipulation, such as open database, close database, create table, set the storage validation, and delete the storage contents.
+
+
+- Music Group Manager
+
+Music Group Manager component is responsible for manipulation of tracks by the group type, such as album, artist, genre, and etc.
+
+- Music Item Manager
+
+Music Item Manager component is responsible for music track manipulation, including add track, delete track, copy track, move track, refresh track metadata, and etc.
+
+- Playlist Manager
+
+Playlist Manager component is responsible for managing playlists and its contents, such as appending playlist, deleting playlist, and manage the tracks in playlist.
+
+@image html SLP_MusicSVC_PG_image001.png
+
+<h1 class="pg">Audio Service API usage</h1>
+<h2 class="pg">Database Manager</h2>
+
+This part describes the APIs of the Database Manager component.
+
+<b>Database schema design</b>
+@image html SLP_MusicSVC_PG_image002.png
+
+
+<b>Functions</b>
+
+The followings are full proto types of database manager functions.
+
+- int audio_svc_open(void);
+
+- int audio_svc_close(void);
+
+- int audio_svc_create_table();
+
+- int audio_svc_set_db_valid(audio_svc_storage_type_e storage_type, int valid);
+
+- int audio_svc_delete_all(audio_svc_storage_type_e storage_type);
+
+<b>Open music database and create tables</b>
+
+- Purpose
+       - Be prepared for registering music tracks into database.
+
+
+Make music database and table by using the following steps:
+
+-# Make database or connect to database using audio_svc_open().
+-# Create table using audio_svc_create_table(). All table will be made by this API.
+
+The following is a sample code:
+
+@code
+
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       // open music database
+       ret = audio_svc_open();
+       // open failed
+       if (ret < 0)
+       {
+               printf( "Cannot open music db. error code->%d", ret);
+               return;
+       }
+
+       // create muisc tables of phone type
+       ret = audio_svc_create_table();
+
+       if (ret < 0)
+       {
+               printf( "unable to create music phone table. error code->%d", ret);
+               return;
+       }
+
+       return;
+
+@endcode
+
+<b>Close music database</b>
+
+- Purpose
+       - Disconnects with the music database.
+
+The following is a sample code:
+
+@code
+
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       // close music database
+       ret = audio_svc_close();
+       // close failed
+       if (ret < 0)
+       {
+               printf( "unable to close music db. error code->%d", ret);
+               return ret;
+       }
+
+
+@endcode
+
+<h2 class="pg">Music Group Manager</h2>
+
+This section describes APIs used for managing music groups.
+
+The following are supported functions in the group manager module.
+               - int   audio_svc_list_item_new(AudioHandleType **record, int count);
+
+               - int   audio_svc_list_item_free(AudioHandleType *record);
+
+               - int   #audio_svc_list_item_get_val(AudioHandleType *record, int index, audio_svc_list_item_type_e first_field_name, ...);
+
+               - int   audio_svc_list_item_get(AudioHandleType *record, int index, AudioHandleType **item);
+
+               - int   audio_svc_count_group_item(audio_svc_group_type_e group_type, const char *limit_string1, const char *limit_string2, const char *filter_string, const char *filter_string2, int *count);
+
+               - int   audio_svc_get_group_item(audio_svc_group_type_e group_type, const char *limit_string1, const char *limit_string2, const char *filter_string, const char *filter_string2, int offset, int rows, AudioHandleType *result_records);
+
+               - int   audio_svc_count_list_item(audio_svc_track_type_e item_type, const char *type_string, const char *type_string2, const char *filter_string, const char *filter_string2, int *count);
+
+               - int   audio_svc_get_list_item(audio_svc_track_type_e item_type, const char *type_string, const char *type_string2, const char *filter_string, const char *filter_string2, int offset, int rows, AudioHandleType *track);
+
+
+<b>Get Album groups</b>
+
+- Purpose
+       - Find all albums in the music database.
+
+
+Find all albums in music database and get album and artist name information from database by using the following steps:
+
+-# Make database or connect to database using audio_svc_open().
+-# Count albums using audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "", "", "", "", &count).
+-# Make array to get all album info using audio_svc_list_item_new(&groups, count).
+-# Get the all album info using audio_svc_get_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "", "", "", "", 0, count, groups).
+-# Get each album's attribute value using audio_svc_list_item_get_val(groups, i, AUDIO_SVC_LIST_ITEM_TITLE, &first_name, &size,  -1).
+-# free memory using audio_svc_list_item_free(groups).
+
+The following is a sample code:
+
+@code
+
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int i = 0, count = -1, size = -1;
+       AudioHandleType  *groups = NULL;
+       char * first_name = NULL, second_name = NULL, thumbnail_path = NULL;
+
+       // open music database
+       ret = audio_svc_open();
+       if (ret < 0)
+       {
+               printf( "Cannot open music db. error code->%d", ret);
+               return;
+       }
+
+       //Count album
+       ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "", "", "", "", &count);
+       if (ret < 0)
+       {
+               printf( "Fail to count groups. error code->%d", ret);
+               return;
+       }
+
+       if(count == 0)
+       {
+               DEBUG_TRACE("There is no item");
+               return FALSE;
+       }
+
+       ret = audio_svc_list_item_new(&groups, count);
+       if (ret < 0)
+       {
+               printf( "Fail to allocate memory for list. error code->%d", ret);
+               return;
+       }
+
+       ret = audio_svc_get_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "", "", "", "", 0, count, groups);
+       if (ret < 0)
+       {
+               printf( "Fail to get groups. error code->%d", ret);
+               return;
+       }
+
+       for(i=0; i < count; i++)
+       {
+               //Get album name
+               audio_svc_list_item_get_val(groups, i, AUDIO_SVC_LIST_ITEM_TITLE, &first_name, &size,  -1);
+               //Get artist name of album
+               audio_svc_list_item_get_val(groups, i, AUDIO_SVC_LIST_ITEM_ARTIST, &second_name, &size,  -1);
+               //Get thumbnail path of first item in album
+               audio_svc_list_item_get_val(groups, i, AUDIO_SVC_LIST_ITEM_THUMBNAIL_PATH, &thumbnail_path, &size,  -1);
+       }
+
+       ret = audio_svc_list_item_free(groups);
+       if (ret < 0)
+       {
+               printf( "Fail to free memory for list. error code->%d", ret);
+       }
+
+       return;
+
+@endcode
+
+
+<b>Search and get all tracks in music library</b>
+
+- Purpose
+       - Find all tracks and get metadata in the music database.
+
+
+Find all tracks in music database and get metadata information from database by using the following steps:
+
+-# Make database or connect to database using audio_svc_open().
+-# Count tracks using audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &rows).
+-# Make array to get all tracks info using audio_svc_list_item_new(&tracks, rows).
+-# Get the all tracks info using audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, NULL, NULL, NULL, NULL, 0, rows, tracks).
+-# Get each tracks attribute value using audio_svc_item_get_val(item, AUDIO_SVC_TRACK_DATA_AUDIO_ID, &audio_id, AUDIO_SVC_TRACK_DATA_TITLE, &title, &size, AUDIO_SVC_TRACK_DATA_ALBUM, &album, &size, AUDIO_SVC_TRACK_DATA_ARTIST, &artist, &size, AUDIO_SVC_TRACK_DATA_THUMBNAIL_PATH, &thumbname, &size, AUDIO_SVC_TRACK_DATA_YEAR, &year, &size, -1);
+-# Free memory allocation using audio_svc_list_item_free(tracks).
+
+
+The following is a sample code:
+
+
+@code
+
+       AudioHandleType *item;
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int audio_id;
+       int i, j;
+       int rows;
+       AudioHandleType*tracks = NULL;
+
+       // open music database
+       ret = audio_svc_open();
+       if (ret < 0)
+       {
+               printf( "Cannot open music db. error code->%d", ret);
+               return;
+       }
+
+       // Count all tracks
+       ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &rows);
+       if (ret < 0)
+       {
+               printf( "failed to  count items. error code->%d", ret);
+               return;
+       }
+
+       ret = audio_svc_list_item_new(&tracks, rows);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,
+               NULL, //type_string,
+               NULL, //type_string2,
+               NULL, //filter_string,
+               NULL, //filter_string2,
+               0, //offset,
+               rows, //rows,
+               tracks
+               );
+
+       if (ret == AUDIO_SVC_ERROR_NONE) {
+               audio_svc_item_new(&item);
+               for (i = 0; i < rows; i++)
+               {
+                       audio_svc_list_item_get_val(tracks, i, AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, -1);
+                       ret = audio_svc_get_item_by_audio_id(audio_id, item);
+                       if (ret == AUDIO_SVC_ERROR_NONE) {
+                               int audio_id;
+                               char *title, *album, *artist, *thumbname, *year;
+                               int size;
+                               audio_svc_item_get_val(item,
+                                       AUDIO_SVC_TRACK_DATA_AUDIO_ID, &audio_id,
+                                       AUDIO_SVC_TRACK_DATA_TITLE, &title, &size,
+                                       AUDIO_SVC_TRACK_DATA_ALBUM, &album, &size,
+                                       AUDIO_SVC_TRACK_DATA_ARTIST, &artist, &size,
+                                       AUDIO_SVC_TRACK_DATA_THUMBNAIL_PATH, &thumbname, &size,
+                                       AUDIO_SVC_TRACK_DATA_YEAR, &year, &size,
+                                       -1);
+
+                               printf(" [audio_id]:%d, [title] :%s, [album] : %s, [artist] : %s, [thumb] : %s, [year] : %s\n",
+                                       audio_id, title, album, artist, thumbname, year);
+                       }
+                       else
+                       {
+                               printf("error to get item by audio_id : %d\n", audio_id);
+                       }
+               }
+               audio_svc_item_free(item);
+       }
+       else
+       {
+               printf( "failed to  get items. error code->%d", ret);
+       }
+
+       ret = audio_svc_list_item_free(tracks);
+       if (ret < 0)
+       {
+               printf( "Fail to free memory, error code->%d", ret);
+       }
+
+       return;
+
+@endcode
+
+
+<h2 class="pg">Muisc Item Manager</h2>
+
+Muisc Item Manager module provides APIs to manage music tracks in library.
+
+The following are supported functions
+
+               - int   audio_svc_item_new(AudioHandleType **record);
+
+               - int   audio_svc_item_free(AudioHandleType *record);
+
+               - int   #audio_svc_item_set_val(AudioHandleType *record, audio_svc_track_data_type_e  first_field_name, ...);
+
+               - int   #audio_svc_item_get_val(AudioHandleType *record, audio_svc_track_data_type_e  first_field_name, ...);
+
+               - int   audio_svc_insert_item(audio_svc_storage_type_e storage_type, const char *path, int category);
+
+               - int   audio_svc_get_item_by_audio_id(int audio_id, AudioHandleType *item_handle);
+
+               - int   audio_svc_get_item_by_path(const char *path, AudioHandleType *item_handle);
+
+               - int   audio_svc_delete_item_by_path(const char *path);
+
+               - int   audio_svc_move_item(audio_svc_storage_type_e src_storage, const char *src_path, audio_svc_storage_type_e dest_storage, const char *dest_path);
+
+               - int   audio_svc_get_path_by_audio_id(int audio_id, char *path);
+
+               - int   audio_svc_set_item_valid(const char *path, int valid);
+
+               - int   audio_svc_refresh_metadata(int audio_id);
+
+               - int   audio_svc_check_item_exist(const char *path);
+
+<b>Insert music item to music database</b>
+
+- Purpose
+       - Insert music item into database with path. audio service extract metadata and register it in music database.
+
+
+Insert music item by using the following steps:
+
+-# Make database or connect to database using audio_svc_open().
+-# define path for music item.
+-# insert item to music database using audio_svc_insert_item(AUDIO_SVC_STORAGE_PHONE, path, category).
+
+The following is a sample code
+
+@code
+
+       int ret = AUDIO_SVC_ERROR_NONE;
+       const char *path = "/opt/media/Sounds/Music/Layla.mp3";
+       int category = AUDIO_SVC_CATEGORY_MUSIC;
+
+       // open music database
+       ret = audio_svc_open();
+       if (ret < 0)
+       {
+               printf( "Cannot open music db. error code->%d", ret);
+               return;
+       }
+
+       // insert a track into music db
+       ret = audio_svc_insert_item(AUDIO_SVC_STORAGE_PHONE, path, category);
+
+       if (ret < 0)
+       {
+               printf( "unable to insert item, error code->%d", ret);
+               return;
+       }
+
+       return;
+
+@endcode
+
+
+<h2 class="pg">Music Playlist Manager</h2>
+
+Music Playlist Manager module provides APIs to manage playlist and its contents.
+
+The following are supported functions :
+
+       - int   audio_svc_playlist_new(AudioHandleType **record, int count);
+
+       - int   audio_svc_playlist_free(AudioHandleType *record);
+
+       - int   #audio_svc_playlist_get_val(AudioHandleType *playlists, int index, audio_svc_playlist_e first_field_name, ...);
+
+       - int   #audio_svc_playlist_set_val(AudioHandleType *playlists, int index, audio_svc_playlist_e  first_field_name, ...);
+
+       - int   audio_svc_playlist_get_item(AudioHandleType *record, int index, AudioHandleType **plst);
+
+       - int   audio_svc_add_playlist(const char *playlist_name, int *playlist_id);
+
+       - int   audio_svc_count_playlist(const char *filter_string, const char *filter_string2, int *count);
+
+       - int   audio_svc_get_playlist(const char *filter_string, const char *filter_string2, int offset, int rows, AudioHandleType *playlists);
+
+       - int   audio_svc_delete_playlist(int playlist_id);
+
+       - int   audio_svc_get_unique_playlist_name(const char *orig_name, char *unique_name);
+
+       - int   audio_svc_update_playlist_name(int playlist_id, const char *new_playlist_name);
+
+       - int   audio_svc_count_playlist_by_name(const char *playlist_name, int *count);
+
+       - int   audio_svc_add_item_to_playlist(int playlist_id, int audio_id);
+
+       - int   audio_svc_remove_item_from_playlist_by_uid(int playlist_id, int audio_id);
+
+       - int   audio_svc_check_duplicate_insertion_in_playlist(int playlist_id, int audio_id, int *count);
+
+       - int   audio_svc_get_playlist_name_by_playlist_id(int playlist_id, char *playlist_name);
+
+       - int   audio_svc_update_playlist_item_idx(int playlist_id, int audio_id, int new_idx);
+
+
+<b>Make new playlist</b>
+
+- Purpose
+       -  User can make own playlist and resiger it to database.
+
+
+Make and Add new playlist with unique name into database by using the following steps:
+
+-# Make database or connect to database using audio_svc_open().
+-# Add playlist into database using audio_svc_add_playlist(playlist_name, &plst_id).
+-# User can handle playlist by using plst_id.
+
+The following is a sample code:
+
+@code
+
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int plst_id = -1;
+       const char *playlist_name = "plst_test_001";
+       int test_audio_id = 50;
+
+       // open music database
+       ret = audio_svc_open();
+       if (ret < 0)
+       {
+               printf( "Cannot open music db. error code->%d", ret);
+               return;
+       }
+
+       //append playlist "plst_test_001" into db.
+       ret = audio_svc_add_playlist(playlist_name, &plst_id);
+       if (ret < 0)
+       {
+               printf( "failed to add playlist. error code->%d", ret);
+               return;
+       }
+
+       return;
+
+@endcode
+
+
+<b>Add and Remove items from playlist</b>
+
+- Purpose
+       -  Add music items and Remove items from user made playlist. music items        just removed from playlist and not deleted on filesystem.
+
+
+Add and Remove music items from playlist and register it into database by using the following steps:
+
+-# Make database or connect to database using audio_svc_open().
+-# Add playlist into database using audio_svc_add_playlist(playlist_name, &plst_id).
+-# Add music item to playlist with plst_id and music item audio_id using audio_svc_add_item_to_playlist(plst_id, test_audio_id).
+-# Remove music item from playlist with plst_id and music item audio_id using audio_svc_add_item_to_playlist(plst_id, test_audio_id).
+
+The following is a sample code:
+
+@code
+
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int plst_id = -1;
+       const char *playlist_name = "plst_test_001";
+       int test_audio_id = 50;
+
+       // open music database
+       ret = audio_svc_open();
+       if (ret < 0)
+       {
+               printf( "Cannot open music db. error code->%d", ret);
+               return;
+       }
+
+       //append playlist "plst_test_001" into db.
+       ret = audio_svc_add_playlist(playlist_name, &plst_id);
+       if (ret < 0)
+       {
+               printf( "failed to add playlist. error code->%d", ret);
+               return;
+       }
+
+       //add music item with audio_id "50" to playlist "plst_test_001"
+       ret = audio_svc_add_item_to_playlist(plst_id, test_audio_id);
+       if (ret < 0)
+       {
+               printf( "failed to add item to playlist. error code->%d", ret);
+               return;
+       }
+
+       //remove music item with audio_id "50" from playlist "plst_test_001"
+       ret = audio_svc_remove_item_from_playlist(plst_id, test_audio_id);
+       if (ret < 0)
+       {
+               printf( "failed to remove item to playlist. error code->%d", ret);
+               return;
+       }
+
+       return;
+
+@endcode
+
+
+<b> Get all user playlist info</b>
+
+- Purpose
+       -  Get all user playlist name and playlist id from music database.
+
+
+Get user playlist info from database by using the following steps:
+
+-# Make database or connect to database using audio_svc_open().
+-# Count all user playlist using audio_svc_count_playlist("", "", &count).
+-# Allocate memory block to get the playlist using audio_svc_playlist_new(&playlists, count).
+-# Get playlist items using audio_svc_get_playlist("", "", 0, count, playlists).
+-# Get attribute values using audio_svc_playlist_get_val(playlists, i, AUDIO_SVC_PLAYLIST_ID, &plst_id, -1);
+-# free memory using audio_svc_playlist_free(playlists);
+
+The following is a sample code:
+
+@code
+
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *playlists;
+       char *name = NULL;
+       int i = 0, count = -1, size = -1, plst_id = -1;
+
+       // open music database
+       ret = audio_svc_open();
+       if (ret < 0)
+       {
+               printf( "Cannot open music db. error code->%d", ret);
+               return;
+       }
+
+       // count all user playlist
+       ret = audio_svc_count_playlist("", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get playlist count. error code->%d", ret);
+               return;
+       }
+
+       if(count == 0)
+       {
+               DEBUG_TRACE("there is no user playlist");
+               return;
+       }
+
+       // allocate memory block for playlist
+       ret = audio_svc_playlist_new(&playlists, count);
+       if (ret < 0)
+       {
+               printf( "failed to make playlist. error code->%d", ret);
+               return;
+       }
+
+       //get playlist items
+       ret = audio_svc_get_playlist("", "", 0, count, playlists);
+       if (ret < 0)
+       {
+               printf( "failed to get playlist. error code->%d", ret);
+               audio_svc_playlist_free(playlists)
+               return;
+       }
+
+       // get each playlist's attribute value
+       for(i = 0; i < count; i++)
+       {
+               audio_svc_playlist_get_val(playlists, i, AUDIO_SVC_PLAYLIST_ID, &plst_id, -1);
+               audio_svc_playlist_get_val(playlists, i, AUDIO_SVC_PLAYLIST_NAME, &name, &size, -1);
+
+       }
+
+       ret = audio_svc_playlist_free(playlists);
+       if (ret < 0)
+       {
+               printf( "failed to free memoy. error code->%d", ret);
+       }
+
+       return;
+
+@endcode
+
+/**
+*@}
+*/
diff --git a/include/SLP_MediaSvc_PG.h b/include/SLP_MediaSvc_PG.h
new file mode 100644 (file)
index 0000000..bcdec16
--- /dev/null
@@ -0,0 +1,702 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ *
+ * @defgroup   MB_SVC_PG Media Service
+ * @ingroup SLP_PG
+   @{
+
+
+<h1 class="pg">Introduction</h1>
+<h2 class="pg">Purpose</h2>
+
+The purpose of this document is to give the application developer detailed information to access  media(images and videos) database using the Media Service API's.
+
+
+<h2 class="pg">Scope</h2>
+
+The scope of this document is limited to Samsung platform Media Service API usage.
+
+<h2 class="pg">Abbreviations</h2>
+
+       <table>
+               <tr>
+                       <td>
+                         Media
+                       </td>
+                       <td>
+                        In this document, Media items mean multimedia items including image and video, not music. If you want to manage music items, Please see Music Service Document
+                       </td>
+               </tr>
+               <tr>
+                       <td>
+                       API
+                       </td>
+                       <td>
+                       Application Programming Interface
+                       </td>
+               </tr>
+               <tr>
+                       <td>
+                         Cluster
+                       </td>
+                       <td>
+                        a collection of related images or videos like Album or Folder
+                       </td>
+               </tr>
+               <tr>
+                       <td>
+                         extractor
+                       </td>
+                       <td>
+                         Extracts metadata associated with a particular media format from a file or records in the databases.
+                       </td>
+               </tr>
+               <tr>
+                       <td>
+                         File manager service
+                       </td>
+                       <td>
+                         Detect and manage all of file system chagnes.
+                       </td>
+               </tr>
+       </table>
+
+<h1 class="pg"> Media Service Architecture</h1>
+
+
+Media Service is designed to provide easy to use services for accessing media library database based on an embedded Linux platform.
+Media Service is used to maintain media content in SQLite database. The content stored in database consists of media items from both MMC and Phone flash. 
+
+
+<h2 class="pg">Features</h2>
+You can use Media Service to organize your digital media collection. 
+You can do a number of things with them, including playing, creating playlists.
+
+- Add media items to the media database.
+       - File manager service automatically searches certain default folders on your phone     and MMC for media files, and then adds those files to the system media database.  If you ever add or remove files from these folders, File manager service automatically updates the database accordingly.
+
+- Delete media items from the media database.
+       - You can delete a media file from the library, and it will be removed forever in your device.
+
+- Find media items in the media database. 
+       - Media Service provides smart search for you to find items in the media database. To ensure that you can easily find items in the database, it is important that files have accurate and complete media information.
+
+- Organizing media items in the media database.
+       - Media Service provides a great way to organize media items in the media database as you want. You can also sort by name, date, or etc.
+
+<h2 class="pg">Architecture diagram</h2>
+
+
+<b>Modules</b>
+
+- User Interface
+       - User interface is a group of api, which is open to public. User could access and control media data in the media database with using these apis. Also, user could extract thumbnail from media of image or video.
+
+- List Organizer
+       - List organizer performs querying db, organizing and returning results as a type of list. This component return a list, which is sorted by what user wants, for example, by name or date.
+
+- Database Manager
+        - Database manager is responsible for database manipulation, such as open database, close database, create table, set the storage validation, and delete the storage contents.
+
+- Thumbnail Extractor
+       - Thumbnail extractor supports for user to extract a thumbnail from media of image or video. Also, user could get the path of the produced thumbnail.
+
+
+@image html SLP_MediaSvc_PG_image001.png
+
+<h1 class="pg">Database Schema Design</h1>
+
+This image describes the design of the media database schema.
+
+@image html SLP_MediaSvc_PG_image002.png
+
+<h1 class="pg"> API descriptions </h2>
+
+<h2 class="pg"> Open and close media service </h2>
+
+<b> Purpose </b>
+- To be prepared for accessing to the media database.
+       - Use function minfo_init().
+- To be finalized for accessing to the media database.
+       - Use function minfo_finalize().
+- Applications should call minfo_init() before using media-svc and call minfo_finalize() after finishing jobs in related to the media-svc.
+
+The following is a sample code:
+
+@code
+       #include <media-svc.h>
+
+       int ret = -1;
+
+       //open a databse file.
+       ret = minfo_init();
+       if(ret< 0)
+       { 
+               printf("minfo_init error\n");
+               return ret;
+       }
+
+       //close database file.
+       ret = minfo_finalize();
+
+       if(ret< 0)
+       { 
+               printf("minfo_finalize error\n");
+               return ret;
+       }
+
+@endcode
+
+<h2 class="pg"> Get a cluster list of media </h2>
+<b> Purpose </b>
+- To get a list of clusters in the media database.
+
+<b> Usage </b>
+- User can set the minfo_cluster_filter to get what user wants.
+       - User can set minfo_folder_type
+               - MINFO_CLUSTER_TYPE_ALL : All type of media
+               - MINFO_CLUSTER_TYPE_LOCAL_ALL : lcoal both phone and mmc
+               - MINFO_CLUSTER_TYPE_LOCAL_PHONE : lcoal phone only
+               - MINFO_CLUSTER_TYPE_LOCAL_MMC : lcoal mmc only
+               - MINFO_CLUSTER_TYPE_WEB : web album
+               - MINFO_CLUSTER_TYPE_STREAMING : streaming album
+       - User can set minfo_folder_sort_type
+               - MINFO_CLUSTER_SORT_BY_NONE : No Sort
+               - MINFO_CLUSTER_SORT_BY_NAME_DESC : Sort by display name descending
+               - MINFO_CLUSTER_SORT_BY_NAME_ASC : Sort by display name ascending
+               - MINFO_CLUSTER_SORT_BY_DATE_DESC : Sort by modified_date descending
+               - MINFO_CLUSTER_SORT_BY_DATE_ASC : Sort by modified_date ascending 
+       - User can set start position and end position.
+               - If user want to get all clusters in the database, set -1 to both.
+       - User should define a iterative callback to insert clusters to user list. It makes user to be able to use specific list type user wants.
+
+The following is a sample code:
+
+@code
+#include <media-svc.h>
+
+static int _cluster_ite_fn( Mcluster* cluster, void* user_data)
+{
+       GList** list = (GList**) user_data;
+       *list = g_list_append( *list, cluster );
+
+       return 0;
+}
+
+int get_cluster_list_exam()
+{
+       int err = -1;
+       int img_cnt = 0;
+       int i;
+       Mcluster* cluster;
+       GList* list = NULL
+
+       minfo_cluster_filter cluster_filter_all ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_DATE_ASC,0,10};
+       minfo_cluster_filter cluster_filter_mmc ={MINFO_CLUSTER_TYPE_LOCAL_MMC,MINFO_CLUSTER_SORT_BY_NAME_DESC, -1, -1};
+                       
+       err = minfo_get_cluster_list(cluster_filter_all, _cluster_ite_fn, &p_list);
+
+       if( err < 0)
+       {
+                printf("minfo_get_cluster_list failed\n");
+                return -1;
+       }
+
+       img_cnt = g_list_length(p_list);
+
+       for(i=0; i<img_cnt; i++)
+       {
+               cluster = (Mcluster*)g_list_nth_data(p_list, i);
+               printf("cluster ID=%d, sns_type = %d, display_name= %s, \n", cluster->_id, cluster->sns_type,cluster->display_name);
+       }               
+
+       err = minfo_get_cluster_list(cluster_filter_mmc, _cluster_ite_fn, &p_list);
+
+       if( err < 0)
+       {
+                printf("minfo_get_cluster_list failed\n");
+                return -1;
+       }
+
+       img_cnt = g_list_length(p_list);
+
+       for(i=0; i<img_cnt; i++)
+       {
+               cluster = (Mcluster*)g_list_nth_data(p_list, i);
+               printf("cluster ID=%d, sns_type = %d, display_name= %s, \n", cluster->_id, cluster->sns_type,cluster->display_name);
+       }               
+
+       return 0;
+}
+
+@endcode
+
+<h2 class="pg"> Get a item list of media </h2>
+<b> Purpose </b>
+- To get a list of items in a cluster in the media database.
+
+<b> Usage </b>
+- User can set minfo_item_filter to get what user wants.
+       - User can set minfo_file_type
+               - MINFO_ITEM_NONE : none
+               - MINFO_ITEM_IMAGE : image files
+               - MINFO_ITEM_VIDEO : video files 
+       - User can set minfo_media_sort_type
+               - MINFO_MEDIA_SORT_BY_NONE : No Sort
+               - MINFO_MEDIA_SORT_BY_NAME_DESC : Sort by display name descending
+               - MINFO_MEDIA_SORT_BY_NAME_ASC : Sort by display name ascending
+               - MINFO_MEDIA_SORT_BY_DATE_DESC : Sort by modified_date descending
+               - MINFO_MEDIA_SORT_BY_DATE_ASC : Sort by modified_date ascending 
+       - User can set minfo_media_favorite_type
+               - MINFO_MEDIA_FAV_ALL : Includes all favorite and unfavorite media
+               - MINFO_MEDIA_FAV_ONLY : Includes only favorite media
+               - MINFO_MEDIA_UNFAV_ONLY : Includes only unfavorite media
+       - User can set start position and end position.
+               - If user want to get all items in the cluster, set -1 to both.
+       - User should define a iterative callback to insert items to user list. It makes user to be able to use specific list type user wants.
+
+The following is a sample code:
+
+@code
+
+static int _ite_fn( Mitem* item, void* user_data) 
+{
+       GList** list = (GList**) user_data;
+       *list = g_list_append( *list, item );
+
+       return 0;
+}
+
+int get_item_list_exam()
+{
+       int err = -1;
+       int img_cnt = 0;
+       int cluster_id = 0;
+       int i;
+       Mcluster* cluster;
+       Mitem* cluster;
+       GList* list = NULL
+
+       minfo_item_filter item_filter_all = {MINFO_ITEM_ALL,MINFO_MEDIA_SORT_BY_NONE,-1,-1,false,MINFO_MEDIA_FAV_ALL};
+       minfo_item_filter item_filter_image = {MINFO_ITEM_IMAGE,MINFO_MEDIA_SORT_BY_DATE_DESC,0,1,FALSE, MINFO_MEDIA_FAV_ONLY};
+
+       // Id of the cluster in which user want to get items
+       cluster_id = 1; 
+       err = minfo_get_item_list(cluster_id, item_filter_all, _ite_fn, &p_list);
+
+       if( err < 0)
+       {
+               printf("minfo_get_item_list failed\n");
+               return -1;
+       }
+
+       img_cnt = g_list_length(p_list);
+               
+       for(i=0; i<img_cnt; i++)
+       {
+               mitem = (Mitem*)g_list_nth_data(p_list, i);
+               printf("mitem ID=%d, %s\n",mitem->_id, mitem->file_url);
+       }
+
+       err = minfo_get_item_list(cluster_id, item_filter_image, &p_list);
+
+       if( err < 0)
+       {
+               printf("minfo_get_item_list failed\n");
+               return -1;
+       }
+
+       img_cnt = g_list_length(p_list);
+                       
+       for(i=0; i<img_cnt; i++)
+       {
+               mitem = (Mitem*)g_list_nth_data(p_list, i);
+               printf("mitem ID=%d, %p\n",mitem->_id, mitem);
+       }
+}
+
+@endcode
+
+<h2 class="pg"> Delete a user list, which is got by media-svc </h2>
+<b> Purpose </b>
+- To delete media-svc items that user get through media-svc api.
+
+<b> Usage </b>
+- To delete media-svc specified items, user should call minfo_destroy_mtype_item(). It can delete all media-svc specified types below:
+       - Mcluster
+       - Mitem
+       - Mmeta
+       - Mbookmark
+
+The following is a sample code:
+
+@code
+
+// plist is a list which user get through media-svc api
+int delete_all_mediasvc_items_exam(GList** plist)
+{
+       int count = 0;
+       int i = 0;  
+       void* item = NULL; 
+                                        
+       if(p_list == NULL)
+       {
+               mb_svc_debug("p_list == NULL\n");
+               return MB_SVC_ERROR_INVALID_ARG;
+       }
+
+       count = g_list_length(*p_list);
+
+       for(i = 0; i < count; i++)
+       {
+               item = (void*)g_list_nth_data(*p_list, i);
+
+               minfo_destroy_mtype_item(item);
+               item = NULL; 
+       }
+
+       g_list_free(*p_list);
+       *p_list = NULL; 
+       return 0;
+}
+
+
+@endcode
+
+<h2 class="pg"> Add a cluster to DB</h2>
+<b> Purpose </b>
+- To make and add new cluster to the media database.
+
+<b> Usage </b>
+- User must specify the url of the cluster path.
+- User can get the id of the new cluster. 
+
+The following is a sample code:
+
+@code
+
+int minfo_add_cluster_exam()
+{
+       const char* cluster_url = "/opt/media/Images and videos/new";
+       int new_cluster_id;
+
+       err = minfo_add_cluster(cluster_url, &new_cluster_id);
+
+       if( err < 0)
+       {
+               printf("minfo_add_media failed\n");
+               return -1;
+       }
+       else 
+       {
+               printf("minfo_add_media succeed. New cluster's id is %d\n", new_cluster_id);
+               return 0;
+       }
+}
+
+@endcode
+
+<h2 class="pg"> Delete a cluster from DB</h2>
+<b> Purpose </b>
+- To delete a cluster in the media database.
+
+<b> Usage </b>
+- User can delete a media by the id of the cluster.
+
+The following is a sample code:
+
+@code
+
+int minfo_delete_cluster_exam()
+{
+       int cluster_id = 1;
+
+       err = minfo_delete_cluster(cluster_id);
+
+       if( err < 0)
+       {
+               printf("minfo_delete_media failed\n");
+               return -1;
+       }
+}
+
+@endcode
+
+<h2 class="pg"> Add a media to DB</h2>
+<b> Purpose </b>
+- To add user's media item to the media database.
+
+<b> Usage </b>
+- User must specify the url of the media file.
+- User must specify a type of the media. ( image or video )
+
+The following is a sample code:
+
+@code
+
+int minfo_add_media_exam()
+{
+       const char* file_url = "/opt/media/Images and videos/image.jpg";
+       minfo_file_type type = MINFO_ITEM_IMAGE;
+
+       err = minfo_add_media(file_url, type);
+
+       if( err < 0)
+       {
+               printf("minfo_add_media failed\n");
+               return -1;
+       }
+}
+
+@endcode
+
+<h2 class="pg"> Update a media to DB</h2>
+<b> Purpose </b>
+- To update media in the media database.
+
+<b> Usage </b>
+- To update a name of cluster, call minfo_update_cluster_name()
+       -User must specify the id of the cluster and new name user wants.
+- To update a favorite set of media item, call minfo_update_media_favorite()
+       -User must specify the id of the media and a value of favorite ( true or false )
+- To update a name of media item, call minfo_update_media_name()
+       -User must specify the id of the media and new name user wants.
+- To update meta information of integer type of video item, call minfo_update_video_meta_info_int()
+       - User can set minfo_video_meta_field_t
+               - MINFO_VIDEO_META_ID :  media medta ID field
+               - MINFO_VIDEO_META_MEDIA_ID media medta ID field
+               - MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED : medta bookmark field
+               - MINFO_VIDEO_META_DURATION : medta duration field
+- To update meta information of string type of video item, call minfo_update_video_meta_info_string()
+       - User can set minfo_video_meta_field_t
+               - MINFO_VIDEO_META_ALBUM : medta album field
+               - MINFO_VIDEO_META_ARTIST : medta artist field
+               - MINFO_VIDEO_META_TITLE : medta title field
+               - MINFO_VIDEO_META_DESCRIPTION : medta description field
+               - MINFO_VIDEO_META_YOUTUBE_CATEGORY : medta youtube cat field
+
+The following is a sample code:
+
+@code
+
+int minfo_update_cluster_name_exam()
+{
+       int err = -1;
+       int cluster_id = 1;
+       const char* new_name = "NewCluster";
+
+       err = minfo_update_cluster_name(cluster_id, new_name);
+
+       if( err < 0)
+       {
+               printf("minfo_update_cluster_name failed\n");
+               return -1;
+       }
+}
+
+int minfo_update_media_name_exam()
+{
+       int err = -1;
+       int media_id = 1;
+       const char* new_name = "NewMedia";
+
+       err = minfo_update_media_name(media_id, new_name);
+
+       if( err < 0)
+       {
+               printf("minfo_update_media_name failed\n");
+               return -1;
+       }
+}
+
+int minfo_update_media_favorite_exam()
+{
+       int err = -1;
+       int media_id = 1;
+       int favorite = TRUE;
+
+       err = minfo_update_media_favorite(media_id, favorite);
+
+       if( err < 0)
+       {
+               printf("minfo_update_media_favorite failed\n");
+               return -1;
+       }
+}
+
+int minfo_update_media_videometa_exam()
+{
+       int err = -1;
+       int media_id = 1;
+       minfo_video_meta_field_t meta_field;
+       int last_played_time = 1259000000;
+       const char* title = "New Title";
+
+       // Update last played time
+       err = minfo_update_video_meta_info_int(media_id, last_played_time);
+
+       if( err < 0)
+       {
+               printf("minfo_update_video_meta_info_int failed\n");
+               return -1;
+       }
+
+       // Update title
+       err = minfo_update_video_meta_info_string(media_id, title);
+
+       if( err < 0)
+       {
+               printf("minfo_update_video_meta_info_string failed\n");
+               return -1;
+       }
+}
+
+@endcode
+
+<h2 class="pg">  Copy media </h2>
+<b> Purpose </b>
+- To copy media from original folder to the other folder, not only updating database but also operating system call.
+
+<b> Usage </b>
+- User can copy a media by the path of origin media and the path of destination cluster. In this case, user should call minfo_copy_media().
+       - User must specify minfo_file_type.
+               - MINFO_ITEM_IMAGE : image
+               - MINFO_ITEM_VIDEO : video
+- User can copy a media by the id of the origin media and the id of destination cluster. In this case, user should call minfo_cp_media().
+
+The following is a sample code:
+
+@code
+
+int minfo_copy_exam_by_path()
+{
+       const char* file_url = "/opt/media/Images and videos/image.jpg";
+       const char* dest_url = "/opt/media/Images and videos/second";
+       minfo_file_type file_type = MINFO_ITEM_IMAGE;
+
+       err = minfo_copy_media(file_url, dest_url, file_type);
+
+       if( err < 0)
+       {
+               printf("minfo_copy_media failed\n");
+               return -1;
+       }
+}
+
+int minfo_copy_exam_by_id()
+{
+       int media_id = 1;
+       int dest_cluster_id = 3;
+
+       err = minfo_cp_media(media_id, dest_cluster_id );
+
+       if( err < 0)
+       {
+               printf("minfo_copy_media failed\n");
+               return -1;
+       }
+}
+
+@endcode
+
+<h2 class="pg">  Move media </h2>
+<b> Purpose </b>
+- To move media from original folder to the other folder, not only updating database but also operating system call.
+
+<b> Usage </b>
+- User can move a media by the path of origin media and the path of destination cluster. In this case, user should call minfo_move_media().
+       - User must specify minfo_file_type.
+               - MINFO_ITEM_IMAGE : image
+               - MINFO_ITEM_VIDEO : video
+- User can move a media by the id of the origin media and the id of destination cluster. In this case, user should call minfo_mv_media().
+
+The following is a sample code:
+
+@code
+
+int minfo_move_exam_by_path()
+{
+       const char* file_url = "/opt/media/Images and videos/image.jpg";
+       const char* dest_url = "/opt/media/Images and videos/second";
+       minfo_file_type file_type = MINFO_ITEM_IMAGE;
+
+       err = minfo_move_media(file_url, dest_url, file_type);
+
+       if( err < 0)
+       {
+               printf("minfo_move_media failed\n");
+               return -1;
+       }
+}
+
+int minfo_move_exam_by_id()
+{
+       int media_id = 1;
+       int dest_cluster_id = 3;
+
+       err = minfo_mv_media(media_id, dest_cluster_id );
+
+       if( err < 0)
+       {
+               printf("minfo_mv_media failed\n");
+               return -1;
+       }
+}
+
+@endcode
+
+<h2 class="pg"> Get a thumbnail of media </h2>
+<b> Purpose </b>
+- To get thumbnail of the choosen media.
+
+<b> Usage </b>
+- User must specify the url of the video or image media .
+- If thumbnail of the media exists, just set the filepath of the thumbnail. If not, create new thumbnail and set the filepath of the thumbnail.
+
+The following is a sample code:
+
+@code
+
+int minfo_get_thumb_path_exam()
+{
+       int ret = -1;
+       const char* file_url = "/opt/media/Images and videos/image.jpg";
+       char thumb_path[255] = {0,};
+
+
+       ret = minfo_get_thumb_path(file_url, thumb_path, 255);
+
+       if(ret < 0)
+       {
+               printf("minfo_get_thumb_path fails\n" );
+               return -1;
+       }
+
+       printf("minfo_get_thumb_path : %s\n", thumb_path);
+}
+
+@endcode
+
+@}
+*/
+
diff --git a/include/audio-svc-error.h b/include/audio-svc-error.h
new file mode 100755 (executable)
index 0000000..8e10d99
--- /dev/null
@@ -0,0 +1,74 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+\r
+#ifndef _AUDIO_SVC_ERROR_H_\r
+#define _AUDIO_SVC_ERROR_H_\r
+\r
+/**\r
+       @addtogroup AUDIO_SVC\r
+       @{\r
+       * @file         audio-svc-error.h\r
+       * @brief                This file defines error codes for audio service.\r
+\r
+ */\r
+\r
+/**\r
+        @defgroup AUDIO_SVC_COMMON  Global data structure and error code\r
+        @{\r
+\r
+        @par\r
+         type definition and error code\r
+ */\r
+\r
+\r
+#define AUDIO_SVC_ERROR_NONE                                                   0                       /**< No Error */\r
+\r
+#define AUDIO_SVC_ERROR_INVALID_PARAMETER                      -1                      /**< Invalid parameter */\r
+#define AUDIO_SVC_ERROR_INVALID_MEDIA                          -2                      /**< Invalid media */\r
+#define AUDIO_SVC_ERROR_FILE_NOT_EXIST                                 -3                      /**< File not exist */\r
+\r
+#define AUDIO_SVC_ERROR_FILE_IO                                                -11                     /**< File IO error */\r
+#define AUDIO_SVC_ERROR_OUT_OF_MEMORY                          -12                     /**< Out of memory */\r
+\r
+#define AUDIO_SVC_ERROR_MAKE_PLAYLIST_NAME_FAILED      -101            /**< fail to make new playlist name */\r
+\r
+#define AUDIO_SVC_ERROR_DB_CONNECT                                     -201            /**< DB connect error */\r
+#define AUDIO_SVC_ERROR_DB_DISCONNECT                          -202            /**< DB disconnect error */\r
+#define AUDIO_SVC_ERROR_DB_CREATE_TABLE                                -203            /**< DB create table error */\r
+#define AUDIO_SVC_ERROR_DB_NO_RECORD                           -204            /**< Item not found in DB */\r
+#define AUDIO_SVC_ERROR_DB_OUT_OF_RANGE                                -205            /**< Invalid range */\r
+#define AUDIO_SVC_ERROR_DB_INTERNAL                                    -206            /**< DB internal error */\r
+\r
+#define AUDIO_SVC_ERROR_NOT_IMPLEMENTED                                -997            /**< Not implemented */\r
+#define AUDIO_SVC_ERROR_INTERNAL                                               -998            /**< Internal error */\r
+#define AUDIO_SVC_ERROR_UNKNOWN                                                -999            /**< Unknown error */\r
+\r
+/**\r
+       @}\r
+*/\r
+\r
+/**\r
+       @}\r
+*/\r
+\r
+#endif /*_AUDIO_SVC_ERROR_H_*/\r
diff --git a/include/audio-svc-types.h b/include/audio-svc-types.h
new file mode 100755 (executable)
index 0000000..b0abe5a
--- /dev/null
@@ -0,0 +1,262 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+\r
+#ifndef _AUDIO_SVC_TYPES_H_\r
+#define _AUDIO_SVC_TYPES_H_\r
+\r
+/**\r
+       @addtogroup AUDIO_SVC\r
+       @{\r
+                * @file                        audio-svc-types.h\r
+                * @brief               This file defines various types and macros of audio service.\r
+\r
+ */\r
+\r
+/**\r
+        @addtogroup AUDIO_SVC_COMMON\r
+        @{\r
+*/\r
+\r
+\r
+#define AUDIO_SVC_METADATA_LEN_MAX                     193                                             /**<  Length of metadata*/\r
+#define AUDIO_SVC_FILENAME_SIZE                                1024                                    /**<  Length of File name.*/\r
+#define AUDIO_SVC_PATHNAME_SIZE                                4096                                    /**<  Length of Path name. */\r
+#define AUDIO_SVC_PLAYLIST_NAME_SIZE                   101                                             /**<  Length of palylist name*/\r
+#define AUDIO_SVC_FAVORITE_LIST_ID                             0                                               /**< The index for favorite list*/\r
+#define AUDIO_SVC_UUID_SIZE                                            36                                              /**< Length of UUID*/\r
+\r
+/**\r
+ * Handle type\r
+ */\r
+typedef int AudioHandleType;           /**< Handle type */\r
+\r
+\r
+/**\r
+ * Type definition for storage_type\r
+ */\r
+typedef enum{\r
+       AUDIO_SVC_STORAGE_PHONE,                        /**< Phone storage*/\r
+       AUDIO_SVC_STORAGE_MMC,                  /**< MMC storage*/\r
+}audio_svc_storage_type_e;\r
+\r
+/**\r
+ * Type definition for category\r
+ */\r
+typedef enum{\r
+       AUDIO_SVC_CATEGORY_MUSIC,               /**< Music Category*/\r
+       AUDIO_SVC_CATEGORY_SOUND                /**< Sound Category*/\r
+}audio_svc_category_type_e;\r
+\r
+/**\r
+ * Type definition for rating\r
+ */\r
+typedef enum{\r
+       AUDIO_SVC_RATING_NONE,                  /**< No rating or Rating 0*/\r
+       AUDIO_SVC_RATING_1,                             /**< Rating 1*/\r
+       AUDIO_SVC_RATING_2,                             /**< Rating 2*/\r
+       AUDIO_SVC_RATING_3,                             /**< Rating 3*/\r
+       AUDIO_SVC_RATING_4,                             /**< Rating 4*/\r
+       AUDIO_SVC_RATING_5,                             /**< Rating 5*/\r
+}audio_svc_rating_type_e;\r
+\r
+/**\r
+       @}\r
+ */\r
+\r
+/**\r
+        @addtogroup AUDIO_SVC_GROUP_API\r
+        @{\r
+*/\r
+\r
+/**\r
+ * Type definition for group\r
+ */\r
+typedef enum{\r
+       AUDIO_SVC_GROUP_BY_ALBUM,                                       /**< Group by album*/\r
+       AUDIO_SVC_GROUP_BY_ARTIST,                                      /**< Group by artist*/\r
+       AUDIO_SVC_GROUP_BY_ARTIST_ALBUM,                        /**< Group by album which has special artist condition*/\r
+       AUDIO_SVC_GROUP_BY_GENRE,                                       /**< Group by genre*/\r
+       AUDIO_SVC_GROUP_BY_GENRE_ARTIST,                                /**< Group by artist which has special genre condition*/\r
+       AUDIO_SVC_GROUP_BY_GENRE_ALBUM,                         /**< Group by album which has special genre condition*/\r
+       AUDIO_SVC_GROUP_BY_GENRE_ARTIST_ALBUM,          /**< Group by album which has special genre and artist condirion*/\r
+       AUDIO_SVC_GROUP_BY_FOLDER,                                      /**< Group by folder*/\r
+       AUDIO_SVC_GROUP_BY_YEAR,                                                /**< Group by year*/\r
+       AUDIO_SVC_GROUP_BY_COMPOSER                             /**< Group by author*/\r
+}audio_svc_group_type_e;\r
+\r
+\r
+/**\r
+ * Type definition for tracks\r
+ */\r
+typedef enum{\r
+       AUDIO_SVC_TRACK_ALL,                                                    /**< All tracks*/\r
+       AUDIO_SVC_TRACK_BY_ALBUM,                                       /**< Album tracks*/\r
+       AUDIO_SVC_TRACK_BY_ARTIST_ALBUM,                                /** < Albums which has special artist condition */\r
+       AUDIO_SVC_TRACK_BY_ARTIST,                                      /**< Artist tracks*/\r
+       AUDIO_SVC_TRACK_BY_ARTIST_GENRE,                                /**< Genre tracks which has special artist condition*/\r
+       AUDIO_SVC_TRACK_BY_GENRE,                                               /**< Genre tracks*/\r
+       AUDIO_SVC_TRACK_BY_FOLDER,                                      /**< Genre tracks*/\r
+       AUDIO_SVC_TRACK_BY_YEAR,                                                /**< Year tracks*/\r
+       AUDIO_SVC_TRACK_BY_COMPOSER,                            /**< Author tracks*/\r
+       AUDIO_SVC_TRACK_BY_TOPRATING,                           /**< Toprating tracks*/\r
+       AUDIO_SVC_TRACK_BY_PLAYED_TIME,                         /**< Recently played tracks*/\r
+       AUDIO_SVC_TRACK_BY_ADDED_TIME,                          /**< Recently added tracks*/\r
+       AUDIO_SVC_TRACK_BY_PLAYED_COUNT,                                /**< Most played tracks*/\r
+       AUDIO_SVC_TRACK_BY_PLAYLIST,                                    /**< User playlist tracks*/\r
+}audio_svc_track_type_e;\r
+\r
+/**\r
+ * Type definition for group data\r
+ */\r
+typedef enum{\r
+       AUDIO_SVC_GROUP_ITEM_MAIN_INFO,                         /**< The main group info for the list*/\r
+       AUDIO_SVC_GROUP_ITEM_SUB_INFO,                          /**< The sub group info for the list*/\r
+       AUDIO_SVC_GROUP_ITEM_THUMBNAIL_PATH,            /**< Thumbnail path of first item in the group */\r
+       AUDIO_SVC_GROUP_ITEM_RATING,                                    /**< Album rating*/\r
+}audio_svc_group_item_type_e;\r
+\r
+/**\r
+ * Type definition for list data (track meta data)\r
+ */\r
+typedef enum{\r
+       AUDIO_SVC_LIST_ITEM_AUDIO_ID,                                   /**< Unique media file index*/\r
+       AUDIO_SVC_LIST_ITEM_PATHNAME,                           /**< Full path and file name of media file*/\r
+       AUDIO_SVC_LIST_ITEM_THUMBNAIL_PATH,                     /**< Thumbnail path of first item in the group */\r
+       AUDIO_SVC_LIST_ITEM_TITLE,                                              /**< Title of media file */\r
+       AUDIO_SVC_LIST_ITEM_ARTIST,                                     /**< Artist of media file */\r
+       AUDIO_SVC_LIST_ITEM_DURATION,                                   /**< Duration of media file*/\r
+       AUDIO_SVC_LIST_ITEM_RATING,                                     /**< The rating used in mtp*/\r
+}audio_svc_list_item_type_e;\r
+\r
+/**\r
+ * Type definition of track meta data for playlist\r
+ */\r
+\r
+typedef enum{\r
+       AUDIO_SVC_PLAYLIST_ITEM_UID,                                            /**< Unique index of playlist item*/\r
+       AUDIO_SVC_PLAYLIST_ITEM_AUDIO_ID,                                       /**< Unique media file index*/\r
+       AUDIO_SVC_PLAYLIST_ITEM_PATHNAME,                               /**< Full path and file name of media file*/\r
+       AUDIO_SVC_PLAYLIST_ITEM_THUMBNAIL_PATH,                 /**< Thumbnail path of first item in the group */\r
+       AUDIO_SVC_PLAYLIST_ITEM_TITLE,                                          /**< Title of media file */\r
+       AUDIO_SVC_PLAYLIST_ITEM_ARTIST,                                 /**< Artist of media file */\r
+       AUDIO_SVC_PLAYLIST_ITEM_DURATION,                               /**< Duration of media file*/\r
+       AUDIO_SVC_PLAYLIST_ITEM_RATING,                                 /**< The rating used in mtp*/\r
+       AUDIO_SVC_PLAYLIST_ITEM_PLAY_ORDER,                             /**     < Play order of media file*/\r
+}audio_svc_playlist_item_type_e;\r
+\r
+/**\r
+       @}\r
+ */\r
+\r
+/**\r
+        @addtogroup AUDIO_SVC_ITEM_API\r
+        @{\r
+*/\r
+\r
+/**\r
+ * Type definition for track meta data\r
+ */\r
+typedef enum{\r
+       AUDIO_SVC_TRACK_DATA_STORAGE,                           /**< Storage of media file : internal/external*/\r
+       AUDIO_SVC_TRACK_DATA_AUDIO_ID,                          /**< Unique media file index*/\r
+       AUDIO_SVC_TRACK_DATA_PATHNAME,                          /**< Full path and file name of media file*/\r
+       AUDIO_SVC_TRACK_DATA_THUMBNAIL_PATH,            /**< Thumbnail image file path*/\r
+       AUDIO_SVC_TRACK_DATA_PLAYED_COUNT,                      /**< Played count*/\r
+       AUDIO_SVC_TRACK_DATA_PLAYED_TIME,                       /**< Last played time*/\r
+       AUDIO_SVC_TRACK_DATA_ADDED_TIME,                        /**< Added time*/\r
+       AUDIO_SVC_TRACK_DATA_RATING,                                    /**< User defined rating*/\r
+       AUDIO_SVC_TRACK_DATA_CATEGORY,                          /**< Category : Music/Sound*/\r
+       AUDIO_SVC_TRACK_DATA_TITLE,                                     /**< Track title*/\r
+       AUDIO_SVC_TRACK_DATA_ARTIST,                                    /**< Artist name*/\r
+       AUDIO_SVC_TRACK_DATA_ALBUM,                                     /**< Album name*/\r
+       AUDIO_SVC_TRACK_DATA_GENRE,                                     /**< Genre of track*/\r
+       AUDIO_SVC_TRACK_DATA_AUTHOR,                            /**< Author name*/\r
+       AUDIO_SVC_TRACK_DATA_COPYRIGHT,                         /**< Copyright of track*/\r
+       AUDIO_SVC_TRACK_DATA_DESCRIPTION,                       /**< Description of track*/\r
+       AUDIO_SVC_TRACK_DATA_FORMAT,                            /**< Format of track*/\r
+       AUDIO_SVC_TRACK_DATA_DURATION,                          /**< Duration of track*/\r
+       AUDIO_SVC_TRACK_DATA_BITRATE,                           /**< Bitrate of track*/\r
+       AUDIO_SVC_TRACK_DATA_YEAR,                                      /**< Year of track*/\r
+       AUDIO_SVC_TRACK_DATA_TRACK_NUM,                 /**< Trac number*/\r
+       AUDIO_SVC_TRACK_DATA_ALBUM_RATING,                      /**< Rating of Album*/\r
+       AUDIO_SVC_TRACK_DATA_FAVOURATE  ,                       /**< Favourate of media file*/\r
+}audio_svc_track_data_type_e;\r
+/**\r
+       @}\r
+ */\r
+\r
+/**\r
+        @addtogroup AUDIO_SVC_PLST_API\r
+        @{\r
+*/\r
+\r
+\r
+/**\r
+ * Type definition for track meta data\r
+ */\r
+typedef enum{\r
+       AUDIO_SVC_PLAYLIST_ID,                                          /**< Playlist ID*/\r
+       AUDIO_SVC_PLAYLIST_NAME,                                        /**< Playlist Name*/\r
+       AUDIO_SVC_PLAYLIST_THUMBNAIL_PATH               /**< Thumbnail path of first item in the playlist */\r
+}audio_svc_playlist_e;\r
+\r
+/**\r
+ * Type definition for search field\r
+ */\r
+typedef enum {\r
+       AUDIO_SVC_SEARCH_TITLE,                                 /**< Track title*/\r
+       AUDIO_SVC_SEARCH_ALBUM,                                 /**< Album name*/\r
+       AUDIO_SVC_SEARCH_ARTIST,                                /**< Artist name*/\r
+       AUDIO_SVC_SEARCH_GENRE,                                 /**< Genre of track*/\r
+       AUDIO_SVC_SEARCH_AUTHOR                                 /**< Author name*/\r
+} audio_svc_serch_field_e;\r
+\r
+/**\r
+ * Type definition for order field\r
+ */\r
+typedef enum {\r
+       AUDIO_SVC_ORDER_BY_TITLE_DESC,                                  /**< Title descending */\r
+       AUDIO_SVC_ORDER_BY_TITLE_ASC,                                   /**< Title ascending */\r
+       AUDIO_SVC_ORDER_BY_ALBUM_DESC,                                  /**< Album descending*/\r
+       AUDIO_SVC_ORDER_BY_ALBUM_ASC,                                   /**< Album ascending*/\r
+       AUDIO_SVC_ORDER_BY_ARTIST_DESC,                                 /**< Artist descending*/\r
+       AUDIO_SVC_ORDER_BY_ARTIST_ASC,                                  /**< Artist ascending*/\r
+       AUDIO_SVC_ORDER_BY_GENRE_DESC,                                  /**< Genre descending*/\r
+       AUDIO_SVC_ORDER_BY_GENRE_ASC,                                   /**< Genre ascending*/\r
+       AUDIO_SVC_ORDER_BY_AUTHOR_DESC,                                 /**< Author descending*/\r
+       AUDIO_SVC_ORDER_BY_AUTHOR_ASC,                                  /**< Author ascending*/\r
+       AUDIO_SVC_ORDER_BY_PLAY_COUNT_DESC,                             /**< Play count descending*/\r
+       AUDIO_SVC_ORDER_BY_PLAY_COUNT_ASC,                              /**< Play count ascending*/\r
+       AUDIO_SVC_ORDER_BY_ADDED_TIME_DESC,                             /**< Added time descending*/\r
+       AUDIO_SVC_ORDER_BY_ADDED_TIME_ASC,                              /**< Added time ascending*/\r
+} audio_svc_search_order_e;\r
+\r
+/**\r
+       @}\r
+ */\r
+\r
+/**\r
+       @}\r
+ */\r
+\r
+#endif /*_AUDIO_SVC_TYPES_H_*/\r
diff --git a/include/audio-svc.h b/include/audio-svc.h
new file mode 100755 (executable)
index 0000000..3404707
--- /dev/null
@@ -0,0 +1,3584 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#ifndef _AUDIO_SVC_H_
+#define _AUDIO_SVC_H_
+
+#include <stddef.h>
+#include "audio-svc-types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+       @defgroup       AUDIO_SVC       Audio Service
+       @{
+        * @file                        audio-svc.h
+        * @brief               This file defines API's for audio service.
+        * @version             1.0
+ */
+
+/**
+        @defgroup AUDIO_SVC_DB_API    Database Manager API
+        @{
+
+        @par
+        manage the service database.
+ */
+
+
+/**
+ *     audio_svc_open:\n
+ *     Open audio service library. This is the function that an user who wants to use music-service calls first.
+ *     This function connects with the music database and initialize efreet mime libary.
+ *
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ *                             Please refer 'audio-svc-types.h' to know the exact meaning of the error.
+ *     @see            audio_svc_close
+ *     @pre            None.
+ *     @post           call audio_svc_close() to close music database
+ *     @remark The database name is "/opt/dbspace/.music.db".
+ *     @par example
+ *     @code
+
+#include <audio-svc.h>
+
+void open_music_db()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       // open music database
+       ret = audio_svc_open();
+       // open failed
+       if (ret < 0)
+       {
+               printf( "Cannot open music db. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+int audio_svc_open(void);
+
+
+/**
+ *    audio_svc_close:\n
+ *     Close audio service library. This is the function need to call before close the application.
+ *     This function disconnects with the music database and shutdown the efreet mime libary.
+ *
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ *                             Please refer 'audio-svc-types.h' to know the exact meaning of the error.
+ *     @see            audio_svc_open
+ *     @pre            music database already is opened.
+ *     @post           None
+ *     @remark memory free before you call this function to close database.
+ *     @par example
+ *     @code
+
+#include <audio-svc.h>
+
+void close_music_db()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       // close music database
+       ret = audio_svc_close();
+       // close failed
+       if (ret < 0)
+       {
+               printf( "unable to close music db. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+int audio_svc_close(void);
+
+
+/**
+ *    audio_svc_create_table:\n
+ *     Create the tables in music database. File manager service need to call this function before it register media data into
+ *     music database. In all music database consists of 5 tables, music table for Phone tracks, music table for MMC tracks,
+ *     music view for both Phone and MMC tracks, playlist table, and playlist items table.\n
+ *
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ *                             Please refer 'audio-svc-types.h' to know the exact meaning of the error.
+ *     @remark This function is called only by file manager service library.
+ *     @pre            open music database firstly.
+ *     @post           None.
+ *     @see            audio_svc_open
+ *     @par example
+ *     @code
+
+#include <audio-svc.h>
+
+void create_music_table()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       // create muisc tables of phone type
+       ret = audio_svc_create_table();
+       if (ret < 0)
+       {
+               printf( "unable to create table. error code->%d", ret);
+               return;
+       }
+
+       return ret;
+}
+
+ *     @endcode
+ */
+int    audio_svc_create_table(void);
+
+/**
+ *     audio_svc_set_db_valid:\n
+ *     This function set whether all the tracks in a storage are valid.
+ *     Actually audio service filter all the tracks query from database by the track validation.\n
+ *     This function is always used for MMC card insert/inject operation, in file manager service library.
+ *     When inject a MMC card, the track records for MMC are not deleted really, but are set to be invalid.
+ *
+ *     @param[in]   storage_type               information for storage type
+ *     @param[in]      valid                           whether the track item is valid.
+ *     @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @see            audio_svc_set_item_valid
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <audio-svc.h>
+
+void set_db_valid(bool valid)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       //set the validation of tracks in MMC storage in db.
+       ret = audio_svc_set_db_valid(AUDIO_SVC_STORAGE_MMC, valid);
+       if (ret < 0)
+       {
+               printf( "failed to set db invalid. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+int audio_svc_set_db_valid(audio_svc_storage_type_e storage_type, int valid);
+
+/**
+ *     audio_svc_delete_all:\n
+ *     This function deletes all  items in a storage, from both the tracks table (phone/mmc table) and the playlist items table.
+ *     This function also delete the existing thumbnail image files associated with the tracks.
+ *
+ *     @param[in]      storage_type    storage type to delete
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            None
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void delete_all()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       // delete all the tracks in phone storage.
+       ret = audio_svc_delete_all(AUDIO_SVC_STORAGE_PHONE);
+       if (ret < 0)
+       {
+               printf( "failed to delete phone storage. error code->%d", ret);
+               return;
+       }
+       return;
+}
+
+ *     @endcode
+ */
+int audio_svc_delete_all(audio_svc_storage_type_e storage_type);
+
+
+/** @} */
+
+/**
+        @defgroup AUDIO_SVC_GROUP_API     music group manager API
+        @{
+        @par
+        manage group list and its contents
+ */
+
+
+/**
+ *      audio_svc_count_group_item:\n
+ *     This function counts the number of unique group name according to group type with filter condition.
+ *     This parameter "limit_string1" is necessary to specify parent group. It should be defined in case group type is
+ *     AUDIO_SVC_GROUP_BY_ARTIST_ALBUM, AUDIO_SVC_GROUP_BY_GENRE_ARTIST, AUDIO_SVC_GROUP_BY_GENRE_ALBUM,
+ *     AUDIO_SVC_GROUP_BY_GENRE_ARTIST_ALBUM.
+ *     This parameter "limit_string2" is necessary to specify subgroup. It should be defined in case group type
+ *     is AUDIO_SVC_GROUP_BY_GENRE_ARTIST_ALBUM.
+ *
+ *     @param[in]              group_type              group type (refer to audio_svc_group_type_e)
+ *     @param[in]              limit_string1           It is possible to make a subgroup within a specific group.
+ *     @param[in]              limit_string2           It is possible to make a small group of subgroup.
+ *     @param[in]              filter_string           the filter condition for group name.
+ *     @param[in]              filter_string2          the filter condition for group name.
+ *     @param[out]             count           the returned group count.
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @par example     audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ARTIST_ALBUM, "abc", NULL)
+ *                                     => It counts unique album which artist name is "abc".
+ *     @par example    audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_GENRE_ARTIST_ALBUM, "abc", "123")
+ *                                     => It counts unique album which genre name is "abc" and artist name is "123".
+ *     @pre                    None
+ *     @post                   None
+ *     @see                    audio_svc_get_group_item
+ *     @remark         None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+ void get_group_count()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int count = -1;
+
+       // count the groups by artist
+       ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ARTIST, "", "", "", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get groups. error code->%d", ret);
+               return;
+       }
+
+       printf("group count is %d", count);
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_count_group_item(audio_svc_group_type_e group_type, const char *limit_string1, const char *limit_string2, const char *filter_string, const char *filter_string2, int *count);
+
+
+/**
+ *      audio_svc_get_group_item:\n
+ *     This function retrieves unique group name according to group type.
+ *     This parameter "limit_string1" is necessary to specify parent group, It should be defined in case group type
+ *     is AUDIO_SVC_GROUP_BY_ARTIST_ALBUM, AUDIO_SVC_GROUP_BY_GENRE_ARTIST, AUDIO_SVC_GROUP_BY_GENRE_ALBUM,
+ *     or AUDIO_SVC_GROUP_BY_GENRE_ARTIST_ALBUM.\n
+ *     This parameter "limit_string2" is necessary to specify subgroup. It should be defined in case group type is
+ *     AUDIO_SVC_GROUP_BY_GENRE_ARTIST_ALBUM.
+ *
+ *     @param[in]              group_type              group type (refer to audio_svc_group_type_e)
+ *     @param[in]              limit_string1           It is possible to make a subgroup within a specific group.
+ *     @param[in]              limit_string2           It is possible to make a small group of subgroup.
+ *     @param[in]              filter_string           the filter condition for group name.
+ *     @param[in]              filter_string2          the filter condition for group name.
+ *     @param[in]              offset                  start position to fetch the records satisfied with given condition.
+ *     @param[in]              rows                    the number of required records which is satisfied with given condition.
+ *     @param[out]             result_records  reference pointer of result records.
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ *                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+  *    @pre            None
+ *     @post           None
+ *     @see            audio_svc_get_list_item
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void get_groups()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int count = -1;
+       AudioHandleType *handle = NULL;
+
+       //count the albms with name "Unplugged"
+       ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of groups. error code->%d", ret);
+               return;
+       }
+
+       if(count > 0)
+       {
+               // allocate the result records with count
+               ret = audio_svc_group_item_new(&handle, count);
+               if (ret < 0)
+               {
+                       printf( "failed to allocate handle. error code->%d", ret);
+                       return;
+               }
+
+               ret = audio_svc_get_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", 0, ret, handle);
+               if (ret < 0)
+               {
+                       printf( "failed to get groups. error code->%d", ret);
+               }
+               audio_svc_group_item_free(handle);
+       }
+       else
+       {
+               printf( "There is no track items");
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_get_group_item(audio_svc_group_type_e group_type, const char *limit_string1, const char *limit_string2, const char *filter_string, const char *filter_string2,int offset, int rows, AudioHandleType *result_records);
+
+
+/**
+ *     audio_svc_group_item_new:\n
+ *     This function is used to allocate  a block (an array) of elements of type AudioHandleType for group items.
+ *     where number of elements is speicified by the second parameter "count". Therefore, the first parameter
+ *     "record" points to a valid block of memory with space for "count" elements.
+ *
+ *     @param[in]              record          The handle for service group items
+ *     @param[in]              count           the elements number
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre                    None.
+ *     @post                   None
+ *     @see                    audio_svc_group_item_free
+ *     @remark         None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void group_item_new()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *handle = NULL;
+       int count = 5;
+
+       //allocate the memory of type group item with count
+       ret = audio_svc_group_item_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_group_item_new(AudioHandleType **record, int count);
+
+
+/**
+ *     audio_svc_group_item_free:\n
+ *     This function is used to free memory allocated for arrays of element with type AudioHandleType for group items.
+ *     The value passed as argument to delete must be either a pointer to a memory block previously allocated
+ *     with audio_svc_group_item_new(), or a null pointer (in the case of a null pointer, this function produces no effect).
+ *
+ *     @param[in]      record          The handle for service list
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None.
+ *     @post           None
+ *     @see            audio_svc_group_item_new.
+ *     @remark None.
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void group_item_free()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *handle = NULL;
+       int count = 5;
+
+       //allocate the memory of type group item with count
+       ret = audio_svc_group_item_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       //free the list item memory.
+       ret = audio_svc_group_item_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+
+ *     @endcode
+ */
+
+int audio_svc_group_item_free(AudioHandleType *record);
+
+
+/**
+ *     audio_svc_group_item_get_val:\n
+ *     This function allows to retrieve a group attributes for the specified element in the elements array by index.
+ *     This function takes a variable number of arguments, the arguments format is pair of atrribute index and attribute value.
+ *     The last parameter should be "-1", which tell the compiler that the arguments list is over.
+ *
+ *     @param[in]      record          The handle for service list
+ *     @param[in]      index           The element index in array
+ *     @param[in]      first_field_name        the variable arguements list
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None.
+ *     @post           None.
+ *     @see            audio_svc_group_item_new, audio_svc_group_item_free.
+ *     @remark None.
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void get_group_item_get_value()
+{
+       int count = 0;
+       AudioHandleType *handle = NULL;
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of groups. error code->%d", ret);
+               return;
+       }
+
+       if(count > 0)
+       {
+               // allocate the result records with count
+               ret = audio_svc_group_item_new(&handle, count);
+               if (ret < 0)
+               {
+                       printf( "failed to allocate handle. error code->%d", ret);
+                       return;
+               }
+
+               ret = audio_svc_get_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", 0, count, handle);
+               if (ret < 0)
+               {
+                       printf( "failed to get groups. error code->%d", ret);
+                       audio_svc_group_item_free(handle);
+                       return;
+               }
+       }
+       else
+       {
+               printf( "There is no track items");
+               return;
+       }
+
+       for (i = 0; i < count; i++)
+       {
+               char *main_info = NULL, *sub_info = NULL, *thumbname = NULL;
+               int album_rating = AUDIO_SVC_RATING_NONE;
+               int size = 0;
+               int count = 0;
+
+               //get the group info
+               ret = audio_svc_group_item_get_val(groups, i ,
+                       AUDIO_SVC_GROUP_ITEM_THUMBNAIL_PATH, &thumbname, &size,
+                       AUDIO_SVC_GROUP_ITEM_MAIN_INFO, &main_info, &size,
+                       AUDIO_SVC_GROUP_ITEM_SUB_INFO, &sub_info, &size,
+                       AUDIO_SVC_GROUP_ITEM_RATING, &album_rating,
+                       -1);
+
+               if (ret < 0)
+               {
+                       printf( "failed to get group items. error code->%d", ret);
+                       audio_svc_group_item_free(handle);
+                       return;
+               }
+       }
+
+       ret = audio_svc_group_item_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_group_item_get_val(AudioHandleType *record, int index, audio_svc_group_item_type_e first_field_name, ...);
+
+
+/**
+ *     audio_svc_group_item_get:\n
+ *     This function is used to retrieve the element from elements arrary by index.
+ *
+ *     @param[in]              record          The handle for service list
+ *     @param[in]              index           The element index
+ *     @param[out]     item            the element to be retrieved.
+ *     @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                      Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            None
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void get_group_item()
+{
+       int count = 0;
+       AudioHandleType *handle = NULL;
+       AudioHandleType *item = NULL;
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of groups. error code->%d", ret);
+               return;
+       }
+
+       if(count > 0)
+       {
+               // allocate the result records with count
+               ret = audio_svc_group_item_new(&handle, count);
+
+               ret = audio_svc_get_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", 0, count, handle);
+               if (ret < 0)
+               {
+                       printf( "failed to allocate handle. error code->%d", ret);
+                       return;
+               }
+
+               if (ret < 0)
+               {
+                       printf( "failed to get groups. error code->%d", ret);
+                       audio_svc_group_item_free(handle);
+                       return;
+               }
+       }
+       else
+       {
+               printf( "There is no track items");
+               return;
+       }
+
+       ret = audio_svc_group_item_get(handle,0, &item);
+       if (ret < 0)
+       {
+               printf( "failed to get group item. error code->%d", ret);
+               return;
+       }
+
+       ret = audio_svc_group_item_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_group_item_get(AudioHandleType *record, int index, AudioHandleType **item);
+
+
+/**
+ *     audio_svc_count_list_item:\n
+ *      This function counts the number of items according to item type.\n
+ *     The param type_string defines the group name contains the tracks. If item type is AUDIO_SVC_TRACK_BY_ALBUM, AUDIO_SVC_TRACK_BY_ARTIST,
+ *     AUDIO_SVC_TRACK_BY_GENRE, AUDIO_SVC_TRACK_BY_YEAR or AUDIO_SVC_TRACK_BY_COMPOSER the type_string should be defined. If item type is AUDIO_SVC_TRACK_BY_PLAYLIST, the type_string
+ *     should be entered as type string after converting playlist index to character type.\n
+ *     The filter string act as the LIKE cluase for item title in the SQL condition search. The parameter "rows" and "offset"
+ *     is used as the LIMIT expression and OFFSET expression.
+ *
+ *     @param[in]              item_type               item retrieval type or order type (refer to audio_svc_track_type_e)
+ *     @param[in]              type_string             This parameter is necessayto retrieve items belonging to specific group.
+ *     @param[in]              type_string2            This parameter is necessayto retrieve items belonging to specific group.
+ *     @param[in]              filter_string           the filter condition for track title.
+ *     @param[in]              filter_string2          the filter condition for track title.
+ *     @param[out]             count                   the returned tracks count.
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @see                    audio_svc_count_group_item
+ *     @pre                    None
+ *     @post                   None
+ *     @remark         None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void get_item_count()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int count = -1;
+       // get the count of all tracks in db.
+       ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of items. error code->%d", ret);
+               return;
+       }
+
+       printf("item count is %d", count);
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_count_list_item(audio_svc_track_type_e item_type, const char *type_string, const char *type_string2, const char *filter_string, const char *filter_string2, int *count);
+
+
+/**
+ *     audio_svc_get_list_item:\n
+ *     This function retrieves items according to item type. The param type_string defines the group name contains the tracks.
+ *     If item type is AUDIO_SVC_TRACK_BY_ALBUM, AUDIO_SVC_TRACK_BY_ARTIST, AUDIO_SVC_TRACK_BY_GENRE,
+ *     AUDIO_SVC_TRACK_BY_YEAR or AUDIO_SVC_TRACK_BY_COMPOSER the type_string should be defined. If item type is AUDIO_SVC_TRACK_BY_PLAYLIST, the type_string
+ *     should be entered as type string after converting playlist index to character type.\n
+ *     The filter string act as the LIKE cluase for item title in the SQL condition search. The parameter "rows" and "offset"
+ *     is used as the LIMIT expression and OFFSET expression.
+ *
+ *     @param[in]              item_type               item retrieval type or order type (refer to audio_svc_track_type_e)
+ *     @param[in]              type_string             This parameter is necessayto retrieve items belonging to specific group.
+ *     @param[in]              type_string2            This parameter is necessayto retrieve items belonging to specific group.
+ *     @param[in]              filter_string           the filter condition for track title.
+ *     @param[in]              filter_string2          the filter condition for track title.
+ *     @param[in]              offset                  start position to fetch the records satisfied with given condition.
+ *     @param[in]              rows                    the number of required records which is satisfied with given condition.
+ *     @param[out]             track                   reference pointer of result records.
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @see                    audio_svc_count_list_item
+ *     @pre                    None
+ *     @post                   None
+ *     @remark         None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void get_track_item()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *handle = NULL;
+       int count = -1;
+
+       // get the count of all tracks
+       ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of items. error code->%d", ret);
+               return;
+       }
+
+       if(count > 0)
+       {
+               // allocate result records
+               ret = audio_svc_list_item_new(&handle, count);
+               if (ret < 0)
+               {
+                       printf( "failed to allocate handle. error code->%d", ret);
+                       return;
+               }
+
+               // get items
+               ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", 0, ret, handle);
+
+               if (ret < 0)
+               {
+                       printf( "failed to  get items. error code->%d", ret);
+                       audio_svc_list_item_free(handle);
+                       return;
+               }
+               audio_svc_list_item_free(handle);
+       }
+       else
+       {
+               printf( "There is no track items");
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_get_list_item(audio_svc_track_type_e item_type, const char *type_string, const char *type_string2, const char *filter_string, const char *filter_string2, int offset, int rows, AudioHandleType *track);
+
+
+/**
+ *     audio_svc_list_item_new:\n
+ *     This function is used to allocate  a block (an array) of elements of type AudioHandleType.
+ *     where number of elements is speicified by the second parameter "count". Therefore, the first parameter
+ *     "record" points to a valid block of memory with space for "count" elements.
+ *
+ *     @param[in]              record          The handle for service list
+ *     @param[in]              count           the elements number
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre                    None.
+ *     @post                   None
+ *     @see                    audio_svc_list_item_free
+ *     @remark         None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void list_item_new()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *handle = NULL;
+       int count = 5;
+
+       //allocate the memory of type list item with count
+       ret = audio_svc_list_item_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_list_item_new(AudioHandleType **record, int count);
+
+/**
+ *     audio_svc_list_item_free:\n
+ *     This function is used to free memory allocated for arrays of element with type AudioHandleType.
+ *     The value passed as argument to delete must be either a pointer to a memory block previously allocated
+ *     with audio_svc_list_item_new(), or a null pointer (in the case of a null pointer, this function produces no effect).
+ *
+ *     @param[in]      record          The handle for service list
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None.
+ *     @post           None
+ *     @see            audio_svc_list_item_new.
+ *     @remark None.
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void list_item_free()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *handle = NULL;
+       int count = 5;
+
+       //allocate the memory of type list item with count
+       ret = audio_svc_list_item_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       //free the list item memory.
+       ret = audio_svc_list_item_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+
+ *     @endcode
+ */
+
+int audio_svc_list_item_free(AudioHandleType *record);
+
+/**
+ *     audio_svc_list_item_get_val:\n
+ *     This function allows to retrieve a list of attributes for the specified element in the elements array by index.
+ *     This function takes a variable number of arguments, the arguments format is pair of atrribute index and attribute value.
+ *     The last parameter should be "-1", which tell the compiler that the arguments list is over.
+ *
+ *     @param[in]      record          The handle for service list
+ *     @param[in]      index           The element index in array
+ *     @param[in]      first_field_name        the variable arguements list
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None.
+ *     @post           None
+ *     @see            audio_svc_list_item_new, audio_svc_list_item_free.
+ *     @remark None.
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void get_list_item_get_value()
+{
+       int count = 0;
+       AudioHandleType *handle = NULL;
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of items. error code->%d", ret);
+               return;
+       }
+
+       ret = audio_svc_list_item_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       //get the all track items.
+       ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,
+               NULL, //type_string,
+               NULL, //type_string2,
+               NULL, //filter_string,
+               NULL, //filter_string2,
+               0, //offset,
+               count, //rows,
+               handle
+               );
+
+       if (ret < 0)
+       {
+               audio_svc_list_item_free(handle);
+               return;
+       }
+
+       for (i = 0; i < count; i++)
+       {
+               char *audio_id = NULL, *title = NULL, *artist = NULL, *thumbname = NULL, *pathname = NULL;
+               int rating = AUDIO_SVC_RATING_NONE;
+               int duration = 0;
+               int size = 0;
+
+               ret = audio_svc_list_item_get_val(handle, i ,
+                       AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, &size,
+                       AUDIO_SVC_LIST_ITEM_THUMBNAIL_PATH, &thumbname, &size,
+                       AUDIO_SVC_LIST_ITEM_TITLE, &title, &size,
+                       AUDIO_SVC_LIST_ITEM_ARTIST, &artist, &size,
+                       AUDIO_SVC_LIST_ITEM_PATHNAME, &pathname, &size,
+                       AUDIO_SVC_LIST_ITEM_DURATION, &duration,
+                       AUDIO_SVC_LIST_ITEM_RATING, &rating,
+                       -1);
+
+               if (ret < 0)
+               {
+                       printf( "failed to get list items. error code->%d", ret);
+                       audio_svc_list_item_free(handle);
+                       return;
+               }
+       }
+
+       ret = audio_svc_list_item_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_list_item_get_val(AudioHandleType *record, int index, audio_svc_list_item_type_e first_field_name, ...);
+
+
+/**
+ *     audio_svc_list_item_get:\n
+ *     This function is used to retrieve the element from elements arrary by index.
+ *
+ *     @param[in]      record          The handle for service list
+ *     @param[in]      index           The element index
+ *     @param[out]     item            the element to be retrieved.
+ *     @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                      Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            None
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void get_svc_item()
+{
+       AudioHandleType *handle = NULL;
+       AudioHandleType *item = NULL;
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int count = 0;
+       int i = 0
+
+       ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of items. error code->%d", ret);
+               return;
+       }
+
+       ret = audio_svc_list_item_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       //get the all tracks item.
+       ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,
+               NULL, //type_string,
+               NULL, //type_string2,
+               NULL, //filter_string,
+               NULL, //filter_string2,
+               0, //offset,
+               count, //rows,
+               handle
+               );
+
+       if (ret < 0)
+       {
+               printf( "failed to get items. error code->%d", ret);
+               audio_svc_list_item_free(handle);
+               return;
+       }
+
+       for (i = 0; i < count; i++)
+       {
+               char *audio_id = NULL;
+               int size = 0;
+               //get the list item with index "i"
+               ret = audio_svc_list_item_get(handle, i, &item);
+               if (ret < 0)
+               {
+                       printf( "failed to get list items. error code->%d", ret);
+                       audio_svc_list_item_free(handle);
+                       return;
+               }
+
+               ret = audio_svc_list_item_get_val(item, 0, AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, &size, -1);
+               if (ret < 0)
+               {
+                       printf( "failed to get list items value. error code->%d", ret);
+                       audio_svc_list_item_free(handle);
+                       return;
+               }
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_list_item_get(AudioHandleType *record, int index, AudioHandleType **item);
+
+
+/** @} */
+
+/**
+        @defgroup AUDIO_SVC_ITEM_API     music item manager API
+        @{
+        @par
+        manage music item.
+ */
+
+/**
+ *     audio_svc_item_new:\n
+ *     This function is used to allocate  a block (an array) of elements of type AudioHandleType,
+ *     where number of elements is speicified by the second parameter "count". Therefore, the first parameter
+ *     "record" points to a valid block of memory with space for "count" elements of type audio_svc_audio_item_s.
+ *
+ *     @param[in]      record          The handle for service item
+ *     @param[in]      count           the elements number
+ *     @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                      Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            audio_svc_item_free
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void new_svc_item()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *handle = NULL;
+
+       //create the svc item object.
+       ret = audio_svc_item_new(&handle);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+}
+
+ *     @endcode
+ */
+
+int audio_svc_item_new(AudioHandleType **record);
+
+/**
+ *     audio_svc_item_free:\n
+ *     This function is used to free memory allocated for arrays of element with type AudioHandleType.
+ *     The value passed as argument to delete must be either a pointer to a memory block previously allocated
+ *     with audio_svc_item_new(), or a null pointer (in the case of a null pointer, this function produces no effect).
+ *
+ *     @param[in]      record          The handle for service item
+ *
+ *     @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                      Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            audio_svc_item_new
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void free_svc_item()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *handle = NULL;
+
+       //create svc item object, object number is count.
+       ret = audio_svc_item_new(&handle);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       //free the svc item object.
+       ret = audio_svc_item_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_item_free(AudioHandleType *record);
+
+
+/**
+ *     audio_svc_item_get_val:\n
+ *     This function allows to retrieve a list of attributes for the specified element in the elements array by index.
+ *     This function takes a variable number of arguments, the arguments format is pair of atrribute index and attribute value.
+ *     The last parameter should be "-1", which tell the compiler that the arguments list is over.
+ *
+ *     @param[in]      record          The handle for service list
+ *     @param[in]      first_field_name        the variable arguements list
+ *
+ *     @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                      Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            audio_svc_item_set_val
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <audio-svc.h>
+
+void get_svc_item_value()
+{
+       int count = 0;
+       AudioHandleType*handle = NULL;
+
+       ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of items. error code->%d", ret);
+               return;
+       }
+
+       ret = audio_svc_list_item_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       //get all tracks from db.
+       ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,
+               NULL, //type_string,
+               NULL, //type_string2,
+               NULL, //filter_string,
+               NULL, //filter_string2,
+               0, //offset,
+               count, //count,
+               handle
+               );
+
+       if (ret < 0)
+       {
+               printf( "failed to get items. error code->%d", ret);
+               audio_svc_list_item_free(handle);
+               return;
+       }
+
+       ret = audio_svc_item_new(&item);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       for (i = 0; i < count; i++)
+       {
+               int size = 0;
+               char *audio_id = NULL, *title = NULL, *album = NULL, *artist = NULL, *thumbname = NULL;
+               //get the track audio_id with index "i" in handle array.
+               ret = audio_svc_list_item_get_val(handle, i, AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, &size, -1);
+               if (ret < 0)
+               {
+                       printf( "failed to get list items. error code->%d", ret);
+                       audio_svc_item_free(item);
+                       audio_svc_list_item_free(handle);
+                       return;
+               }
+
+               ret = audio_svc_get_item_by_audio_id(audio_id, item);
+               if (ret < 0)
+               {
+                       printf( "failed to get items. error code->%d", ret);
+                       audio_svc_item_free(item);
+                       audio_svc_list_item_free(handle);
+                       return;
+               }
+
+               //get the property value of svc item
+               ret = audio_svc_item_get_val(item,
+                       AUDIO_SVC_TRACK_DATA_AUDIO_ID, &audio_id, &size, 
+                       AUDIO_SVC_TRACK_DATA_TITLE, &title, &size,
+                       AUDIO_SVC_TRACK_DATA_ALBUM, &album, &size,
+                       AUDIO_SVC_TRACK_DATA_ARTIST, &artist, &size,
+                       AUDIO_SVC_TRACK_DATA_THUMBNAIL_PATH, &thumbname, &size,
+                       -1);
+               if (ret < 0)
+               {
+                       printf( "failed to get item value. error code->%d", ret);
+                       audio_svc_item_free(item);
+                       audio_svc_list_item_free(handle);
+                       return;
+               }
+       }
+       ret = audio_svc_item_free(item);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       ret = audio_svc_list_item_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_item_get_val(AudioHandleType *record, audio_svc_track_data_type_e  first_field_name, ...);
+
+/**
+ *     audio_svc_search_item_new:\n
+ *     This function is used to allocate  a block (an array) of elements of type AudioHandleType to be searched,
+ *     where number of elements is speicified by the second parameter "count". Therefore, the first parameter
+ *     "record" points to a valid block of memory with space for "count" elements of type audio_svc_audio_item_s.
+ *
+ *     @param[in]      record          The handle for service item
+ *     @param[in]      count           the elements number
+ *     @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                      Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            audio_svc_search_item_free, audio_svc_search_item_get
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void new_search_item()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *handle = NULL;
+
+       //create the search item object.
+       ret = audio_svc_search_item_new(&handle, 10);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+}
+
+ *     @endcode
+ */
+
+int audio_svc_search_item_new(AudioHandleType **record, int count);
+
+/**
+ *     audio_svc_search_item_get:\n
+ *     This function is used to retrieve the element from searched elements arrary by index.
+ *
+ *     @param[in]      record          The handle for search list
+ *     @param[in]      index           The element index
+ *     @param[out]     item            the element to be retrieved.
+ *     @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                      Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            audio_svc_list_by_search, audio_svc_search_item_free, audio_svc_search_item_new
+ *     @remark None
+ *     @par example
+ *     @code
+#include <audio-svc.h>
+
+void test_audio_svc_list_by_search()
+{
+               int offset = 0, count = 10, i = 0;
+               const char *str = "Sa";
+               AudioHandleType *handle = NULL;
+
+               err = audio_svc_search_item_new(&handle, count);
+               if (err < 0) {
+                       printf("audio_svc_search_item_new failed:%d\n", err);
+                       return err;
+               }
+
+               err = audio_svc_list_by_search(handle, AUDIO_SVC_ORDER_BY_TITLE_ASC, offset, count, AUDIO_SVC_SEARCH_TITLE, str, strlen(str), AUDIO_SVC_SEARCH_ALBUM, str, strlen(str), AUDIO_SVC_SEARCH_ARTIST, str, strlen(str), -1);
+
+               if (err != AUDIO_SVC_ERROR_NONE) {
+                       mediainfo_dbg("Fail to get items : %d", err);
+                       return err;
+               }
+               
+               for (i = 0; i < count; i++) {
+                       AudioHandleType *item = NULL;
+                       err = audio_svc_search_item_get(handle, i, &item);
+                       char *audio_id = NULL, *title = NULL, *artist = NULL, *pathname = NULL, *album = NULL;
+                       int size = 0;
+                       if (err < 0) {
+                               printf("[%d] audio_svc_search_item_get failed : %d\n", i, err);
+                       } else {
+                               audio_svc_item_get_val(item,  
+                                               AUDIO_SVC_TRACK_DATA_AUDIO_ID, &audio_id, &size, 
+                                               AUDIO_SVC_TRACK_DATA_PATHNAME, &pathname, &size,
+                                               AUDIO_SVC_TRACK_DATA_TITLE, &title, &size,
+                                               AUDIO_SVC_TRACK_DATA_ARTIST, &artist, &size,
+                                               AUDIO_SVC_TRACK_DATA_ALBUM, &album, &size,
+                                               -1);
+
+                               if( audio_id == NULL ) break;
+
+                               printf("[%d] ID: %s\n", i, audio_id);
+                               printf("[%d] Path: %s\n", i, pathname);
+                               printf("[%d] Title: %s\n", i, title);
+                               printf("[%d] Artist: %s\n", i, artist);
+                               printf("[%d] Album: %s\n", i, album);
+                       }
+               }
+
+               audio_svc_search_item_free(handle);
+}
+
+
+ *     @endcode
+ */
+
+int audio_svc_search_item_get(AudioHandleType *record, int index, AudioHandleType **item);
+
+/**
+ *     audio_svc_search_item_free:\n
+ *     This function is used to free memory allocated for arrays of element with type AudioHandleType to be searched.
+ *     The value passed as argument to delete must be either a pointer to a memory block previously allocated
+ *     with audio_svc_item_new(), or a null pointer (in the case of a null pointer, this function produces no effect).
+ *
+ *     @param[in]      record          The handle for search item
+ *
+ *     @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                      Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            audio_svc_search_item_new, audio_svc_search_item_get
+ *     @remark None
+ *     @par example
+ *     @code
+
+  #include <audio-svc.h>
+
+void free_search_item()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *handle = NULL;
+
+       //create search item object, object number is count.
+       ret = audio_svc_search_item_new(&handle, 10);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       //free the search item object.
+       ret = audio_svc_search_item_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_search_item_free(AudioHandleType *record);
+
+int audio_svc_insert_item_start(int data_cnt);
+int audio_svc_insert_item_end(void);
+
+/**
+ *    audio_svc_insert_item:\n
+ *     Register music track into DB. The "Category" property is defined by file manager service, and Only
+ *     "MUSIC" type tracks can be listed in music app.
+ *     This function extract the metadata of track then insert it into the database.
+ *
+ *     @param[in]              storage_type    Information for storage type
+ *     @param[in]              path                    Information for file path
+ *     @param[in]              category                        Information for file category, defined by file manager.
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @see            None
+ *     @remark None
+ *     @pre            music table is already created
+ *     @post           None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void insert_item_to_db()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       const char *path = "/opt/media/Sounds/Music/Layla.mp3";
+       int category = AUDIO_SVC_CATEGORY_MUSIC;
+       // insert a track into music db
+       ret = audio_svc_insert_item(AUDIO_SVC_STORAGE_PHONE, path, category);
+
+       if (ret < 0)
+       {
+               printf( "unable to insert item, error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+int audio_svc_insert_item(audio_svc_storage_type_e storage_type, const char *path, audio_svc_category_type_e category);
+
+int audio_svc_move_item_start(int data_cnt);
+int audio_svc_move_item_end(void);
+
+
+/**
+ *     audio_svc_move_item:\n
+ *     This function moves item with source path to destination.\n
+ *     This function is called by file manager service when user move music file in myfile app. Audio Service need
+ *     to create the thumbnail path of new item itself.
+ *
+ *     @param[in]      src_storage             Storage type of the src_path
+ *     @param[in]      src_path                        file full path before moving
+ *     @param[in]      dest_storage    Storage type of the dest_path
+ *     @param[in]      dest_path               file full path after moving
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @see            None
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+ void move_item()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       audio_svc_storage_type_e storage = AUDIO_SVC_STORAGE_PHONE;
+       const char *dest_path = "/opt/media/Sounds/BeyondSamsung.mp3";
+       const char *src_path = "/opt/media/Sounds/Music/BeyondSamsung.mp3";
+       // move the track to dest path
+       ret = audio_svc_move_item(storage, src_path, storage, dest_path);
+
+       if (ret < 0)
+       {
+               printf( "failed to move item. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+*      @endcode
+*/
+
+int audio_svc_move_item(audio_svc_storage_type_e src_storage, const char *src_path, audio_svc_storage_type_e dest_storage, const char *dest_path);
+
+
+/**
+ *    audio_svc_delete_item_by_path:\n
+ *     This function deletes item with file path from music database. deleting the track from phone/MMC track
+ *     table, the service also deleting the same track from playlist item table.
+ *
+ *     @param[in]      path                    Full file path.
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @see            audio_svc_get_item_by_path
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+ void delete_item_by_path()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       // delete music item by path
+       ret = audio_svc_delete_item_by_path("test.mp3");
+       if (ret < 0)
+       {
+               printf("failed to delete item by path. error code->%d", ret);
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+int audio_svc_delete_item_by_path(const char *path);
+
+
+/**
+ *     audio_svc_delete_invalid_items:\n
+ *     This function deletes invalid items in a storage, from both the tracks table (phone/mmc table).
+ *     This function also delete the existing thumbnail image files associated with the tracks.
+ *
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            None
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void delete_all()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       audio_svc_storage_type_e storage = AUDIO_SVC_STORAGE_PHONE;
+       
+       // delete all invalid item in phone storage.
+       ret = audio_svc_delete_invalid_items(storage);
+       if (ret < 0)
+       {
+               printf( "failed to delete invalid item. error code->%d", ret);
+               return;
+       }
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_delete_invalid_items(audio_svc_storage_type_e storage);
+
+int audio_svc_set_item_valid_start(int data_cnt);
+int audio_svc_set_item_valid_end(void);
+
+/**
+ *     audio_svc_set_item_valid:\n
+ *     This function set whether a track is valid in database.If a track is not valid, then it cannot be listed in music application.
+ *     Actually audio service filter all the tracks query from database by the track validation.\n
+ *     This function is always used for MMC card insert/inject operation, in file manager service library.
+ *
+ *     @param[in]      path                    file full path
+ *     @param[in]      valid                   whether the track item is valid.
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            None
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void set_item_valid()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       const char * test_path = "/opt/media/Sounds/Music/Layla.mp3";
+
+       //set the track with "audio_id" in MMC storage to be valid.
+       ret = audio_svc_set_item_valid(test_path, true);
+       if (ret < 0)
+       {
+               printf( "failed to set item valid. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_set_item_valid(const char *path, int valid);
+
+
+/**
+ *    audio_svc_get_item_by_audio_id:\n
+ *     This function retrieves music track item with db index, querying from the virtual view including all phone
+ *     tracks and MMC tracks. The parameter "item" should be allocated before calling this function.
+ *
+ *     @param[in]              audio_id                                        Information for db index
+ *     @param[out]     item_handle                             Information for music track record.
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @see            audio_svc_get_item_by_path
+ *     @remark None
+ *     @pre            None
+ *     @post           None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+ void get_item_by_audio_id()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *handle = NULL;
+       char audio_id[AUDIO_SVC_UUID_SIZE+1] = "550e8400-e29b-41d4-a716-446655440000";
+
+       ret = audio_svc_item_new(&handle);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       // retrieve the music item by audio_id.
+       ret = audio_svc_get_item_by_audio_id(audio_id, handle);
+       if (ret < 0)
+       {
+               printf("failed to get item by audio_id. error code->%d", ret);
+               audio_svc_item_free(handle);
+               return;
+       }
+
+       //free the music item
+       ret = audio_svc_item_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+int audio_svc_get_item_by_audio_id(const char *audio_id, AudioHandleType *item_handle);
+
+
+/**
+ *    audio_svc_get_item_by_path:\n
+ *     This function retrieves music track item with file path, querying from the virtual view including all phone
+ *     tracks and MMC tracks. The parameter "item" should be allocated before calling this function.
+ *
+ *     @param[out]             item_handle                     Information for music track record.
+ *     @param[in]              path            Information for file path.
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @see            audio_svc_get_item_by_audio_id
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <audio-svc.h>
+
+void get_item_by_path()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       const char *path = "/opt/media/Sounds/Music/Layla.mp3";
+       AudioHandleType *handle = NULL;
+
+       ret = audio_svc_item_new(&handle);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       // retrieve the music item by file path.
+       ret = audio_svc_get_item_by_path(path, handle);
+       if (ret < 0)
+       {
+               printf("failed to get item by path. error code->%d", ret);
+               audio_svc_item_free(handle);
+               return;
+       }
+
+       //free the music item
+       ret = audio_svc_item_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+int audio_svc_get_item_by_path(const char *path, AudioHandleType *item_handle);
+
+
+/**
+ *     audio_svc_check_item_exist:\n
+ *     This function check whether item(content) is exist or not in DB.
+ *     Application can use this when before delete item or update item and so on..
+ *
+ *     @param[in]      path                    the file path.
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success or when item exist, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            None
+ *     @remark None
+ *     @par example
+ *     @code
+
+  #include <audio-svc.h>
+
+void check_item_Exist()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       const char *path = "/opt/media/Sounds/Music/The Last Laugh.mp3";
+
+       //check item exist
+       ret = audio_svc_check_item_exist(path);
+       if (ret < 0)
+       {
+               printf("Item not found");
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_check_item_exist(const char *path);
+
+
+/**
+ *     audio_svc_get_path_by_audio_id:\n
+ *     This function retrieves the track pathname by its db index.\n
+ *     Sometimes application only knows the track's db index and want to extract its thumbnail image, then it can
+ *     use this function to get path firstly.
+ *
+ *     @param[in]      audio_id                                Information for db index
+ *     @param[in]      path                            Full path of track
+  *    @param[in]      max_path_length Max path length
+ *     @return                         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre                            None
+ *     @post                           None
+ *     @see                            None
+ *     @remark                 None
+ *     @par example
+ *     @code
+ *
+ #include <audio-svc.h>
+
+char * get_path_by_audio_id (const char *audio_id)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int count = -1;
+       char pathname[AUDIO_SVC_PATHNAME_SIZE] = {0,};
+
+       //retrieve the file path by track audio_id.
+       ret = audio_svc_get_path_by_audio_id(audio_id, pathname, AUDIO_SVC_PATHNAME_SIZE);
+       if (ret < 0)
+       {
+               printf( "failed to get path. error code->%d", ret);
+               return NULL;
+       }
+       return pathname;
+}
+ *     @endcode
+ */
+int audio_svc_get_path_by_audio_id(const char *audio_id, char *path, size_t max_path_length);
+
+
+/**
+ *     audio_svc_get_audio_id_by_path:\n
+ *     This function retrieves the track index by track path.\n
+ *     Application can use this api when only knows the track's path and want to know its db index.
+ *
+ *     @param[in]              path                    Full path of track
+ *     @param[out]     audio_id                                Information for db index
+ *     @return                                                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                                                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre                                                    None
+ *     @post                                                   None
+ *     @see                                                    None
+ *     @remark                                         None
+ *     @par example
+ *     @code
+ *
+ #include <audio-svc.h>
+
+int get_audio_id_by_path ()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       const char * test_path = "/opt/media/Sounds/Music/Layla.mp3";
+       char audio_id[AUDIO_SVC_UUID_SIZE+1] = {0,};
+
+       //retrieve the file path by track audio_id.
+       ret = audio_svc_get_audio_id_by_path(test_path, audio_id, AUDIO_SVC_UUID_SIZE);
+       if (ret < 0)
+       {
+               printf( "failed to get audio_id. error code->%d", ret);
+               return 0;
+       }
+
+       return audio_id;
+}
+ *     @endcode
+ */
+
+int audio_svc_get_audio_id_by_path(const char *path, char *audio_id, size_t max_audio_id_length);
+
+/**
+ *     audio_svc_get_thumbnail_path_by_path:\n
+ *     This function retrieves the thumbnail path by track path.\n
+ *     Application can use this api when only knows the track's path.
+ *
+ *     @param[in]              path                                            Full path of track
+ *     @param[in]              max_thumb_path_length           Max thumb path length
+ *     @param[out]     thumb_path                                      thumbnail path of track
+ *     @return                                                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                                                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre                                                    None
+ *     @post                                                   None
+ *     @see                                                    None
+ *     @remark                                         None
+ *     @par example
+ *     @code
+ *
+ #include <audio-svc.h>
+
+int get_thumbnail_path_by_path ()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       const char * test_path = "/opt/media/Sounds/Music/Layla.mp3";
+       char thumb_path[AUDIO_SVC_PATHNAME_SIZE] = {0};
+
+       //retrieve the thumbnail path by track path.
+       ret = audio_svc_get_thumbnail_path_by_path(test_path, thumb_path, AUDIO_SVC_PATHNAME_SIZE);
+       if (ret < 0)
+       {
+               printf( "failed to get thumbnail_path. error code->%d", ret);
+               return ret;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+ *     @endcode
+ */
+
+int audio_svc_get_thumbnail_path_by_path(const char *path, char *thumb_path, size_t max_thumb_path_length);
+
+
+/**
+ *     audio_svc_update_item_metadata:\n
+ *     This function allows to update attributes for the specified element.
+ *     This function takes a variable number of arguments, the arguments format is pair of atrribute index and attribute value.
+ *     The last parameter should be "-1", which tell the compiler that the arguments list is over.
+ *
+ *     @param[in]      audio_id                                db index of item to update play time
+ *     @param[in]      first_field_name        the variable arguements list
+ *
+ *     @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                      Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            None
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void update_svc_item()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *handle = NULL;
+       int count = 0;
+
+       ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of items. error code->%d", ret);
+               return;
+       }
+
+       ret = audio_svc_list_item_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       //get all tracks from db.
+       ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,
+               NULL, //type_string,
+               NULL, //type_string2,
+               NULL, //filter_string,
+               NULL, //filter_string2,
+               0, //offset,
+               count, //count,
+               handle
+               );
+
+       if (ret < 0)
+       {
+               printf( "failed to get service list items. error code->%d", ret);
+               audio_svc_list_item_free(handle);
+               return;
+       }
+
+       for (i = 0; i < count; i++)
+       {
+               char *audio_id = NULL;
+               int size = 0;
+               ret = audio_svc_list_item_get_val(handle, i, AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, &size, -1);
+               if (ret < 0)
+               {
+                       printf( "failed to get list items. error code->%d", ret);
+                       audio_svc_list_item_free(handle);
+                       return;
+               }
+
+               ret = audio_svc_update_item_metadata(audio_id,
+                       AUDIO_SVC_TRACK_DATA_PLAYED_COUNT, 5,
+                       AUDIO_SVC_TRACK_DATA_PLAYED_TIME, 5,
+                       AUDIO_SVC_TRACK_DATA_ADDED_TIME, 5,
+                       AUDIO_SVC_TRACK_DATA_RATING,     AUDIO_SVC_RATING_5,
+                       AUDIO_SVC_TRACK_DATA_TITLE, "Test title", strlen("Test title"),
+                       AUDIO_SVC_TRACK_DATA_ARTIST, "Test artist", strlen("Test artist"),
+                       AUDIO_SVC_TRACK_DATA_ALBUM, "Test album", strlen("Test album"),
+                       AUDIO_SVC_TRACK_DATA_GENRE, "Test genre", strlen("Test genre"),
+                       AUDIO_SVC_TRACK_DATA_AUTHOR, "Test author", strlen("Test author"),
+                       AUDIO_SVC_TRACK_DATA_DESCRIPTION, "Test description", strlen("Test description"),
+                       AUDIO_SVC_TRACK_DATA_YEAR, 2011,
+                       AUDIO_SVC_TRACK_DATA_TRACK_NUM, 10,
+                       AUDIO_SVC_TRACK_DATA_ALBUM_RATING, AUDIO_SVC_RATING_5,
+                       -1);
+
+               if (ret < 0)
+               {
+                       printf( "failed to update items. error code->%d", ret);
+                       audio_svc_list_item_free(handle);
+                       return;
+               }
+
+       }
+
+       ret = audio_svc_list_item_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_update_item_metadata(const char *audio_id, audio_svc_track_data_type_e  first_field_name, ...);
+
+
+/**
+ *     audio_svc_refresh_metadata:\n
+ *     This function extracts metadata from file and save them into database. \n
+ *     This function checks whether the metadata is already extracted, if so, then do nothing and return. If not, then extracted metadata by
+ *     mm-fileinfo middleware library API, and update the music record in database with the result metadata.
+ *
+ *     @param[in]      audio_id                                db index of item to refresh metadata
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @remark This function will be called when receiving right object of DRM content.
+ *                             If it has already valid metadata, then it just returns TRUE without extracting metadata.
+ *     @pre            None
+ *     @post           None
+ *     @see            None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <audio-svc.h>
+
+void
+refresh_drm_metadata()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       char * test_audio_id = "550e8400-e29b-41d4-a716-446655440000";
+
+       ret = audio_svc_refresh_metadata(test_audio_id);
+       if (ret < 0)
+       {
+               printf( "failed to refresh metadata. error code->%d", ret);
+               return;
+       }
+       return;
+}
+
+ *     @endcode
+ */
+int audio_svc_refresh_metadata(const char *audio_id);
+
+
+/** @} */
+
+/**
+        @defgroup AUDIO_SVC_PLST_API     Playlist API
+        @{
+        @par
+        manage playlist and its contents.
+ */
+
+
+/**
+ *     audio_svc_count_playlist:\n
+ *     This function counts the playlists created by user by given filter condition. The filter string act as the LIKE cluase for playlist name in
+ *     the SQL condition search, such as "where name like %s".
+ *
+ *     @param[in]              filter_string           the filter for playlist name.
+ *     @param[in]              filter_string2          the filter for playlist name.
+  *    @param[out]             count                   the return count of playlist.
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre                    None
+ *     @post                   None
+ *     @see                    audio_svc_get_playlist
+ *     @remark         None
+ *     @par example
+ *     @code
+
+#include <audio-svc.h>
+
+void get_playlist_count()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int count = -1;
+
+       // get the count of all playlist in db.
+       ret = audio_svc_count_playlist("", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of playlists. error code->%d", ret);
+               return;
+       }
+
+       printf("playlist count is %d", count);
+
+       return;
+}
+
+*      @endcode
+*/
+
+int audio_svc_count_playlist(const char *filter_string, const char *filter_string2, int *count);
+
+
+/**
+ *     audio_svc_get_playlist:\n
+ *     This function retrieves the playlists created by user with given filter condition. The filter string act as the LIKE cluase for playlist name in
+ *     the SQL condition search. The parameter "rows" and "offset" is used as the LIMIT expression and OFFSET expression.
+ *
+ *     @param[in]              filter_string           the filter for playlist name.
+ *     @param[in]              filter_string2          the filter for playlist name.
+  *    @param[in]              offset                  start position to fetch the records
+ *     @param[in]              rows                    the number of required records
+ *     @param[out]     playlists                       reference pointer of result records. Its memory size should be rows*sizeof(audio_svc_playlist_s).
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @see                    audio_svc_count_playlist
+ *     @pre                    None
+ *     @post                   None
+ *     @remark         None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void get_playlists()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int count = -1;
+       AudioHandleType *handle = NULL;
+
+       // get the count of all playlist in db.
+       ret = audio_svc_count_playlist("", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of playlists. error code->%d", ret);
+               return;
+       }
+
+       if(count < 1)
+       {
+               printf("there is no playlist");
+               return;
+       }
+
+       ret = audio_svc_playlist_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       ret = audio_svc_get_playlist("", "", 0, count, handle);
+       if (ret < 0)
+       {
+               printf( "failed to get playlists. error code->%d", ret);
+               audio_svc_playlist_free(handle);
+               return;
+       }
+
+       ret = audio_svc_playlist_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_get_playlist(const char *filter_string, const char *filter_string2, int offset, int rows, AudioHandleType *playlists);
+
+
+/**
+ *     audio_svc_playlist_new:\n
+ *     This function is used to allocate  a block (an array) of elements of type AudioHandleType,
+ *     where number of elements is speicified by the second parameter "count". Therefore, the first parameter
+ *     "record" points to a valid block of memory with space for "count" elements of type audio_svc_playlist_s.
+ *
+ *     @param[in]      record                  The handle for playlist object.
+ *     @param[in]      count                   The element count to be allocate
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            audio_svc_playlist_free
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void new_playlist()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *handle = NULL;
+       int count = 5;
+
+       //create playlists
+       ret = audio_svc_playlist_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_playlist_new(AudioHandleType **record, int count);
+
+/**
+ *     audio_svc_playlist_free:\n
+ *     This function is used to free memory allocated for arrays of element with type AudioHandleType.
+ *     The value passed as argument to delete must be either a pointer to a memory block previously allocated
+ *     with audio_svc_list_playlist_new(), or a null pointer (in the case of a null pointer, this function produces no effect).
+ *
+ *     @param[in]      record          The handle for playlist object.
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            audio_svc_playlist_new
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void free_playlist()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *handle = NULL;
+       int count = 5;
+
+       //create playlist object, object number is "count".
+       ret = audio_svc_playlist_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       //free playlist object
+       ret = audio_svc_playlist_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_playlist_free(AudioHandleType *record);
+
+/**
+ *     audio_svc_playlist_get_val:\n
+ *     This function allows to get a list of attributes for the specified element in the elements array by index.
+ *     This function takes a variable number of arguments, the arguments format is pair of atrribute index and attribute value.
+ *     The last parameter should be "-1", which tell the compiler that the arguments list is over.
+ *
+ *     @param[in]      playlists       The handle for playlist
+ *     @param[in]      index           The element index in array
+ *     @param[in]      first_field_name        the variable arguements list
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            audio_svc_playlist_set_val
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void get_playlist_value()
+{
+       AudioHandleType*handle = NULL;
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int i = 0;
+       int count = 0;
+
+       ret = audio_svc_count_playlist("", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of playlist. error code->%d", ret);
+               return;
+       }
+
+       if (count < 1)
+       {
+               printf( "there is no playlist");
+               return;
+       }
+
+       ret = audio_svc_playlist_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       //get all the playlists in db.
+       ret = audio_svc_get_playlist(
+                               NULL, //filter_string,
+                               NULL, //filter_string2,
+                               0, //offset,
+                               count, //count
+                               handle);
+       if (ret < 0)
+       {
+               printf( "failed to get playlist. error code->%d", ret);
+               audio_svc_playlist_free(handle);
+               return;
+       }
+
+       for (i = 0; i < count; i++) {
+               char *p = NULL;
+               int plst_id;
+               int size;
+               //get the playlist id and playlist name of each playlist
+               ret = audio_svc_playlist_get_val(handle, i, AUDIO_SVC_PLAYLIST_ID, &plst_id, AUDIO_SVC_PLAYLIST_NAME, &p, &size, -1);
+               if (ret < 0)
+               {
+                       printf( "failed to get playlist attribute value. error code->%d", ret);
+                       audio_svc_playlist_free(handle);
+                       return;
+               }
+       }
+
+       ret = audio_svc_playlist_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_playlist_get_val(AudioHandleType *playlists, int index, audio_svc_playlist_e first_field_name, ...);
+
+/**
+ *     audio_svc_playlist_set_val:\n
+ *     This function allows to retrieve a list of attributes for the specified element in the elements array by index.
+ *     This function takes a variable number of arguments, the arguments format is pair of atrribute index and attribute value.
+ *     The last parameter should be "-1", which tell the compiler that the arguments list is over.
+ *
+ *     @param[in]      playlists                       The handle for playlist
+ *     @param[in]      index                   The element index in array
+ *     @param[in]      first_field_name        the variable arguements list
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            audio_svc_playlist_get_val
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void set_playlist_value()
+{
+       int count = 0;
+       AudioHandleType *handle = NULL;
+       int ret = AUDIO_SVC_ERROR_NONE;
+       char *p = NULL;
+       int plst_id = 0;
+       int size = AUDIO_SVC_METADATA_LEN_MAX;
+       int i = 0;
+
+       ret = audio_svc_count_playlist("", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of playlist. error code->%d", ret);
+               return;
+       }
+
+       if (count < 1)
+       {
+               printf( "there is no playlist");
+               return;
+       }
+
+       ret = audio_svc_playlist_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       //get all the playlists.
+       ret = audio_svc_get_playlist(
+                               NULL, //filter_string,
+                               NULL, //filter_string2,
+                               0, //offset,
+                               count, //rows
+                               handle);
+       if (ret < 0)
+       {
+               printf( "failed to get playlist. error code->%d", ret);
+               audio_svc_playlist_free(handle);
+               return;
+       }
+
+       //set the name of first playlist to "playlist_test_name"
+       ret = audio_svc_playlist_set_val(handle, i, AUDIO_SVC_PLAYLIST_NAME, "playlist_test_name", size, -1);
+       if (ret < 0)
+       {
+               printf( "failed to set playlist attribute value. error code->%d", ret);
+               audio_svc_playlist_free(handle);
+               return;
+       }
+
+       ret = audio_svc_playlist_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_playlist_set_val(AudioHandleType *playlists, int index, audio_svc_playlist_e  first_field_name, ...);
+
+/**
+ *     audio_svc_set_item_valid:\n
+ *     This function is used to retrieve the element from elements arrary by index.
+ *     Internally the element type is audio_svc_playlist_s.
+ *
+ *     @param[in]              record          The handle for playlist
+ *     @param[in]              index           The element index
+ *     @param[out]             plst                    the element to be retrieved.
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre                    None
+ *     @post                   None
+ *     @see                    audio_svc_list_item_get
+ *     @remark         None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void get_playlist_item()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType*handle = NULL;
+       int count = 0;
+       int i = 0;
+
+       ret = audio_svc_count_playlist("", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of playlist. error code->%d", ret);
+               return;
+       }
+
+       if (count < 1)
+       {
+               printf( "there is no playlist");
+               return;
+       }
+
+       ret = audio_svc_playlist_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       ret = audio_svc_get_playlist(
+                               NULL, //filter_string,
+                               NULL, //filter_string2,
+                               0, //offset,
+                               count, //rows
+                               handle);
+       if (ret < 0)
+       {
+               printf( "failed to get playlist. error code->%d", ret);
+               return;
+       }
+
+       for (i = 0; i < count; i++) {
+               char *p = NULL;
+               int plst_id;
+               int size;
+               AudioHandleType *plst = NULL;
+
+               //get the playlist object with index "i"
+               ret = audio_svc_playlist_get_item(handle, i, &plst);
+               if (ret < 0)
+               {
+                       printf( "failed to get playlist item. error code->%d", ret);
+                       audio_svc_playlist_free(handle);
+                       return;
+               }
+
+               //get the id and name of playlist object.
+               ret = audio_svc_playlist_get_val(plst, 0, AUDIO_SVC_PLAYLIST_ID, &plst_id, AUDIO_SVC_PLAYLIST_NAME, &p, &size, -1);
+               if (ret < 0)
+               {
+                       printf( "failed to get playlist attribute value. error code->%d", ret);
+                       audio_svc_playlist_free(handle);
+                       return;
+               }
+       }
+
+       ret = audio_svc_playlist_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+
+}
+
+ *     @endcode
+ */
+
+int audio_svc_playlist_get_item(AudioHandleType *record, int index, AudioHandleType **plst);
+
+
+/**
+ *     audio_svc_count_playlist_item:\n
+ *     This function counts the number of playlist item.\n
+ *     The filter string act as the LIKE cluase for item title in the SQL condition search. The parameter "rows" and "offset"
+ *     is used as the LIMIT expression and OFFSET expression.
+ *
+ *     @param[in]              playlist_id             playlist id.
+ *     @param[in]              filter_string           the filter condition for track title.
+ *     @param[in]              filter_string2          the filter condition for track title.
+ *     @param[out]             count                   the returned tracks count.
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @see                    None
+ *     @pre                    None
+ *     @post                   None
+ *     @remark         None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void get_playlist_item_count()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int count = -1;
+       int playlist_id = 1;
+       // get the count of all tracks in db.
+       ret = audio_svc_count_playlist_item(playlist_id, "", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of playlist items. error code->%d", ret);
+               return;
+       }
+
+       printf("playlist item count is %d", count);
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_count_playlist_item(int playlist_id, const char *filter_string, const char *filter_string2, int *count);
+
+
+/**
+ *     audio_svc_get_playlist_item:\n
+ *     This function retrieves items of playlist.
+ *     The filter string act as the LIKE cluase for item title in the SQL condition search. The parameter "rows" and "offset"
+ *     is used as the LIMIT expression and OFFSET expression.
+ *
+ *     @param[in]              playlist_id             playlist id.
+ *     @param[in]              filter_string           the filter condition for track title.
+ *     @param[in]              filter_string2          the filter condition for track title.
+ *     @param[in]              offset                  start position to fetch the records satisfied with given condition.
+ *     @param[in]              rows                    the number of required records which is satisfied with given condition.
+ *     @param[out]             track                   reference pointer of result records.
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @see                    audio_svc_count_playlist_item
+ *     @pre                    None
+ *     @post                   None
+ *     @remark         None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void get_track_item()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *handle = NULL;
+       int count = -1;
+       int playlist_id = 1;
+
+       // get the count of all tracks in db.
+       ret = audio_svc_count_playlist_item(playlist_id, "", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of playlist items. error code->%d", ret);
+               return;
+       }
+
+       if(count < 0)
+       {
+               printf( "There is no items");
+               return;
+       }
+
+       ret = audio_svc_playlist_item_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       //get the playlist items.
+       ret = audio_svc_get_playlist_item(plst_id,
+               NULL, //filter_string,
+               NULL, //filter_string2,
+               0, //offset,
+               count, //rows,
+               handle
+               );
+
+       if (ret < 0)
+       {
+               audio_svc_playlist_item_free(handle);
+               return;
+       }
+
+       audio_svc_playlist_item_free(handle);
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_get_playlist_item(int playlist_id, const char *filter_string, const char *filter_string2, int offset, int rows, AudioHandleType *playlist_item);
+
+
+/**
+ *     audio_svc_playlist_item_new:\n
+ *     This function is used to allocate  a block (an array) of elements of type AudioHandleType.
+ *     where number of elements is speicified by the second parameter "count". Therefore, the first parameter
+ *     "record" points to a valid block of memory with space for "count" elements.
+ *
+ *     @param[in]              record          The handle for service list
+ *     @param[in]              count           the elements number
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre                    None.
+ *     @post                   None
+ *     @see                    audio_svc_count_playlist_item, audio_svc_playlist_item_free
+ *     @remark         None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void playlist_item_new()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *handle = NULL;
+       int count = 0;
+
+       ret = audio_svc_count_playlist_item(AUDIO_SVC_TRACK_ALL, "", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of items. error code->%d", ret);
+               return;
+       }
+
+       //allocate the memory of type list item with count
+       ret = audio_svc_playlist_item_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_playlist_item_new(AudioHandleType **record, int count);
+
+
+/**
+ *     audio_svc_playlist_item_free:\n
+ *     This function is used to free memory allocated for arrays of element with type AudioHandleType.
+ *     The value passed as argument to delete must be either a pointer to a memory block previously allocated
+ *     with audio_svc_playlist_item_new(), or a null pointer (in the case of a null pointer, this function produces no effect).
+ *
+ *     @param[in]      record          The handle for service list
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None.
+ *     @post           None
+ *     @see            audio_svc_playlist_item_new.
+ *     @remark None.
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void playlist_item_free()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       AudioHandleType *handle = NULL;
+       int count = 5;
+
+       //allocate the memory of type list item with count
+       ret = audio_svc_playlist_item_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       //free the list item memory.
+       ret = audio_svc_playlist_item_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+
+ *     @endcode
+ */
+
+int audio_svc_playlist_item_free(AudioHandleType *record);
+
+
+/**
+ *     audio_svc_playlist_item_get_val:\n
+ *     This function allows to retrieve a list of attributes for the specified element in the elements array by index.
+ *     This function takes a variable number of arguments, the arguments format is pair of atrribute index and attribute value.
+ *     The last parameter should be "-1", which tell the compiler that the arguments list is over.
+ *
+ *     @param[in]      record          The handle for service list
+ *     @param[in]      index           The element index in array
+ *     @param[in]      first_field_name        the variable arguements list
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None.
+ *     @post           None
+ *     @see            audio_svc_playlist_item_new, audio_svc_playlist_item_free, audio_svc_count_playlist_item.
+ *     @remark None.
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void get_playlist_item_get_value()
+{
+       int count = 0;
+       AudioHandleType *handle = NULL;
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int plst_id = 1;
+
+       ret = audio_svc_count_playlist_item(plst_id, "", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of playlist items. error code->%d", ret);
+               return;
+       }
+
+       ret = audio_svc_playlist_item_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       //get the playlist items.
+       ret = audio_svc_get_playlist_item(plst_id,
+               NULL, //filter_string,
+               NULL, //filter_string2,
+               0, //offset,
+               count, //rows,
+               handle
+               );
+
+       if (ret < 0)
+       {
+               audio_svc_playlist_item_free(handle);
+               return;
+       }
+
+       for (i = 0; i < count; i++)
+       {
+               char *audio_id = NULL, *title = NULL, *artist = NULL, *thumbname = NULL, *pathname = NULL;
+               int uid = -1;
+               int rating = AUDIO_SVC_RATING_NONE;
+               int duration = 0;
+               int size = 0;
+               int play_order = 0;
+
+               ret = audio_svc_playlist_item_get_val(handle, i ,
+                       AUDIO_SVC_PLAYLIST_ITEM_UID, &uid,
+                       AUDIO_SVC_PLAYLIST_ITEM_AUDIO_ID, &audio_id, &size,
+                       AUDIO_SVC_PLAYLIST_ITEM_THUMBNAIL_PATH, &thumbname, &size,
+                       AUDIO_SVC_PLAYLIST_ITEM_TITLE, &title, &size,
+                       AUDIO_SVC_PLAYLIST_ITEM_ARTIST, &artist, &size,
+                       AUDIO_SVC_PLAYLIST_ITEM_PATHNAME, &pathname, &size,
+                       AUDIO_SVC_PLAYLIST_ITEM_DURATION, &duration,
+                       AUDIO_SVC_PLAYLIST_ITEM_RATING, &rating,
+                       AUDIO_SVC_PLAYLIST_ITEM_PLAY_ORDER, &play_order,
+                       -1);
+
+               if (ret < 0)
+               {
+                       printf( "failed to get playlist items. error code->%d", ret);
+                       audio_svc_playlist_item_free(handle);
+                       return;
+               }
+       }
+
+       ret = audio_svc_playlist_item_free(handle);
+       if (ret < 0)
+       {
+               printf( "failed to free handle. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_playlist_item_get_val(AudioHandleType *record, int index, audio_svc_playlist_item_type_e first_field_name, ...);
+
+
+/**
+ *     audio_svc_playlist_item_get:\n
+ *     This function is used to retrieve the element from elements arrary by index.
+ *
+ *     @param[in]      record          The handle for service list
+ *     @param[in]      index           The element index
+ *     @param[out]     item            the element to be retrieved.
+ *     @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                      Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            None
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void get_playlist_item()
+{
+       AudioHandleType *handle = NULL;
+       AudioHandleType *item = NULL;
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int count = 0;
+       int i = 0
+
+       ret = audio_svc_count_playlist_item(plst_id, "", "", &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of playlist items. error code->%d", ret);
+               return;
+       }
+
+       ret = audio_svc_playlist_item_new(&handle, count);
+       if (ret < 0)
+       {
+               printf( "failed to allocate handle. error code->%d", ret);
+               return;
+       }
+
+       //get the playlist items.
+       ret = audio_svc_get_playlist_item(plst_id,
+               NULL, //filter_string,
+               NULL, //filter_string2,
+               0, //offset,
+               count, //rows,
+               handle
+               );
+
+       if (ret < 0)
+       {
+               audio_svc_playlist_item_free(handle);
+               return;
+       }
+
+       for (i = 0; i < count; i++)
+       {
+               char *audio_id = NULL;
+               int size = 0;
+               //get the playlist item with index "i"
+               ret = audio_svc_playlist_item_get(handle, i, &item);
+               if (ret < 0)
+               {
+                       printf( "failed to get playlistlist items. error code->%d", ret);
+                       audio_svc_playlist_item_free(handle);
+                       return;
+               }
+               
+               ret = audio_svc_playlist_item_get_val(item, 0, AUDIO_SVC_PLAYLIST_ITEM_AUDIO_ID, &audio_id, &size, -1);
+               if (ret < 0)
+               {
+                       printf( "failed to get playlist items value. error code->%d", ret);
+                       audio_svc_playlist_item_free(handle);
+                       return;
+               }
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_playlist_item_get(AudioHandleType *record, int index, AudioHandleType **item);
+
+/**
+ *     audio_svc_add_playlist:\n
+ *     This function saves new playlist. When user create a new playlist, application call this function to save it.
+ *
+ *     @param[in]              playlist_name   playlist name
+ *     @param[out]     playlist_id             playlist index
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @remark         To guarantee uniqueness of playlist name, call 'audio_svc_check_duplication_of_playlist_name()' before this function.
+ *     @pre                    None
+ *     @post                   This created playlist index can be used
+ *     @see                    audio_svc_delete_playlist
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+ void add_playlist()
+ {
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int plst_id = -1;
+       const char *playlist_name = "plst_test_001";
+       // add playlist with name "plst_test_001"
+       ret = audio_svc_add_playlist(playlist_name, &plst_id);
+
+       if (ret < 0)
+       {
+               printf( "failed to add playlist. error code->%d", ret);
+               return;
+       }
+       // printf the playlist index
+       printf("playlist index is %d", plst_id);
+
+       return;
+}
+
+*      @endcode
+*/
+int audio_svc_add_playlist(const char *playlist_name, int *playlist_id);
+
+
+/**
+ *     audio_svc_delete_playlist:\n
+ *     This function deletes a playlist. Internally this function not only deletes the playlist records from playlist table,
+ *     but also deletes track items from playlist item table belongs to the playlist.
+ *
+ *     @param[in]      playlist_id     index of playlist. It will be allocated when saving a playlist.
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @see            audio_svc_add_playlist
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <audio-svc.h>
+
+void delete_playlist()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int plst_id = -1;
+       const char *playlist_name = "plst_test_001";
+
+       //append a playlist with name "plst_test_001" into db.
+       ret = audio_svc_add_playlist(playlist_name, &plst_id);
+       if (ret < 0)
+       {
+               printf( "failed to add playlist. error code->%d", ret);
+               return;
+       }
+
+       //delete the playlist "plst_test_001"
+       ret = audio_svc_delete_playlist(plst_id);
+       if (ret < 0)
+       {
+               printf( "failed to delete playlist. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+int audio_svc_delete_playlist(int playlist_id);
+
+
+/**
+ *     audio_svc_add_item_to_playlist:\n
+ *     This function adds a track item to playlist.. Internally this function insert a record into playlist item table.
+ *
+ *     @param[in]      playlist_id             playlist index
+ *     @param[in]      audio_id                        db index of item to be added
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            the playlist with index "playlist_id" should exist, the track with "audio_id" should be valid.
+ *     @post           None
+ *     @see            audio_svc_remove_item_from_playlist_by_uid
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void add_item_to_playlist()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int plst_id = -1;
+       const char *playlist_name = "plst_test_001";
+       char * test_audio_id = "550e8400-e29b-41d4-a716-446655440000";
+
+       // append a playlist with name "plst_test_001"
+       ret = audio_svc_add_playlist(playlist_name, &plst_id);
+       if (ret < 0)
+       {
+               printf( "failed to add playlist. error code->%d", ret);
+               return;
+       }
+
+       // append a track with test_audio_id into playlist "plst_test_001"
+       ret = audio_svc_add_item_to_playlist(plst_id, test_audio_id);
+       if (ret < 0)
+       {
+               printf( "failed to add item to playlist. error code->%d", ret);
+               return;
+       }
+
+       return;
+
+}
+
+ *     @endcode
+ */
+int audio_svc_add_item_to_playlist(int playlist_id, const char *audio_id);
+
+
+/**
+ *     audio_svc_remove_item_from_playlist_by_uid:\n
+ *     This function removes a track item from playlist. Internally this function delete the record from playlist item table.
+ *     In the playlist item table, the playlist index and audio_id both can identify a unique record.\n
+ *     When user deletes a track from a playlist, application call this function to complete the task.
+ *     @param[in]      playlist_id             playlist index
+ *     @param[in]      uid                     db index of playlist item not audio_id
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            None
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+ void remove_item_from_playlist()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int plst_id = -1;
+       const char *playlist_name = "plst_test_001";
+       int test_uid = 50;
+
+       //append playlist "plst_test_001" into db.
+       ret = audio_svc_add_playlist(playlist_name, &plst_id);
+       if (ret < 0)
+       {
+               printf( "failed to add playlist. error code->%d", ret);
+               return;
+       }
+
+       //remove music item with uid "50" from playlist "plst_test_001"
+       ret = audio_svc_remove_item_from_playlist_by_uid(plst_id, test_uid);
+       if (ret < 0)
+       {
+               printf( "failed to remove item to playlist. error code->%d", ret);
+               return;
+       }
+
+       return;
+
+}
+
+ *     @endcode
+ */
+
+int audio_svc_remove_item_from_playlist_by_uid(int playlist_id, int uid);
+
+
+/**
+ *     audio_svc_remove_item_from_playlist_by_audio_id:\n
+ *     This function removes a track item from playlist. Internally this function delete the record from playlist item table.
+ *     In the playlist item table, the playlist index and audio_id both can identify a unique record.\n
+ *     When user deletes a track from a playlist, application call this function to complete the task.
+ *     @param[in]      playlist_id             playlist index
+ *     @param[in]      audio_id                db index of playlist item
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            None
+ *     @remark None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+ void remove_item_from_playlist()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int plst_id = -1;
+       const char *playlist_name = "plst_test_001";
+       char * test_audio_id = "550e8400-e29b-41d4-a716-446655440000";
+
+       //append playlist "plst_test_001" into db.
+       ret = audio_svc_add_playlist(playlist_name, &plst_id);
+       if (ret < 0)
+       {
+               printf( "failed to add playlist. error code->%d", ret);
+               return;
+       }
+
+       //remove music item with uid "50" from playlist "plst_test_001"
+       ret = audio_svc_remove_item_from_playlist_by_audio_id(plst_id, test_audio_id);
+       if (ret < 0)
+       {
+               printf( "failed to remove item to playlist. error code->%d", ret);
+               return;
+       }
+
+       return;
+
+}
+
+ *     @endcode
+ */
+
+int audio_svc_remove_item_from_playlist_by_audio_id(int playlist_id, const char *audio_id);
+
+
+/**
+ *     audio_svc_get_unique_playlist_name:\n
+ *     This function makes unique name and returns it after retrieving playlist table with original playlist name.
+ *     This function call audio_svc_count_playlist_by_name() to check whether the playlist with "orignal_name"
+ *     exist or not.
+ *
+ *     @param[in]              orig_name                                       the original name to be checked
+ *     @param[in]              max_unique_name_length  max length of unique name 
+ *     @param[out]     unique_name                             the unique playlist name based on the original name
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre                    None
+ *     @post                   None
+ *     @see                    None
+ *     @remark         None
+ *     @par example
+ *     @code
+
+#include <audio-svc.h>
+
+gchar* get_new_playlist_name (void)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       char unique_name[24] = "\0";
+
+       //get a unique playlist name, based on "My playlist"
+       ret = audio_svc_get_unique_playlist_name("My playlist", unique_name, 24);
+       if (ret < 0)
+       {
+               printf( "failed to get unique playlist name. error code->%d", ret);
+               return NULL;
+       }
+
+       if(unique_name == NULL)
+       {
+               printf("playlist name is NULL");
+               return NULL;
+       }
+       else
+       {
+               return g_strdup(unique_name);
+       }
+
+       return NULL;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_get_unique_playlist_name(const char* orig_name, char *unique_name, size_t max_unique_name_length);
+
+
+/**
+ *     audio_svc_get_playlist_name_by_playlist_id:\n
+ *     This function retrieves the playlist name by playlist index.\n
+ *     Internally in music database the playlist index is the primary key of playlist table.
+ *
+ *     @param[out]     playlist_name                           playlist name
+ *     @param[in]              max_playlist_name_length        max length of playlist name
+ *     @param[in]              playlist_id                                     playlist index
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre                    None
+ *     @post                   None
+ *     @see                    None
+ *     @remark         None
+ *     @par example
+ *     @code
+ *
+ #include <audio-svc.h>
+
+char * get_playlist_name_by_playlist_id (int playlist_id)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       char playlist_name[AUDIO_SVC_PATHNAME_SIZE] = {0,};
+
+       //get the playlist name by playlist id "playlist_id"
+       ret = audio_svc_get_playlist_name_by_playlist_id(playlist_id, playlist_name, AUDIO_SVC_PATHNAME_SIZE);
+       if (ret < 0)
+       {
+               printf( "failed to get playlist name. error code->%d", ret);
+               return NULL;
+       }
+       return playlist_name;
+}
+ *     @endcode
+ */
+
+int audio_svc_get_playlist_name_by_playlist_id(int playlist_id, char *playlist_name, size_t max_playlist_name_length);
+
+
+/**
+ *     audio_svc_get_playlist_id_by_playlist_name:\n
+ *     This function find playlist index by playlist name in music db.
+ *     playlist id and playlist name are unique value
+ *
+ *     @param[in]              playlist_name   playlist name for find playlist index.
+ *     @param[out]     playlist_id             the unique playlist id.
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre                    None
+ *     @post                   None
+ *     @see                    None
+ *     @remark         None
+ *     @par example
+ *     @code
+
+#include <audio-svc.h>
+
+int get_playlist_id (void)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int playlist_id = 0;
+
+       //get a playlist index.
+       ret = audio_svc_get_playlist_id_by_playlist_name("My playlist", &playlist_id);
+       if (ret < 0)
+       {
+               printf( "failed to get playlist index. error code->%d", ret);
+       }
+
+       return ret;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_get_playlist_id_by_playlist_name(const char *playlist_name, int *playlist_id);
+
+
+/**
+ *     audio_svc_update_playlist_name:\n
+ *     This function updates the playlist with index "playlist_id" to the new name " playlist name".
+ *     Here the "playlist_id" is the value of "_id" field in playlist talbe, and the "_id" field is the primary key.
+ *     So internally audio service can locate a playlist with "playlist_id".
+ *
+ *     @param[in]      playlist_id                     index of playlist. It will be allocated when saving a playlist.
+ *     @param[in]      new_playlist_name       changed playlist name
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @see            audio_svc_add_playlist
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <audio-svc.h>
+
+void
+update_playlist_name()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int plst_id = -1;
+       const char *playlist_name = "plst_test_001";
+
+       //append a playlist "plst_test_001" into db.
+       ret = audio_svc_add_playlist(playlist_name, &plst_id);
+       if (ret < 0)
+       {
+               printf( "failed to add playlist. error code->%d", ret);
+               return;
+       }
+
+       //rename playlist name to "plst_test_002"
+       ret = audio_svc_update_playlist_name(plst_id, "plst_test_002");
+       if (ret < 0)
+       {
+               printf( "failed to update playlist name. error code->%d", ret);
+               return;
+       }
+}
+
+ *     @endcode
+ */
+int audio_svc_update_playlist_name(int playlist_id, const char *new_playlist_name);
+
+
+/**
+ *     audio_svc_update_playlist_item_play_order:\n
+ *     This function update the playlist item play order.\n
+ *     This function is used for playlist item reorder. When user reorder the items in a playlist, app call this function to finished the reorder in database.
+ *     In music application, the track items are listed by the order of item index.
+ *
+ *     @param[in]      playlist_id                     playlist id.
+ *     @param[in]      uid                                     unique playlist item id. not audio_id.
+ *     @param[in]      new_play_order          new play order.
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None
+ *     @post           None
+ *     @see            None
+ *     @remark None
+ *     @par example
+ *     @code
+
+  #include <audio-svc.h>
+
+void update_playlist_order()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int playlist_id = 1;
+       int uid = 1;
+       int new_play_order = 5;
+
+       //update the item index in playlist
+       ret = audio_svc_update_playlist_item_play_order(playlist_id, uid, new_play_order);
+       if (ret < 0)
+       {
+               printf( "failed to update play order. error code->%d", ret);
+               return;
+       }
+       return;
+}
+ *     @endcode
+ */
+
+int audio_svc_update_playlist_item_play_order(int playlist_id, int uid, int new_play_order);
+
+
+/**
+ *     audio_svc_count_playlist_by_name:\n
+ *     This function checks whether playlist with 'playlist_name' does exist or not in database.
+ *     If exist, the returned output parameter 'count' will be positive.
+ *
+ *     @param[in]              playlist_name           playlist name
+ *     @param[out]             count                           the count of playlists
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre                    None
+ *     @post                   None
+ *     @see                    None
+ *     @remark         None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+int
+get_playlist_count(void)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int count = -1;
+       const char *playlist_name = "plst_test_001";
+
+       //get the count of playlists whose name are "plst_test_001"
+       ret = audio_svc_count_playlist_by_name(playlist_name, &count);
+       if (ret < 0)
+       {
+               printf( "failed to get count of playlist . error code->%d", ret);
+               return -1;
+       }
+
+       printf("playlist count is %d", count)
+
+       return count;
+}
+
+ *     @endcode
+ */
+
+int audio_svc_count_playlist_by_name(const char* playlist_name, int*count);
+
+
+/**
+ *     audio_svc_check_duplicate_insertion_in_playlist:\n
+ *     This function checks whether a track with db index "audio_id" does exist or not in a playlist with index "playlist_id".
+ *     This function is alwayed used for avoiding inserting duplicate track into a playlist.
+ *
+ *     @param[in]              playlist_id             playlist index
+ *     @param[in]              audio_id                                db index of item to be added
+ *     @param[out]             count                   the count of tracks in playlist
+ *     @return                 This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                                     Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre                    None
+ *     @post                   None
+ *     @see                    audio_svc_add_item_to_playlist
+ *     @remark         None
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+bool check_item_exist (gint plst_id, gint key_id)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int count = -1;
+       char *audio_id = "550e8400-e29b-41d4-a716-446655440000";
+
+       //get the count of music track with audio_id in playlist "plst_id"
+       ret = audio_svc_check_duplicate_insertion_in_playlist(plst_id, audio_id, &count);
+       if (ret < 0)
+       {
+               if(count > 0)
+                       return TRUE;
+               else
+                       return FALSE;
+       }
+       else
+       {
+               printf( "failed to check duplicate insertion. error code->%d", ret);
+               return ret;
+       }
+}
+
+ *     @endcode
+ */
+int audio_svc_check_duplicate_insertion_in_playlist(int playlist_id, const char *audio_id, int * count);
+
+/**
+ *     audio_svc_list_by_search:\n
+ *     This function allows to search tracks by string to be searched.
+ *     This function takes a variable number of arguments, the arguments format is pair of atrribute index and attribute value.
+ *     The last parameter should be "-1", which tell the compiler that the arguments list is over.
+ *
+ *     @param[in]      handle                  The handle for search
+ *     @param[in]      order_field             field to order
+ *                             Please refer 'audio-svc-types.h', and see the enum audio_svc_search_order_e
+ *     @param[in]      offset          offset of list to be searched
+ *     @param[in]      count           count of list to be searched
+ *     @param[in]      first_field_name        the variable arguements list of field to search
+ *                             Please refer 'audio-svc-types.h', and see the enum audio_svc_serch_field_e
+ *     @return         This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ *     @pre            None.
+ *     @post           None.
+ *     @see            None.
+ *     @remark None.
+ *     @par example
+ *     @code
+
+ #include <audio-svc.h>
+
+void test_audio_svc_list_by_search()
+{
+               int offset = 0, count = 10, i = 0;
+               const char *str = "Sa";
+               AudioHandleType *handle = NULL;
+
+               err = audio_svc_search_item_new(&handle, count);
+               if (err < 0) {
+                       printf("audio_svc_search_item_new failed:%d\n", err);
+                       return err;
+               }
+
+               err = audio_svc_list_by_search(handle, AUDIO_SVC_ORDER_BY_TITLE_ASC, offset, count, AUDIO_SVC_SEARCH_TITLE, str, strlen(str), AUDIO_SVC_SEARCH_ALBUM, str, strlen(str), AUDIO_SVC_SEARCH_ARTIST, str, strlen(str), -1);
+
+               if (err != AUDIO_SVC_ERROR_NONE) {
+                       mediainfo_dbg("Fail to get items : %d", err);
+                       return err;
+               }
+               
+               for (i = 0; i < count; i++) {
+                       AudioHandleType *item = NULL;
+                       err = audio_svc_search_item_get(handle, i, &item);
+                       char *audio_id = NULL, *title = NULL, *artist = NULL, *pathname = NULL, *album = NULL;
+                       int size = 0;
+                       if (err < 0) {
+                               printf("[%d] audio_svc_search_item_get failed : %d\n", i, err);
+                       } else {
+                               audio_svc_item_get_val(item,  
+                                               AUDIO_SVC_TRACK_DATA_AUDIO_ID, &audio_id, &size,
+                                               AUDIO_SVC_TRACK_DATA_PATHNAME, &pathname, &size,
+                                               AUDIO_SVC_TRACK_DATA_TITLE, &title, &size,
+                                               AUDIO_SVC_TRACK_DATA_ARTIST, &artist, &size,
+                                               AUDIO_SVC_TRACK_DATA_ALBUM, &album, &size,
+                                               -1);
+
+                               if( audio_id == NULL ) break;
+
+                               printf("[%d] ID: %s\n", i, audio_id);
+                               printf("[%d] Path: %s\n", i, pathname);
+                               printf("[%d] Title: %s\n", i, title);
+                               printf("[%d] Artist: %s\n", i, artist);
+                               printf("[%d] Album: %s\n", i, album);
+                       }
+               }
+
+               audio_svc_search_item_free(handle);
+}
+
+ *     @endcode
+ */
+int audio_svc_list_by_search(AudioHandleType *handle,
+                                                       audio_svc_search_order_e order_field,
+                                                       int offset,
+                                                       int count,
+                                                       audio_svc_serch_field_e first_field_name,
+                                                       ...);
+
+
+/** @} */
+
+/**
+       @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_AUDIO_SVC_H_*/
diff --git a/include/media-info-error.h b/include/media-info-error.h
new file mode 100755 (executable)
index 0000000..6e6a229
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#ifndef _MEDIA_INFO_ERROR_H_
+#define _MEDIA_INFO_ERROR_H_
+
+/**
+       @addtogroup MEDIA_INFO
+        @{
+        * @file                media-info-error.h
+        * @brief       This file defines error codes for media info.
+
+ */
+
+/**
+        @defgroup MEDIA_INFO_COMMON  Global data structure and error code
+        @{
+
+        @par
+         type definition and error code
+ */
+
+
+#define MEDIA_INFO_ERROR_NONE                                                  0                       /**< No Error */
+
+#define MEDIA_INFO_ERROR_INVALID_PARAMETER                     -1                      /**< Invalid parameter */
+#define MEDIA_INFO_ERROR_INVALID_MEDIA                         -2                      /**< Invalid media */
+#define MEDIA_INFO_ERROR_INVALID_FILE_FORMAT           -3                      /**< Invalid file format */
+#define MEDIA_INFO_ERROR_INVALID_PATH                          -4                      /**< Invalid file path */
+#define MEDIA_INFO_ERROR_OUT_OF_MEMORY                         -5                      /**< Out of memory */
+#define MEDIA_INFO_ERROR_OUT_OF_STORAGE                                -6                      /**< Out of storage */
+#define MEDIA_INFO_ERROR_INSERT_FAIL                                   -7                      /**< Insert failed  */
+#define MEDIA_INFO_ERROR_DRM_INSERT_FAIL                               -8                      /**< DRM file insert failed */
+
+#define MEDIA_INFO_ERROR_ITEM_NOT_FOUND                                -11                     /**< Item not found */
+#define MEDIA_INFO_ERROR_FILE_NOT_FOUND                                -12                     /**< File not found */
+#define MEDIA_INFO_ERROR_APPEND_ITEM_FAILED                    -13                     /**< Append item failed */
+#define MEDIA_INFO_ERROR_REMOVE_ITEM_FAILED                    -14                     /**< Remove item failed */
+#define MEDIA_INFO_ERROR_GET_ITEM_FAILED                               -15                     /**< Get item failed */
+#define MEDIA_INFO_ERROR_REMOVE_FILE_FAILED                    -16                     /**< Remove file failed */
+#define MEDIA_INFO_ERROR_EXTRACT_FAILED                                -17                     /**< Extract Failed */
+#define MEDIA_INFO_ERROR_MAKE_PLAYLIST_NAME_FAILED     -18                     /**< fail to make new playlist name */
+
+#define MEDIA_INFO_ERROR_DATABASE_CONNECT                      -100            /**< DB connect error */
+#define MEDIA_INFO_ERROR_DATABASE_DISCONNECT           -101            /**< DB disconnect error */
+#define MEDIA_INFO_ERROR_DATABASE_QUERY                                -104            /**< DB query error */
+#define MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN           -105            /**< DB table open error */
+#define MEDIA_INFO_ERROR_DATABASE_INVALID                      -106            /**< DB invalid error */
+#define MEDIA_INFO_ERROR_DATABASE_INTERNAL                     -107            /**< DB internal error */
+
+#define MEDIA_INFO_ERROR_SOCKET_CONN                                   -201            /**< Socket connect error */
+#define MEDIA_INFO_ERROR_SOCKET_MSG                                    -202            /**< Socket message error */
+#define MEDIA_INFO_ERROR_SOCKET_SEND                                   -203            /**< Socket send error */
+#define MEDIA_INFO_ERROR_SOCKET_RECEIVE                                -204            /**< Socket receive error */
+#define MEDIA_INFO_ERROR_SOCKET_RECEIVE_TIMEOUT        -205            /**< Socket time out */
+
+#define MEDIA_INFO_ERROR_INTERNAL                                              -998            /**< Internal error */
+#define MEDIA_INFO_ERROR_UNKNOWN                                       -999            /**< Unknown error */
+#define MEDIA_INFO_ERROR_NOT_IMPLEMENTED                       -200            /**< Not implemented */
+/**
+       @}
+*/
+
+/**
+       @}
+*/
+
+#endif /*_MEDIA_INFO_ERROR_H_*/
diff --git a/include/media-info-types.h b/include/media-info-types.h
new file mode 100755 (executable)
index 0000000..92795c0
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#ifndef _MEDIA_INFO_TYPES_H_
+#define _MEDIA_INFO_TYPES_H_
+
+#ifndef DEPRECATED_API
+#  define DEPRECATED_API __attribute__ ((deprecated))
+#endif
+
+#endif /*_MEDIA_INFO_TYPES_H_*/
diff --git a/include/media-info.h b/include/media-info.h
new file mode 100755 (executable)
index 0000000..5451174
--- /dev/null
@@ -0,0 +1,275 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#ifndef _MEDIA_INFO_H_
+#define _MEDIA_INFO_H_
+
+#include "media-info-types.h"
+#include "media-info-error.h"
+#include <sqlite3.h>
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+       @defgroup       MEDIA_INFO      Media Information Service
+        @{
+         * @file                       media-info.h
+         * @brief              This file defines API's for media information service.
+         * @version            1.0
+ */
+
+/**
+        @defgroup MP_DB_API    Database Manager API
+        @{
+
+        @par
+        manage the service database.
+ */
+
+
+/**
+ *     mediainfo_open:
+ *     Open media information service library. This is the function that an user who wants to use media information service calls first.
+ *     This function connects to the media database.
+ *
+ *     @return         This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'media-info-error.h' to know the exact meaning of the error.
+ *     @see            mediainfo_close
+ *     @pre            None.
+ *     @post           call mediainfo_close() to close the media database
+ *     @remark The database name is "/opt/dbspace/.media.db".
+ *     @par example
+ *     @code
+
+#include <media-info.h>
+
+void open_media_db()
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       // open media database
+       ret = mediainfo_open();
+       // open failed
+       if (ret < 0)
+       {
+               printf( "Cannot open media db. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+int mediainfo_open(void);
+
+/**
+ *     mediainfo_close:
+ *     Open media information service library. This is the function that an user who wants to finalize media information service calls before closing the application.
+ *     This function disconnects to the media database.
+ *
+ *     @return         This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'media-info-error.h' to know the exact meaning of the error.
+ *     @see            mediainfo_open
+ *     @pre            None.
+ *     @post           call mediainfo_open() to open the media database
+ *     @remark The database name is "/opt/dbspace/.media.db".
+ *     @par example
+ *     @code
+
+#include <media-info.h>
+
+void close_media_db()
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       // close media database
+       ret = mediainfo_close();
+       // close failed
+       if (ret < 0)
+       {
+               printf( "Cannot close media db. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+int mediainfo_close(void);
+
+/**
+ *     mediainfo_connect_db_with_handle:
+ *     Connect to the media database. This is the function that an user who wants to get a handle to access the media database. 
+ *     This function connects to the media database.
+ *
+ *  @param             db_handle [out]         Handle to access database using sqlite3 libs
+ *     @return         This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'media-info-error.h' to know the exact meaning of the error.
+ *     @see            mediainfo_disconnect_db_with_handle
+ *     @pre            None.
+ *     @post           call mediainfo_connect_db_with_handle to connect to the media database
+ *     @remark The database name is "/opt/dbspace/.media.db".
+ *     @par example
+ *     @code
+
+#include <media-info.h>
+
+void connect_media_db()
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3* my_handle = NULL;
+
+       // connect to the media database
+       ret = mediainfo_connect_db_with_handle(&my_handle);
+
+       if (ret < 0)
+       {
+               printf("Fatal error to connect DB\n");
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+int mediainfo_connect_db_with_handle(sqlite3** db_handle);
+
+
+/**
+ *     mediainfo_disconnect_db_with_handle:
+ *     Disconnect to the media database. This is the function that an user who wants to disconnect the media database. 
+ *     This function disconnects to the media database.
+ *
+ *  @param             db_handle [out]         Handle to access database using sqlite3 libs
+ *     @return         This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'media-info-error.h' to know the exact meaning of the error.
+ *     @see            mediainfo_connect_db_with_handle
+ *     @pre            None.
+ *     @post           call mediainfo_disconnect_db_with_handle to disconnect to the media database
+ *     @remark The database name is "/opt/dbspace/.media.db".
+ *     @par example
+ *     @code
+
+#include <media-info.h>
+
+void disconnect_media_db()
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3* my_handle = NULL;
+
+       // connect to the media database
+       ret = mediainfo_connect_db_with_handle(&my_handle);
+
+       if (ret < 0)
+       {
+               printf("Fatal error to connect DB\n");
+               return;
+       }
+
+       //
+       // Do something using my_handle
+       //
+       
+
+       ret = mediainfo_disconnect_db_with_handle(my_handle);
+       if (ret < 0)
+       {
+               printf("Fatal error to disconnect DB\n");
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+int mediainfo_disconnect_db_with_handle(sqlite3* db_handle);
+
+/**
+ *     mediainfo_register_file:
+ *     This function registers multimedia file to media DB
+ *  When you did some file operations such as Create, Copy, Move, Rename, and Delete in phone or mmc storage, media-server registers the result to database automatically by inotify mechanism.
+ *  However, automatic registration will have a little delay because the method is asynchronous.
+ *  If you want to register some files to database immediately, you should use this API.
+ *
+ *  @param             file_full_path [in]             full path of file for register
+ *     @return         This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
+ *                             Please refer 'media-info-error.h' to know the exact meaning of the error.
+ *     @see            None.
+ *     @pre            None.
+ *     @post           None.
+ *     @remark The database name is "/opt/dbspace/.media.db".
+ *                   You have to use this API only for registering multimedia files. If you try to register no multimedia file, this API returns error.
+ *     @par example
+ *     @code
+
+#include <media-info.h>
+
+int main()
+{
+       int result = -1;
+
+       result = mediainfo_register_file("/opt/media/test.txt");
+       if( result < 0 )
+       {
+               printf("FAIL to mediainfo_register_file\n");
+               return 0;
+       }
+       else
+       {
+               printf("SUCCESS to register file\n");
+       }
+       
+       return 0;
+}
+
+ *     @endcode
+ */
+DEPRECATED_API int mediainfo_register_file(const char *file_full_path);
+
+typedef GArray* minfo_list;
+
+DEPRECATED_API int mediainfo_list_new(minfo_list *list);
+
+DEPRECATED_API int mediainfo_list_add(minfo_list list, const char* file_full_path);
+
+DEPRECATED_API int mediainfo_list_free(minfo_list list);
+
+DEPRECATED_API int mediainfo_register_files(const minfo_list list);
+
+
+/** @} */
+
+/**
+       @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_MEDIA_INFO_H_*/
diff --git a/include/media-svc-error.h b/include/media-svc-error.h
new file mode 100755 (executable)
index 0000000..c0c2c1c
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/** 
+ * This file defines the error code of media service
+ *
+ * @file               media-svc-error.h
+ * @author             Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version    1.0
+ * @brief      This file defines the error code of media service 
+ */
+
+/**
+* @ingroup MINFO_SVC_API
+* @defgroup    MEDIA_SVC_ERROR Media service error code table
+* @{
+*/
+
+#ifndef _MEDIA_SVC_ERROR_H_
+#define _MEDIA_SVC_ERROR_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+//Error types definition
+#define MB_SVC_ERROR_NONE                                      0                               /**< base */
+#define MB_SVC_ERROR_INVALID_PARAMETER                 -1                      /**< invalid parameter(s) */
+#define MB_SVC_ERROR_INVALID_MEDIA             -2                              /**< invalid or unknown media */
+#define MB_SVC_ERROR_FILE_NOT_EXSITED          -3                              /**< file doesn't exist */
+#define MB_SVC_ERROR_DIR_NOT_EXSITED           -4                              /**< folder doesn't exist */
+
+#define MB_SVC_ERROR_FILE_IO                           -11                             /**< file I/O error  */
+#define MB_SVC_ERROR_OUT_OF_MEMORY             -12                             /**< memory allocation error*/
+
+#define MB_SVC_ERROR_CREATE_THUMBNAIL       -101                       /**< create thumbnail */
+#define MB_SVC_ERROR_COPY_THUMBNAIL                    -102                    /**< copy thumbnail */
+#define MB_SVC_ERROR_MOVE_THUMBNAIL                    -103                    /**< move thumbnail */
+
+#define MB_SVC_ERROR_DB_CONNECT                        -201                    /**< connect DB error */
+#define MB_SVC_ERROR_DB_DISCONNECT                     -202                    /**< disconnect DB error  */
+#define MB_SVC_ERROR_DB_CREATE_TABLE           -203                    /**< create table error */
+#define MB_SVC_ERROR_DB_NO_RECORD                      -204                    /**< No record */
+#define MB_SVC_ERROR_DB_OUT_OF_RANGE           -205                    /**< DB out of table records range*/
+#define MB_SVC_ERROR_DB_INTERNAL                       -206                    /**< internal db error  */
+
+#define MB_SVC_ERROR_NOT_IMPLEMENTED           -997                    /**< Not implemented */
+#define MB_SVC_ERROR_INTERNAL                          -998                    /**< internal error */
+#define MB_SVC_ERROR_UNKNOWN                           -999                    /**< Unknown error */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/**
+* @}
+*/
+
+#endif /*_MEDIA_SVC_ERROR_H_*/
+
+
+
diff --git a/include/media-svc.h b/include/media-svc.h
new file mode 100755 (executable)
index 0000000..dff89f8
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/** 
+ * This file is  main header file of media service.
+ *
+ * @file                       media-svc.h
+ * @author             Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version    1.0
+ * @brief              This file is  main header file of media service.
+ */
+
+
+#ifndef _MEDIA_SERVICE_H_
+#define _MEDIA_SERVICE_H_
+
+/**
+ * @addtogroup MEDIA_SVC media-svc
+ * @{
+ */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "media-svc-error.h"
+#include "minfo-types.h"
+
+#include "minfo-api.h"
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/**
+ * @}
+ */
+
+
+#endif /*_MEDIA_SERVICE_H_*/
+
diff --git a/include/minfo-api.h b/include/minfo-api.h
new file mode 100755 (executable)
index 0000000..096517b
--- /dev/null
@@ -0,0 +1,2872 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+       
+#ifndef _MINFO_INFO_H_
+#define _MINFO_INFO_H_
+
+/** 
+ * This file defines minfo apis for media service..
+ *
+ * @file               minfo-api.h
+ * @author      Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version    1.0
+ * @brief      This file defines minfo apis for media service.
+ */
+
+#include "minfo-types.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+       @mainpage MINFO_SVC
+
+       @par
+       This document provides necessary information for developers who are
+       going to implement gallery application and ug-imageviewer or other
+       3rd party applications.
+ */
+
+/**
+ *  @ingroup MEDIA_SVC
+       @defgroup MINFO_SVC_API Media Service
+       @{
+
+       @par
+       Call Directly.
+ */
+
+
+
+/**
+* This function connects to media service database before any database operations. if it will check 
+* whether these required tables(folder,media,video_bookmark,web_streaming,video_meta,
+* image_meta) have existed, if no,  it will create all of them and operate them then.
+* If finish operating the database file, call this function, minfo_finalize() to close the database
+* file. 
+*
+* @return      This function returns 0 on success, or negative value with error code.
+* @remarks     Before invoking any API of media service, this function must be 
+*                   invoked first to initialize database connection.it should be invoked,
+*                   but only once. it's thread-independent and thread-safe.
+* @see          minfo_finalize()
+* @pre         None
+* @post                Call minfo_finalize() to finalize minfo api
+* @par example
+* @code
+
+
+     #include <media-svc.h>
+       void test_minfo_init(void)
+       {
+               int ret = -1;
+               //open a databse file.
+               ret = minfo_init();
+
+               if(ret< 0) { 
+                       printf("minfo_init error\n");
+                       return ret;
+               }
+       }
+* @endcode       
+*/
+
+int
+minfo_init(void);
+
+
+/** 
+*  Close media service library. This is the function need to call before close the application. 
+*  This function disconnects with the media database and shutdown the other used libary.
+*
+*
+* @return      This function returns 0 on success, or negative value with error code.
+* @remarks     After invoking any API of media service, this function must be 
+*                  invoked to finalize database connection. if this function is missed, 
+*                      database connection leak happenes .and if invoke it without minfo_init,
+*                      it fails directly and return error.
+* @see          minfo_init()
+* @pre         minfo_init is already called.
+* @post                None
+* @par example
+* @code
+
+
+#include <media-svc.h>
+       void test_minfo_finalize(void)
+       {
+               int ret = -1;
+               minfo_init();
+
+               //close database file.
+               ret = minfo_finalize();
+
+               if(ret< 0) { 
+                       printf("minfo_finalize error\n");
+                       return ret;
+               }
+       }
+* @endcode      
+*/
+
+int
+minfo_finalize(void);
+
+
+/**
+ * This function gets mitem list, which include all or portion of a cluster or folder specified by 
+ * @p cluster_id. @p filter could specify some filter conditions, like, type of got items, sort by type,
+ * start and end positions of items, including meta data or not, whether just get the favorites, etc.
+ * Menawhile data of each mitem instance mainly derive from media table record. However meta data
+ * is composed of video_meta or image_meta record.
+ * 
+ *
+ * @param      cluster_id      [in]    the folder id in which media files are in. if the parameter is -1, then query all folders.
+ * @param      filter          [in]    the filter to specify some filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, whether just get the favorites, etc.
+ * @param      func      [in]  Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ * @param      user_data      [out]   user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks    type of data memeber of list is pointer to the structure type 'Mitem'
+ *                     when free list, it need free every item first and then free list itself. 
+ * @see                None.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+    #include <media-svc.h>
+     
+       int mitem_ite_cb(Mitem *item, void *user_data)
+       {
+               GList** list = (GList**)user_data;
+               //append an item to linked list.
+               *list = g_list_append(*list, item);
+       }
+
+       void test_minfo_get_item_list(void)
+       {
+               int ret = -1;
+               int img_cnt = 0;
+               GList *p_list = NULL;
+               const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+               minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,3,10,true,true};
+               //get a set of items
+               ret = minfo_get_item_list(cluster_id, item_filter, mitem_ite_cb, &p_list);
+
+               if(ret< 0) { 
+                       printf("minfo_get_item_list error\n");
+                       return;
+               }
+       }
+ * @endcode  
+
+ */
+
+int
+minfo_get_item_list(const char *cluster_id, const minfo_item_filter filter, minfo_item_ite_cb func, void *user_data);
+
+/**
+ * This function gets mitem list, which include all or portion of a or many clusters or folders specified by 
+ * @p cluster_type. @p filter could specify some filter conditions, like, type of got items, sort by type,
+ * start and end positions of items, including meta data or not, whether just get the favorites, etc.
+ * Meanwhile data of each mitem instance mainly derive from media table record. However meta data
+ * is composed of video_meta or image_meta record.
+ * 
+ *
+ * @param      cluster_type    [in]    the folder type which specify media files belong to.
+ * @param      filter          [in]    the filter to specify some filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, whether just get the favorites, etc.
+ * @param      func      [in]  Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ * @param      user_data      [out]   user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks    type of data memeber of list is pointer to the structure type 'Mitem'
+ *                     when free list, it need free every item first and then free list itself. 
+ * @see                minfo_get_item_list.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+    #include <media-svc.h>
+     
+       int mitem_ite_cb(Mitem *item, void *user_data)
+       {
+               GList** list = (GList**)user_data;
+               //append an item to linked list.
+               *list = g_list_append(*list, item);
+       }
+
+       void test_minfo_get_item_list(void)
+       {
+               int ret = -1;
+               int img_cnt = 0;
+               GList *p_list = NULL;
+
+               minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,3,10,true,true};
+               //get a set of items, which all reside on local storage, including MMC and phone.
+               ret = minfo_get_all_item_list(MINFO_CLUSTER_TYPE_LOCAL_ALL, item_filter, mitem_ite_cb, &p_list);
+
+               if(ret< 0) { 
+                       printf("minfo_get_item_list error\n");
+                       return;
+               }
+       }
+ * @endcode  
+
+ */
+
+int
+minfo_get_all_item_list(const minfo_folder_type cluster_type, const minfo_item_filter filter, minfo_item_ite_cb func, void *user_data);
+
+/**
+ * This function gets mitem list, which is searched by string specified by user.
+ * @p search_field is a field to want to search. @p search_str could specify string to search.
+ * Menawhile data of each mitem instance mainly derive from media table record. However meta data
+ * is composed of video_meta or image_meta record.
+ *
+ * @param      search_field    [in] A field to want search. Please refer the enum type minfo_search_field_t in 'minfo-types.h'.
+ * @param      search_str      [in]    A string to search.
+ * @param      folder_type     [in]    the folder type which specify media files belong to.
+ * @param      filter          [in]    the filter to specify some filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, whether just get the favorites, etc.
+ * @param   func      [in]  Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ * @param   user_data      [out]   user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
+ * @return     This function returns 0 on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @remarks    type of data memeber of list is pointer to the structure type 'Mitem'
+ *                     when free list, it need free every item first and then free list itself. 
+ * @see                None.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+    #include <media-svc.h>
+     
+       int mitem_ite_cb(Mitem *item, void *user_data)
+       {
+               GList **list = (GList **)user_data;
+               //append an item to linked list.
+               *list = g_list_append(*list, item);
+       }
+
+       void test_minfo_get_item_list_search(void)
+       {
+               int ret = -1;
+               GList *p_list = NULL;
+               const char *search_str = "Hiphop";
+               minfo_search_field_t search_field = MINFO_SEARCH_BY_NAME;
+               minfo_folder_type folder_type = MINFO_CLUSTER_TYPE_ALL;
+
+               minfo_item_filter item_filter = {MINFO_ITEM_VIDEO, MINFO_MEDIA_SORT_BY_NAME_ASC, 0, 9, false, MINFO_MEDIA_FAV_ALL};
+
+               ret = minfo_get_item_list_search(search_field, search_str, folder_type, item_filter, mitem_ite_cb, &p_list);
+
+               if (ret< 0) {
+                       printf("minfo_get_item_list_search error\n");
+                       return;
+               }
+       }
+ * @endcode  
+
+ */
+
+int
+minfo_get_item_list_search(minfo_search_field_t search_field, const char *search_str, minfo_folder_type folder_type, const minfo_item_filter filter, minfo_item_ite_cb func, void *user_data);
+
+/**
+ * This function gets count of all records in media table. This function returns the count of all items, which are unlocked excluding web media.
+ *
+ * @param   cnt         [out]   returned value, count of all records
+ * @return     This function returns zero(MB_SVC_ERROR_BASE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @remarks    None. 
+ * @see        None.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+     #include <media-svc.h>
+     
+       void test_minfo_get_all_item_cnt(void)
+       {
+               int ret = -1;
+               int cnt = 0;
+
+               ret = minfo_get_all_item_cnt(&cnt);
+               if(ret< 0) { 
+                       printf("minfo_get_all_item_cnt error\n");
+                       return;
+               }
+       }
+ * @endcode
+ */
+
+int
+minfo_get_all_item_cnt(int *cnt);
+
+
+/**
+ * This function gets count of matched records in media table with the specified @p filter, which 
+ * specify some filter conditions, like, type of got items, sort by type, start and end positions 
+ * of items, including meta data or not, whether just get the favorites, etc.
+ * The detail structure type of @p filter, could refer to the defination 'minfo_item_filter'
+ * in header file, minfo-types.h.
+ *
+ * @param      cluster_id      [in]    the folder id in which media files are in. if the parameter is -1, then query all folders.
+ * @param      filter          [in]    the filter to specify some filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, whether just get the favorites, etc.
+ * @param   cnt         [out]   returned value, count of matched records
+ * @return     This function returns 0 on success, or negative value with error code.
+ *                     
+ * @remarks    list contains a set of full path string of cover file. 
+ * @see                minfo_get_item_list.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+     #include <media-svc.h>
+     
+       void test_minfo_get_item_cnt(void)
+       {
+               int ret = -1;
+               const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+               minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,-1,10,true,true};
+
+               //get count of a set of items.
+               ret = minfo_get_item_cnt(cluster_id, item_filter, &cnt);
+               if(ret< 0) { 
+                       printf("test_minfo_get_item_cnt error\n");
+                       return;
+               }
+       }
+ * @endcode
+ */
+
+int
+minfo_get_item_cnt(const char *cluster_id, const minfo_item_filter filter, int *cnt);
+
+
+
+/**
+ * This function gets count of matched records from folder table  with the specified @p filter, which 
+ * specify some filter conditions, like, type of got clusters, sort by type, start and end positions 
+ * of clusters, etc. The detail structure type of @p filter, could refer to the defination 'minfo_cluster_filter'
+ * in header file, minfo-types.h.
+ * 
+ *
+ *
+ * @param      filter          [in]    filter to specify some filter conditions, like, type of got clusters, sort by type, start and end positions of clusters
+ * @param   cnt         [out]  returned value, count of matched records
+ * @return     This function returns 0 on success, or negative
+ *                     value with error code.
+ * @remarks    None.
+ * @see                                 minfo_get_cluster_list.         
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+   
+      #include <media-svc.h>
+     
+       void test_minfo_get_cluster_cnt(void)
+       {
+               int ret = -1;
+               minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,-1,10};
+
+               //get the count of items which is owned by a cluster.
+               ret = minfo_get_cluster_cnt(cluster_filter, &cnt);
+               if(ret< 0) { 
+                       printf("test_minfo_get_cluster_cnt error\n");
+                       return;
+               }
+       }
+ * @endcode    
+ */
+
+int
+minfo_get_cluster_cnt(const minfo_cluster_filter filter, int *cnt);
+
+
+/**
+ * This function gets Mcluster instances list. Data of each instance is composed of the matched records from folder table 
+ * with the @p filter, which specify some filter conditions, like, type of got clusters, sort by type, start and end positions 
+ * The detail structure type of @p filter, could refer to the defination 'minfo_cluster_filter'
+ * in header file, minfo-types.h.
+ *
+ * @param      filter          [in]    filter to specify some filter conditions, like, type of got clusters, sort by type, start and end positions of clusters
+ * @param      func      [in]  Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ * @param      user_data      [out]   user's data structure to contain items of the type Mcluster. It is passed to the iterative callback.
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks         item type in list is pointer to structure mcluster
+ *                    when free list, it need free every item first and then free list itself.
+ * @see                None.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+    #include <media-svc.h>
+     
+       int mcluster_ite_cb(Mcluster *cluster, void *user_data)
+       {
+               GList** list = (GList**)user_data;
+               *list = g_list_append(*list, cluster);
+       }
+
+       void test_minfo_get_cluster_list(void)
+       {
+               int ret = -1;
+               int i;
+               int img_cnt;
+               GList *p_list = NULL;
+               Mcluster* cluster = NULL;
+
+        //get a linked list which include all of clusters based on a specified filter.
+               minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,0,10};
+
+               ret = minfo_get_cluster_list(cluster_filter, mcluster_ite_cb, &p_list);
+
+               if( ret < 0) {
+                        return;
+               }
+       }
+ * @endcode     
+ */
+
+int
+minfo_get_cluster_list(const minfo_cluster_filter filter, minfo_cluster_ite_cb func, void *user_data);
+
+
+/**
+ * This function gets matched 'Mmeta' instances. Data of the instance is composed of the matched media record from 
+ * 'video_meta'/'image_meta' table, when finish using the Mmeta instance, should call API, minfo_mmeta_destroy to 
+ * destroy this created instance.
+ *
+ * @param                      media_id       [in]                     specified _id field in media table record
+ * @param                  meta                   [out]                pointer to pointer of matched Mmeta instance
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks    after using meta, it must be freed.           .                               
+ * @see                None.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+     #include <media-svc.h>
+     
+       void test_minfo_get_meta_info(void)
+       {
+               int ret = -1;
+               Mmeta* mt = NULL;
+               const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+
+               //get a matched meta data.
+               ret = minfo_get_meta_info(media_id, &mt);
+               if( ret < 0) {
+                       printf("minfo_get_meta_info failed\n");
+                       return ret;
+               }
+               minfo_mmeta_destroy(mt);
+       }
+
+ * @endcode                
+ */
+
+int
+minfo_get_meta_info(const char *media_id, Mmeta** meta);
+
+/**
+ * This function will update the corresponding field's value in database 'image_meta' table, this will be decided by the
+ * @p meta_field, whose type is 'minfo_image_meta_field_t', and indicate which field will be replaced by the value of int type
+ * pointered to by @p updated_value.
+ *
+ * @param                  media_id       [in]                 specified _id field in media table record
+ * @param                  meta_field             [in]         the enum value indicate which field of database table will be updated
+ * @param                  updated_value         [in]          value of int, which will replace the original value in database image meta table
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks    after using meta, it must be freed.
+ * @see                None.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+      #include <media-svc.h>
+     
+       void test_minfo_update_image_meta_info_int(void)
+       {
+               int ret = -1;
+               int width = 640;
+               int height = 480;
+               const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+
+               // update image meta's 'width and height' member 
+               ret = minfo_update_image_meta_info_int(media_id, MINFO_IMAGE_META_WIDTH, width, MINFO_IMAGE_META_HEIGHT, height);
+               if( ret < 0) {
+                       printf("minfo_update_image_meta_info_int failed\n");
+                       return;
+               }
+       }
+
+ * @endcode                
+ */
+
+EXPORT_API int
+minfo_update_image_meta_info_int(const char *media_id,
+                               minfo_image_meta_field_t meta_field,
+                               const int updated_value,
+                               ...);
+
+/**
+ * This function will update the corresponding field's value in database 'video_meta' table, this will be decided by the
+ * @p meta_field, whose type is 'minfo_video_meta_field_t', and indicate which field will be replaced by the value of int type
+ * pointered to by @p updated_value.
+ *
+ * @param                  media_id       [in]                 specified _id field in media table record
+ * @param                  meta_field             [in]         the enum value indicate which field of database table will be updated
+ * @param                  updated_value         [in]          value of int, which will replace the original value in database video meta table
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks    after using meta, it must be freed.
+ * @see                None.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+      #include <media-svc.h>
+     
+       void test_minfo_update_video_meta_info_int(void)
+       {
+               int ret = -1;
+               int _value = 876;
+               const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+
+               //update video meta's 'last_played_time' member
+               ret = minfo_update_video_meta_info_int(media_id, MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED, _value);
+
+               if( ret < 0) {
+                       printf("minfo_update_video_meta_info_int failed\n");
+                       return;
+               }
+       }
+
+ * @endcode                
+ */
+
+int
+minfo_update_video_meta_info_int(const char *media_id, minfo_video_meta_field_t meta_field, const int updated_value);
+
+
+/**
+* 
+* This function free an type instantiated object, whose type may be any one recognized by media-svc, these type
+* will include Mitem, Mimage, Mvideo, Mmeta, Mcluster, etc. In this function, it will check the concrete type for the 
+* @p item, and then decide which free function will really be called.
+*
+* @return            This function returns 0 on success, and negativa value on failure.
+* @param             item [in]        the input parameter, inlcuding the instanciated object.
+* @exception                    None.
+* @remarks             This function is general one, it will be able to destroy any recognized instantiated object 
+*                              by media-svc, so when you create or get an instantiated object from media-svc, and then call
+*                         this function to free it.                        
+*                                       
+* @see         None.
+* @pre None
+* @post        None
+* @par example
+* @code
+
+     #include <media-svc.h>
+     
+       void test_minfo_destroy_mtype_item(void)
+       {
+               int ret = -1;
+               Mitem *mi = NULL;
+               
+               char* file_url = "/opt/media/Images/Wallpapers/Home_01.png";
+               ret = minfo_get_item(file_url, &mi);
+
+               //destroy an item whose type is 'Mitem'.
+               ret = minfo_destroy_mtype_item(mi);
+
+               if( ret < 0) {
+                        return ret;
+               }
+               
+       }
+ * @endcode     
+*/
+
+int
+minfo_destroy_mtype_item(void* item);
+
+
+/**
+ * This function inserts new media file information into media table,video_meta table/image_meta table.
+   Or updates file information in these tables if the file is updated
+ *
+ * @param      trans_count  [in]              count of trasaction user wants
+
+ * @return     This function returns 0/positive on success, or negative value with error code. (0 : added, 1: updated, 2: skipped )
+ * @remarks    if invoke this function with same input parameter, it fails
+ * @see        minfo_add_media_end, minfo_add_media_batch
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+    #include <media-svc.h>
+     
+       void test_minfo_add_media_batch(void)
+       {
+               int err = -1, i;
+
+               err = minfo_add_media_start(100);
+               if( err < 0) {
+                       printf("minfo_add_media_start failed\n");
+                       return;
+               }
+
+               for (i = 0; i < 200; i++) {
+                       err = minfo_add_media_batch(image_files[i], MINFO_ITEM_IMAGE);
+
+                       if( err < 0) {
+                               printf("minfo_add_media_start failed\n");
+                               return;
+                       }
+               }
+
+               err = minfo_add_media_end();
+               if( err < 0) {
+                       printf("minfo_add_media_end failed\n");
+                       return;
+               }
+       }
+ * @endcode                    
+ */
+
+int
+minfo_add_media_start(int trans_count);
+
+
+/**
+ * This function inserts new media file information into media table,video_meta table/image_meta table.
+   Or updates file information in these tables if the file is updated
+ *
+ * @param      file_url  [in]              the local file full path
+ * @param       type     [in]     the file type, maybe it's video file or image file
+
+ * @return     This function returns 0/positive on success, or negative value with error code. (0 : added, 1: updated, 2: skipped )
+ * @remarks    if invoke this function with same input parameter, it fails
+ * @see         minfo_add_media_start, minfo_add_media_end
+ * @pre        None
+ * @post       None
+ * @par example
+ * @code
+    #include <media-svc.h>
+       
+       void test_minfo_add_media_batch(void)
+       {
+               int err = -1, i;
+
+               err = minfo_add_media_start(100);
+               if( err < 0) {
+                       printf("minfo_add_media_start failed\n");
+                       return;
+               }
+
+               for (i = 0; i < 100; i++) {
+                       err = minfo_add_media_batch(image_files[i], MINFO_ITEM_IMAGE);
+
+                       if( err < 0) {
+                               printf("minfo_add_media_start failed\n");
+                               return;
+                       }
+               }
+
+               err = minfo_add_media_end();
+               if( err < 0) {
+                       printf("minfo_add_media_end failed\n");
+                       return;
+               }
+       }
+ * @endcode                    
+ */
+
+int
+minfo_add_media_batch(const char* file_url, minfo_file_type content_type);
+
+/**
+ * This function inserts new media file information into media table,video_meta table/image_meta table.
+   Or updates file information in these tables if the file is updated
+ *
+ * @return     This function returns 0/positive on success, or negative value with error code. (0 : added, 1: updated, 2: skipped )
+ * @remarks    if invoke this function with same input parameter, it fails
+ * @see        minfo_add_media_start, minfo_add_media_batch
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+    #include <media-svc.h>
+     
+       void test_minfo_add_media_batch(void)
+       {
+               int err = -1, i;
+
+               err = minfo_add_media_start(100);
+               if( err < 0) {
+                       printf("minfo_add_media_start failed\n");
+                       return;
+               }
+
+               for (i = 0; i < 200; i++) {
+                       err = minfo_add_media_batch(image_files[i], MINFO_ITEM_IMAGE);
+
+                       if( err < 0) {
+                               printf("minfo_add_media_start failed\n");
+                               return;
+                       }
+               }
+
+               err = minfo_add_media_end();
+               if( err < 0) {
+                       printf("minfo_add_media_end failed\n");
+                       return;
+               }
+       }
+ * @endcode                    
+ */
+
+int
+minfo_add_media_end();
+
+/**
+ * This function inserts new media file information into media table,video_meta table/image_meta table.
+   Or updates file information in these tables if the file is updated
+ *
+ * @param      file_url  [in]              the local file full path
+ * @param       type     [in]     the file type, maybe it's video file or image file
+
+ * @return     This function returns 0/positive on success, or negative value with error code. (0 : added, 1: updated, 2: skipped )
+ * @remarks    if invoke this function with same input parameter, it fails
+ * @see         minfo_delete_media
+ * @pre        None
+ * @post       None
+ * @par example
+ * @code
+
+       #include <media-svc.h>
+     
+       void test_minfo_add_media(void)
+       {
+               int err = -1;
+               char *file_url = "/opt/media/Images/Wallpapers/Home_01.png";
+
+               //add a new media content whose url is 'file_url'.
+               err = minfo_add_media(file_url, MINFO_ITEM_IMAGE);
+
+               if( err < 0) {
+                       printf("minfo_add_media failed\n");
+                       return;
+               }
+       }
+ * @endcode                    
+ */
+
+
+int
+minfo_add_media(const char* file_url, minfo_file_type content_type);
+
+
+
+/**
+ * This function deletes matched media table record, video_meta/image_meta record. After that, if the folder which this file is in is empty, then delete the folder record.
+ * When user actually delete a media file in file system, he/she should call this function to delete the corresponding record in 'media' table, meanwhile it may delete the 
+ * folder record in 'folder' table if this folder will not include any media content.
+ *
+ * @param                      file_url       [in]                      matched local file full path
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks     None.  
+ * @see         minfo_add_media 
+ * @pre        None
+ * @post       None
+ * @par example
+ * @code
+
+    #include <media-svc.h>
+     
+    void test_minfo_delete_media(void) 
+       {
+               int ret = -1;
+               char *file_url = "/opt/media/Images/Wallpapers/Home_01.png";
+
+               //delete a media reord from 'media' table.
+               ret= minfo_delete_media(file_url);
+
+               if( ret < 0) {
+                       printf("minfo_delete_media failed\n");
+                       return;
+               }
+       }
+ * @endcode                
+ */
+
+int
+minfo_delete_media(const char* file_url);
+
+
+
+/**
+ * This function moves the media file to another place. When user actually move a media file ( @p old_file_url )in file system to the destination
+ * pathname ( @p new_file_url ), he/she need to call this function to move the record of 'media' table. Meanwhile user is responsible for identifying 
+ * the file's type, like image, video, etc. 
+ * @param    old_file_url   [in]               old local file full path of the media file
+ * @param       new_file_url   [in]                new local file full path of the media file
+ * @param       type           [in]                     media file type,maybe vidoe or image
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks    None.   
+ * @see   minfo_mv_media, minfo_copy_media, minfo_update_media_name.
+ * @pre        None
+ * @post       None
+ * @par example
+ * @code
+
+
+      #include <media-svc.h>
+     
+       void test_minfo_move_media(void)
+       {
+               int ret = -1;
+               char* old_file_url = "/opt/media/Images/Wallpapers/Home_01.png";
+               char* new_file_url = "/opt/media/Images/Wallpapers/Home_01_1.png";
+
+               //move an item to a specified location.
+               ret = minfo_move_media(old_file_url, new_file_url, MINFO_ITEM_IMAGE);
+
+               if( ret < 0) {
+                       printf("minfo_move_media failed\n");
+                       return;
+               }
+       }
+ * @endcode     
+ */
+
+int
+minfo_move_media(const char* old_file_url, const char *new_file_url, minfo_file_type content_type);
+
+
+
+/**
+ * This function copies the media file to another place. User should pass the full pathnames for these parameters, @p old_file_url and @ new_file_url
+ * respectively. The @p old_file_url indicate the original full pathname of this media content, and @ new_file_url indicate the destination full pathname of
+ * the copied file.
+ * @param    old_file_url   [in]               old local file full path of the media file
+ * @param       new_file_url   [in]                new local file full path of the media file
+ * @param       type           [in]                     media file type, maybe vidoe or image
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks    This function will not return the thumbnail pathname of new media file, user could get this new thumnail file using the function, minfo_get_thumb_path.
+ * @see         minfo_cp_media, minfo_update_media_name, minfo_move_media
+ * @pre        None
+ * @post       None
+ * @par example
+ * @code
+
+    #include <media-svc.h>
+     
+    void test_minfo_copy_media(void)
+    {
+        int ret =-1;
+        
+        char *file_url = "/opt/media/Images/Wallpapers/Home_01.png";
+           char *new_file_url = "/opt/media/Images/Wallpapers/Home_01_1.png";
+
+           //copy a media file to other location whos name is specified by 'new_file_url'.
+        ret  = minfo_copy_media( old_file_url, new_file_url, file_type);
+        if( ret < 0) {
+              printf("minfo_copy_media failed\n");
+              return;
+               }
+
+    }
+ * @endcode     
+ */
+
+int
+minfo_copy_media(const char* old_file_url, const char *new_file_url, minfo_file_type content_type);
+
+
+/**
+ * This function rename a image or video file. Here this function will assume the folder name of 
+ * file whose name is changed keep unchanged. That is, this file which is changed name still is located in the same folder.
+ * This function actually call sqlite3 
+ * UPDATE %s SET ... WHERE _id = _id;
+ * @param    media_id   [in]          the id of specified media file
+ * @param       new_name       [in]                new name of the media file
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks     None.  
+ * @see    minfo_move_media, minfo_copy_media.   
+ * @pre        None
+ * @post       None
+ * @par example
+ * @code
+
+     #include <media-svc.h>
+     
+     void test_minfo_update_media_name(void)
+     {
+        int ret = -1;
+               const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";  
+
+        //update media name
+        ret = minfo_update_media_name(media_id, new_name);
+           if( ret < 0) {
+              printf("test_minfo_update_media_name failed\n");
+              return;
+           }
+     }
+ * @endcode      
+ */
+
+int
+minfo_update_media_name(const char *media_id, const char* new_name);
+
+/**
+ * This function updates a thumbpath of the media in DB.
+ * @param    media_id   [in]          the id of specified media file
+ * @param       thumb_path     [in]                new thumbnail path of the media file
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks     None.  
+ * @see None
+ * @pre        None
+ * @post None
+ * @par example
+ * @code
+
+     #include <media-svc.h>
+     
+     void test_minfo_update_media_thumb(void)
+     {
+        int ret = -1;
+               const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+               const char *thumb_path = "/opt/media/test.jpg";
+
+        //update thumbnail path
+        ret = minfo_update_media_thumb(media_id, thumb_path);
+        if( ret < 0) {
+                  printf("minfo_update_media_thumb failed\n");
+                  return;
+           }
+     }
+ * @endcode      
+ */
+
+int
+minfo_update_media_thumb(const char *media_id, const char* thumb_path);
+
+/**
+ * This function updates favorite field of image or video file in 'media' table. This function actually call the Sqlite3 UPDATE,
+ * In Gallery application or ug-imageviewer, user could want to set a media file as favorite or unfovarite, so he/she could call
+ * this API to do it.
+ * @param    media_id       [in]              Unique id of the media file
+ * @param    favorite_level    [in]               new favorite_level of the media file, indicate whether this media content is favorite or unfavorite.
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks    None.   
+ * @see     None.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+     #include <media-svc.h>
+     
+     void test_minfo_update_media_favorite(void)
+     {
+         int ret = -1;
+                const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+
+         //update an item's favorite record
+         ret = minfo_update_media_favorite(media_id, favorite_level);
+
+            if( ret < 0) {
+                   printf("minfo_update_media_favorite failed\n");
+                   return;
+            }
+     }
+ * @endcode     
+ */
+
+int  
+minfo_update_media_favorite(const char *media_id, const int favorite_level);
+
+
+/**
+ * This function updates modified date of image or video file in 'media' table. This function actually call the Sqlite3 UPDATE.
+ * In Gallery application or ug-imageviewer, user could want to set moedified date of a media, so he/she could call this API to do it.
+ * @return  This function returns zero(MB_SVC_ERROR_BASE) on success, or negative value with error code.
+ * @param    media_id       [in]              Unique id of the media file
+ * @param    modified_date     [in]               date to modify, which is a type of time_t 
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks    None.   
+ * @see     None.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+     #include <media-svc.h>
+     
+     void test_minfo_update_media_date(void)
+     {
+        int ret = -1;
+               const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+
+               time_t today;
+        time(&today);
+
+        //update an item's date record
+        ret = minfo_update_media_date(media_id, today);
+           if( ret < 0) {
+                  printf("minfo_update_media_date failed\n");
+                  return;
+           }
+     }
+ * @endcode     
+ */
+
+int  
+minfo_update_media_date(const char *media_id, time_t modified_date);
+
+
+/**
+ * This function adds new local folder. This function could be called when user want to add a Album(local folder)
+ * in Gallery application. This function actually call the sqlite INSERT statement to insert the record in folder
+ * table. Meanwhile it will return new added local folder's ID to @p id.
+ * Sqlie3 statement looks like this, INSERT INTO folder (...);
+ * @param    cluster_url       [in]          the local directory of added folder, it should be full pathname of local folder
+ * @param       id                    [out]      id of the added folder, this function will return a unique ID to calling application
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks    if invoke this function with same input parameter, it fails   
+ * @see     minfo_delete_cluster
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+     #include <media-svc.h>
+     
+       void test_minfo_add_cluster(void)
+       {
+               int ret = -1;
+               char *cluster_url = "/opt/media/Images/Wallpapers";
+               char cluster_id[256];
+
+               //add a new cluster whose url is 'cluster_url'.
+               ret = minfo_add_cluster(cluster_url, cluster_id, sizeof(cluster_id));
+               if( ret < 0) {
+                       printf("minfo_add_cluster failed\n");
+                       return;
+               }
+       }
+ * @endcode    
+ */
+
+int
+minfo_add_cluster(const char* cluster_url, char *id, int max_length);
+
+/**
+ * This function gets mitem information. When user could get the unique ID of a media content, he/she
+ * could get the detail information with the type 'Mitem', which include the below feilds, like, item's unique id,
+ * media content type, media content's thumbnail name, media content's pathname, etc. The detail defination 
+ * of this structute, could refer to the header, minfo-item.h.
+ * @param    media_id       [in]             the local file media id
+ * @param    mitem          [out]        the returned data structure whose type is Mitem.
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks       when invoking this function, *mitem must equals NULL, and
+ *                  the @p media_id should be valid ID, if it is invalid, like -1 or 0, this 
+ *                     function will return @p mitem whose content is NULL. If normally, @p mitem must be freed with minfo_mitem_destroy.
+ * @see     minfo_get_item.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+     #include <media-svc.h>
+     
+       void test_minfo_get_item_by_id(void)
+       {
+               int ret = -1;
+               const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+               Mitem *mi = NULL;
+
+               //get an item based on its media ID.
+               ret = minfo_get_item_by_id(media_id, &mi);
+               if(ret < 0) {
+                       return;
+               }
+
+               minfo_destroy_mtype_item(mi);
+       }
+ * @endcode    
+ */
+
+int
+minfo_get_item_by_id(const char *media_id, Mitem **mitem);
+
+
+/**
+ * This function gets mitem information. When user could get the full pathname of a media content, he/she
+ * could get the detail information with the type 'Mitem', which include the below feilds, like, item's unique id,
+ * media content type, media content's thumbnail name, media content's pathname, etc. The detail defination 
+ * of this structute, could refer to the header, minfo-item.h.
+ * @param    file_url          [in]          the local file full pathname
+ * @param    mitem          [out]        the returned data structure whose type is Mitem.
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks       when invoking this function, *mitem must equals NULL, and
+ *                  after using mitem, it must be freed with minfo_mitem_destroy.
+ * @see     minfo_get_item_by_id.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+     #include <media-svc.h>
+     
+       void test_minfo_get_item(void)
+       {
+               int ret = -1;
+               Mitem *mi = NULL;
+               char* file_url = "/opt/media/Images/Wallpapers/Home_01.png";
+
+               //get an item based on its url.
+               ret = minfo_get_item(file_url, &mi);
+               if(ret < 0) {
+                       return;
+               }
+
+               minfo_destroy_mtype_item(mi);
+       }
+ * @endcode    
+ */
+
+int
+minfo_get_item(const char* file_url, Mitem **mitem);
+
+/**
+ * This function gets mitem information. When user could get the http url of a media content, which is downloaded from web, he/she
+ * could get the detail information with the type 'Mitem', which include the below feilds, like, item's unique id,
+ * media content type, media content's thumbnail name, etc. The detail defination 
+ * of this structute, could refer to the header, minfo_item/minfo-item.h.
+ * @param    http_url    [in]        the http url of a media, which is downloaded from web.
+ * @param    mitem          [out]        the returned data structure whose type is Mitem.
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @remarks       when invoking this function, *mitem must equals NULL, and
+ *                  after using mitem, it must be freed with minfo_mitem_destroy.
+ * @see     minfo_get_item_by_id, minfo_get_item
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+     #include <media-svc.h>
+     
+       void test_minfo_get_item_by_http_url(void)
+       {
+               int ret = -1;
+               Mitem *mi = NULL;
+               char* http_url = "http://picasa.com/myaccount/Home_01.png";
+
+               //get an item based on its http url.
+               ret = minfo_get_item_by_http_url(http_url, &mi);
+               if(ret < 0) {
+                       return;
+               }
+
+               minfo_destroy_mtype_item(mi);
+       }
+ * @endcode    
+ */
+
+int 
+minfo_get_item_by_http_url(const char* http_url, Mitem **mitem);
+
+
+/**
+* 
+* This function gets mcluster information by folder full path or cluster id when user could not know exact url of cluster. When user could get full path of a folder, he/she
+* could get the detail information with the type 'Mcluster' about this cluster/local folder, the type 'Mcluster'
+* mainly include folder/cluster ID, display name, count of included media content, etc. The detail defination
+* of this type could refer to the herder file, minfo-cluster.h.
+*
+* @return             This function returns 0 on success, or negative value with error code.
+* @param             cluster_url [in]          local folder full path, it indicate which folder user want to get it's detail information
+* @param             cluster_id  [in]  the cluster ID which indentify a cluster
+* @param             mcluster [out]   mcluster to be returned, which is a 'Mcluster' type
+* @exception                    None.
+* @remarks                        when user could not know exact url of a cluster, he/she could choose alternative way he/she pass cluster id to this function, so that 
+*                                      this function still could get the wanted cluster.
+*                                      when invoking this function, *mcluster must equals NULL, and
+*                                     after using mitem, it must be freed with minfo_mcluster_destroy.
+* @see      minfo_mcluster_destroy
+* @pre         None
+* @post        None
+* @par example
+* @code
+*
+
+     #include <media-svc.h>
+     
+     void test_minfo_get_cluster(void)
+     {
+            int ret = -1;
+            Mcluster *mc = NULL;
+            char *cluster_url = "/opt/media/Images/Wallpapers";
+                       const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+            //get a cluster using cluster's url.
+            ret = minfo_get_cluster(cluster_url, cluster_id, &mc);
+                       if(ret < 0) {
+                               printf("minfo_get_cluster fail: %d \n", ret);
+                               return;
+                       }
+
+                       printf("minfo_get_cluster: %s \n", mc->display_name);
+                       minfo_mcluster_destroy(mc);
+        }
+* @endcode
+*/
+
+int 
+minfo_get_cluster(const char* cluster_url, const char *cluster_id, Mcluster **mcluster);
+
+
+/**
+ * This function gets thumbnail path of cover files by cluster id. This function could get the cover of a cluster
+ * or folder which may include first several items' thumbnails, maybe 5 or other number, user could specify it
+ * using @p img_cnt. 
+ *
+ * @param      cluster_id      [in]    the folder id in which media files are in. if the parameter is -1, then query all folders.
+ * @param      img_cnt         [in]    the count of cover thumbnails
+ * @param      func      [in]  Iterative callback implemented by a user. This callback is called when an thumbnail path has to be inserted to user's list.
+ * @param      user_data      [out]   user's data structure to contain items of thumbnail path. It is passed to the iterative callback.
+ *
+ * @return     This function returns 0 on success, or negative value with error code.
+ *                     
+ * @remarks    type of item is pointer to char*,
+ *                     when free list, needn't free every string. 
+ * @see                None.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+ *
+
+    #include <media-svc.h>
+
+       int cover_ite_cb(char *thumb_path, void *user_data)
+       {
+               GList** list = (GList**)user_data;
+               *list = g_list_append(*list, thumb_path);
+       }
+
+       void test_minfo_get_cluster_cover(void)
+       {
+               int ret = -1;
+               GList *p_list = NULL;
+               int img_cnt = 5;
+               const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+               //get the cover of a cluster.
+               ret = minfo_get_cluster_cover(cluster_id, img_cnt, cover_ite_cb, &p_list);
+               if(ret< 0) { 
+                       printf("test_minfo_get_cluster_cover error\n");
+                       return;
+               }
+       }
+
+  * @endcode
+  */
+
+int 
+minfo_get_cluster_cover(const char *cluster_id, const int img_cnt, minfo_cover_ite_cb func, void *user_data);
+
+
+/**
+ * This function gets the type 'Mbookmark' instances list. Data of each this type instance is 
+ * composed of the matched record indentified by the media id from  'video_bookmark' table. 
+ * The type 'Mbookmark' mainly include the these information, like, bookmark id, media id, 
+ * marked time, corresponding thumbnail pathanme, etc.
+ *
+ * @param      media_id                   [in] media_id field of video_bookmark table record
+ * @param      func      [in]  Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ * @param      user_data      [out]   User's data structure to contain items of the type Mbookmark. It is passed to the iterative callback.
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks       member data in list is pointer to structure Mbookmark,
+ *                    when free list, it need free every item first and then free list itself.
+ * @see                None.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+    #include <media-svc.h>
+
+       int mbookmark_ite_cb(Mbookmark *bm, void *user_data)
+       {
+               GList** list = (GList**)user_data;
+               *list = g_list_append(*list, bm);
+       }
+     
+    void test_minfo_get_bookmark_list(void)
+       {
+               int ret = -1;
+               const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+               GList *p_list = NULL;
+
+        //get a linked list which will include all of bookmarks of a media file.
+               ret = minfo_get_bookmark_list(media_id, mbookmar_ite_cb, &p_list);
+               if( ret < 0) {
+                       return;
+               }
+       }
+  * @endcode    
+ */
+
+int
+minfo_get_bookmark_list(const char *media_id, minfo_bm_ite_cb func, void *user_data);
+
+
+/**
+ * This function gets the type 'Mitem' instances list. Data of each instance is composed of the matched record identified 
+ * by @p filter from 'media' table. Except that the got items pass the criterion of  @p filter, they should position where the longitude
+ * is between @p min_longitude and @p max_longitude, and the latitude is between @p min_latitude and @p max_latitude.
+*  This function gets 'Mitem' list matched with latitude, longitude, filter and cluster id.
+
+ * @param                      cluster_id       [in]                   indicate the value, 'fold_id' field in 'media' table record
+ * @param                      filter           [in]           specified filter to get matched media record
+ * @param                      store_filter           [in]             specified storage filter to get matched media record
+ * @param                      min_longitude    [in]                    minimum value of 'longitude' field in 'vidoe_meta'/'image_meta' table
+ * @param                      max_longitude    [in]            maximum value of longitude field in 'vidoe_meta'/'image_meta' table
+ * @param                      min_latitude     [in]            minimum value of 'latitude' field in 'video_meta'/'image_meta' record 
+ * @param                      max_latitude     [in]            maximum value of 'latitude' field in 'video_meta'/'image_meta' record
+ * @param      func      [in]  Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ * @param      user_data      [out]   user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks         item type in list is pointer to structure Mitem,
+ *                    when free list, it need free every item first  and then free list itself. 
+ * @see                None.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+    #include <media-svc.h>
+
+       int mitem_ite_cb(Mitem *item, void *user_data)
+       {
+               GList** list = (GList**)user_data;
+               *list = g_list_append(*list, item);
+       }
+     
+    void test_minfo_get_geo_item_list(void)
+    {
+
+               int ret = -1; 
+               const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+               int min_longitude = 120.0;
+               int max_longitude = 123.0;
+               int min_latitude = 19.0;
+               int max_latitude = 24.0;
+               GList *p_list = NULL;
+
+               //get a linked list which include a set of items based on their location.
+               ret = minfo_get_geo_item_list(cluster_id, 
+                                               store_filter,
+                                   filter, 
+                                   min_longitude, 
+                                   max_longitude, 
+                                   min_latitude, 
+                                   max_latitude,
+                                               mitem_ite_cb,
+                                   &p_list);
+               if( ret < 0) {
+                       printf("minfo_get_geo_item_list failed\n");
+                       return;
+               }
+    }
+  * @endcode      
+ */
+
+int
+minfo_get_geo_item_list(const char *cluster_id, 
+                                               minfo_folder_type store_filter,
+                                               minfo_item_filter filter, 
+                                               double min_longitude, 
+                                               double max_longitude, 
+                                               double min_latitude, 
+                                               double max_latitude,
+                                               minfo_item_ite_cb func,
+                        void *user_data);
+
+
+
+
+
+/**
+ * This function gets thumbnail path of specified image file. When user could get the full pathname of a image content.
+ * He/She wants to get the thumbnail file corresponding to the image content identified by the @p file_url.
+ * User is responsible for allocating the memory for @p thumb_path so that this function could fill up the thumbnail pathname to it.
+ * @param                                       file_url         [in]          local file full path, identify a media record in 'media' table
+ * @param                                       thumb_path       [out] the returned thumbnail path of specified file, user is responsible for allocating memory for it first
+ * @param                                      max_thumb_path    [in] The max length of the returned thumbnail path
+ *
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks                     one file full path always matches one thumbnail path,
+                               here, it returns thumbnail path , but maybe thumbnail file doesn't exist, return NULL. 
+ * @see                minfo_get_thumb_path_for_video.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+     #include <media-svc.h>
+     
+       void test_minfo_get_thumb_path(void)
+       {
+               int ret = -1;
+               char thumb_path[256] = {'\0'};
+               char *file_url = "/opt/media/Images/Wallpapers/Home_01.png";
+
+               //get thumbnail pathname of an item.
+               ret = minfo_get_thumb_path(file_url, thumb_path, sizeof(thumb_path));
+               if( ret < 0) {
+                       printf("minfo_get_thumb_path failed\n");
+                       return;
+               }
+       }
+* @endcode       
+ */
+
+int
+minfo_get_thumb_path(const char* file_url, char* thumb_path, size_t max_thumb_path);
+
+/**
+ * This function gets thumbnail path of specified video file. When user could get the full pathname of a video content.
+ * He/She wants to get the thumbnail file corresponding to the video content identified by the @p file_url.
+ * User is responsible for allocating the memory for @p thumb_path so that this function could fill up the thumbnail pathname to it.
+ * @param                                       file_url         [in]          local file full path, identify a media record in 'media' table
+ * @param                                       thumb_path       [out] the returned thumbnail path of specified file, user is responsible for allocating memory for it first
+ * @param                                      max_thumb_path    [in] The max length of the returned thumbnail path
+ *
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks                     one file full path always matches one thumbnail path,
+                               here, it returns thumbnail path , but maybe thumbnail file doesn't exist, return NULL. 
+ * @see                minfo_get_thumb_path.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+     #include <media-svc.h>
+     
+       void test_minfo_get_thumb_path_for_video(void)
+       {
+               int ret = -1;
+               char thumb_path[256] = {'\0'};
+               char *file_url = "/opt/media/Images and videos/My video clip/Helicopter.mp4";
+
+               //get thumbnail pathname of an item.
+               ret = minfo_get_thumb_path_for_video(file_url,thumb_path, sizeof(thumb_path));
+               if( ret < 0) {
+                       printf("minfo_get_thumb_path_for_video failed\n");
+                       return;
+               }
+       }
+* @endcode       
+ */
+
+int
+minfo_get_thumb_path_for_video(const char* file_url, char* thumb_path, size_t max_thumb_path);
+
+/**
+ * This function deletes matched record identified by the @p media_id from 'media' table , 'video_meta'/'image_meta' record. 
+ * After that, if the folder which this deleted file is in becomes empty, then delete the folder record from 'folder' table, too. 
+ * In order that user could successfully delete the corresponding record from 'media' table, he/she should be able to the correct _id 
+ * of media content before it.
+ *
+ * @param      media_id       [in]                      represent the value, media '_id' in 'media' table record
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks    None.  
+ * @see     minfo_delete_media.  
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+       #include <media-svc.h>
+     
+    void test_minfo_delete_media_id(void) 
+       {
+               int ret = -1;
+               const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+
+               //delete an item according to its ID.
+               ret = minfo_delete_media_id(media_id);
+               if( ret < 0) {
+                       printf("test_minfo_delete_media_id failed\n");
+                       return;
+               }
+       }
+* @endcode             
+ */
+
+int
+minfo_delete_media_id(const char *media_id);
+
+
+
+/**
+ * This function copies specified media file to another folder, which is identified by the folder id, @p dst_cluster_id. Meanwhile the copied media file
+ * is identified by it's media id. Compared to API, minfo_copy_media, the different is , this function copy a media content to specified folder,
+ * according to the media content id and the destination folder's id, however the function, minfo_copy_media, copy a media content to specified folder
+ * according to the media file's full pathname and folder's full name.
+ * @param    src_media_id       [in]          id of the source media file, it's value is from '_id' field of the 'media' table
+ * @param       dst_cluster_id     [in]                   id of the destination folder, it's value is from '_id' field of the 'folder' table 
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks    This function will implement the same functionality as minfo_copy_media.
+ * @see  minfo_copy_media
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+    #include <media-svc.h>
+     
+     void test_minfo_cp_media(void)
+     {
+             int ret = -1;
+                        const char *src_media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+                        const char *dst_cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+             //copy the a media file whose ID is specified by, 'src_media_id', to a cluster.
+             ret = minfo_cp_media(src_media_id, dst_cluster_id);
+                    if( ret < 0) {
+                printf("minfo_cp_media failed\n");
+                return;
+                    }
+     }
+* @endcode      
+ */
+
+int
+minfo_cp_media(const char *src_media_id, const char *dst_cluster_id);
+
+
+
+/**
+ * This function moves specified media file to another folder, which is identified by the folder id, @p dst_cluster_id. Meanwhile the moved media file
+ * is identified by it's media id. Compared to API, minfo_move_media, the difference is that this function moves a media content to specified folder,
+ * according to the media content id and the destination folder's id, however the function, minfo_move_media, move a media content to specified folder
+ * according to the media file's full pathname and folder's full name.
+ * @param    src_media_id       [in]          id of the source media file, it's value is from '_id' field of the 'media' table
+ * @param       dst_cluster_id     [in]         id of the destination folder, it's value is from '_id' field of the 'folder' table 
+
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks    None.   
+ * @see   minfo_move_media.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+     #include <media-svc.h>
+     
+     void test_minfo_mv_media(void)
+     {
+               int ret = -1;
+               const char *src_media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+               const char *dst_cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+        //move an item to specified cluster.
+               ret = minfo_mv_media(src_media_id, dst_cluster_id);
+               if( ret < 0) {
+                       printf("minfo_mv_media failed\n");
+                       return;
+               }
+     }
+* @endcode  
+ */
+
+
+int
+minfo_mv_media(const char *src_media_id, const char *dst_cluster_id);
+
+
+
+/**
+ * This function deletes specified cluster, which is identified by the @p cluster_id. When user launch Gallery and in edit 'Albums' mode, if he/she
+ * want to delete a cluster/folder, so call this function to do it. When delete a cluster/folder, the media-svc will not only delete the record in 'folder' table,
+ * but delete all of records in 'media' table which are located in this folder, meanwhile delete the corresponding records in 'video_bookmark' table, etc.
+ * @param                                       cluster_id    [in]             cluster id, to indicate the deleted folder/cluster
+ * @return     This function returns 0 on success, or negative value with error code.
+* @remarks                        delete all releated contents in cluster together with cluster
+*                                     like all media files, image/video meta,bookmark information.   
+ * @see   minfo_add_cluster
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+     #include <media-svc.h>
+     
+     void test_minfo_delete_cluster(void)
+     {
+        int ret = -1;
+               const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+        //delete a cluster record, meanwhile this function will delete all of items owned by this cluster.
+        ret = minfo_delete_cluster(cluster_id);
+               if( ret < 0) {
+                       printf("minfo_delete_cluster failed\n");
+                       return;
+               }
+     }
+* @endcode       
+ */
+
+int
+minfo_delete_cluster(const char *cluster_id);
+
+
+
+/**
+ * This function updates the specified cluster name using @p new_name, which just indicate the new folder name. User could 
+ * call this function, when he/she wants to change some folder/cluster name. This really update the corresponding record in 
+ * 'folder' table.
+ * @param                                       cluster_id    [in]             cluster id, this value is from the '_id' field of 'folder' table
+ * @param                                       new_name      [in]             new cluster name
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks    None.   
+ * @see   None.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+     #include <media-svc.h>
+     
+     void test_minfo_update_cluster_name(void)
+     {
+        int ret = -1;
+               const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+        char *new_name = "newfolder";
+
+        //update a cluster's name
+        ret = minfo_update_cluster_name(cluster_id,new_name);
+               if( ret < 0) {
+                       printf("minfo_update_cluster_name failed\n");
+                       return;
+               }
+     }
+* @endcode      
+ */
+
+int
+minfo_update_cluster_name(const char *cluster_id, const char* new_name);
+
+/**
+ * This function updates the specified cluster modified date using @p modified_date, which just indicate the new modified date. User could 
+ * call this function, when he/she wants to change some clsuter's modified date. This really update the corresponding record in the DB
+ * @param                                       cluster_id    [in]             cluster id, this value is the identifier of the cluster
+ * @param                                       modified_date      [in]                date to modify, which is a type of time_t
+ * @return     This function returns zero(MB_SVC_ERROR_BASE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @remarks    None.   
+ * @see   None.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+     #include <media-svc.h>
+        #include <time.h>
+     
+     void test_minfo_update_cluster_date(void)
+     {
+               int ret = -1;
+               const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+               time_t today;
+               time(&today);
+
+               //update a cluster's name
+               ret = minfo_update_cluster_date(cluster_id, today);
+
+               if( ret < 0) {
+                       printf("minfo_update_cluster_date failed\n");
+                       return;
+               }
+     }
+* @endcode      
+ */
+
+int
+minfo_update_cluster_date(const char *cluster_id,  time_t modified_date);
+
+
+
+/**
+ * This function inserts new bookmark record into 'video_bookmark' table. The inserted data should include marked time of video content, @p position 
+ * and @p thumb_path, current extracted thumbnail file in marked time, etc. User should use @p media_id to identify the 
+ * video content, so that add bookmark to it.
+ * @param                                       media_id    [in]               media file id, uniquely identify the media content
+ * @param                                       position    [in]               marked time of the media file
+ * @param                                       thumb_path  [in]               the extracted thumbnail path for this marked time
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks                         if add same input parameters twice, it fails          
+ * @see    minfo_delete_bookmark
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+     #include <media-svc.h>
+     
+     void test_minfo_add_bookmark(void)
+     {
+        int ret = -1;
+        int position = 2346;
+               const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+        char *thumb_path = "tmp1";
+
+        //add a bookmark which include position, thumbnail, etc. to an item.
+        ret = minfo_add_bookmark(media_id,position,thumb_path);
+               if( ret < 0) {
+                       printf("minfo_add_bookmark failed\n");
+                       return;
+               }
+     }
+* @endcode        
+ */
+
+
+int
+minfo_add_bookmark(const char *media_id, const int position, const char* thumb_path);
+
+
+/**
+ * This function deletes specified bookmark record from 'video_bookmark' table, the deleted bookmark should be identified by @p bookmark_id. 
+ * This function actually call the sqlite3 statement, 
+ * "DELETE FROM video_bookmark WHERE _id = bookmark_id; "
+ * In gallery or ug-imageviewer, user could get a linked list bookmark for some media file, so he/she could delete one of them using @p bookmark_id.
+ * 
+ * @param                                       bookmark_id    [in]            _id field in video_bookmark table.
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks    user should give a correct bookmark ID to successfully delete it.
+ * @see  minfo_add_bookmark
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+     #include <media-svc.h>
+     
+     void test_minfo_delete_bookmark(void)
+     {
+        int ret = -1;
+        int bookmark_id = 1;
+
+        //delete a bookmark record in 'video_bookmark' table.
+        ret = minfo_delete_bookmark(bookmark_id);
+
+               if( ret < 0) {
+                       printf("minfo_delete_bookmark failed\n");
+                       return;
+               }
+     }
+* @endcode      
+ */
+
+int
+minfo_delete_bookmark(const int bookmark_id);
+
+
+
+
+/**
+* 
+* This function gets some folder's full path. This will be called when user want to know what one folder's unique
+* ID is. 
+*
+* @return                                      This function returns 0 on success, and -1 on failure.
+* @param[in]                           url         folder  path
+* @param[out]                          cluster_id               folder ID
+* @exception                           None.
+* @remarks                                     None.  
+* @see None.
+* @pre         None
+* @post        None
+* @par example
+* @code
+
+     #include <media-svc.h>
+     
+     void test_minfo_get_cluster_id_by_url(void)
+     {
+        int ret = -1;
+               char cluster_id[256] = {0,};
+        char *url = "/opt/media/Images/Wallpapers";
+
+        //get cluster's ID using cluster's url.
+        ret = minfo_get_cluster_id_by_url(url, cluster_id, sizeof(cluster_id));
+               if( ret < 0) {
+                       printf("test_minfo_get_cluster_id_by_url failed\n");
+                       return;
+               }
+     }
+* @endcode      
+*/
+int 
+minfo_get_cluster_id_by_url(const char* url, char* cluster_id, int max_length);
+
+
+/**
+* 
+* This function gets folder's name. This will be called when user want to know what one folder's name
+*
+* @return                                      This function returns 0 on success, and -1 on failure.
+* @param[in]                           cluster_id         folder ID
+* @param[out]                          cluster_name       folder name
+* @param[in]                           max_length         The max length of the returned folder name.
+* @exception                           None.
+* @remarks                                     None.  
+* @see None.
+* @pre         None
+* @post        None
+* @par example
+* @code
+
+     #include <media-svc.h>
+     
+     void test_minfo_get_cluster_name_by_id(void)
+     {
+               int ret = -1;
+               const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+               char *cluster_name[1024];
+
+               //get cluster's name using cluster's id.
+               ret = minfo_get_cluster_name_by_id(cluster_id, cluster_name, sizeof(cluster_name));
+
+               if( ret < 0) {
+                       printf("test_minfo_get_cluster_name_by_id failed\n");
+                       return;
+               } else {
+                       printf("cluster name is %s\n", cluster_name);
+                       return;
+               }
+     }
+* @endcode
+*/
+int 
+minfo_get_cluster_name_by_id(const char *cluster_id, char *cluster_name, int max_length );
+
+/**
+* 
+* This function gets folder's full path. This will be called when user want to know what one folder's full path.
+* User should specify the maximum length of the @p folder_path, so as to avoid over flow of the string.
+*
+* @return                                      This function returns 0 on success, and -1 on failure.
+* @param[in]                           cluster_id         folder ID
+* @param[out]                          folder_path       folder path name
+* @param[in]                      max_length   specify the maximum length of @p folder_path.
+
+* @exception                           None.
+* @remarks                                     None.  
+* @see None.
+* @pre         None
+* @post        None
+* @par example
+* @code
+
+     #include <media-svc.h>
+     
+     void test_minfo_get_cluster_fullpath_by_id(void)
+     {
+               int ret = -1;
+               const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+               char *folder_path[1024];
+
+               //get cluster's path name using cluster's id.
+               ret = minfo_get_cluster_fullpath_by_id(cluster_id, folder_path, sizeof(folder_path));
+
+               if( ret < 0) {
+                       printf("test_minfo_get_cluster_fullpath_by_id failed\n");
+                       return;
+               } else {
+                       printf("path name is %s\n", cluster_name);
+                       return;
+               }
+     }
+* @endcode      
+*/
+
+int
+minfo_get_cluster_fullpath_by_id(const char *cluster_id, char *folder_path, int max_length);
+
+
+
+/**
+* @fn     int  minfo_set_cluster_lock_status( int cluster_id, int lock_status );
+* This function set status for lock to DB. This will be called when user want to set to lock an album.
+*
+* @return                                      This function returns 0 on success, and -1 on failure.
+* @param[in]                           cluster_id          folder ID
+* @param[in]                           lock_status         status for lock to be saved ( 0 : unlock, 1 : lock )
+* @exception                           None.
+* @remarks                                     None.  
+* @see minfo_get_cluster_lock_status.
+* @pre         None
+* @post        None
+* @par example
+* @code
+
+     #include <media-svc.h>
+     
+     void test_minfo_set_cluster_lock_status(void)
+     {
+        int ret = -1;
+        int status = 1;
+               const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+        //set s cluster lock status.
+        ret = minfo_set_cluster_lock_status(cluster_id, status);
+
+               if( ret < 0) {
+                       printf("test_minfo_set_cluster_lock_status failed\n");
+                       return;
+               }
+     }
+* @endcode
+*/
+
+int
+minfo_set_cluster_lock_status(const char *cluster_id, int lock_status);
+
+/**
+* @fn     int  minfo_get_cluster_lock_status( int cluster_id, int *lock_status );
+* This function gets status for lock from DB.  This will be called when user want to get lock status for an album.
+*
+* @return                                      This function returns 0 on success, and -1 on failure.
+* @param[in]                           cluster_id          folder ID
+* @param[out]                          lock_status         status for cuurent lock status
+* @exception                           None.
+* @remarks                                     None.  
+* @see minfo_set_cluster_lock_status.
+* @pre         None
+* @post        None
+* @par example
+* @code
+
+     #include <media-svc.h>
+     
+     void test_minfo_get_cluster_lock_status(void)
+     {
+        int ret = -1;
+               const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+               int status = -1;
+
+        //get a cluster's status.
+        ret = minfo_get_cluster_lock_status(cluster_id, &status);
+
+               if( ret < 0) {
+                       printf("test_minfo_get_cluster_lock_status failed\n");
+                       return;
+               } else {
+                       print("Current status : %d\n", status);
+                       return;
+               }
+     }
+* @endcode
+*/
+
+int
+minfo_get_cluster_lock_status(const char *cluster_id, int *lock_status );
+
+/**
+* @fn     int  minfo_get_media_path( minfo_store_type storage_type, char* media_path, size_t max_media_path);
+* This function gets the path of media.  This will be called when user want to get path of direcotry containing media in device.
+*
+*
+* @return                                      This function returns 0 on success, and -1 on failure.
+* @param[in]                           storage_type         store type, which means type of device containg media.
+* @param[out]                          media_path         path of media
+* @param[in]                           max_media_path     The max length of the returned media_path.
+* @exception                           None.
+* @remarks                             None.  
+* @see None.
+* @pre         None
+* @post        None
+* @par example
+* @code
+
+     #include <media-svc.h>
+     
+     void test_minfo_get_media_path(void)
+     {
+        int ret = -1;
+               char media_path[256] = {'\0'};
+
+               //get media's fullpath.
+        ret = minfo_get_media_path(MINFO_PHONE, media_path, sizeof(media_path));
+
+               if( ret < 0) {
+                       printf("minfo_get_media_path failed\n");
+                       return;
+               } else {
+                       print("The returned path : %s\n", media_path);
+                       return;
+               }
+     }
+* @endcode
+*/
+
+int
+minfo_get_media_path( minfo_store_type storage_type, char* media_path, size_t max_media_path );
+
+
+/**
+ *     minfo_set_db_valid:\n
+ *     This function set whether all the media contents in a type of storage are valid, like phone or MMC.
+ *     Actually media service will filter all the media contents query from database by the media validation.\n
+ *     This function is always used for MMC card insert/inject operation, in file manager service library.
+ *     When inject a MMC card, the media records for MMC are not deleted really, but are set to be invalid.
+ *
+ *     @param[in]   storage_type               information for storage type
+ *     @param[in]      valid                           whether the track item is valid.
+ *     @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ *     @see            minfo_delete_invalid_media_records.
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <media-svc.h>
+
+void set_db_valid()
+{
+       int ret = MB_SVC_ERROR_NONE;
+       bool valid = TRUE;
+
+       //set the validation of medias in MMC storage in db.
+       ret = minfo_set_db_valid(MINFO_MMC, valid);
+       if (ret < 0) {
+               printf( "failed to set db invalid. error code->%d", ret);
+               return;
+       }
+}
+
+ *     @endcode
+ */
+
+int minfo_set_db_valid(const minfo_store_type storage_type, int valid);
+
+
+/**
+ *     minfo_delete_invalid_media_records:\n
+ *     This function delete all of invalid media records in a type of storage are valid, like phone or MMC.
+ *     Actually media service will filter all the media contents query from database by the media validation.\n
+ *     This function is always used for MMC card insert/inject operation, in file manager service library.
+ *     When inject a MMC card, the media records for MMC are not deleted really, but are set to be invalid.
+ *
+ *     @param[in]   storage_type               information for storage type
+ *     @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ *     @see            minfo_set_db_valid.
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <media-svc.h>
+
+void set_db_valid()
+{
+       int ret = MB_SVC_ERROR_NONE;
+
+       //delete the invalid media records in MMC storage in db.
+       ret = minfo_delete_invalid_media_records(MINFO_MMC);
+       if (ret < 0) {
+               printf( "failed to delete invalid items. error code->%d", ret);
+               return;
+       }
+}
+
+ *     @endcode
+ */
+
+int
+minfo_delete_invalid_media_records(const minfo_store_type storage_type);
+
+/**
+ *     minfo_delete_tag:\n
+ *     This function could delete a tag or some member of the tag in 'media_tag' table in database. When user pass @p media_id not equal
+ *    to -1, the tag will be deleted, otherwise some member of the tag will be deleted. Whatever cases, user should pass the correct tag name with
+ *    @p tag_name to successfully delete.
+ *
+ *     @param[in]   media_id           identify a media item with this ID
+ *     @param[in]   tag_name           name of deleted tag
+ *     @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ *     @see            None.
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <media-svc.h>
+
+void add_a_tag()
+{
+       int ret = MB_SVC_ERROR_NONE;
+
+       //delete all tag records in 'media_tag' in db, whose tag name is 'test_tag'.
+       ret = minfo_delete_tag(-1, "test tag");
+       if (ret < 0) {
+               printf( "failed to delete a tag record. error code->%d", ret);
+               return;
+       }
+}
+
+ *     @endcode
+ */
+
+int
+minfo_delete_tag(const char *media_id, const char* tag_name);
+
+
+/**
+ *     minfo_rename_tag:\n
+ *     This function could rename a tag_name  to another tag_name in 'media_tag' table in database. User need to pass @p src_tagname which indicate original 
+ *    tag name, @p dst_tag_name which is new tag name replacing @p src_tagname. This function will check whether the new tag name, @p dst_tag_name, has
+ *    existed in 'media_tag' table. If yes, this function will item by item replace old tag name, if no, this function will directly update old tag name to new tag name.
+ *   
+ *
+ *     @param[in]   src_tagname                identify original tag name
+ *     @param[in]   dst_tag_name               new tag name.
+ *     @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ *     @see            None.
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <media-svc.h>
+
+void test_minfo_rename_tag()
+{
+       int ret = MB_SVC_ERROR_NONE;
+
+       //rename all tag records with new tag name 'test_tag2'.
+       ret = minfo_rename_tag("test tag1", "test tag2");
+       if (ret < 0) {
+               printf( "failed to rename tag records. error code->%d", ret);
+               return;
+       }
+}
+
+ *     @endcode
+ */
+
+int
+minfo_rename_tag(const char* src_tagname, const char* dst_tag_name);
+
+/**
+ *     minfo_rename_tag_by_id:\n
+ *     This function could rename a tag_name for some tag record to another tag_name in 'media_tag' table in database. User need to pass @p src_tagname which indicate original 
+ *    tag name, @p media_id which combine with the @p src_tagname to indentify one tag record, @p dst_tag_name which is new tag name replacing @p src_tagname. 
+ *    This function will check whether the new tag name with @p media_id has existed in 'media_tag' table. If yes, this function will delete old tag record, if no, this function will directly 
+ *    update old tag record  to new tag record.
+ *   
+ *
+ *     @param[in]   media_id                   identify original tag record with @p src_tagname
+ *     @param[in]   src_tagname                identify original tag record with @p media_id
+ *     @param[in]   dst_tag_name               new tag name.
+ *     @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ *     @see            None.
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <media-svc.h>
+
+void test_minfo_rename_tag_by_id()
+{
+       int ret = MB_SVC_ERROR_NONE;
+       const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+
+       //rename some tag record with new tag name 'test_tag2'.
+       ret = minfo_rename_tag_by_id(media_id, "test tag1", "test tag2");
+       if (ret < 0) {
+               printf( "failed to rename tag records. error code->%d", ret);
+               return;
+       }
+}
+
+ *     @endcode
+ */
+
+int
+minfo_rename_tag_by_id(const char *media_id, const char* src_tagname, const char* dst_tag_name);
+
+
+
+
+/**
+ *     minfo_add_tag:\n
+ *     This function could add a new tag into 'media_tag' table in database. When user create a new tag and will
+ *    not add any media item to it, he/she should set @p media_id as 0. When user create a new tag and want to add 
+ *    some media items to it, he/she should do a loop to insert them into 'media_tag' table in database, meanwhile
+ *    should fill up @p media_id and @p tag_name with appropriate values.
+ *
+ *     @param[in]   media_id           identify a media item with this ID
+ *     @param[in]   tag_name           name of new added tag
+ *     @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ *     @see            None.
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <media-svc.h>
+
+void add_a_tag()
+{
+       int ret = MB_SVC_ERROR_NONE;
+
+       //add a tag record in 'media_tag' in db, and not add any media item to it.
+       ret = minfo_add_tag(NULL, "test tag");
+       if (ret < 0)
+       {
+               printf( "failed to add a tag record. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int
+minfo_add_tag(const char *media_id, const char* tag_name);
+
+/**
+ *     minfo_get_media_list_by_tagname:\n
+ *     This function could get a media items' list who are included to the same tag according to tag name .
+ *     User could dictate whether he/she hope to get meta data of media item with @p with_meta. Yes if TRUE,
+ *    no if FALSE.
+ *
+ *     @param[in]   tag_name                   tag name
+ *     @param[in]   with_meta          indicate whether want to get meta data of media item
+ *     @param[in]      func        Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ *     @param[out]  user_data       user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
+ *     @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ *     @see            None.
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <media-svc.h>
+
+int mitem_ite_cb(Mitem *item, void *user_data)
+{
+       GList** list = (GList**)user_data;
+       *list = g_list_append(*list, item);
+}
+
+
+void get_media_list_tag_name()
+{
+       int ret = MB_SVC_ERROR_NONE;
+       GList *p_list = NULL;
+
+       //get a media items' list who are included to the same tag with 'test tag'.
+       ret = minfo_get_media_list_by_tagname("test tag", FALSE, mitem_ite_cb, &p_list);
+       if (ret < 0) {
+               printf( "failed to get a media items' list. error code->%d", ret);
+               return;
+       }
+}
+
+ *     @endcode
+ */
+
+int
+minfo_get_media_list_by_tagname(const char* tag_name, bool with_meta, minfo_item_ite_cb func, void* user_data );
+
+/**
+ *     minfo_get_media_list_by_tagname_with_filter:\n
+ *     This function could get a media items' list who are included to the same tag according to tag name and filter.
+ *     User could dictate whether he/she hope to get meta data of media item with @p with_meta. Yes if TRUE,
+ *    no if FALSE.
+ *
+ *     @param[in]   tag_name           tag name
+ *  @param[in]   filter                        the filter to specify some tag filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, etc.
+ *     @param[in]      func        Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ *     @param[out]  user_data       user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
+ *     @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ *     @see            None.
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <media-svc.h>
+
+int mitem_ite_cb(Mitem *item, void *user_data)
+{
+       GList** list = (GList**)user_data;
+       *list = g_list_append(*list, item);
+}
+
+
+void get_media_list_by_tagname_with_filter()
+{
+       int ret = MB_SVC_ERROR_NONE;
+       GList *p_list = NULL;
+       minfo_tag_filter filter;
+
+       filter.start_pos = 0;
+       filter.end_pos = 3;
+       filter.file_type = MINFO_ITEM_ALL;
+       filter.with_meta = FALSE;
+
+       //get a media items' list who are included to the same tag with 'test tag'.
+       ret = minfo_get_media_list_by_tagname_with_filter("test tag", filter, mitem_ite_cb, &p_list);
+       if (ret < 0) {
+               printf( "failed to get a media items' list. error code->%d", ret);
+               return;
+       }
+}
+
+ *     @endcode
+ */
+
+int
+minfo_get_media_list_by_tagname_with_filter(const char* tag_name, minfo_tag_filter filter, minfo_item_ite_cb func, void* user_data );
+
+/**
+ *     minfo_get_media_count_by_tagname:\n
+ *     This function could get count of media items, which are included to the same tag according to tag name .
+ *     User could dictate whether he/she hope to get count of media items.
+ *
+ *     @param[in]   tag_name           tag name
+ *     @param[out]  count                      count of media items
+ *     @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ *     @see            None.
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <media-svc.h>
+
+void test_minfo_get_media_count_by_tagname()
+{
+       int ret = MB_SVC_ERROR_NONE;
+       int count = 0;
+
+       //get count of media items, which are included to the same tag with 'test tag'.
+       ret = minfo_get_media_count_by_tagname("test tag", &count);
+       if (ret < 0) {
+               printf( "failed to get a media items' list. error code->%d", ret);
+       } else {
+               printf( "Count is %d\n", count );       
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int
+minfo_get_media_count_by_tagname(const char* tag_name, int* count );
+
+/**
+ *     minfo_get_tag_list_by_media_id:\n
+ *     This function could get a tags' list whose memeber is Mtag type. User should pass @p media_id to indicate which
+ *    media item will be searched. Also he/she should define a callback function to be called by this function.
+ *
+ *     @param[in]   media_id           identify a media item with ID
+ *     @param[in]      func        Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ *     @param[out]  user_data       user's data structure to contain items of the type Mtag. It is passed to the iterative callback.
+ *     @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ *     @see            minfo_set_db_valid.
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <media-svc.h>
+
+int mtag_ite_cb(Mtag *i_tag, void *user_data)
+{
+       GList** list = (GList**)user_data;
+       *list = g_list_append(*list, item);
+}
+
+
+void get_tag_list_media_id()
+{
+       int ret = MB_SVC_ERROR_NONE;
+       const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+       GList *p_list = NULL;
+
+       //get a tags' list which include the same media item and it's media_id is b6a4f4ac-26ea-458c-a228-9aef7f70349d.
+       ret = minfo_delete_invalid_media_records(media_id, mtag_ite_cb, &p_list);
+       if (ret < 0) {
+               printf( "failed to get a tags' list. error code->%d", ret);
+               return;
+       }
+}
+
+ *     @endcode
+ */
+
+int
+minfo_get_tag_list_by_media_id(const char *media_id, minfo_tag_ite_cb func, void* user_data);
+
+/**
+ *     minfo_add_web_cluster:\n
+ *     This function could add a web album through specifying it's @p name, @p account_id. After adding a web
+ *    album, this function will return @p id.
+ *
+ *     @param[in]   sns_type           sns type, like, facebook, flickr, etc.
+ *     @param[in]      name        new added web album's name.
+ *     @param[in]  account_id       account ID.
+ *     @param[out]  id                         return album's id.
+ *     @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ *     @see            minfo_add_web_cluster_album_id.
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <media-svc.h>
+
+
+void add_web_cluster()
+{
+       int ret = MB_SVC_ERROR_NONE;
+       char cluster_id[256] = {0,};
+       
+       //add a web album.
+       ret = minfo_add_web_cluster(1, "web_album",  "1", cluster_id, sizeof(cluster_id));
+       if (ret < 0) {
+               printf( "failed to add a web album. error code->%d", ret);
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int
+minfo_add_web_cluster(int sns_type, const char* name,const char *account_id, char* id, int max_length);
+
+
+/**
+ *     minfo_add_web_cluster_album_id:\n
+ *     This function could add a web album through specifying it's @p name, @p account_id, @p album_id. After adding a web
+ *    album, this function will return @p id.
+ *
+ *     @param[in]   sns_type           sns type, like, facebook, flickr, etc.
+ *     @param[in]      name        new added web album's name.
+ *     @param[in]  account_id       account ID.
+ *     @param[in]  album_id       web album id
+ *     @param[out]  id                         return album's id.
+ *     @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ *     @see            minfo_add_web_cluster.
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <media-svc.h>
+
+
+void add_web_cluster_album_id()
+{
+       int ret = MB_SVC_ERROR_NONE;
+       char cluster_id[256] = {0,};
+       
+       //add a web album.
+       ret = minfo_add_web_cluster_album_id(1, "web_album",  "1", "1", cluster_id, sizeof(cluster_id));
+       if (ret < 0) {
+               printf( "failed to add a web album. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int
+minfo_add_web_cluster_album_id(int sns_type, const char* name, const char *account_id, const char *album_id, char *id, int max_length);
+
+/**
+ *     minfo_delete_web_cluster:\n
+ *     This function could delete a web album through specifying @p cluster_id. After deleteing a web
+ *    album, the application will not be able to get this web album displaying.
+ *
+ *     @param[in]   cluster_id         cluster ID identifying a web album.
+ *     @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ *     @see            None.
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <media-svc.h>
+
+
+void delete_web_cluster()
+{
+       int ret = MB_SVC_ERROR_NONE;
+       const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+       
+       //delete a web album.
+       ret = minfo_delete_web_cluster(cluster_id);
+       if (ret < 0) {
+               printf( "failed to delete a web album. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int
+minfo_delete_web_cluster(const char *cluster_id);
+
+/**
+* 
+* This function gets list of mcluster by web account id. User could get the detail information with
+* the type 'Mcluster' about this cluster, the type 'Mcluster' mainly include folder/cluster ID, display name, 
+* count of included media content, etc. The detail defination of this type could refer to the herder file, minfo_item/minfo-cluster.h.
+*
+* @return            This function returns 0 on success, or negative value with error code.
+*                    Please refer 'media-svc-error.h' to know the exact meaning of the error.
+* @param             web_account_id  [in]  the web account ID which indentify a cluster
+* @param                    func   [in]     Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+* @param                    user_data   [out]    user's data structure to contain items of the type Mcluster. It is passed to the iterative callback.
+* @exception                    None.
+* @remarks                        User could pass web account id to this function, so that 
+*                                      this function still could get the wanted list of clusters 
+*                                      when invoking this function.
+* @see      None.
+* @pre         None
+* @post        None
+* @par example
+* @code
+*
+
+     #include <media-svc.h>
+     int mcluster_ite_cb(Mcluster *cluster, void *user_data)
+        {
+               GList** list = (GList**)user_data;
+               *list = g_list_append(*list, cluster);
+        }
+
+     void test_minfo_get_web_cluster_by_web_account_id(void)
+     {
+               int ret = -1;
+               const char* account_id = "user";
+               GList *p_list = NULL;
+               
+               //get a web cluster using account id.
+               ret = minfo_get_web_cluster_by_web_account_id(account_id, mcluster_ite_cb, &p_list);
+               if(ret < 0) {
+                       printf("minfo_get_web_cluster_by_web_account_id fail: %d \n", ret);
+                       return;
+               }
+        }
+* @endcode
+*/
+
+int
+minfo_get_web_cluster_by_web_account_id(const char* web_account_id, minfo_cluster_ite_cb func, void *user_data);
+
+/**
+* 
+* This function gets mcluster information by web cluster id. User could get the detail information with
+* the type 'Mcluster' about this cluster, the type 'Mcluster' mainly include folder/cluster ID, display name, 
+* count of included media content, etc. The detail defination of this type could refer to the herder file, minfo-cluster.h.
+*
+* @return             This function returns 0 on success, or negative value with error code.
+* @param             cluster_id  [in]  the cluster ID which indentify a cluster
+* @param             mcluster [out]   mcluster to be returned, which is a 'Mcluster' type
+* @exception                    None.
+* @remarks                        User could pass cluster id to this function, so that 
+*                                      this function still could get the wanted cluster.
+*                                      when invoking this function, *mcluster must equals NULL, and
+*                                     after using mitem, it must be freed with minfo_destroy_mtype_item.
+* @see      None.
+* @pre         None
+* @post        None
+* @par example
+* @code
+*
+
+     #include <media-svc.h>
+     
+     void test_minfo_get_web_cluster_web_album_id(void)
+     {
+            int ret = -1;
+            Mcluster *mc = NULL;
+                       const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+         
+            //get a cluster using cluster's id.
+            ret = minfo_get_web_cluster_web_album_id(cluster_id, &mc);
+                       if(ret < 0) {
+                               printf("minfo_get_web_cluster_web_album_id fail: %d \n", ret);
+                               return;
+                       }
+
+                       minfo_destroy_mtype_item(mc);
+        }
+* @endcode
+*/
+
+int
+minfo_get_web_cluster_web_album_id(const char *web_album_id, Mcluster **mcluster);
+
+/**
+ *     minfo_add_web_media:\n
+ *     This function could add a web media to web album specified by @p cluster_id, in addition, user need to pass @p http_url, @p file_name
+ *    @p thumb_path. If failed to add it to web album, this function will return an error code.
+ *
+ *     @param[in]   cluster_id         specify cluster id to indentify a web album.
+ *     @param[in]      http_url        web media's url.
+ *     @param[in]  file_name       file name.
+ *     @param[in]  thumb_path       thumbnail full path of this web media
+ *     @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ *     @see            None.
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <media-svc.h>
+
+
+void test_minfo_add_web_media()
+{
+       int ret = MB_SVC_ERROR_NONE;
+       const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+       
+       //add a web media to a web album.
+       ret = minfo_add_web_media(cluster_id, "http://user/specifying/address",  "web_media", "thumbnail path");
+       if (ret < 0) {
+               printf( "failed to add to a web album. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+DEPRECATED_API int
+minfo_add_web_media(const char *cluster_id, const char* http_url, const char* file_name, const char* thumb_path);
+
+/**
+ *     minfo_add_web_media_with_type:\n
+ *     This function could add a web media to web album specified by @p cluster_id, in addition, user need to pass @p http_url, @p file_name, @p content_type, 
+ *    @p thumb_path. If failed to add it to web album, this function will return an error code.
+ *
+ *     @param[in]   cluster_id         specify cluster id to indentify a web album.
+ *     @param[in]   http_url        web media's url.
+ *     @param[in]  file_name        file name.
+ *     @param[in]  content_type     type of the media.
+ *     @param[in]  thumb_path       thumbnail full path of this web media
+ *     @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ *                     Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ *     @see            None.
+ *     @pre            None
+ *     @post           None
+ *     @remark None
+ *     @par example
+ *     @code
+
+#include <media-svc.h>
+
+
+void test_minfo_add_web_media_with_type()
+{
+       int ret = MB_SVC_ERROR_NONE;
+       const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+       
+       //add a web media to a web album.
+       ret = minfo_add_web_media_with_type(cluster_id, "http://user/specifying/address",  "web_media", MINFO_ITEM_IMAGE, "thumbnail name");
+       if (ret < 0) {
+               printf( "failed to add to a web album. error code->%d", ret);
+               return;
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int
+minfo_add_web_media_with_type(const char *cluster_id, const char* http_url, const char* file_name, minfo_file_type content_type, const char* thumb_path);
+
+/**
+ * This function extracts thumbnail and update thumbnail path of specified media in db table file and also update width and height in image meta table if the media is a type of image.
+ * @param[in]          media_id        specified _id field in media table record
+ * @param[in]          content_type    type of the media.
+ * @return     This function returns 0 on success, or negative value with error code.
+ * @remarks    None
+ * @see                minfo_get_thumb_path_for_video.
+ * @pre                None
+ * @post       None
+ * @par example
+ * @code
+
+
+     #include <media-svc.h>
+     
+       void test_minfo_extract_thumbnail(void)
+       {
+               int ret = -1;
+               const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+
+               ret = minfo_extract_thumbnail(media_id, MINFO_ITEM_IMAGE);
+               if( ret < 0) {
+                       printf("minfo_extract_thumbnail failed\n");
+                       return;
+               }
+       }
+* @endcode       
+ */
+
+DEPRECATED_API int
+minfo_extract_thumbnail(const char *media_id, minfo_file_type content_type);
+
+/**
+       @}
+ */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+
+
+
+#endif /*_MINFO_API_H_*/
+
+
diff --git a/include/minfo-types.h b/include/minfo-types.h
new file mode 100755 (executable)
index 0000000..dbe16ab
--- /dev/null
@@ -0,0 +1,403 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/** 
+ * This file defines structure for minfo part.
+ *
+ * @file               minfo-types.h
+ * @author             Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version    1.0
+ * @brief      This file defines structure for minfo part.
+ */
+
+ /**
+  * @ingroup MINFO_SVC_API
+  * @defgroup MINFO_TYPES minfo types
+  * @{
+  */
+
+#ifndef _MINFO_TYPES_H_
+#define _MINFO_TYPES_H_
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifndef EXPORT_API
+#  define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef DEPRECATED_API
+#  define DEPRECATED_API __attribute__ ((deprecated))
+#endif
+
+
+//(un)favoriate item
+#define MB_SVC_DEFAULT 0
+#define MB_SVC_FAVORITE 1    //favorite item
+
+#define MINFO_DEFAULT_GPS 1000.00
+
+
+/**
+ *@enum minfo_file_type
+ * Enumerations of  minfo file type
+ */
+
+typedef enum {
+       MINFO_ITEM_NONE = 0x00000000,                   /**< none */
+       MINFO_ITEM_IMAGE = 0x00000001,                  /**< image files */
+       MINFO_ITEM_VIDEO = 0x00000002,                  /**< video files */
+       MINFO_ITEM_ALL   = 0x00000008,                          /**< all the supported media types */
+}minfo_file_type;
+
+/**
+ * @enum minfo_folder_type
+ * Enumerations of  folder(cluster/album) type
+ */
+typedef enum {
+       MINFO_CLUSTER_TYPE_ALL,                         /**< All type of media */
+       MINFO_CLUSTER_TYPE_LOCAL_ALL,           /**< lcoal both phone and mmc */
+       MINFO_CLUSTER_TYPE_LOCAL_PHONE,         /**< lcoal phone only */
+       MINFO_CLUSTER_TYPE_LOCAL_MMC,           /**< lcoal mmc only */
+       MINFO_CLUSTER_TYPE_WEB,                         /**< web album */
+       MINFO_CLUSTER_TYPE_STREAMING,           /**< streaming album */
+       MINFO_CLUSTER_TYPE_MAX,                         /**< Max value*/
+} minfo_folder_type;
+
+/**
+* @enum minfo_media_favorite_type
+* Enumerations of favorite of getting media item list.
+*/
+typedef enum{  
+       MINFO_MEDIA_FAV_ALL,                    /**< Includes all favorite and unfavorite media */
+       MINFO_MEDIA_FAV_ONLY,                   /**< Includes only favorite media */
+       MINFO_MEDIA_UNFAV_ONLY,                 /**< Includes only unfavorite media */
+}minfo_media_favorite_type;
+
+/**
+* @enum minfo_media_sort_type
+* Enumerations of sort of getting media item list.
+*/
+typedef enum{  
+       MINFO_MEDIA_SORT_BY_NONE,                       /**< No Sort */
+       MINFO_MEDIA_SORT_BY_NAME_DESC,          /**< Sort by display name descending */
+       MINFO_MEDIA_SORT_BY_NAME_ASC,           /**< Sort by display name ascending */
+       MINFO_MEDIA_SORT_BY_DATE_DESC,          /**< Sort by modified_date descending */
+       MINFO_MEDIA_SORT_BY_DATE_ASC,           /**< Sort by modified_date ascending */
+}minfo_media_sort_type;
+
+/**
+* @enum minfo_folder_sort_type
+* Enumerations of sort of getting folder item list.
+*/
+typedef enum{  
+       MINFO_CLUSTER_SORT_BY_NONE,                             /**< No Sort */
+       MINFO_CLUSTER_SORT_BY_NAME_DESC,                /**< Sort by display name descending */
+       MINFO_CLUSTER_SORT_BY_NAME_ASC,                 /**< Sort by display name ascending */
+       MINFO_CLUSTER_SORT_BY_DATE_DESC,                /**< Sort by modified_date descending */
+       MINFO_CLUSTER_SORT_BY_DATE_ASC,                 /**< Sort by modified_date ascending */
+}minfo_folder_sort_type;
+
+/**
+* @enum minfo_store_type
+* Enumerations of store type.
+*/
+
+typedef enum
+{
+       MINFO_PHONE,                    /**< Stored only in phone */
+       MINFO_MMC,                              /**< Stored only in MMC */      
+       MINFO_WEB,                              /**< Stored only in web album */
+       MINFO_WEB_STREAMING,    /**< Stored only in web streaming album */
+       MINFO_SYSTEM,                   /**< Stored in ALL*/
+} minfo_store_type;
+
+/**
+ * @enum minfo_image_meta_field_t
+ * Enumerations for image_meta field name.
+ */
+typedef enum {
+       MINFO_IMAGE_META_LONGITUDE,         /**< image meta longitude(double) field */
+       MINFO_IMAGE_META_LATITUDE,          /**< image meta latitude(double) field */
+       MINFO_IMAGE_META_DESCRIPTION,           /**< image meta description(string) field */
+       MINFO_IMAGE_META_WIDTH,             /**< image meta width(int) field */
+       MINFO_IMAGE_META_HEIGHT,                /**< image meta height(int) field */
+       MINFO_IMAGE_META_ORIENTATION,       /**< image meta orientation(int) field */
+       MINFO_VIDEO_META_DATE_TAKEN,        /**< image meta datetaken(int) field */
+} minfo_image_meta_field_t;
+
+/**
+ * @enum minfo_video_meta_field_t
+ * Enumerations for video_meta field name.
+ */
+typedef enum { 
+       MINFO_VIDEO_META_ID,             /**< media medta ID field */
+       MINFO_VIDEO_META_MEDIA_ID,       /**< media medta ID field */
+       MINFO_VIDEO_META_ALBUM,          /**< medta album field */
+       MINFO_VIDEO_META_ARTIST,         /**< medta artist field */
+       MINFO_VIDEO_META_TITLE,          /**< medta title field */
+       MINFO_VIDEO_META_DESCRIPTION,      /**< medta description field */
+       MINFO_VIDEO_META_YOUTUBE_CATEGORY, /**< medta youtube cat field */
+       MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED,  /**< medta bookmark field */
+       MINFO_VIDEO_META_DURATION,              /**< medta duration field */
+       MINFO_VIDEO_META_LONGISTUDE,            /**< medta longistude field */
+       MINFO_VIDEO_META_LATITUDE,              /**< medta latitude field */
+} minfo_video_meta_field_t;
+
+/**
+ * @enum minfo_search_field_t
+ * Enumerations for field to search
+ */
+typedef enum {
+       MINFO_SEARCH_BY_NAME = 0x00000001,       /**< media display name field */
+       MINFO_SEARCH_BY_PATH = 0x00000002,       /**< media path field */
+       MINFO_SEARCH_BY_HTTP_URL = 0x00000004,   /**< media http url field */
+       MINFO_SEARCH_MAX = 0x00000008,                  /**< maximum */
+} minfo_search_field_t;
+
+/**
+* @struct minfo_item_filter
+* This structure defines filter of minfo item.
+* it assumes that there are (n) records matching filter, the valid index range is from 0 to n-1,  
+* so there are some limitation on start_pos and end_pos.
+* start_pos, if equals -1, it gets all records, end_pos is meaningless,
+* start_pos it can't set to be bigger than (n-1), its valid range is 0 to (n-2).
+* end_pos, if equals -1, it gets continuous record from start_pos until last item,
+* end_pos, if bigger than n-1, it's meaningless and automatically regarded as (n-1).
+*
+*/
+
+typedef struct {
+   minfo_file_type file_type;                  /**< Image, Video */
+   minfo_media_sort_type sort_type;    /**< sort type */
+   int start_pos;                                              /**< first item index, start from 0*/ 
+   int end_pos;                                                        /**< last item index */
+   bool with_meta;                                             /**< include image_meta or video_meta */
+   int favorite;                                               /**< favourite */
+}minfo_item_filter;
+
+/**
+* @struct minfo_cluster_filter
+* This structure defines filter of minfo cluster.
+* it assumes that there are (n) records matching filter, the valid index range is from 0 to n-1, 
+* so there are some limitation on start_pos and end_pos
+* start_pos, if equals -1, it gets all records, end_pos is meaningless,
+* start_pos it can't set to be bigger than (n-1), its valid range is 0 to (n-2).
+* end_pos, if equals -1, it gets  continuous record from start_pos until last item,
+* end_pos, if bigger than n-1, it's meaningless and automatically regarded as (n-1).
+*
+*/
+
+typedef struct {
+   minfo_folder_type cluster_type;     /**< Local/Web/Streaming */ 
+   minfo_folder_sort_type sort_type;   /**< sort type */ 
+   int start_pos;                                              /**< first item index, start from 0 */ 
+   int end_pos;                                                        /**< last item index*/ 
+}minfo_cluster_filter;
+
+/**
+* @struct minfo_tag_filter
+* This structure defines filter of minfo tag.
+* it assumes that there are (n) records matching filter, the valid index range is from 0 to n-1,  
+* so there are some limitation on start_pos and end_pos.
+* start_pos, if equals -1, it gets all records, end_pos is meaningless,
+* start_pos it can't set to be bigger than (n-1), its valid range is 0 to (n-2).
+* end_pos, if equals -1, it gets continuous record from start_pos until last item,
+* end_pos, if bigger than n-1, it's meaningless and automatically regarded as (n-1).
+*
+*/
+
+typedef struct {
+   minfo_file_type file_type;                  /**< Image, Video */
+   int start_pos;                                              /**< first item index, start from 0*/ 
+   int end_pos;                                                        /**< last item index */
+   bool with_meta;                                             /**< include image_meta or video_meta */
+}minfo_tag_filter;
+
+/**
+* @struct _Mcluster
+* This structure defines _Mcluster, same with Mcluster
+*/
+
+typedef struct _Mcluster
+{
+       int gtype;                                              /**< self-defination type */
+       
+       /*< public >*/
+       //unsigned int _id;                             /**< cluster id */
+       char *uuid;                                             /**< UUID */
+       char *thumb_url;                                /**< thumbnail full path */
+       time_t mtime;                                   /**< modified time */
+       int type;                                               /**< type */
+       char *display_name;                             /**< cluster name */
+       int count;                                              /**< content count */
+       int sns_type;                                   /**< web account type */
+       char *account_id;                               /**< web account */
+       int lock_status;                                /**< status for album lock */
+       char *web_album_id;              /**< web album id */
+       void* _reserved;                                /**< reserved  */
+}Mcluster;
+
+/**
+* @struct _Mvideo
+* This structure defines _Mvideo, same with Mvideo
+*/
+
+typedef struct _Mvideo
+{
+       int gtype;
+
+       char *album_name;                                       /**< album name */
+       char *artist_name;                                      /**< artist name */
+       char *title;                                            /**< title */
+       unsigned int last_played_pos;           /**< last played position */
+       unsigned int duration;                          /**< duration */
+       char *web_category;                                     /**< web category */
+       GList* bookmarks;                               /**< bookmark info */
+       void* _reserved;                                        /**< reserved */
+}Mvideo;
+
+/**
+* @struct _Mimage
+* This structure defines _Mimage, same with Mimage
+*/
+
+typedef struct _Mimage
+{
+       int gtype;
+       
+       int     orientation;                    /**< orientation */
+       void* _reserved;                                /**< reserved */
+       
+}Mimage;
+
+
+/**
+* @struct _Mmeta
+* This structure defines _Mmeta, same with Mmeta
+*/
+
+typedef struct _Mmeta
+{
+       int gtype;
+
+       //int item_id;                                  /**< media id */
+       char *media_uuid;                               /**< media UUID */
+       int type;                                               /**< type */
+       char *description;                              /**< description */
+       double  longitude;                              /**< longitude */
+       double  latitude;                               /**< latitude */
+
+       int width;                                              /**< width */
+       int height;                                             /**< height */
+       int datetaken;                                  /**< datetaken */
+
+       union
+       {
+               Mimage* image_info;                     /**< image info */
+               Mvideo* video_info;                     /**< video info */
+       };
+       void* _reserved;                                /**< reserve */
+}Mmeta;
+
+/**
+* @struct _Mitem
+* This structure defines _Mitem, same with Mitem
+*/
+
+typedef struct _Mitem
+{
+       int gtype;
+       
+       //unsigned int _id;                                     /**< item id */
+       char *uuid;                                                     /**< UUID */
+       int type;                                                       /**< file type */
+       char *thumb_url;                                        /**< thumbnail full path */     
+       char *file_url;                                         /**< file full path */
+       time_t mtime;                                           /**< modified time */
+       char *ext;                                                      /**< ext */     
+       //unsigned int cluster_id;                      /**< cluster id */
+       char *cluster_uuid;                                     /**< cluster UUID */
+       char *display_name;                                     /**< item name */
+       int rate;                                                       /**< favorite level */
+       Mmeta* meta_info;                                       /**< image or video info */
+       void *_reserved;                                        /**< reserved */
+}Mitem;
+
+
+/**
+* @struct _Mbookmark
+* This structure defines _Mbookmark, same with Mbookmark
+*/
+typedef struct _Mbookmark
+{
+       int gtype;                                      /**< self-defination type */
+       
+       unsigned int _id;               /**< bookmark id */
+       //unsigned int media_id;        /**< media id */
+       char *media_uuid;                       /**< media UUID */
+       unsigned int position;          /**< marked time */
+       char *thumb_url;                /**< thumnail full path */
+}Mbookmark;
+
+/**
+* @struct _Mtag
+* This structure defines _Mtag, same with Mtag
+*/
+typedef struct _Mtag
+{
+       int gtype;                                      /**< self-defination type */
+       
+       unsigned int _id;               /**< tag id */
+       //unsigned int media_id;        /**< media id */
+       char *media_uuid;                       /**< media UUID */
+       char *tag_name;         /**< tag name*/
+       int  count;             /**< count of media content included into a tag*/
+       void *_reserved;                                        /**< reserved */
+}Mtag;
+
+
+typedef int (*minfo_cluster_ite_cb)( Mcluster *cluster, void *user_data );
+typedef int (*minfo_item_ite_cb)( Mitem *item, void *user_data );
+typedef int (*minfo_bm_ite_cb)( Mbookmark *bookmark, void *user_data );
+typedef int (*minfo_cover_ite_cb)( const char *thumb_path, void *user_data );
+typedef int (*minfo_tag_ite_cb)( Mtag *_tag_, void *user_data );
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+/**
+* @}
+*/
+
+#endif /*_MINFO_TYPES__H_*/
+
+
diff --git a/libmedia-service.pc.in b/libmedia-service.pc.in
new file mode 100755 (executable)
index 0000000..978a9c9
--- /dev/null
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: @PROJECT_NAME@
+Description: Samsung Linux platform @PROJECT_NAME@ library
+Version: @VERSION@
+Requires: glib-2.0 dlog sqlite3 db-util mm-common
+Libs: -L${libdir} -lmedia-service -lmedia-svc-hash
+Cflags: -I${includedir}/media-service
diff --git a/license b/license
new file mode 100644 (file)
index 0000000..b519b16
--- /dev/null
+++ b/license
@@ -0,0 +1,10 @@
+libmedia-service:
+
+Most files in libmedia-service are under the Apache License Version 2.0.
+Read the file LICENSE for details.
+
+Some parts of libmedia-service are licensed under the GNU Lesser General Public License version 2.1
+See the file COPYING for details.
+
+Specifically, the LGPL parts of libmedia-service are
+ - md5/media-svc-hash.c
diff --git a/md5/md5.c b/md5/md5.c
new file mode 100644 (file)
index 0000000..59b47ba
--- /dev/null
+++ b/md5/md5.c
@@ -0,0 +1,253 @@
+/*
+ * This code implements the MD5 message-digest algorithm.
+ * The algorithm is due to Ron Rivest.  This code was
+ * written by Colin Plumb in 1993, no copyright is claimed.
+ * This code is in the public domain; do with it what you wish.
+ *
+ * Equivalent code is available from RSA Data Security, Inc.
+ * This code has been tested against that, and is equivalent,
+ * except that you don't need to include two pages of legalese
+ * with every copy.
+ *
+ * To compute the message digest of a chunk of bytes, declare an
+ * MD5Context structure, pass it to MD5Init, call MD5Update as
+ * needed on buffers full of bytes, and then call MD5Final, which
+ * will fill a supplied 16-byte array with the digest.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>            /* for memcpy() */
+#include "md5.h"
+
+#if (__BYTE_ORDER == 1234)
+#define byteReverse(buf, len)  /* Nothing */
+#else
+void byteReverse(unsigned char *buf, unsigned longs);
+
+/*
+ * Note: this code is harmless on little-endian machines.
+ */
+void byteReverse(unsigned char *buf, unsigned longs)
+{
+       uint32_t t;
+       do {
+               t = (uint32_t) ((unsigned)buf[3] << 8 | buf[2]) << 16 |
+                   ((unsigned)buf[1] << 8 | buf[0]);
+               *(uint32_t *) buf = t;
+               buf += 4;
+       } while (--longs);
+}
+#endif
+
+/*
+ * Start MD5 accumulation.  Set bit count to 0 and buffer to mysterious
+ * initialization constants.
+ */
+void MD5Init(MD5_CTX *ctx)
+{
+       ctx->buf[0] = 0x67452301;
+       ctx->buf[1] = 0xefcdab89;
+       ctx->buf[2] = 0x98badcfe;
+       ctx->buf[3] = 0x10325476;
+
+       ctx->bits[0] = 0;
+       ctx->bits[1] = 0;
+}
+
+/*
+ * Update context to reflect the concatenation of another buffer full
+ * of bytes.
+ */
+void MD5Update(MD5_CTX *ctx, unsigned char const *buf, unsigned len)
+{
+       uint32_t t;
+
+       /* Update bitcount */
+
+       t = ctx->bits[0];
+       if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t) {
+               ctx->bits[1]++; /* Carry from low to high */
+       }
+
+       ctx->bits[1] += len >> 29;
+
+       t = (t >> 3) & 0x3f;    /* Bytes already in shsInfo->data */
+
+       /* Handle any leading odd-sized chunks */
+
+       if (t) {
+               unsigned char *p = (unsigned char *)ctx->in + t;
+
+               t = 64 - t;
+               if (len < t) {
+                       memcpy(p, buf, len);
+                       return;
+               }
+               memcpy(p, buf, t);
+               byteReverse(ctx->in, 16);
+               MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+               buf += t;
+               len -= t;
+       }
+       /* Process data in 64-byte chunks */
+
+       while (len >= 64) {
+               memcpy(ctx->in, buf, 64);
+               byteReverse(ctx->in, 16);
+               MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+               buf += 64;
+               len -= 64;
+       }
+
+       /* Handle any remaining bytes of data. */
+
+       memcpy(ctx->in, buf, len);
+}
+
+/*
+ * Final wrapup - pad to 64-byte boundary with the bit pattern 
+ * 1 0* (64-bit count of bits processed, MSB-first)
+ */
+void MD5Final(unsigned char digest[16], MD5_CTX *ctx)
+{
+       unsigned count;
+       unsigned char *p;
+
+       /* Compute number of bytes mod 64 */
+       count = (ctx->bits[0] >> 3) & 0x3F;
+
+       /* Set the first char of padding to 0x80.  This is safe since there is
+          always at least one byte free */
+       p = ctx->in + count;
+       *p++ = 0x80;
+
+       /* Bytes of padding needed to make 64 bytes */
+       count = 64 - 1 - count;
+
+       /* Pad out to 56 mod 64 */
+       if (count < 8) {
+               /* Two lots of padding:  Pad the first block to 64 bytes */
+               memset(p, 0, count);
+               byteReverse(ctx->in, 16);
+               MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+
+               /* Now fill the next block with 56 bytes */
+               memset(ctx->in, 0, 56);
+       } else {
+               /* Pad block to 56 bytes */
+               memset(p, 0, count - 8);
+       }
+       byteReverse(ctx->in, 14);
+
+       /* Append length in bits and transform */
+       ((uint32_t *) ctx->in)[14] = ctx->bits[0];
+       ((uint32_t *) ctx->in)[15] = ctx->bits[1];
+
+       MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+       byteReverse((unsigned char *)ctx->buf, 4);
+       memcpy(digest, ctx->buf, 16);
+       memset((char *)ctx, 0, sizeof(ctx));    /* In case it's sensitive */
+}
+
+/* The four core functions - F1 is optimized somewhat */
+
+/* #define F1(x, y, z) (x & y | ~x & z) */
+#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
+#define F2(x, y, z) (F1((z), (x), (y)))
+#define F3(x, y, z) ((x) ^ (y) ^ (z))
+#define F4(x, y, z) ((y) ^ ((x) | ~(z)))
+
+/* This is the central step in the MD5 algorithm. */
+#define MD5STEP(f, w, x, y, z, data, s) \
+(w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x)
+
+/*
+ * The core of the MD5 algorithm, this alters an existing MD5 hash to
+ * reflect the addition of 16 longwords of new data.  MD5Update blocks
+ * the data and converts bytes into longwords for this routine.
+ */
+void MD5Transform(uint32_t buf[4], uint32_t const in[16])
+{
+       register uint32_t a, b, c, d;
+
+       a = buf[0];
+       b = buf[1];
+       c = buf[2];
+       d = buf[3];
+
+       MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
+       MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
+       MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
+       MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
+       MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
+       MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
+       MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
+       MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
+       MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
+       MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
+       MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
+       MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
+       MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
+       MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
+       MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
+       MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
+
+       MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
+       MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
+       MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
+       MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
+       MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
+       MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
+       MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
+       MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
+       MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
+       MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
+       MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
+       MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
+       MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
+       MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
+       MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
+       MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
+
+       MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
+       MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
+       MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
+       MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
+       MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
+       MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
+       MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
+       MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
+       MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
+       MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
+       MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
+       MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
+       MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
+       MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
+       MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
+       MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
+
+       MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
+       MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
+       MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
+       MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
+       MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
+       MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
+       MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
+       MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
+       MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
+       MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
+       MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
+       MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
+       MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
+       MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
+       MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
+       MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
+
+       buf[0] += a;
+       buf[1] += b;
+       buf[2] += c;
+       buf[3] += d;
+}
diff --git a/md5/md5.h b/md5/md5.h
new file mode 100644 (file)
index 0000000..dac53fb
--- /dev/null
+++ b/md5/md5.h
@@ -0,0 +1,39 @@
+/*
+ * This code implements the MD5 message-digest algorithm.
+ * The algorithm is due to Ron Rivest.  This code was
+ * written by Colin Plumb in 1993, no copyright is claimed.
+ * This code is in the public domain; do with it what you wish.
+ *
+ * Equivalent code is available from RSA Data Security, Inc.
+ * This code has been tested against that, and is equivalent,
+ * except that you don't need to include two pages of legalese
+ * with every copy.
+ *
+ * To compute the message digest of a chunk of bytes, declare an
+ * MD5Context structure, pass it to MD5Init, call MD5Update as
+ * needed on buffers full of bytes, and then call MD5Final, which
+ * will fill a supplied 16-byte array with the digest.
+ */
+
+
+#ifndef _MD5_H_
+#define _MD5_H_
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#define MD5_HASHBYTES 16
+
+typedef struct MD5Context {
+       uint32_t buf[4];
+       uint32_t bits[2];
+       unsigned char in[64];
+} MD5_CTX;
+
+extern void   MD5Init(MD5_CTX *context);
+extern void   MD5Update(MD5_CTX *context,unsigned char const *buf,unsigned len);
+extern void   MD5Final(unsigned char digest[MD5_HASHBYTES], MD5_CTX *context);
+
+extern void   MD5Transform(uint32_t buf[4], uint32_t const in[16]);
+
+#endif
diff --git a/md5/media-svc-hash.c b/md5/media-svc-hash.c
new file mode 100644 (file)
index 0000000..f31ce9c
--- /dev/null
@@ -0,0 +1,132 @@
+/* GLIB - Library of useful routines for C programming
+ *
+ * gconvert.c: Convert between character sets using iconv
+ * Copyright Red Hat Inc., 2000
+ * Authors: Havoc Pennington <hp@redhat.com>, Owen Taylor <otaylor@redhat.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/* The array below is taken from gconvert.c, which is licensed by GNU Lesser General Public License
+ * Code to escape string is also taken partially from gconvert.c
+ * File name is changed to media-svc-hash.c
+ */
+
+#include "media-svc-error.h"
+#include "md5.h"
+#include <string.h>
+#include <alloca.h>
+
+
+static const char ACCEPTABLE_URI_CHARS[96] = {
+       /*      !    "    #    $    %    &    '    (    )    *    +    ,    -    .    / */
+       0x00, 0x3F, 0x20, 0x20, 0x28, 0x00, 0x2C, 0x3F, 0x3F, 0x3F, 0x3F, 0x2A,
+           0x28, 0x3F, 0x3F, 0x1C,
+       /* 0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ? */
+       0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x38, 0x20,
+           0x20, 0x2C, 0x20, 0x20,
+       /* @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O */
+       0x38, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
+           0x3F, 0x3F, 0x3F, 0x3F,
+       /* P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _ */
+       0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x20,
+           0x20, 0x20, 0x20, 0x3F,
+       /* `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o */
+       0x20, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
+           0x3F, 0x3F, 0x3F, 0x3F,
+       /* p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~  DEL */
+       0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x20,
+           0x20, 0x20, 0x3F, 0x20
+};
+
+char *_mb_svc_generate_hash_name(const char *file)
+{
+       int n;
+       MD5_CTX ctx;
+       static char md5out[(2 * MD5_HASHBYTES) + 1];
+       unsigned char hash[MD5_HASHBYTES];
+       static const char hex[] = "0123456789abcdef";
+
+       char *uri;
+       char *t;
+       const unsigned char *c;
+       int length;
+
+       if (!file) {
+               return NULL;
+       }
+
+       length = 3 * strlen(file) + 9;
+
+       memset(md5out, 0, sizeof(md5out));
+
+#define _check_uri_char(c) \
+((c) >= 32 && (c) < 128 && (ACCEPTABLE_URI_CHARS[(c) - 32] & 0x08))
+
+       uri = alloca(length);
+       if (uri == NULL) {
+               return NULL;
+       }
+
+       strncpy(uri, "file://", length);
+       uri[length - 1] = '\0';
+       t = uri + sizeof("file://") - 1;
+
+       for (c = (const unsigned char *)file; *c != '\0'; c++) {
+               if (!_check_uri_char(*c)) {
+                       *t++ = '%';
+                       *t++ = hex[*c >> 4];
+                       *t++ = hex[*c & 15];
+               } else {
+                       *t++ = *c;
+               }
+       }
+       *t = '\0';
+#undef _check_uri_char
+
+       MD5Init(&ctx);
+       MD5Update(&ctx, (unsigned char const *)uri, (unsigned)strlen(uri));
+       MD5Final(hash, &ctx);
+
+       for (n = 0; n < MD5_HASHBYTES; n++) {
+               md5out[2 * n] = hex[hash[n] >> 4];
+               md5out[2 * n + 1] = hex[hash[n] & 0x0f];
+       }
+       md5out[2 * n] = '\0';
+
+       return md5out;
+}
+
+int mb_svc_generate_hash_code(const char *origin_path, char *hash_code, int max_length)
+{
+       char *hash = NULL;
+
+       if (max_length < ((2 * MD5_HASHBYTES) + 1)) {
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       hash = _mb_svc_generate_hash_name(origin_path);
+
+       if (hash == NULL) {
+               return MB_SVC_ERROR_INTERNAL;
+       }
+
+       strncpy(hash_code, hash, max_length);
+       hash_code[strlen(hash_code)] ='\0';
+
+       return MB_SVC_ERROR_NONE;
+}
+
diff --git a/packaging/libmedia-service.spec b/packaging/libmedia-service.spec
new file mode 100644 (file)
index 0000000..34997a4
--- /dev/null
@@ -0,0 +1,83 @@
+Name:      libmedia-service
+Summary:    Media Service
+Version:    0.1.33
+Release:    0
+Group:      System/Libraries
+License:    LGPL
+Source0:    %{name}-%{version}.tar.gz
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+BuildRequires: cmake, expat-devel
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(sqlite3)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(db-util)
+BuildRequires: pkgconfig(mm-common)
+BuildRequires: pkgconfig(libpng)
+BuildRequires: pkgconfig(libpng12)
+BuildRequires: pkgconfig(mm-fileinfo)
+BuildRequires: pkgconfig(drm-service)
+BuildRequires: pkgconfig(aul)
+BuildRequires: pkgconfig(libexif)
+BuildRequires: pkgconfig(xdmcp)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(ecore-evas)
+BuildRequires: pkgconfig(evas)
+BuildRequires: pkgconfig(mmutil-imgp)
+
+
+%description
+Media information service library for multimedia applications.
+
+
+%package devel
+Summary:    Media Service
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+Media information service library for multimedia applications. (developement files)
+
+%prep
+%setup -q
+
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%defattr(-,root,root,-)
+/usr/lib/libmedia-service.so.1
+/usr/lib/libmedia-service.so.1.0.0
+/usr/lib/libmedia-svc-hash.so.1
+/usr/lib/libmedia-svc-hash.so.1.0.0
+
+%files devel
+%defattr(-,root,root,-)
+/usr/lib/libmedia-service.so
+/usr/lib/libmedia-svc-hash.so
+/usr/lib/pkgconfig/libmedia-service.pc
+/usr/include/media-service/audio-svc-error.h
+/usr/include/media-service/audio-svc-types.h
+/usr/include/media-service/audio-svc.h
+/usr/include/media-service/media-info-error.h
+/usr/include/media-service/media-info-types.h
+/usr/include/media-service/media-info.h
+/usr/include/media-service/media-svc-error.h
+/usr/include/media-service/media-svc.h
+/usr/include/media-service/minfo-api.h
+/usr/include/media-service/minfo-types.h
diff --git a/src/audio/audio-svc-db-utils.c b/src/audio/audio-svc-db-utils.c
new file mode 100755 (executable)
index 0000000..4a2be07
--- /dev/null
@@ -0,0 +1,221 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+/**
+ * This file defines structure and functions related to database.
+ *
+ * @file               audio-svc-db-utils.c
+ * @version    0.1
+ * @brief      This file defines sqlite utilities for Audio Service.
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include "audio-svc-debug.h"
+#include "audio-svc-error.h"
+#include "audio-svc-db-utils.h"
+#include "media-info-util.h"
+
+int _audio_svc_sql_busy_handler(void *pData, int count)
+{
+       usleep(50000);
+       
+       printf("_audio_svc_sql_busy_handler called : %d\n", count);
+       audio_svc_debug("_audio_svc_sql_busy_handler called : %d\n", count);
+
+       return 100 - count;
+}
+
+int _audio_svc_sql_query(const char *sql_str)
+{
+       int err = -1;
+       char *zErrMsg = NULL;
+       
+       audio_svc_debug("SQL = [%s]", sql_str);
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               audio_svc_error("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+       
+       err = sqlite3_exec(handle, sql_str, NULL, NULL, &zErrMsg);
+
+       if (SQLITE_OK != err) {
+               audio_svc_error("failed to execute [%s], err[%d]", zErrMsg, err);
+       } else {
+               audio_svc_debug("query success");
+       }
+
+       if (zErrMsg)
+               sqlite3_free (zErrMsg);
+
+       return err;
+}
+
+int _audio_svc_sql_query_list(GList **query_list)
+{
+       int i = 0;
+       int length = g_list_length(*query_list);
+       int err = -1;
+       char *sql = NULL;
+       
+       audio_svc_debug("query list length : [%d]", length);
+
+       for (i = 0; i < length; i++) {
+               sql = (char*)g_list_nth_data(*query_list, i);
+               if(sql != NULL) {
+                       err = _audio_svc_sql_query(sql);
+                       sqlite3_free(sql);
+                       sql = NULL;
+                       if (err != SQLITE_OK) {
+                               return AUDIO_SVC_ERROR_DB_INTERNAL;
+                       }
+               }
+       }
+
+       _audio_svc_sql_query_release(query_list);
+
+       return AUDIO_SVC_ERROR_NONE;
+
+}
+
+int _audio_svc_sql_prepare_to_step(const char *sql_str, sqlite3_stmt** stmt)
+{
+       int err = -1;
+
+       audio_svc_debug("[SQL query] : %s", sql_str);
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               audio_svc_error("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+       
+       err = sqlite3_prepare_v2(handle, sql_str, -1, stmt, NULL);
+       sqlite3_free((char *)sql_str);
+       
+       if (err != SQLITE_OK) {
+               audio_svc_error ("prepare error [%s]", sqlite3_errmsg(handle));
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       err = sqlite3_step(*stmt);
+       if (err != SQLITE_ROW) {
+               audio_svc_error("Item not found. end of row [%s]", sqlite3_errmsg(handle));
+               SQLITE3_FINALIZE(*stmt);
+               return AUDIO_SVC_ERROR_DB_NO_RECORD;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_sql_begin_trans(void)
+{
+       char *err_msg = NULL;
+
+       audio_svc_debug("========_audio_svc_sql_begin_trans");
+       
+       sqlite3 *handle = _media_info_get_proper_handle();
+
+       if (handle == NULL) {
+               audio_svc_error("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (SQLITE_OK != sqlite3_exec(handle, "BEGIN IMMEDIATE;", NULL, NULL, &err_msg)) {
+               audio_svc_error("Error:failed to begin transaction: error=%s", err_msg);
+               sqlite3_free(err_msg);
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+       
+       sqlite3_free(err_msg);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_sql_end_trans(void)
+{
+       char *err_msg = NULL;
+
+       audio_svc_debug("========_audio_svc_sql_end_trans");
+       
+       sqlite3 *handle = _media_info_get_proper_handle();
+       
+       if (handle == NULL) {
+               audio_svc_error("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (SQLITE_OK != sqlite3_exec(handle, "COMMIT;", NULL, NULL, &err_msg)) {
+               audio_svc_error("Error:failed to end transaction: error=%s", err_msg);
+               sqlite3_free(err_msg);
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+       
+       sqlite3_free(err_msg);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_sql_rollback_trans(void)
+{
+       char *err_msg = NULL;
+
+       audio_svc_debug("========_audio_svc_sql_rollback_trans");
+       
+       sqlite3 *handle = _media_info_get_proper_handle();
+
+       if (handle == NULL) {
+               audio_svc_error("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (SQLITE_OK != sqlite3_exec(handle, "ROLLBACK;", NULL, NULL, &err_msg)) {
+               audio_svc_error("Error:failed to rollback transaction: error=%s", err_msg);
+               sqlite3_free(err_msg);
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       sqlite3_free(err_msg);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+void _audio_svc_sql_query_add(GList **query_list, char **query)
+{
+       *query_list = g_list_append( *query_list, *query);
+}
+
+void _audio_svc_sql_query_release(GList **query_list)
+{
+       if (*query_list) {
+               audio_svc_debug("_audio_svc_sql_query_release");
+               g_list_free(*query_list);
+               *query_list = NULL;
+       }
+}
+
diff --git a/src/audio/audio-svc-music-table.c b/src/audio/audio-svc-music-table.c
new file mode 100755 (executable)
index 0000000..4ffd9c9
--- /dev/null
@@ -0,0 +1,3372 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file defines structure and functions related to database for managing music item.
+ *
+ * @file               audio-svc-music-table.c
+ * @version    0.1
+ */
+
+#include <glib.h>
+#include <sys/stat.h>
+#include "media-info-util.h"
+#include "audio-svc-error.h"
+#include "audio-svc-music-table.h"
+#include "audio-svc-playlist-table.h"
+#include "audio-svc-debug.h"
+#include "audio-svc-types-priv.h"
+#include "audio-svc-utils.h"
+#include <drm-service.h>
+#include "audio-svc-db-utils.h"
+
+
+typedef enum {
+       AUDIO_SVC_AUDIO_INFO_AUDIO_ID,
+       AUDIO_SVC_AUDIO_INFO_PATH,
+       AUDIO_SVC_AUDIO_INFO_THUMBNAIL_PATH,
+       AUDIO_SVC_AUDIO_INFO_TITLE,
+       AUDIO_SVC_AUDIO_INFO_ALBUM,
+       AUDIO_SVC_AUDIO_INFO_ARTIST,
+       AUDIO_SVC_AUDIO_INFO_GENRE,
+       AUDIO_SVC_AUDIO_INFO_AUTHOR,
+       AUDIO_SVC_AUDIO_INFO_YEAR,
+       AUDIO_SVC_AUDIO_INFO_COPYRIGHT,
+       AUDIO_SVC_AUDIO_INFO_DESCRIPTION,
+       AUDIO_SVC_AUDIO_INFO_FORMAT,
+       AUDIO_SVC_AUDIO_INFO_BITRATE,
+       AUDIO_SVC_AUDIO_INFO_TRACK,
+       AUDIO_SVC_AUDIO_INFO_DURATION,
+       AUDIO_SVC_AUDIO_INFO_RATING,
+       AUDIO_SVC_AUDIO_INFO_PLAYCOUNT,
+       AUDIO_SVC_AUDIO_INFO_PLAYTIME,
+       AUDIO_SVC_AUDIO_INFO_ADDTIME,
+       AUDIO_SVC_AUDIO_INFO_RATEDTIME,
+       AUDIO_SVC_AUDIO_INFO_ALBUM_RATING,
+       AUDIO_SVC_AUDIO_INFO_DATE_MODIFIED,
+       AUDIO_SVC_AUDIO_INFO_SIZE,
+       AUDIO_SVC_AUDIO_INFO_CATEGORY,
+       AUDIO_SVC_AUDIO_INFO_VALID,
+       AUDIO_SVC_AUDIO_INFO_FOLDER_ID,
+       AUDIO_SVC_AUDIO_INFO_STORAGE,
+       AUDIO_SVC_AUDIO_INFO_FAVOURATE,
+       AUDIO_SVC_AUDIO_INFO_CONTENT_TYPE,
+} audio_svc_audio_info_e;
+
+#define AUDIO_SVC_ORDER_BY_TITLE               "ORDER BY title COLLATE NOCASE"
+#define AUDIO_SVC_ORDER_BY_ALBUM               "ORDER BY album COLLATE NOCASE"
+#define AUDIO_SVC_ORDER_BY_GENRE               "ORDER BY genre COLLATE NOCASE"
+#define AUDIO_SVC_ORDER_BY_AUTHOR      "ORDER BY author COLLATE NOCASE"
+#define AUDIO_SVC_ORDER_BY_ARTIST              "ORDER BY artist COLLATE NOCASE"
+#define AUDIO_SVC_COLLATE_NOCASE               "COLLATE NOCASE"
+
+static const char *g_audio_svc_music_fields =
+    "audio_id, path, thumbnail_path, title, album, artist, genre, author, year,\
+copyright, description, format, bitrate,track_num,duration, rating, played_count, last_played_time, added_time, modified_date, size, category, valid, folder_id, storage_type";
+
+static __thread GList *g_audio_svc_item_valid_query_list = NULL;
+static __thread GList *g_audio_svc_move_item_query_list = NULL;
+static __thread GList *g_audio_svc_insert_item_query_list = NULL;
+
+
+static int __audio_svc_create_music_db_table();
+static void __audio_svc_get_next_record(audio_svc_audio_item_s *item,
+                                       sqlite3_stmt *stmt);
+static int
+__audio_svc_count_invalid_records_with_thumbnail(audio_svc_storage_type_e
+                                                storage_type);
+static int __audio_svc_count_records_with_thumbnail(audio_svc_storage_type_e
+                                                   storage_type);
+static int
+__audio_svc_get_invalid_records_with_thumbnail(audio_svc_storage_type_e
+                                              storage_type, int count,
+                                              mp_thumbnailpath_record_t *
+                                              thumb_path);
+static int __audio_svc_get_records_with_thumbnail(audio_svc_storage_type_e
+                                                 storage_type, int count,
+                                                 mp_thumbnailpath_record_t *
+                                                 thumb_path);
+
+
+static int __audio_svc_create_music_db_table(void)
+{
+       int err = -1;
+
+       char *sql = sqlite3_mprintf("create table if not exists %s (\
+                               audio_id                        text primary key, \
+                               path                            text unique, \
+                               thumbnail_path  text, \
+                               title                           text, \
+                               album                   text, \
+                               artist                  text, \
+                               genre                   text, \
+                               author                  text, \
+                               year                            integer default -1, \
+                               copyright               text, \
+                               description             text, \
+                               format                  text, \
+                               bitrate                 integer default -1, \
+                               track_num               integer default -1, \
+                               duration                        integer default -1, \
+                               rating                  integer default 0, \
+                               played_count            integer default 0, \
+                               last_played_time        integer default -1, \
+                               added_time              integer,\
+                               rated_time              integer,\
+                               album_rating            integer default 0,\
+                               modified_date   integer default 0, \
+                               size                            integer default 0, \
+                               category                INTEGER default 0, \
+                               valid                           integer default 0, \
+                               folder_id                       TEXT NOT NULL, \
+                               storage_type            integer, \
+                               favourite                       integer default 0, \
+                               content_type            integer default %d);",
+                               AUDIO_SVC_DB_TABLE_AUDIO,
+                               AUDIO_SVC_CONTENT_TYPE);
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to create db table (%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_CREATE_TABLE;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+static void __audio_svc_get_next_record(audio_svc_audio_item_s *item,
+                                       sqlite3_stmt *stmt)
+{
+       _strncpy_safe(item->audio_id,
+                     (const char *)sqlite3_column_text(stmt, AUDIO_SVC_AUDIO_INFO_AUDIO_ID), sizeof(item->audio_id));
+       _strncpy_safe(item->pathname,
+                     (const char *)sqlite3_column_text(stmt, AUDIO_SVC_AUDIO_INFO_PATH), sizeof(item->pathname));
+       _strncpy_safe(item->thumbname,
+                     (const char *)sqlite3_column_text(stmt, AUDIO_SVC_AUDIO_INFO_THUMBNAIL_PATH), sizeof(item->thumbname));
+       _strncpy_safe(item->audio.title,
+                     (const char *)sqlite3_column_text(stmt, AUDIO_SVC_AUDIO_INFO_TITLE), sizeof(item->audio.title));
+       _strncpy_safe(item->audio.album,
+                     (const char *)sqlite3_column_text(stmt, AUDIO_SVC_AUDIO_INFO_ALBUM), sizeof(item->audio.album));
+       _strncpy_safe(item->audio.artist,
+                     (const char *)sqlite3_column_text(stmt, AUDIO_SVC_AUDIO_INFO_ARTIST), sizeof(item->audio.artist));
+       _strncpy_safe(item->audio.genre,
+                     (const char *)sqlite3_column_text(stmt, AUDIO_SVC_AUDIO_INFO_GENRE), sizeof(item->audio.genre));
+       _strncpy_safe(item->audio.author,
+                     (const char *)sqlite3_column_text(stmt, AUDIO_SVC_AUDIO_INFO_AUTHOR), sizeof(item->audio.author));
+       _strncpy_safe(item->audio.year,
+                     _year_2_str(sqlite3_column_int(stmt, AUDIO_SVC_AUDIO_INFO_YEAR)), sizeof(item->audio.year));
+       _strncpy_safe(item->audio.copyright,
+                     (const char *)sqlite3_column_text(stmt, AUDIO_SVC_AUDIO_INFO_COPYRIGHT), sizeof(item->audio.copyright));
+       _strncpy_safe(item->audio.description,
+                     (const char *)sqlite3_column_text(stmt, AUDIO_SVC_AUDIO_INFO_DESCRIPTION), sizeof(item->audio.description));
+       _strncpy_safe(item->audio.format, 
+                       (const char *)sqlite3_column_text(stmt, AUDIO_SVC_AUDIO_INFO_FORMAT), sizeof(item->audio.format));
+       
+       item->audio.bitrate = sqlite3_column_int(stmt, AUDIO_SVC_AUDIO_INFO_BITRATE);
+       item->audio.track = sqlite3_column_int(stmt, AUDIO_SVC_AUDIO_INFO_TRACK);
+       item->audio.duration = sqlite3_column_int(stmt, AUDIO_SVC_AUDIO_INFO_DURATION);
+       item->rating = sqlite3_column_int(stmt, AUDIO_SVC_AUDIO_INFO_RATING);
+       item->played_count = sqlite3_column_int(stmt, AUDIO_SVC_AUDIO_INFO_PLAYCOUNT);
+       item->time_played = sqlite3_column_int(stmt, AUDIO_SVC_AUDIO_INFO_PLAYTIME);
+       item->time_added = sqlite3_column_int(stmt, AUDIO_SVC_AUDIO_INFO_ADDTIME);
+       item->audio.album_rating = sqlite3_column_int(stmt, AUDIO_SVC_AUDIO_INFO_ALBUM_RATING);
+       item->category = sqlite3_column_int(stmt, AUDIO_SVC_AUDIO_INFO_CATEGORY);
+       item->storage_type = sqlite3_column_int(stmt, AUDIO_SVC_AUDIO_INFO_STORAGE);
+       item->favourate = sqlite3_column_int(stmt, AUDIO_SVC_AUDIO_INFO_FAVOURATE);
+
+}
+
+static int
+__audio_svc_count_invalid_records_with_thumbnail(audio_svc_storage_type_e
+                                                storage_type)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int count = -1;
+       sqlite3_stmt *sql_stmt = NULL;
+       char *sql =
+           sqlite3_mprintf
+           ("select count(*) from %s where valid=0 and storage_type=%d and thumbnail_path is not null",
+            AUDIO_SVC_DB_TABLE_AUDIO, storage_type);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error
+                   ("error when __audio_svc_count_invalid_records_with_thumbnail. err = [%d]",
+                    ret);
+               return count;
+       }
+
+       count = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return count;
+
+}
+
+static int __audio_svc_count_records_with_thumbnail(audio_svc_storage_type_e
+                                                   storage_type)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int count = -1;
+       sqlite3_stmt *sql_stmt = NULL;
+       char *sql =
+           sqlite3_mprintf
+           ("select count(*) from %s where storage_type=%d and thumbnail_path is not null",
+            AUDIO_SVC_DB_TABLE_AUDIO, storage_type);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error
+                   ("error when __audio_svc_count_records_with_thumbnail. err = [%d]",
+                    ret);
+               return count;
+       }
+
+       count = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return count;
+
+}
+
+static int
+__audio_svc_get_invalid_records_with_thumbnail(audio_svc_storage_type_e
+                                              storage_type, int count,
+                                              mp_thumbnailpath_record_t *
+                                              thumb_path)
+{
+       int err = -1;
+       int idx = 0;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               audio_svc_debug("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       char *sql =
+           sqlite3_mprintf
+           ("select thumbnail_path from %s where valid=0 and storage_type=%d and thumbnail_path is not null",
+            AUDIO_SVC_DB_TABLE_AUDIO, storage_type);
+
+       audio_svc_debug("[SQL query] : %s", sql);
+
+       err = sqlite3_prepare_v2(handle, sql, -1, &sql_stmt, NULL);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("prepare error [%s]", sqlite3_errmsg(handle));
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
+               _strncpy_safe(thumb_path[idx].thumbnail_path,
+                             (const char *)sqlite3_column_text(sql_stmt, 0),
+                             sizeof(thumb_path[idx]));
+               idx++;
+               audio_svc_debug("thumb_path[%d]=[%s]", idx,
+                               thumb_path[idx].thumbnail_path);
+       }
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+static int __audio_svc_get_records_with_thumbnail(audio_svc_storage_type_e
+                                                 storage_type, int count,
+                                                 mp_thumbnailpath_record_t *
+                                                 thumb_path)
+{
+       int err = -1;
+       int idx = 0;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               audio_svc_debug("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       char *sql =
+           sqlite3_mprintf
+           ("select thumbnail_path from %s where storage_type=%d and thumbnail_path is not null",
+            AUDIO_SVC_DB_TABLE_AUDIO, storage_type);
+
+       audio_svc_debug("[SQL query] : %s", sql);
+
+       err = sqlite3_prepare_v2(handle, sql, -1, &sql_stmt, NULL);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("prepare error [%s]", sqlite3_errmsg(handle));
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
+               _strncpy_safe(thumb_path[idx].thumbnail_path,
+                             (const char *)sqlite3_column_text(sql_stmt, 0),
+                             sizeof(thumb_path[idx]));
+               idx++;
+               audio_svc_debug("thumb_path[%d]=[%s]", idx,
+                               thumb_path[idx].thumbnail_path);
+       }
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_create_music_table(void)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       ret = __audio_svc_create_music_db_table();
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_truncate_music_table(audio_svc_storage_type_e storage_type)
+{
+       int idx = 0;
+       mp_thumbnailpath_record_t *thumbpath_record = NULL;
+       int err = -1;
+       int invalid_count = 0;
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       invalid_count = __audio_svc_count_records_with_thumbnail(storage_type);
+       audio_svc_debug("invalid count: %d\n", invalid_count);
+
+       if (invalid_count > 0) {
+               thumbpath_record =
+                   (mp_thumbnailpath_record_t *)
+                   malloc(sizeof(mp_thumbnailpath_record_t) * invalid_count);
+               if (thumbpath_record == NULL) {
+                       audio_svc_debug("fail to memory allocation");
+                       return AUDIO_SVC_ERROR_OUT_OF_MEMORY;
+               }
+               memset(thumbpath_record, 0,
+                      sizeof(mp_thumbnailpath_record_t) * invalid_count);
+
+               ret =
+                   __audio_svc_get_records_with_thumbnail(storage_type,
+                                                          invalid_count,
+                                                          thumbpath_record);
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       audio_svc_error("error when get thumbnail record");
+                       SAFE_FREE(thumbpath_record);
+                       return ret;
+               }
+       } else {
+               audio_svc_debug("There is no item with thumbnail");
+       }
+
+       char *sql =
+           sqlite3_mprintf("delete from %s where storage_type=%d",
+                           AUDIO_SVC_DB_TABLE_AUDIO, storage_type);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to truncate table (%d)", err);
+               SAFE_FREE(thumbpath_record);
+
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       for (idx = 0; idx < invalid_count; idx++) {
+               if (strlen(thumbpath_record[idx].thumbnail_path) > 0) {
+                       ret =
+                           _audio_svc_check_and_remove_thumbnail
+                           (thumbpath_record[idx].thumbnail_path);
+                       if (ret != AUDIO_SVC_ERROR_NONE) {
+                               audio_svc_error
+                                   ("error _audio_svc_check_and_remove_thumbnail");
+                               SAFE_FREE(thumbpath_record);
+                               return ret;
+                       }
+               }
+       }
+
+       SAFE_FREE(thumbpath_record);
+       return AUDIO_SVC_ERROR_NONE;
+
+}
+
+int _audio_svc_create_folder_table(void)
+{
+       int err = -1;
+       char *sql = sqlite3_mprintf("create table if not exists %s (\
+                       _id                             text primary key, \
+                       path                            text,\
+                       folder_name             text,\
+                       storage_type            integer,\
+                       modified_date   integer default 0);", AUDIO_SVC_DB_TABLE_AUDIO_FOLDER);
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("error while create folder table");
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_CREATE_TABLE;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_delete_folder(audio_svc_storage_type_e storage_type, const char *folder_id)
+{
+       int err = -1;
+       char *sql = NULL;
+       if ((storage_type != AUDIO_SVC_STORAGE_PHONE)
+           && (storage_type != AUDIO_SVC_STORAGE_MMC)) {
+               audio_svc_error("Invalid storage type");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if ((storage_type == AUDIO_SVC_STORAGE_MMC) && (folder_id == NULL)) {   /* when mmc card removed. */
+               sql = sqlite3_mprintf("delete from %s where storage_type=%d", 
+                                   AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, storage_type);
+               err = _audio_svc_sql_query(sql);
+               sqlite3_free(sql);
+               if (err != SQLITE_OK) {
+                       audio_svc_debug("It failed to delete item (%d)", err);
+                       if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                               return err;
+                       }
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+       } else {
+               sql =
+                   sqlite3_mprintf("delete from %s where _id='%q'",
+                                   AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, folder_id);
+               err = _audio_svc_sql_query(sql);
+               sqlite3_free(sql);
+               if (err != SQLITE_OK) {
+                       audio_svc_debug("It failed to delete item (%d)", err);
+                       if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                               return err;
+                       }
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_insert_item_with_data(audio_svc_audio_item_s *item, bool stack_query)
+{
+       int err = -1;
+       int ret = AUDIO_SVC_ERROR_NONE;
+       struct stat st;
+       int modified_date = -1;
+       int size = -1;
+       char folder_id[AUDIO_SVC_UUID_SIZE+1] = {0,};
+       int year = -1;
+       char *audio_id = NULL;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               audio_svc_debug("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (item == NULL) {
+               audio_svc_error("Invalid handle");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       audio_id = _media_info_generate_uuid();
+       if(audio_id == NULL ) {
+               audio_svc_error("Invalid UUID");
+               return AUDIO_SVC_ERROR_INTERNAL;
+       }
+       
+       /* set creation date */
+       memset(&st, 0, sizeof(struct stat));
+       if (stat(item->pathname, &st) == 0) {
+               modified_date = st.st_mtime;
+               size = st.st_size;
+       }
+
+       year = str_2_year(item->audio.year);
+       if (year <= 0) {
+               year = -1;
+               audio_svc_debug("year = %d", year);
+               _strncpy_safe(item->audio.year, AUDIO_SVC_TAG_UNKNOWN,
+                             sizeof(item->audio.year));
+       }
+
+       ret = _audio_svc_get_and_append_folder_id_by_path(item->pathname,  item->storage_type, folder_id);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       char *sql =
+           sqlite3_mprintf
+           ("insert into %s (%s) values ('%q', '%q', '%q', '%q', '%q','%q', '%q','%q',%d,'%q','%q','%q',%d,%d,%d,%d,%d,%d,%d,%d, %d, %d, %d, '%q', %d);",
+            AUDIO_SVC_DB_TABLE_AUDIO, g_audio_svc_music_fields,
+            audio_id,
+            item->pathname,
+            item->thumbname,
+            item->audio.title,
+            item->audio.album,
+            item->audio.artist,
+            item->audio.genre,
+            item->audio.author,
+            str_2_year(item->audio.year),
+            item->audio.copyright,
+            item->audio.description,
+            item->audio.format,
+            item->audio.bitrate,
+            item->audio.track,
+            item->audio.duration,
+            item->rating,
+            item->played_count,
+            item->time_played,
+            item->time_added,
+            modified_date,
+            size,
+            item->category,
+            1,
+            folder_id,
+            item->storage_type);
+
+       audio_svc_debug("query : %s", sql);
+
+       if(!stack_query) {
+               err = _audio_svc_sql_query(sql);
+               sqlite3_free(sql);
+               if (err != SQLITE_OK) {
+                       audio_svc_error("failed to insert music record");
+
+                       if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                               return err;
+                       }
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+       } else {
+               _audio_svc_sql_query_add(&g_audio_svc_insert_item_query_list, &sql);
+       }
+
+       //item->audio_id = sqlite3_last_insert_rowid(handle);
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_select_music_record_by_audio_id(const char *audio_id,
+                                              audio_svc_audio_item_s *item)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       char *sql =
+           sqlite3_mprintf
+           ("select * from %s where audio_id='%q' and valid=1 and category=%d",
+            AUDIO_SVC_DB_TABLE_AUDIO, audio_id, AUDIO_SVC_CATEGORY_MUSIC);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error("error when _audio_svc_select_music_record_by_audio_id. ret = [%d]", ret);
+               return ret;
+       }
+
+       __audio_svc_get_next_record(item, sql_stmt);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_select_music_record_by_path(const char *path,
+                                          audio_svc_audio_item_s *item)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+       /* hjkim, 110211, remove category condition for the sound files */
+       char *sql =
+           sqlite3_mprintf("select * from %s where valid=1 and path='%q' ",
+                           AUDIO_SVC_DB_TABLE_AUDIO, path);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error
+                   ("error when _audio_svc_select_music_record_by_path. ret=[%d]",
+                    ret);
+               return ret;
+       }
+
+       __audio_svc_get_next_record(item, sql_stmt);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_delete_music_record_by_audio_id(const char *audio_id)
+{
+       int err = -1;
+       /* hjkim, 110211, remove category condition for the sound files */
+       char *sql =
+           sqlite3_mprintf("delete from %s where valid=1 and audio_id='%q'",
+                           AUDIO_SVC_DB_TABLE_AUDIO, audio_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to delete item (%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_metadata_in_music_record(const char *audio_id,
+                                              audio_svc_audio_item_s *item)
+{
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf
+           ("update %s set thumbnail_path='%q',title='%q',album='%q',artist='%q',arist_seq='%q' ,genre='%q',author='%q',\
+               year=%d,copyright='%q',description='%q',format='%q',track_num=%d,duration=%d,bitrate=%d where valid=1 and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO,
+            item->thumbname,
+            item->audio.title,
+            item->audio.album,
+            item->audio.artist,
+            item->audio.genre,
+            item->audio.author,
+
+            str_2_year(item->audio.year),
+
+            item->audio.copyright,
+            item->audio.description,
+            item->audio.format,
+
+            item->audio.track, item->audio.duration, item->audio.bitrate,
+            audio_id);
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to update metadata (%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_path_in_music_record(const char *src_path,
+                                          const char *path, const char *title)
+{
+       char *sql = NULL;
+       int err = -1;
+
+       if (STRING_VALID(title)) {
+               sql =
+                   sqlite3_mprintf
+                   ("update %s set path='%q', title='%q', where valid=1 and path='%q'",
+                    AUDIO_SVC_DB_TABLE_AUDIO, path, title, src_path);
+       } else {
+               sql =
+                   sqlite3_mprintf
+                   ("update %s set path='%q', where valid=1 and path='%q'",
+                    AUDIO_SVC_DB_TABLE_AUDIO, path, src_path);
+       }
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to update metadata (%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_path_and_storage_in_music_record(const char *src_path, const char *path, audio_svc_storage_type_e storage_type)
+{
+       int err = -1;
+       char *sql = sqlite3_mprintf("update %s set path='%q', storage_type=%d where valid=1 and path='%q'",
+                                AUDIO_SVC_DB_TABLE_AUDIO, path, storage_type, src_path);
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to update metadata (%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_folder_id_in_music_record(const char *path, const char *folder_id)
+{
+       int err = -1;
+       char *sql = sqlite3_mprintf("update %s set folder_id='%q' where path='%q'",
+                           AUDIO_SVC_DB_TABLE_AUDIO, folder_id, path);
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to update metadata (%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_thumb_path_in_music_record(const char *file_path,
+                                                const char *path)
+{
+       int err = -1;
+
+       char *sql =
+           sqlite3_mprintf
+           ("update %s set thumbnail_path='%q' where valid=1 and path='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO, path, file_path);
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to update thumb path (%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_rating_in_music_record(const char *audio_id, int changed_value)
+{
+       int err = -1;
+       int rated_time = -1;
+       rated_time = time(NULL);
+
+       char *sql =
+           sqlite3_mprintf
+           ("update %s set rating=%d, rated_time=%d where valid=1 and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO, changed_value, rated_time, audio_id);
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_debug("To update rating is failed(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_playtime_in_music_record(const char *audio_id, int changed_value)
+{
+
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf
+           ("update %s set last_played_time=%d where valid=1 and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("To update last_played_time is failed(%d)",
+                               err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_playcount_in_music_record(const char *audio_id, int changed_value)
+{
+
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf
+           ("update %s set played_count=%d where valid=1 and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("To update played count is failed(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_addtime_in_music_record(const char *audio_id, int changed_value)
+{
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf
+           ("update %s set added_time=%d where valid=1 and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("To update added_time is failed(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_track_num_in_music_record(const char *audio_id, int changed_value)
+{
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf
+           ("update %s set track_num=%d where valid=1 and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("update track num is failed(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_album_rating_in_music_record(const char *audio_id,
+                                                  int changed_value)
+{
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf
+           ("update %s set album_rating=%d where valid=1 and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("update album_rating is failed(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_year_in_music_record(const char *audio_id, int changed_value)
+{
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf
+           ("update %s set year=%d where valid=1 and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("update year is failed(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_title_in_music_record(const char *audio_id,
+                                           const char *changed_value)
+{
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf
+           ("update %s set title='%q' where valid=1 and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("To update title is failed(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_artist_in_music_record(const char *audio_id,
+                                            const char *changed_value)
+{
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf
+           ("update %s set artist='%q' where valid=1 and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("To update artist is failed(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_album_in_music_record(const char *audio_id,
+                                           const char *changed_value)
+{
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf
+           ("update %s set album='%q' where valid=1 and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("To update album is failed(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_genre_in_music_record(const char *audio_id,
+                                           const char *changed_value)
+{
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf
+           ("update %s set genre='%q' where valid=1 and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("To update genre is failed(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_author_in_music_record(const char *audio_id,
+                                            const char *changed_value)
+{
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf
+           ("update %s set author='%q' where valid=1 and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("To update author is failed(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_description_in_music_record(const char *audio_id,
+                                                 const char *changed_value)
+{
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf
+           ("update %s set description='%q' where valid=1 and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("To update description is failed(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_favourite_in_music_record(const char *audio_id, int changed_value)
+{
+       int err = -1;
+       char *sql = sqlite3_mprintf("update %s set favourite=%d where valid=1 and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("update album_rating is failed(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_count_music_group_records(audio_svc_group_type_e group_type,
+                                        const char *limit_string1,
+                                        const char *limit_string2,
+                                        const char *filter_string,
+                                        const char *filter_string2, int *count)
+{
+       char query[AUDIO_SVC_QUERY_SIZE] = { 0 };
+       char filter_query[AUDIO_SVC_METADATA_LEN_MAX + 5] = { 0 };
+       char filter_query2[AUDIO_SVC_METADATA_LEN_MAX + 5] = { 0 };
+       bool filter_mode = FALSE;
+       bool filter_mode2 = FALSE;
+       int err = -1;
+       int text_bind = 1;
+
+       sqlite3_stmt *sql_stmt = NULL;
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               audio_svc_debug("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (filter_string) {
+               if (strlen(filter_string) > 0) {
+                       snprintf(filter_query, sizeof(filter_query), "%%%s%%",
+                                filter_string);
+                       filter_mode = TRUE;
+               }
+       }
+       if (filter_string2) {
+               if (strlen(filter_string2) > 0) {
+                       snprintf(filter_query2, sizeof(filter_query2), "%%%s%%",
+                                filter_string2);
+                       filter_mode2 = TRUE;
+               }
+       }
+
+       switch (group_type) {
+       case AUDIO_SVC_GROUP_BY_ALBUM:
+               {
+                       snprintf(query, sizeof(query),
+                                "select count(distinct album) from %s where valid=1 and category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+                       if (filter_mode) {
+                               g_strlcat(query, " and album like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and album like ?",
+                                         sizeof(query));
+                       }
+
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_ARTIST:
+               {
+                       snprintf(query, sizeof(query),
+                                "select count(distinct artist) from %s where valid=1 and category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+                       if (filter_mode) {
+                               g_strlcat(query, " and artist like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and artist like ?",
+                                         sizeof(query));
+                       }
+
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_GENRE:
+               {
+                       snprintf(query, sizeof(query),
+                                "select count(distinct genre) from %s where valid=1 and category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+                       if (filter_mode) {
+                               g_strlcat(query, " and genre like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and genre like ?",
+                                         sizeof(query));
+                       }
+
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_FOLDER:
+               {
+                       snprintf(query, sizeof(query),
+                                "select count(distinct folder_id) from %s where valid=1 and category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+                       /*FIX ME. if filter_mode exist. */
+                       if (filter_mode) {
+                               snprintf(query, sizeof(query),
+                                        "select count(distinct a.folder_id) from %s a inner join %s b on a.folder_id = b._id \
+                                       where a.valid=1 and a.category=%d and b.path like ?",
+                                        AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, AUDIO_SVC_CATEGORY_MUSIC);
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and b.path like ?",
+                                         sizeof(query));
+                       }
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_YEAR:
+               {
+                       snprintf(query, sizeof(query),
+                                "select count(distinct year) from %s where valid=1 and category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+                       if (filter_mode) {
+                               g_strlcat(query, " and year like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and year like ?",
+                                         sizeof(query));
+                       }
+
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_COMPOSER:
+               {
+                       snprintf(query, sizeof(query),
+                                "select count(distinct author) from %s where valid=1 and category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+                       if (filter_mode) {
+                               g_strlcat(query, " and author like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and author like ?",
+                                         sizeof(query));
+                       }
+
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_ARTIST_ALBUM:
+               {
+                       snprintf(query, sizeof(query),
+                                "select count(distinct album) from %s where valid=1 and category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+                       if (limit_string1 && strlen(limit_string1) > 0) {
+                               g_strlcat(query, " and artist=?",
+                                         sizeof(query));
+                       } else {
+                               g_strlcat(query, " and artist is null",
+                                         sizeof(query));
+                       }
+                       if (filter_mode) {
+                               g_strlcat(query, " and album like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and album like ?",
+                                         sizeof(query));
+                       }
+
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_GENRE_ARTIST:
+               {
+                       snprintf(query, sizeof(query),
+                                "select count(distinct artist) from %s where valid=1 and category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+                       if (limit_string1 && strlen(limit_string1) > 0) {
+                               g_strlcat(query, " and genre=?", sizeof(query));
+                       } else {
+                               g_strlcat(query, " and genre is null",
+                                         sizeof(query));
+                       }
+                       if (filter_mode) {
+                               g_strlcat(query, " and artist like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and artist like ?",
+                                         sizeof(query));
+                       }
+
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_GENRE_ALBUM:
+               {
+                       snprintf(query, sizeof(query),
+                                "select count(distinct album) from %s where valid=1 and category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+                       if (limit_string1 && strlen(limit_string1) > 0) {
+                               g_strlcat(query, " and genre=?", sizeof(query));
+                       } else {
+                               g_strlcat(query, " and genre is null",
+                                         sizeof(query));
+                       }
+                       if (filter_mode) {
+                               g_strlcat(query, " and album like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and album like ?",
+                                         sizeof(query));
+                       }
+
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_GENRE_ARTIST_ALBUM:
+               {
+                       snprintf(query, sizeof(query),
+                                "select count(distinct album) from %s where valid=1 and category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+                       if (limit_string1 && strlen(limit_string1) > 0) {
+                               if (limit_string2 && strlen(limit_string2) > 0) {
+                                       g_strlcat(query,
+                                                 " and genre=? and artist=?",
+                                                 sizeof(query));
+                               } else {
+                                       g_strlcat(query,
+                                                 " and genre=? and artist is null",
+                                                 sizeof(query));
+                               }
+                       } else {
+                               if (limit_string2 && strlen(limit_string2) > 0) {
+                                       g_strlcat(query,
+                                                 " and genre is null and artist=?",
+                                                 sizeof(query));
+                               } else {
+                                       g_strlcat(query,
+                                                 " and genre is null and artist is null",
+                                                 sizeof(query));
+                               }
+                       }
+
+                       if (filter_mode) {
+                               g_strlcat(query, " and album like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and album like ?",
+                                         sizeof(query));
+                       }
+
+               }
+               break;
+
+       default:
+               {
+                       audio_svc_error("Wrong type [%d]", group_type);
+                       return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       audio_svc_debug("[SQL query] : %s", query);
+
+       err = sqlite3_prepare_v2(handle, query, -1, &sql_stmt, NULL);
+       if (err != SQLITE_OK) {
+               audio_svc_error("prepare error [%s]", sqlite3_errmsg(handle));
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (group_type != AUDIO_SVC_GROUP_BY_ALBUM
+           && group_type != AUDIO_SVC_GROUP_BY_ARTIST
+           && group_type != AUDIO_SVC_GROUP_BY_GENRE
+           && group_type != AUDIO_SVC_GROUP_BY_FOLDER) {
+               if (limit_string1 && strlen(limit_string1) > 0) {
+                       if (SQLITE_OK !=
+                           (err =
+                            sqlite3_bind_text(sql_stmt, text_bind,
+                                              (char *)limit_string1,
+                                              strlen(limit_string1), NULL))) {
+                               audio_svc_error
+                                   ("limit_string(%s) binding is failed (%d)",
+                                    limit_string1, err);
+                               SQLITE3_FINALIZE(sql_stmt);
+                               return AUDIO_SVC_ERROR_DB_INTERNAL;
+                       }
+                       text_bind++;
+               }
+
+               if (limit_string2 && strlen(limit_string2) > 0
+                   && group_type == AUDIO_SVC_GROUP_BY_GENRE_ARTIST_ALBUM) {
+                       if (SQLITE_OK !=
+                           (err =
+                            sqlite3_bind_text(sql_stmt, text_bind,
+                                              (char *)limit_string2,
+                                              strlen(limit_string2), NULL))) {
+                               audio_svc_error
+                                   ("limit_string2(%s) binding is failed (%d)",
+                                    limit_string2, err);
+                               SQLITE3_FINALIZE(sql_stmt);
+                               return AUDIO_SVC_ERROR_DB_INTERNAL;
+                       }
+                       text_bind++;
+               }
+       }
+
+       if (filter_mode) {
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, text_bind,
+                                      (char *)filter_query,
+                                      strlen(filter_query), NULL))) {
+                       audio_svc_error
+                           ("filter_query(%s) binding is failed (%d)",
+                            filter_query, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+               text_bind++;
+       }
+       if (filter_mode2) {
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, text_bind,
+                                      (char *)filter_query2,
+                                      strlen(filter_query2), NULL))) {
+                       audio_svc_error
+                           ("filter_query(%s) binding is failed (%d)",
+                            filter_query2, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+       }
+
+       err = sqlite3_step(sql_stmt);
+       if (err != SQLITE_ROW) {
+               audio_svc_error("end of row [%s]", sqlite3_errmsg(handle));
+               SQLITE3_FINALIZE(sql_stmt);
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       *count = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+
+}
+
+int _audio_svc_get_music_group_records(audio_svc_group_type_e group_type,
+                                      const char *limit_string1,
+                                      const char *limit_string2,
+                                      const char *filter_string,
+                                      const char *filter_string2, int offset,
+                                      int rows, audio_svc_group_item_s *group)
+{
+       char query[AUDIO_SVC_QUERY_SIZE] = { 0 };
+       char tail_query[100] = { 0 };
+       char filter_query[AUDIO_SVC_METADATA_LEN_MAX + 5] = { 0 };
+       char filter_query2[AUDIO_SVC_METADATA_LEN_MAX + 5] = { 0 };
+       bool filter_mode = FALSE;
+       bool filter_mode2 = FALSE;
+       int err = -1;
+       int text_bind = 1;
+       int idx = 0;
+
+       sqlite3_stmt *sql_stmt = NULL;
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               audio_svc_debug("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (filter_string) {
+               if (strlen(filter_string) > 0) {
+                       snprintf(filter_query, sizeof(filter_query), "%%%s%%",
+                                filter_string);
+                       filter_mode = TRUE;
+               }
+       }
+       if (filter_string2) {
+               if (strlen(filter_string2) > 0) {
+                       snprintf(filter_query2, sizeof(filter_query2), "%%%s%%",
+                                filter_string2);
+                       filter_mode2 = TRUE;
+               }
+       }
+
+       switch (group_type) {
+       case AUDIO_SVC_GROUP_BY_ALBUM:
+               {
+                       snprintf(query, sizeof(query),
+                                "select album, min(audio_id), artist, thumbnail_path, album_rating from %s where valid=1 and category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+
+                       if (filter_mode) {
+                               g_strlcat(query, " and album like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and album like ?",
+                                         sizeof(query));
+                       }
+
+                       snprintf(tail_query, sizeof(tail_query), " group by album %s limit %d,%d", AUDIO_SVC_ORDER_BY_ALBUM, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_ARTIST:
+               {
+                       snprintf(query, sizeof(query),
+                                "select artist, min(audio_id), album, thumbnail_path, album_rating from %s where valid=1 and category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+
+                       if (filter_mode) {
+                               g_strlcat(query, " and artist like ? ",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and artist like ? ",
+                                         sizeof(query));
+                       }
+
+                       snprintf(tail_query, sizeof(tail_query), " group by artist %s limit %d,%d", AUDIO_SVC_ORDER_BY_ARTIST, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_ARTIST_ALBUM:
+               {
+                       if (limit_string1 && strlen(limit_string1) > 0) {
+                               snprintf(query, sizeof(query),
+                                        "select album, min(audio_id), artist, thumbnail_path, album_rating \
+                               from %s where valid=1 and category=%d and artist=?",
+                                        AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
+                       } else {
+                               snprintf(query, sizeof(query),
+                                        "select album, min(audio_id), artist, thumbnail_path, album_rating \
+                                       from %s where valid=1 and category=%d and artist is null",
+                                        AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
+                       }
+                       if (filter_mode) {
+                               g_strlcat(query, " and album like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and album like ?",
+                                         sizeof(query));
+                       }
+
+                       snprintf(tail_query, sizeof(tail_query), " group by album %s limit %d,%d", AUDIO_SVC_ORDER_BY_ALBUM, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_GENRE:
+               {
+                       snprintf(query, sizeof(query),
+                                "select genre, min(audio_id), album, thumbnail_path, album_rating from %s where valid=1 and category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+
+                       if (filter_mode) {
+                               g_strlcat(query, " and genre like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and genre like ?",
+                                         sizeof(query));
+                       }
+
+                       snprintf(tail_query, sizeof(tail_query), " group by genre %s limit %d,%d", AUDIO_SVC_ORDER_BY_GENRE, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_FOLDER:
+               {
+                       snprintf(query, sizeof(query),
+                                "select b.folder_name, min(a.audio_id), (b.path), (a.thumbnail_path), (a.album_rating) \
+                                                               from %s as a inner join %s b on a.folder_id = b._id where a.valid=1 and a.category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, AUDIO_SVC_CATEGORY_MUSIC);
+                       if (filter_mode) {
+                               snprintf(query, sizeof(query),
+                                        "select b.folder_name, min(a.audio_id), (b.path), (a.thumbnail_path), (a.album_rating) \
+                                       from %s as a inner join %s b on a.folder_id = b._id where a.valid=1 and a.category=%d and b.path like ?",
+                                        AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, AUDIO_SVC_CATEGORY_MUSIC);
+                       }
+                       if (filter_mode2) {
+                               snprintf(query, sizeof(query),
+                                        "select b.folder_name, min(a.audio_id), (b.path), (a.thumbnail_path), (a.album_rating) \
+                                       from %s as a inner join %s b on a.folder_id = b._id where a.valid=1 and a.category=%d and b.path like ? and b.path like ?",
+                                        AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, AUDIO_SVC_CATEGORY_MUSIC);
+                       }
+
+                       snprintf(tail_query, sizeof(tail_query),
+                                " group by a.folder_id order by b.folder_name %s, b.path %s limit %d,%d",
+                                AUDIO_SVC_COLLATE_NOCASE, AUDIO_SVC_COLLATE_NOCASE, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_YEAR:
+               {
+                       snprintf(query, sizeof(query),
+                                "select year, min(audio_id), album, thumbnail_path, album_rating from %s where valid=1 and category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+
+                       if (filter_mode) {
+                               g_strlcat(query, " and year like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and year like ?",
+                                         sizeof(query));
+                       }
+
+                       snprintf(tail_query, sizeof(tail_query),
+                                " group by year order by year desc limit %d,%d",
+                                offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_COMPOSER:
+               {
+                       snprintf(query, sizeof(query),
+                                "select author, min(audio_id), album, thumbnail_path, album_rating from %s where valid=1 and category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+
+                       if (filter_mode) {
+                               g_strlcat(query, " and author like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and author like ?",
+                                         sizeof(query));
+                       }
+
+                       snprintf(tail_query, sizeof(tail_query), " group by author %s limit %d,%d", AUDIO_SVC_ORDER_BY_AUTHOR, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_GENRE_ARTIST:
+               {
+                       if (limit_string1 && strlen(limit_string1) > 0) {
+                               snprintf(query, sizeof(query),
+                                        "select artist, min(audio_id), album, thumbnail_path, album_rating \
+                                       from %s where valid=1 and category=%d and genre=?",
+                                        AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
+                       } else {
+                               snprintf(query, sizeof(query),
+                                        "select artist, min(audio_id), album, thumbnail_path, album_rating \
+                                       from %s where valid=1 and category=%d and genre is null",
+                                        AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
+                       }
+                       if (filter_mode) {
+                               g_strlcat(query, " and artist like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and artist like ?",
+                                         sizeof(query));
+                       }
+
+                       snprintf(tail_query, sizeof(tail_query), " group by artist %s limit %d,%d", AUDIO_SVC_ORDER_BY_ARTIST, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_GENRE_ALBUM:
+               {
+                       if (limit_string1 && strlen(limit_string1) > 0) {
+                               snprintf(query, sizeof(query),
+                                        "select distinct album, min(audio_id), artist, thumbnail_path, album_rating \
+                                       from %s where valid=1 and category=%d and genre=?",
+                                        AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
+                       } else {
+                               snprintf(query, sizeof(query),
+                                        "select distinct album, min(audio_id), artist, thumbnail_path, album_rating \
+                                       from %s where valid=1 and category=%d and genre is null",
+                                        AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
+                       }
+                       if (filter_mode) {
+                               g_strlcat(query, " and album like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and album like ?",
+                                         sizeof(query));
+                       }
+
+                       snprintf(tail_query, sizeof(tail_query), " group by album %s limit %d,%d", AUDIO_SVC_ORDER_BY_ALBUM, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_GROUP_BY_GENRE_ARTIST_ALBUM:
+               {
+                       if (limit_string1 && strlen(limit_string1) > 0) {
+                               if (limit_string2 && strlen(limit_string2) > 0) {
+                                       snprintf(query, sizeof(query),
+                                                "select album, min(audio_id), artist, thumbnail_path, album_rating \
+                                               from %s where valid=1 and category=%d and genre=? and artist=?",
+                                                AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
+                               } else {
+                                       snprintf(query, sizeof(query),
+                                                "select album, min(audio_id), artist, thumbnail_path, album_rating \
+                                               from %s where valid=1 and category=%d and genre=? and artist is null",
+                                                AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
+                               }
+                       } else {
+                               if (limit_string2 && strlen(limit_string2) > 0) {
+                                       snprintf(query, sizeof(query),
+                                                "select album, min(audio_id), artist, thumbnail_path, album_rating \
+                                               from %s where valid=1 and category=%d and genre is null and artist=?",
+                                                AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
+                               } else {
+                                       snprintf(query, sizeof(query),
+                                                "select album, min(audio_id), artist, thumbnail_path, album_rating \
+                                               from %s where valid=1 and category=%d and genre is null and artist is null",
+                                                AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
+                               }
+                       }
+
+                       if (filter_mode) {
+                               g_strlcat(query, " and album like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and album like ?",
+                                         sizeof(query));
+                       }
+
+                       snprintf(tail_query, sizeof(tail_query), " group by album %s limit %d,%d", AUDIO_SVC_ORDER_BY_ALBUM, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       }
+
+       audio_svc_debug("[SQL query] : %s", query);
+
+       err = sqlite3_prepare_v2(handle, query, -1, &sql_stmt, NULL);
+       if (err != SQLITE_OK) {
+               audio_svc_error("prepare error [%s]", sqlite3_errmsg(handle));
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if ((limit_string1) && strlen(limit_string1)
+           && (group_type != AUDIO_SVC_GROUP_BY_ALBUM)
+           && (group_type != AUDIO_SVC_GROUP_BY_ARTIST)) {
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, text_bind,
+                                      (char *)limit_string1,
+                                      strlen(limit_string1), NULL))) {
+                       audio_svc_error
+                           ("limit_string1(%s) binding is failed (%d)",
+                            limit_string1, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+               text_bind++;
+       }
+
+       if ((limit_string2) && strlen(limit_string2)
+           && (group_type == AUDIO_SVC_GROUP_BY_GENRE_ARTIST_ALBUM)) {
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, text_bind,
+                                      (char *)limit_string2,
+                                      strlen(limit_string2), NULL))) {
+                       audio_svc_error
+                           ("limit_string2(%s) binding is failed (%d)",
+                            limit_string2, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+               text_bind++;
+       }
+
+       if (filter_mode) {
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, text_bind,
+                                      (char *)filter_query,
+                                      strlen(filter_query), NULL))) {
+                       audio_svc_error
+                           ("filter_query(%s) binding is failed (%d)",
+                            filter_query, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+               text_bind++;
+       }
+       if (filter_mode2) {
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, text_bind,
+                                      (char *)filter_query2,
+                                      strlen(filter_query2), NULL))) {
+                       audio_svc_error
+                           ("filter_query(%s) binding is failed (%d)",
+                            filter_query2, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+               text_bind++;
+       }
+
+       while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
+               if (group_type == AUDIO_SVC_GROUP_BY_YEAR) {
+                       int year = sqlite3_column_int(sql_stmt, 0);
+                       if (year == -1 || year == 0) {
+                               _strncpy_safe(group[idx].maininfo,
+                                             AUDIO_SVC_TAG_UNKNOWN,
+                                             sizeof(group[idx].maininfo));
+                       } else {
+                               _strncpy_safe(group[idx].maininfo,
+                                             (const char *)
+                                             sqlite3_column_text(sql_stmt, 0),
+                                             sizeof(group[idx].maininfo));
+                       }
+               } else {
+                       _strncpy_safe(group[idx].maininfo,
+                                     (const char *)
+                                     sqlite3_column_text(sql_stmt, 0),
+                                     sizeof(group[idx].maininfo));
+               }
+
+               _strncpy_safe(group[idx].subinfo,
+                             (const char *)sqlite3_column_text(sql_stmt, 2),
+                             sizeof(group[idx].subinfo));
+
+               _strncpy_safe(group[idx].thumbnail_path,
+                             (const char *)sqlite3_column_text(sql_stmt, 3),
+                             sizeof(group[idx].thumbnail_path));
+
+               group[idx].album_rating = sqlite3_column_int(sql_stmt, 4);
+
+               idx++;
+       }
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+
+}
+
+int _audio_svc_count_music_track_records(audio_svc_track_type_e track_type,
+                                        const char *type_string,
+                                        const char *type_string2,
+                                        const char *filter_string,
+                                        const char *filter_string2, int *count)
+{
+       char query[AUDIO_SVC_QUERY_SIZE] = { 0 };
+       char filter_query[AUDIO_SVC_METADATA_LEN_MAX + 5] = { 0 };
+       char filter_query2[AUDIO_SVC_METADATA_LEN_MAX + 5] = { 0 };
+       bool filter_mode = FALSE;
+       bool filter_mode2 = FALSE;
+       int err = -1;
+       int text_bind = 1;
+
+       sqlite3_stmt *sql_stmt = NULL;
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               audio_svc_debug("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (filter_string) {
+               if (strlen(filter_string) > 0) {
+                       snprintf(filter_query, sizeof(filter_query), "%%%s%%",
+                                filter_string);
+                       filter_mode = TRUE;
+               }
+       }
+       if (filter_string2) {
+               if (strlen(filter_string2) > 0) {
+                       snprintf(filter_query2, sizeof(filter_query2), "%%%s%%",
+                                filter_string2);
+                       filter_mode2 = TRUE;
+               }
+       }
+
+       switch (track_type) {
+       case AUDIO_SVC_TRACK_ALL:
+               snprintf(query, sizeof(query),
+                        "select count(*) from %s where valid=1 and category=%d",
+                        AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
+               break;
+
+       case AUDIO_SVC_TRACK_BY_ALBUM:
+               if (type_string && strlen(type_string) > 0) {
+                       snprintf(query, sizeof(query),
+                                "select count(*) from %s where valid=1 and category=%d and album=?",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+               } else {
+                       snprintf(query, sizeof(query),
+                                "select count(*) from %s where valid=1 and category=%d and album is null",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_ARTIST_ALBUM:
+               if (type_string && strlen(type_string) > 0) {
+                       if (type_string2 && strlen(type_string2) > 0) {
+                               snprintf(query, sizeof(query),
+                                        "select count(*) from %s where valid=1 and category=%d and album=? and artist=?",
+                                        AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       } else {
+                               snprintf(query, sizeof(query),
+                                        "select count(*) from %s where valid=1 and category=%d and album=? and artist is null",
+                                        AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       }
+               } else {
+                       if (type_string2 && strlen(type_string2) > 0) {
+                               snprintf(query, sizeof(query),
+                                        "select count(*) from %s where valid=1 and category=%d and album is null and artist=?",
+                                        AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       } else {
+                               snprintf(query, sizeof(query),
+                                        "select count(*) from %s where valid=1 and category=%d and album is null and artist is null",
+                                        AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       }
+               }
+
+               break;
+
+       case AUDIO_SVC_TRACK_BY_ARTIST:
+               if (type_string && strlen(type_string) > 0) {
+                       snprintf(query, sizeof(query),
+                                "select count(*) from %s where valid=1 and category=%d and artist=?",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+               } else {
+                       snprintf(query, sizeof(query),
+                                "select count(*) from %s where valid=1 and category=%d and artist is null",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_ARTIST_GENRE:
+               if (type_string && strlen(type_string) > 0) {
+                       if (type_string2 && strlen(type_string2) > 0) {
+                               snprintf(query, sizeof(query),
+                                        "select count(*) from %s where valid=1 and category=%d and genre=? and artist=?",
+                                        AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       } else {
+                               snprintf(query, sizeof(query),
+                                        "select count(*) from %s where valid=1 and category=%d and genre=? and artist is null",
+                                        AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       }
+               } else {
+                       if (type_string2 && strlen(type_string2) > 0) {
+                               snprintf(query, sizeof(query),
+                                        "select count(*) from %s where valid=1 and category=%d and genre is null and artist=?",
+                                        AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       } else {
+                               snprintf(query, sizeof(query),
+                                        "select count(*) from %s where valid=1 and category=%d and genre is null and artist is null",
+                                        AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       }
+
+               }
+
+               break;
+
+       case AUDIO_SVC_TRACK_BY_GENRE:
+               if (type_string && strlen(type_string) > 0) {
+                       snprintf(query, sizeof(query),
+                                "select count(*) from %s where valid=1 and category=%d and genre=?",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+               } else {
+                       snprintf(query, sizeof(query),
+                                "select count(*) from %s where valid=1 and category=%d and genre is null",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_FOLDER:
+               if (type_string && strlen(type_string) > 0) {
+                       snprintf(query, sizeof(query),
+                                "select count(*) from %s where valid=1 and category=%d and folder_id=(select _id from %s where path = ?)",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC,
+                                AUDIO_SVC_DB_TABLE_AUDIO_FOLDER);
+               } else {
+                       snprintf(query, sizeof(query),
+                                "select count(*) from %s where valid=1 and category=%d and folder_id is null",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_YEAR:
+               if (type_string && strlen(type_string) > 0) {
+                       snprintf(query, sizeof(query),
+                                "select count(*) from %s where valid=1 and category=%d and year=?",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+               } else {
+                       snprintf(query, sizeof(query),
+                                "select count(*) from %s where valid=1 and category=%d and year is null",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_COMPOSER:
+               if (type_string && strlen(type_string) > 0) {
+                       snprintf(query, sizeof(query),
+                                "select count(*) from %s where valid=1 and category=%d and author=?",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+               } else {
+                       snprintf(query, sizeof(query),
+                                "select count(*) from %s where valid=1 and category=%d and author is null",
+                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_TOPRATING:
+               snprintf(query, sizeof(query),
+                        "select count(*) from %s where valid=1 and category=%d and rating > %d",
+                        AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC,
+                        AUDIO_SVC_RATING_3);
+               break;
+
+       case AUDIO_SVC_TRACK_BY_PLAYED_TIME:
+               snprintf(query, sizeof(query),
+                        "select count(*) from %s where valid=1 and category=%d and last_played_time > 0",
+                        AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
+               break;
+
+       case AUDIO_SVC_TRACK_BY_ADDED_TIME:
+               snprintf(query, sizeof(query),
+                        "select count(*) from %s where valid=1 and category=%d and added_time > 0",
+                        AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
+               break;
+
+       case AUDIO_SVC_TRACK_BY_PLAYED_COUNT:
+               snprintf(query, sizeof(query),
+                        "select count(*) from %s where valid=1 and category=%d and played_count > 0",
+                        AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
+               break;
+
+       case AUDIO_SVC_TRACK_BY_PLAYLIST:
+               {
+                       snprintf(query, sizeof(query),
+                                "select count(*) from %s a, %s b where a.playlist_id=%d and b.audio_id=a.audio_id and b.valid=1 and b.category=%d",
+                                AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP,
+                                AUDIO_SVC_DB_TABLE_AUDIO, (int)type_string,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+
+                       if (filter_mode) {
+                               g_strlcat(query, " and b.title like ?",
+                                         sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               g_strlcat(query, " and b.title like ?",
+                                         sizeof(query));
+                       }
+               }
+               break;
+
+       default:
+               break;
+       }
+
+       if (track_type != AUDIO_SVC_TRACK_BY_PLAYLIST) {
+               if (filter_mode) {
+                       g_strlcat(query, " and title like ?", sizeof(query));
+               }
+               if (filter_mode2) {
+                       g_strlcat(query, " and title like ?", sizeof(query));
+               }
+       }
+       audio_svc_debug("[SQL query] : %s", query);
+
+       err = sqlite3_prepare_v2(handle, query, -1, &sql_stmt, NULL);
+       if (err != SQLITE_OK) {
+               audio_svc_error("prepare error [%s]", sqlite3_errmsg(handle));
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (filter_mode) {
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, text_bind,
+                                      (char *)filter_query,
+                                      strlen(filter_query), NULL))) {
+                       audio_svc_error
+                           ("filter_query(%s) binding is failed (%d)",
+                            filter_query, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+               text_bind++;
+       }
+       if (filter_mode2) {
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, text_bind,
+                                      (char *)filter_query2,
+                                      strlen(filter_query2), NULL))) {
+                       audio_svc_error
+                           ("filter_query(%s) binding is failed (%d)",
+                            filter_query2, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+               text_bind++;
+       }
+
+       if ((track_type >= AUDIO_SVC_TRACK_BY_ALBUM)
+           && (track_type <= AUDIO_SVC_TRACK_BY_COMPOSER)) {
+               if (type_string && strlen(type_string) > 0) {
+                       if ((track_type == AUDIO_SVC_TRACK_BY_YEAR)
+                           && (!strcmp(type_string, AUDIO_SVC_TAG_UNKNOWN))) {
+                               if (SQLITE_OK !=
+                                   (err =
+                                    sqlite3_bind_text(sql_stmt, text_bind,
+                                                      "-1", strlen("-1"),
+                                                      NULL))) {
+                                       audio_svc_error
+                                           ("cont_string1(%s) binding is failed (%d)",
+                                            type_string, err);
+                                       SQLITE3_FINALIZE(sql_stmt);
+                                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+                               }
+                               text_bind++;
+                       } else
+                           if ((track_type == AUDIO_SVC_TRACK_BY_ARTIST_GENRE)
+                               || (track_type ==
+                                   AUDIO_SVC_TRACK_BY_ARTIST_ALBUM)) {
+                               if (type_string2 && strlen(type_string2) > 0) {
+                                       if (SQLITE_OK !=
+                                           (err =
+                                            sqlite3_bind_text(sql_stmt,
+                                                              text_bind,
+                                                              (char *)
+                                                              type_string,
+                                                              strlen
+                                                              (type_string),
+                                                              NULL))) {
+                                               audio_svc_error
+                                                   ("cont_string1(%s) binding is failed (%d)",
+                                                    type_string, err);
+                                               SQLITE3_FINALIZE(sql_stmt);
+                                               return
+                                                   AUDIO_SVC_ERROR_DB_INTERNAL;
+                                       }
+                                       text_bind++;
+                                       if (SQLITE_OK !=
+                                           (err =
+                                            sqlite3_bind_text(sql_stmt,
+                                                              text_bind,
+                                                              (char *)
+                                                              type_string2,
+                                                              strlen
+                                                              (type_string2),
+                                                              NULL))) {
+                                               audio_svc_error
+                                                   ("cont_string2(%s) binding is failed (%d)",
+                                                    type_string2, err);
+                                               SQLITE3_FINALIZE(sql_stmt);
+                                               return
+                                                   AUDIO_SVC_ERROR_DB_INTERNAL;
+                                       }
+                                       text_bind++;
+                               } else {
+                                       if (SQLITE_OK !=
+                                           (err =
+                                            sqlite3_bind_text(sql_stmt,
+                                                              text_bind,
+                                                              (char *)
+                                                              type_string,
+                                                              strlen
+                                                              (type_string),
+                                                              NULL))) {
+                                               audio_svc_error
+                                                   ("cont_string1(%s) binding is failed (%d)",
+                                                    type_string, err);
+                                               SQLITE3_FINALIZE(sql_stmt);
+                                               return
+                                                   AUDIO_SVC_ERROR_DB_INTERNAL;
+                                       }
+                               }
+                       } else {
+                               if (SQLITE_OK !=
+                                   (err =
+                                    sqlite3_bind_text(sql_stmt, text_bind,
+                                                      (char *)type_string,
+                                                      strlen(type_string),
+                                                      NULL))) {
+                                       audio_svc_error
+                                           ("cont_string1(%s) binding is failed (%d)",
+                                            type_string, err);
+                                       SQLITE3_FINALIZE(sql_stmt);
+                                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+                               }
+                       }
+                       text_bind++;
+               }
+       }
+
+       audio_svc_debug("[SQL query] : %s", query);
+
+       err = sqlite3_step(sql_stmt);
+       if (err != SQLITE_ROW) {
+               audio_svc_error("end of row [%s]", sqlite3_errmsg(handle));
+               SQLITE3_FINALIZE(sql_stmt);
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+       *count = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+
+}
+
+int _audio_svc_get_music_track_records(audio_svc_track_type_e track_type,
+                                      const char *type_string,
+                                      const char *type_string2,
+                                      const char *filter_string,
+                                      const char *filter_string2, int offset,
+                                      int rows, audio_svc_list_item_s *track)
+{
+       char query[AUDIO_SVC_QUERY_SIZE] = { 0 };
+       char *result_field =
+           "audio_id, path, thumbnail_path, title, artist, duration, rating";
+
+       char tail_query[70] = { 0 };
+       char filter_query[AUDIO_SVC_METADATA_LEN_MAX + 5] = { 0 };
+       char filter_query2[AUDIO_SVC_METADATA_LEN_MAX + 5] = { 0 };
+       bool filter_mode = FALSE;
+       bool filter_mode2 = FALSE;
+       int err = -1;
+       int len = -1;
+       int text_bind = 1;
+       int idx = 0;
+
+       sqlite3_stmt *sql_stmt = NULL;
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               audio_svc_debug("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+#define filter_condition(filter_mode, filter_mode2, query)     \
+       if ((filter_mode))      g_strlcat((query), " and title like ?", sizeof((query))); \
+       if ((filter_mode2))     g_strlcat((query), " and title like ?", sizeof((query)));
+
+       filter_mode = STRING_VALID(filter_string);
+       filter_mode2 = STRING_VALID(filter_string2);
+
+       if (filter_mode) {
+               snprintf(filter_query, sizeof(filter_query), "%%%s%%",
+                        filter_string);
+       }
+       if (filter_mode2) {
+               snprintf(filter_query2, sizeof(filter_query2), "%%%s%%",
+                        filter_string2);
+       }
+
+       switch (track_type) {
+       case AUDIO_SVC_TRACK_ALL:
+               {
+                       snprintf(query, sizeof(query),
+                                "select %s from %s where valid=1 and category=%d",
+                                result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+                       filter_condition(filter_mode, filter_mode2, query);
+                       snprintf(tail_query, sizeof(tail_query),
+                                " %s limit %d,%d", AUDIO_SVC_ORDER_BY_TITLE, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_ALBUM:
+               {
+                       if (type_string && strlen(type_string) > 0) {
+                               snprintf(query, sizeof(query),
+                                        "select %s from %s where valid=1 and category=%d and album=?",
+                                        result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       } else {
+                               snprintf(query, sizeof(query),
+                                        "select %s from %s where valid=1 and category=%d and album is null",
+                                        result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       }
+                       filter_condition(filter_mode, filter_mode2, query);
+                       snprintf(tail_query, sizeof(tail_query),
+                                " order by track_num limit %d,%d", offset,
+                                rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_ARTIST_ALBUM:
+               {
+                       if (type_string && strlen(type_string) > 0) {
+                               if (type_string2 && strlen(type_string2) > 0) {
+                                       snprintf(query, sizeof(query),
+                                                "select %s from %s where valid=1 and category=%d and album=? and artist=?",
+                                                result_field,
+                                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                                AUDIO_SVC_CATEGORY_MUSIC);
+                               } else {
+                                       snprintf(query, sizeof(query),
+                                                "select %s from %s where valid=1 and category=%d and album=? and artist is null",
+                                                result_field,
+                                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                                AUDIO_SVC_CATEGORY_MUSIC);
+                               }
+                       } else {
+                               if (type_string2 && strlen(type_string2) > 0) {
+                                       snprintf(query, sizeof(query),
+                                                "select %s from %s where valid=1 and category=%d and album is null and artist=?",
+                                                result_field,
+                                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                                AUDIO_SVC_CATEGORY_MUSIC);
+                               } else {
+                                       snprintf(query, sizeof(query),
+                                                "select %s from %s where valid=1 and category=%d and album is null and artist is null",
+                                                result_field,
+                                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                                AUDIO_SVC_CATEGORY_MUSIC);
+                               }
+                       }
+
+                       filter_condition(filter_mode, filter_mode2, query);
+
+                       snprintf(tail_query, sizeof(tail_query),
+                                " %s limit %d,%d", AUDIO_SVC_ORDER_BY_TITLE, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_ARTIST:
+               {
+/*hjkim, 110822, UX changed. query album info to sort by album and title.*/
+                       if (type_string && strlen(type_string) > 0) {
+                               snprintf(query, sizeof(query),
+                                        "select %s, album from %s where valid=1 and category=%d and artist=?",
+                                        result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       } else {
+                               snprintf(query, sizeof(query),
+                                        "select %s, album from %s where valid=1 and category=%d and artist is null",
+                                        result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       }
+                       filter_condition(filter_mode, filter_mode2, query);
+                       snprintf(tail_query, sizeof(tail_query), " order by album %s, title %s limit %d,%d", AUDIO_SVC_COLLATE_NOCASE, AUDIO_SVC_COLLATE_NOCASE, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_ARTIST_GENRE:
+               {
+                       if (type_string && strlen(type_string) > 0) {
+                               if (type_string2 && strlen(type_string2) > 0) {
+                                       snprintf(query, sizeof(query),
+                                                "select %s from %s where valid=1 and category=%d and genre=? and artist=?",
+                                                result_field,
+                                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                                AUDIO_SVC_CATEGORY_MUSIC);
+                               } else {
+                                       snprintf(query, sizeof(query),
+                                                "select %s from %s where valid=1 and category=%d and genre=? and artist is null",
+                                                result_field,
+                                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                                AUDIO_SVC_CATEGORY_MUSIC);
+                               }
+                       } else {
+                               if (type_string2 && strlen(type_string2) > 0) {
+                                       snprintf(query, sizeof(query),
+                                                "select %s from %s where valid=1 and category=%d and genre is null and artist=?",
+                                                result_field,
+                                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                                AUDIO_SVC_CATEGORY_MUSIC);
+                               } else {
+                                       snprintf(query, sizeof(query),
+                                                "select %s from %s where valid=1 and category=%d and genre is null and artist is null",
+                                                result_field,
+                                                AUDIO_SVC_DB_TABLE_AUDIO,
+                                                AUDIO_SVC_CATEGORY_MUSIC);
+                               }
+                       }
+
+                       filter_condition(filter_mode, filter_mode2, query);
+
+                       snprintf(tail_query, sizeof(tail_query),
+                                " %s limit %d,%d", AUDIO_SVC_ORDER_BY_TITLE, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_GENRE:
+               {
+                       if (type_string && strlen(type_string) > 0) {
+                               snprintf(query, sizeof(query),
+                                        "select %s from %s where valid=1 and category=%d and genre=?",
+                                        result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       } else {
+                               snprintf(query, sizeof(query),
+                                        "select %s from %s where valid=1 and category=%d and genre is null",
+                                        result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       }
+                       filter_condition(filter_mode, filter_mode2, query);
+
+                       snprintf(tail_query, sizeof(tail_query),
+                                " %s limit %d,%d", AUDIO_SVC_ORDER_BY_TITLE, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_FOLDER:
+               {
+                       if (type_string && strlen(type_string) > 0) {
+                               snprintf(query, sizeof(query),
+                                        "select %s from %s where valid=1 and category=%d and folder_id=(select _id from %s where path = ?)",
+                                        result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC,
+                                        AUDIO_SVC_DB_TABLE_AUDIO_FOLDER);
+                       } else {
+                               snprintf(query, sizeof(query),
+                                        "select %s from %s where valid=1 and category=%d and folder_id is null",
+                                        result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       }
+                       filter_condition(filter_mode, filter_mode2, query);
+
+                       snprintf(tail_query, sizeof(tail_query),
+                                " %s limit %d,%d", AUDIO_SVC_ORDER_BY_TITLE, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_YEAR:
+               {
+                       if (type_string && strlen(type_string) > 0) {
+                               snprintf(query, sizeof(query),
+                                        "select %s from %s where valid=1 and category=%d and year=?",
+                                        result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       } else {
+                               snprintf(query, sizeof(query),
+                                        "select %s from %s where valid=1 and category=%d and year is null",
+                                        result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       }
+                       filter_condition(filter_mode, filter_mode2, query);
+
+                       snprintf(tail_query, sizeof(tail_query),
+                                " %s limit %d,%d", AUDIO_SVC_ORDER_BY_TITLE, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_COMPOSER:
+               {
+                       if (type_string && strlen(type_string) > 0) {
+                               snprintf(query, sizeof(query),
+                                        "select %s from %s where valid=1 and category=%d and author=?",
+                                        result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       } else {
+                               snprintf(query, sizeof(query),
+                                        "select %s from %s where valid=1 and category=%d and author is null",
+                                        result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                        AUDIO_SVC_CATEGORY_MUSIC);
+                       }
+                       filter_condition(filter_mode, filter_mode2, query);
+
+                       snprintf(tail_query, sizeof(tail_query),
+                                " %s limit %d,%d", AUDIO_SVC_ORDER_BY_TITLE, offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_TOPRATING:
+               {
+                       snprintf(query, sizeof(query),
+                                "select %s from %s where valid=1 and category=%d and rating >= %d",
+                                result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC, AUDIO_SVC_RATING_4);
+
+                       filter_condition(filter_mode, filter_mode2, query);
+
+                       snprintf(tail_query, sizeof(tail_query),
+                                " order by rating desc, rated_time desc limit %d,%d",
+                                offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_PLAYED_TIME:
+               {
+                       snprintf(query, sizeof(query),
+                                "select %s from %s where valid=1 and category=%d and last_played_time > 0",
+                                result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+
+                       filter_condition(filter_mode, filter_mode2, query);
+
+                       snprintf(tail_query, sizeof(tail_query),
+                                " order by last_played_time desc limit %d,%d",
+                                offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_ADDED_TIME:
+               {
+                       snprintf(query, sizeof(query),
+                                "select %s from %s where valid=1 and category=%d and added_time > 0",
+                                result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+
+                       filter_condition(filter_mode, filter_mode2, query);
+
+                       snprintf(tail_query, sizeof(tail_query),
+                                " order by added_time desc limit %d,%d",
+                                offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       case AUDIO_SVC_TRACK_BY_PLAYED_COUNT:
+               {
+                       snprintf(query, sizeof(query),
+                                "select %s from %s where valid=1 and category=%d and played_count > 0",
+                                result_field, AUDIO_SVC_DB_TABLE_AUDIO,
+                                AUDIO_SVC_CATEGORY_MUSIC);
+
+                       filter_condition(filter_mode, filter_mode2, query);
+
+                       snprintf(tail_query, sizeof(tail_query),
+                                " order by played_count desc limit %d,%d",
+                                offset, rows);
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+               /* To permit duplicated track in a playlist, playlist item index should be returned. */
+       case AUDIO_SVC_TRACK_BY_PLAYLIST:
+               {
+                       char *result_field_for_playlist =
+                           "b.audio_id, b.path, b.thumbnail_path, b.title, b.artist, b.duration, b.rating";
+                       len =
+                           snprintf(query, sizeof(query),
+                                    "select %s from %s a, %s b where a.playlist_id=%d and b.audio_id=a.audio_id and b.valid=1 and b.category=%d ",
+                                    result_field_for_playlist,
+                                    AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP,
+                                    AUDIO_SVC_DB_TABLE_AUDIO, (int)type_string,
+                                    AUDIO_SVC_CATEGORY_MUSIC);
+
+                       if (len < 1 || len >= sizeof(query)) {
+                               audio_svc_error
+                                   ("snprintf error occured or truncated");
+                               return AUDIO_SVC_ERROR_INTERNAL;
+                       } else {
+                               query[len] = '\0';
+                       }
+
+                       if (filter_mode) {
+                               snprintf(tail_query, sizeof(tail_query),
+                                        " and b.title like ?");
+                               g_strlcat(query, tail_query, sizeof(query));
+                       }
+                       if (filter_mode2) {
+                               snprintf(tail_query, sizeof(tail_query),
+                                        " and b.title like ?");
+                               g_strlcat(query, tail_query, sizeof(query));
+                       }
+                       snprintf(tail_query, sizeof(tail_query),
+                                "  order by a.play_order limit %d,%d", offset,
+                                rows);
+
+                       g_strlcat(query, tail_query, sizeof(query));
+               }
+               break;
+
+       default:
+               audio_svc_error("Invalid track type");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+
+       }
+
+       audio_svc_debug("[SQL query] : %s", query);
+
+       err = sqlite3_prepare_v2(handle, query, -1, &sql_stmt, NULL);
+       if (err != SQLITE_OK) {
+               audio_svc_error("prepare error [%s]", sqlite3_errmsg(handle));
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if ((track_type >= AUDIO_SVC_TRACK_BY_ALBUM)
+           && (track_type <= AUDIO_SVC_TRACK_BY_COMPOSER)) {
+               if (type_string && strlen(type_string) > 0) {
+                       if ((track_type == AUDIO_SVC_TRACK_BY_YEAR)
+                           && (!strcmp(type_string, AUDIO_SVC_TAG_UNKNOWN))) {
+                               if (SQLITE_OK !=
+                                   (err =
+                                    sqlite3_bind_text(sql_stmt, text_bind,
+                                                      "-1", strlen("-1"),
+                                                      NULL))) {
+                                       audio_svc_error
+                                           ("cont_string1(%s) binding is failed (%d)",
+                                            type_string, err);
+                                       SQLITE3_FINALIZE(sql_stmt);
+                                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+                               }
+
+                       } else {
+                               if (SQLITE_OK !=
+                                   (err =
+                                    sqlite3_bind_text(sql_stmt, text_bind,
+                                                      (const char *)
+                                                      type_string, -1,
+                                                      NULL))) {
+                                       audio_svc_error
+                                           ("cont_string1(%s) binding is failed (%d)",
+                                            type_string, err);
+                                       SQLITE3_FINALIZE(sql_stmt);
+                                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+                               }
+                       }
+                       text_bind++;
+               }
+       }
+
+       if ((track_type == AUDIO_SVC_TRACK_BY_ARTIST_GENRE)
+           || (track_type == AUDIO_SVC_TRACK_BY_ARTIST_ALBUM)) {
+               if (type_string2 && strlen(type_string2) > 0) {
+                       if (SQLITE_OK !=
+                           (err =
+                            sqlite3_bind_text(sql_stmt, text_bind,
+                                              (char *)type_string2,
+                                              strlen(type_string2), NULL))) {
+                               audio_svc_error
+                                   ("cont_string2(%s) binding is failed (%d)",
+                                    type_string2, err);
+                               SQLITE3_FINALIZE(sql_stmt);
+                               return AUDIO_SVC_ERROR_DB_INTERNAL;
+                       }
+                       text_bind++;
+               }
+       }
+
+       if (filter_mode) {
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, text_bind,
+                                      (char *)filter_query,
+                                      strlen(filter_query), NULL))) {
+                       audio_svc_error
+                           ("filter_query(%s) binding is failed (%d)",
+                            filter_query, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+               text_bind++;
+       }
+       if (filter_mode2) {
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, text_bind,
+                                      (char *)filter_query2,
+                                      strlen(filter_query2), NULL))) {
+                       audio_svc_error
+                           ("filter_query(%s) binding is failed (%d)",
+                            filter_query2, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+               text_bind++;
+       }
+
+       while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
+               _strncpy_safe(track[idx].audio_id,
+                             (const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_LIST_ITEM_AUDIO_ID), sizeof(track[idx].audio_id));
+               _strncpy_safe(track[idx].pathname,
+                             (const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_LIST_ITEM_PATHNAME), sizeof(track[idx].pathname));
+               _strncpy_safe(track[idx].thumbnail_path,
+                             (const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_LIST_ITEM_THUMBNAIL_PATH), sizeof(track[idx].thumbnail_path));
+               _strncpy_safe(track[idx].title,
+                             (const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_LIST_ITEM_TITLE), sizeof(track[idx].title));
+               _strncpy_safe(track[idx].artist,
+                             (const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_LIST_ITEM_ARTIST), sizeof(track[idx].artist));
+               track[idx].duration = sqlite3_column_int(sql_stmt, AUDIO_SVC_LIST_ITEM_DURATION);
+               track[idx].rating = sqlite3_column_int(sql_stmt, AUDIO_SVC_LIST_ITEM_RATING);
+               audio_svc_debug ("Index : %d : audio_id = %s, title = %s, pathname = %s, duration = %d",
+                    idx, track[idx].audio_id, track[idx].title, track[idx].pathname, track[idx].duration);
+
+               idx++;
+       }
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+
+}
+
+int _audio_svc_delete_music_track_groups(audio_svc_group_type_e group_type,
+                                        const char *type_string)
+{
+       int err = -1;
+       char *sql = NULL;
+
+       switch (group_type) {
+       case AUDIO_SVC_GROUP_BY_ALBUM:
+               sql =
+                   sqlite3_mprintf
+                   ("delete from %s where album='%q' and valid=1 and category=%d",
+                    AUDIO_SVC_DB_TABLE_AUDIO, type_string,
+                    AUDIO_SVC_CATEGORY_MUSIC);
+               break;
+       case AUDIO_SVC_GROUP_BY_ARTIST:
+               sql =
+                   sqlite3_mprintf
+                   ("delete from %s where artist='%q' and valid=1 and category=%d",
+                    AUDIO_SVC_DB_TABLE_AUDIO, type_string,
+                    AUDIO_SVC_CATEGORY_MUSIC);
+               break;
+       case AUDIO_SVC_GROUP_BY_GENRE:
+               sql =
+                   sqlite3_mprintf
+                   ("delete from %s where genre='%q' and valid=1 and category=%d",
+                    AUDIO_SVC_DB_TABLE_AUDIO, type_string,
+                    AUDIO_SVC_CATEGORY_MUSIC);
+               break;
+       case AUDIO_SVC_GROUP_BY_FOLDER:
+               sql =
+                   sqlite3_mprintf
+                   ("delete from %s where folder_id=(select _id from %s where path = '%q') and valid=1 and category=%d",
+                    AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_DB_TABLE_AUDIO_FOLDER,
+                    type_string, AUDIO_SVC_CATEGORY_MUSIC);
+               break;
+       case AUDIO_SVC_GROUP_BY_YEAR:
+               sql =
+                   sqlite3_mprintf
+                   ("delete from %s where year= %d and valid=1 and category=%d",
+                    AUDIO_SVC_DB_TABLE_AUDIO, str_2_year(type_string),
+                    AUDIO_SVC_CATEGORY_MUSIC);
+               break;
+       case AUDIO_SVC_GROUP_BY_COMPOSER:
+               sql =
+                   sqlite3_mprintf
+                   ("delete from %s where author='%q' and valid=1 and category=%d",
+                    AUDIO_SVC_DB_TABLE_AUDIO, type_string,
+                    AUDIO_SVC_CATEGORY_MUSIC);
+               break;
+       default:
+               audio_svc_error("Invalid track type");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       audio_svc_debug("query (%s)", sql);
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("To delete group is failed(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_search_audio_id_by_path(const char *path, char *audio_id)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       *audio_id = -1;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       char *sql =
+           sqlite3_mprintf
+           ("select audio_id from %s where valid=1 and category=%d and path='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC, path);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error
+                   ("error when _audio_svc_search_audio_id_by_path. ret = [%d]",
+                    ret);
+               return ret;
+       }
+
+       _strncpy_safe(audio_id, (const char *)sqlite3_column_text(sql_stmt, 0), AUDIO_SVC_UUID_SIZE+1);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+
+}
+
+int _audio_svc_update_valid_of_music_records(audio_svc_storage_type_e
+                                           storage_type, int valid)
+{
+       audio_svc_debug("storage_type: %d", storage_type);
+
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf("update %s set valid = %d where storage_type = %d",
+                           AUDIO_SVC_DB_TABLE_AUDIO, valid, storage_type);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("To set all items as invalid is failed(%d)",
+                               err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_count_record_with_path(const char *path)
+{
+
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int count = -1;
+       sqlite3_stmt *sql_stmt = NULL;
+       char *sql =
+           sqlite3_mprintf("select count(*) from %s where path='%q'",
+                           AUDIO_SVC_DB_TABLE_AUDIO, path);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error
+                   ("error when _audio_svc_count_record_with_path. err = [%d]",
+                    ret);
+               return count;
+       }
+
+       count = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return count;
+
+}
+
+int _audio_svc_delete_invalid_music_records(audio_svc_storage_type_e
+                                           storage_type)
+{
+       int idx = 0;
+       mp_thumbnailpath_record_t *thumbpath_record = NULL;
+       int err = -1;
+       int invalid_count = 0;
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       invalid_count = __audio_svc_count_invalid_records_with_thumbnail(storage_type);
+       audio_svc_debug("invalid count: %d\n", invalid_count);
+
+       if (invalid_count > 0) {
+               thumbpath_record = (mp_thumbnailpath_record_t *)malloc(sizeof(mp_thumbnailpath_record_t) * invalid_count);
+               if (thumbpath_record == NULL) {
+                       audio_svc_debug("fail to memory allocation");
+                       return AUDIO_SVC_ERROR_OUT_OF_MEMORY;
+               }
+               memset(thumbpath_record, 0, sizeof(mp_thumbnailpath_record_t) * invalid_count);
+
+               ret = __audio_svc_get_invalid_records_with_thumbnail(storage_type, invalid_count, thumbpath_record);
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       audio_svc_error("error when get thumbnail record");
+                       SAFE_FREE(thumbpath_record);
+                       return ret;
+               }
+       } else {
+               audio_svc_debug("There is no item with thumbnail");
+       }
+
+       char *sql = sqlite3_mprintf("delete from %s where valid = 0 and storage_type=%d", AUDIO_SVC_DB_TABLE_AUDIO, storage_type);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("To delete invalid items is failed(%d)", err);
+               SAFE_FREE(thumbpath_record);
+
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+#if 0
+       for (idx = 0; idx < invalid_count; idx++) {
+               if (strlen(thumbpath_record[idx].thumbnail_path) > 0) {
+                       ret =
+                           _audio_svc_check_and_remove_thumbnail
+                           (thumbpath_record[idx].thumbnail_path);
+                       if (ret != AUDIO_SVC_ERROR_NONE) {
+                               audio_svc_error
+                                   ("error _audio_svc_check_and_remove_thumbnail");
+                               SAFE_FREE(thumbpath_record);
+                               return ret;
+                       }
+               }
+       }
+
+       SAFE_FREE(thumbpath_record);
+#endif
+       for (idx = 0; idx < invalid_count; idx++) {
+               if (strlen(thumbpath_record[idx].thumbnail_path) > 0) {
+                       if (_audio_svc_remove_file(thumbpath_record[idx].thumbnail_path) == FALSE) {
+                               audio_svc_error("fail to remove thumbnail file.");
+                               SAFE_FREE(thumbpath_record);
+                               return AUDIO_SVC_ERROR_INTERNAL;
+                       }
+               }
+       }
+       SAFE_FREE(thumbpath_record);
+       
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_valid_in_music_record(const char *path, int valid)
+{
+       int err = -1;
+
+       char *sql = sqlite3_mprintf("update %s set valid=%d where path= '%q'",
+                                   AUDIO_SVC_DB_TABLE_AUDIO, valid, path);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("To update item as valid is failed(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+       return AUDIO_SVC_ERROR_NONE;
+
+}
+
+int _audio_svc_update_valid_in_music_record_query_add(const char *path, int valid)
+{
+       char *sql = sqlite3_mprintf("update %s set valid=%d where path= '%q'",
+                                   AUDIO_SVC_DB_TABLE_AUDIO, valid, path);
+
+       audio_svc_debug("SQL = [%s]", sql);
+       
+       _audio_svc_sql_query_add(&g_audio_svc_item_valid_query_list, &sql);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_move_item_query_add(const char *src_path, const char *path, audio_svc_storage_type_e storage_type, const char *folder_id)
+{
+       char *sql = NULL;
+       sql = sqlite3_mprintf("update %s set path='%q', storage_type=%d where valid=1 and path='%q'",
+                                       AUDIO_SVC_DB_TABLE_AUDIO, path, storage_type, src_path);
+
+       audio_svc_debug("SQL = [%s]", sql);
+       _audio_svc_sql_query_add(&g_audio_svc_move_item_query_list, &sql);
+
+       sql = sqlite3_mprintf("update %s set folder_id='%q' where path='%q'",
+                                       AUDIO_SVC_DB_TABLE_AUDIO, folder_id, path);
+
+       audio_svc_debug("SQL = [%s]", sql);
+       _audio_svc_sql_query_add(&g_audio_svc_move_item_query_list, &sql);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+//call this API after beginning transaction. this API do sqlite_exec for the g_audio_svc_sqli_query_list.
+int _audio_svc_list_query_do(audio_svc_query_type_e query_type)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       
+       ret = _audio_svc_sql_begin_trans();
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       if (query_type == AUDIO_SVC_QUERY_SET_ITEM_VALID)
+               ret = _audio_svc_sql_query_list(&g_audio_svc_item_valid_query_list);
+       else if (query_type == AUDIO_SVC_QUERY_MOVE_ITEM)
+               ret = _audio_svc_sql_query_list(&g_audio_svc_move_item_query_list);
+       else if (query_type == AUDIO_SVC_QUERY_INSERT_ITEM)
+               ret = _audio_svc_sql_query_list(&g_audio_svc_insert_item_query_list);
+       else
+               ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error("_audio_svc_list_query_do failed. start rollback");
+               _audio_svc_sql_rollback_trans();
+               return ret;
+       }
+
+       ret = _audio_svc_sql_end_trans();
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+               _audio_svc_sql_rollback_trans();
+               return ret;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_get_path(const char *audio_id, char *path)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       char *sql =
+           sqlite3_mprintf
+           ("select path from %s where audio_id='%q' and valid=1 and category=%d",
+            AUDIO_SVC_DB_TABLE_AUDIO, audio_id, AUDIO_SVC_CATEGORY_MUSIC);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error("error when _audio_svc_get_path. ret = [%d]",
+                               ret);
+               return ret;
+       }
+
+       _strncpy_safe(path, (const char *)sqlite3_column_text(sql_stmt, 0),
+                     AUDIO_SVC_PATHNAME_SIZE);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+
+}
+
+int _audio_svc_get_and_append_folder_id_by_path(const char *path, audio_svc_storage_type_e storage_type, char *folder_id)
+{
+       char *path_name = NULL;
+       int ret = AUDIO_SVC_ERROR_NONE;
+       
+       path_name = g_path_get_dirname(path);
+
+       ret = _audio_svc_get_folder_id_by_foldername(path_name, folder_id);
+
+       if(ret == AUDIO_SVC_ERROR_DB_NO_RECORD) {
+               char *folder_name = NULL;
+               int folder_modified_date = 0;
+               char *folder_uuid = _media_info_generate_uuid();
+               if(folder_uuid == NULL ) {
+                       audio_svc_error("Invalid UUID");
+                       SAFE_FREE(path_name);
+                       return AUDIO_SVC_ERROR_INTERNAL;
+               }
+               
+               folder_name = g_path_get_basename(path_name);
+               folder_modified_date = _audio_svc_get_file_dir_modified_date(path_name);
+
+               ret = _audio_svc_append_audio_folder(storage_type, folder_uuid, path_name, folder_name, folder_modified_date);
+               SAFE_FREE(folder_name);
+               _strncpy_safe(folder_id, folder_uuid, AUDIO_SVC_UUID_SIZE+1);
+       }
+
+       SAFE_FREE(path_name);
+
+       return ret;
+}
+int _audio_svc_get_folder_id_by_foldername(const char *folder_name, char *folder_id)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       char *sql = sqlite3_mprintf("SELECT _id FROM %s WHERE path = '%q';", AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, folder_name);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               if(ret == AUDIO_SVC_ERROR_DB_NO_RECORD) {
+                       audio_svc_debug("there is no folder.");
+               }       
+               else {
+                       audio_svc_error("error when _audio_svc_get_folder_id_by_foldername. err = [%d]", ret);
+               }
+               return ret;
+       }
+
+       _strncpy_safe(folder_id, (const char *)sqlite3_column_text(sql_stmt, 0), AUDIO_SVC_UUID_SIZE+1);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return ret;
+}
+
+int _audio_svc_append_audio_folder(audio_svc_storage_type_e storage_type,
+                                   const char *folder_id, const char *path_name, const char *folder_name, int modified_date)
+{
+       int err = -1;
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               audio_svc_debug("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       char *sql = sqlite3_mprintf("insert into %s (_id, path, folder_name, storage_type, modified_date) values ('%q', '%q', '%q', '%d', '%d'); ",
+                                            AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, folder_id, path_name, folder_name, storage_type, modified_date);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("failed to insert albums");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+/* handle by one items. */
+int _audio_svc_check_and_update_folder_table(const char *path_name)
+{
+       int err = -1;
+       char folder_id[AUDIO_SVC_UUID_SIZE+1] = {0,};
+       char *folder_path_name = NULL;
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       folder_path_name = g_path_get_dirname(path_name);
+       if (folder_path_name == NULL) {
+               audio_svc_error("error when get path name");
+               return AUDIO_SVC_ERROR_INTERNAL;
+       }
+
+       ret = _audio_svc_get_folder_id_by_foldername(folder_path_name, folder_id);
+       SAFE_FREE(folder_path_name);
+
+       if(ret == AUDIO_SVC_ERROR_DB_NO_RECORD) {
+               audio_svc_error("error when _audio_svc_get_folder_id_by_foldername ");
+               return AUDIO_SVC_ERROR_DB_NO_RECORD;
+       }
+
+       char *sql =
+           sqlite3_mprintf
+           ("delete from %s where _id='%q' and ((SELECT count(*) FROM %s WHERE folder_id='%q')=0);",
+            AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, folder_id,
+            AUDIO_SVC_DB_TABLE_AUDIO, folder_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("failed to delete audio_folder item");
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+/* batch processing */
+int _audio_svc_update_folder_table(void)
+{
+       int err = -1;
+       char *sql = NULL;
+
+       sql =
+           sqlite3_mprintf
+           ("delete from %s where _id IN (select _id FROM %s where _id NOT IN (select folder_id from %s))",
+            AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, AUDIO_SVC_DB_TABLE_AUDIO_FOLDER,
+            AUDIO_SVC_DB_TABLE_AUDIO);
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("failed to delete audio_folder item");
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_check_and_update_albums_table(const char *album)
+{
+       int err = -1;
+       char *sql = NULL;
+       
+       /* batch processing */
+       if(!STRING_VALID(album)) {
+               sql = sqlite3_mprintf("delete from %s where album_id NOT IN (SELECT album_id FROM %s);",
+                            AUDIO_SVC_DB_TABLE_ALBUMS, AUDIO_SVC_DB_TABLE_AUDIO);
+               err = _audio_svc_sql_query(sql);
+               sqlite3_free(sql);
+               if (err != SQLITE_OK) {
+                       audio_svc_error("failed to update albums table");
+                       if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                               return err;
+                       }
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+       } else {
+               sql = sqlite3_mprintf("delete from %s where album='%q' and ((SELECT count(*) FROM %s WHERE album='%q')=0);",
+                    AUDIO_SVC_DB_TABLE_ALBUMS, album, AUDIO_SVC_DB_TABLE_AUDIO, album);
+               err = _audio_svc_sql_query(sql);
+               sqlite3_free(sql);
+               if (err != SQLITE_OK) {
+                       audio_svc_error("failed to update albums table");
+                       if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                               return err;
+                       }
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_get_thumbnail_path_by_path(const char *path, char *thumb_path)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+       /* hjkim, 110211, remove category condition for the sound files */
+       char *sql =
+           sqlite3_mprintf
+           ("select thumbnail_path from %s where valid=1 and path='%q' ",
+            AUDIO_SVC_DB_TABLE_AUDIO, path);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error
+                   ("error when _audio_svc_get_thumbnail_path_by_path. ret=[%d]",
+                    ret);
+               return ret;
+       }
+
+       _strncpy_safe(thumb_path,
+                     (const char *)sqlite3_column_text(sql_stmt, 0),
+                     AUDIO_SVC_PATHNAME_SIZE);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+char *_audio_svc_get_thumbnail_path_by_album_id(int album_id)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+       char thumbnail_path[AUDIO_SVC_PATHNAME_SIZE] = { 0, };
+
+       char *sql =
+           sqlite3_mprintf("select _data from %s where album_id=%d",
+                           AUDIO_SVC_DB_TABLE_ALBUM_ART, album_id);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error
+                   ("error when __audio_svc_get_genre_id. err = [%d]", ret);
+               return NULL;
+       }
+
+       _strncpy_safe(thumbnail_path,
+                     (const char *)sqlite3_column_text(sql_stmt, 0),
+                     sizeof(thumbnail_path));
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return g_strdup(thumbnail_path);
+}
+
+int _audio_svc_check_and_remove_thumbnail(const char *thumbnail_path)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int count = -1;
+       sqlite3_stmt *sql_stmt = NULL;
+       char *sql =
+           sqlite3_mprintf("select count(*) from %s where thumbnail_path='%q'",
+                           AUDIO_SVC_DB_TABLE_AUDIO, thumbnail_path);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error
+                   ("error when _audio_svc_check_and_remove_thumbnail. err = [%d]",
+                    ret);
+               return ret;
+       }
+
+       count = sqlite3_column_int(sql_stmt, 0);
+       SQLITE3_FINALIZE(sql_stmt);
+
+       if (count < 1) {
+               if (_audio_svc_remove_file(thumbnail_path) == FALSE) {
+                       audio_svc_error("fail to remove thumbnail file.");
+                       return AUDIO_SVC_ERROR_INTERNAL;
+               }
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_list_search(audio_svc_audio_item_s *item,
+                                                       char *where_query,
+                                                       audio_svc_search_order_e order_field,
+                                                       int offset,
+                                                       int count
+                                                       )
+{
+       int len = 0;
+       int err = -1;
+       char query[AUDIO_SVC_QUERY_SIZE] = { 0 };
+       char condition_str[AUDIO_SVC_QUERY_SIZE] = { 0 };
+       char order_str[AUDIO_SVC_QUERY_SIZE] = { 0 };
+
+       sqlite3_stmt *sql_stmt = NULL;
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               audio_svc_debug("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       snprintf(query, sizeof(query), "SELECT * FROM audio_media WHERE %s", where_query);
+
+       audio_svc_debug("");
+       if (_audio_svc_get_order_field_str(order_field, order_str, 
+                       AUDIO_SVC_QUERY_SIZE) < 0) {
+               audio_svc_error("_audio_svc_get_order_field_str failure");
+               return AUDIO_SVC_ERROR_INTERNAL;
+       }
+       audio_svc_debug("");
+
+       snprintf(condition_str, sizeof(condition_str), " ORDER BY %s ", order_str);
+       len = g_strlcat(query, condition_str, sizeof(query));
+
+       if (len >= sizeof(query)) {
+               audio_svc_error("strlcat returns failure ( %d )", len);
+               return AUDIO_SVC_ERROR_INTERNAL;
+       }
+
+       memset(condition_str, 0x00, sizeof(condition_str));
+
+       snprintf(condition_str, sizeof(condition_str), " LIMIT %d,%d ", offset, count);
+       len = g_strlcat(query, condition_str, sizeof(query));
+
+       if (len >= sizeof(query)) {
+               audio_svc_error("strlcat returns failure ( %d )", len);
+               return AUDIO_SVC_ERROR_INTERNAL;
+       }
+
+       audio_svc_debug("Query : %s", query);
+
+       err = sqlite3_prepare_v2(handle, query, -1, &sql_stmt, NULL);
+       if (err != SQLITE_OK) {
+               audio_svc_error("prepare error [%s]", sqlite3_errmsg(handle));
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
+               __audio_svc_get_next_record(item, sql_stmt);
+               item++;
+       }
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
diff --git a/src/audio/audio-svc-playlist-table.c b/src/audio/audio-svc-playlist-table.c
new file mode 100755 (executable)
index 0000000..73d13a7
--- /dev/null
@@ -0,0 +1,987 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file defines structure and functions related to database for managing playlists.
+ *
+ * @file               audio-svc-playlist-table.c
+ * @version    0.1
+ */
+
+#include <glib.h>
+#include "media-info-util.h"
+#include "audio-svc-error.h"
+#include "audio-svc-playlist-table.h"
+#include "audio-svc-debug.h"
+#include "audio-svc-types-priv.h"
+#include "audio-svc-utils.h"
+#include "audio-svc-db-utils.h"
+
+#define AUDIO_SVC_ORDER_BY_PLAYLIST_NAME               "ORDER BY name COLLATE NOCASE"
+
+static int __audio_svc_create_playlist_db_table(void);
+static int __audio_svc_create_playlist_item_db_table(void);
+static int __audio_svc_delete_playlist_item_records_by_playlist_id(int
+                                                                  playlist_id);
+
+static int __audio_svc_create_playlist_db_table(void)
+{
+       int err = -1;
+
+       /* hjkim, 110125, make name to unique */
+       char *sql = sqlite3_mprintf("create table if not exists %s (\
+                       _id                             INTEGER PRIMARY KEY, \
+                       name                    TEXT NOT NULL UNIQUE\
+                       );", AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to create playlist table (%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+/* when memory card is removed, the items in the memory card is displayed in grey out when selecting playlist item view.
+  If same memory card is inserted again, they are handled as same as other phone items in the playlist view. */
+static int __audio_svc_create_playlist_item_db_table(void)
+{
+       int err = -1;
+       char *sql = NULL;
+
+       sql = sqlite3_mprintf("create table if not exists %s (\
+                       _id                     INTEGER primary key autoincrement, \
+                       playlist_id     INTEGER NOT NULL,\
+                       audio_id                TEXT NOT NULL,\
+                       play_order      INTEGER NOT NULL\
+                       );", AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP);
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to create playlist item table (%d)",
+                               err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+       /* hjkim, 111020, add trigger to remove item from audio_playlists_map when item remove */
+       sql =
+           sqlite3_mprintf
+           ("CREATE TRIGGER IF NOT EXISTS audio_playlists_map_cleanup_1 DELETE ON %s BEGIN DELETE FROM %s WHERE audio_id = old.audio_id;END;",
+            AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("error while create TRIGGER albumart_cleanup1");
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+/* when deleting a playlist, all items included in the playlist should be removed together */
+static int __audio_svc_delete_playlist_item_records_by_playlist_id(int
+                                                                  playlist_id)
+{
+       int err = -1;
+       char *sql = sqlite3_mprintf("delete from %s where playlist_id = %d",
+                                   AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP,
+                                   playlist_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to delete items by playlist index");
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_create_playlist_table(void)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       ret = __audio_svc_create_playlist_db_table();
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       ret = __audio_svc_create_playlist_item_db_table();
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_truncate_playlist_table(void)
+{
+       int err = -1;
+       char *sql = sqlite3_mprintf("delete from %s",
+                                   AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_debug("It failed to truncate playlist table", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       sql =
+           sqlite3_mprintf("delete from %s",
+                           AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to truncate playlist item table",
+                               err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_insert_playlist_record(const char *playlist_name,
+                                     int *playlist_id)
+{
+       int err = -1;
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int plist_idx = 0;
+       char *sql = NULL;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       /* get the max play_order */
+       sql =
+           sqlite3_mprintf("select max(_id) from %s",
+                           AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error
+                   ("error when _audio_svc_insert_playlist_record. ret = [%d]",
+                    ret);
+               return ret;
+       }
+
+       plist_idx = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       ++plist_idx;
+
+       sql =
+           sqlite3_mprintf("insert into %s (_id, name) values (%d, '%q')",
+                           AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS, plist_idx,
+                           playlist_name);
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to insert playlist(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       *playlist_id = plist_idx;
+       audio_svc_debug("new playlist id is [%d]", *playlist_id);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_delete_playlist_record(int playlist_id)
+{
+       int err = -1;
+       char *sql = sqlite3_mprintf("delete from %s where _id=%d",
+                                   AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS,
+                                   playlist_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to delete playlist(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return
+           __audio_svc_delete_playlist_item_records_by_playlist_id
+           (playlist_id);
+
+}
+
+int _audio_svc_update_playlist_record_by_name(int playlist_id,
+                                             const char *new_playlist_name)
+{
+       int err = -1;
+       char *sql = sqlite3_mprintf("update %s set name='%q' where _id=%d",
+                                   AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS,
+                                   new_playlist_name, playlist_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to update playlist name(%d)", err);
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_count_playlist_records(const char *filter_string,
+                                     const char *filter_string2, int *count)
+{
+       int err = -1;
+       char query[AUDIO_SVC_QUERY_SIZE] = { 0 };
+       bool filter_mode = FALSE;
+       bool filter_mode2 = FALSE;
+
+       sqlite3_stmt *sql_stmt = NULL;
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               audio_svc_debug("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       const char *filter_1 = " where name like ?";
+       const char *filter_2 = " and name like ?";
+       if (filter_string) {
+               if (strlen(filter_string) > 0) {
+                       filter_mode = TRUE;
+               }
+       }
+       if (filter_string2) {
+               if (strlen(filter_string2) > 0) {
+                       filter_mode2 = TRUE;
+               }
+       }
+
+       snprintf(query, sizeof(query), "select count(*) from %s",
+                AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS);
+
+       if (filter_mode) {
+               g_strlcat(query, filter_1, sizeof(query));
+       }
+       if (filter_mode2) {
+               if (filter_mode) {
+                       g_strlcat(query, filter_2, sizeof(query));
+               } else {
+                       g_strlcat(query, filter_1, sizeof(query));
+               }
+       };
+
+       err = sqlite3_prepare_v2(handle, query, -1, &sql_stmt, NULL);
+       if (SQLITE_OK != err) {
+               audio_svc_error("prepare error [%s]", sqlite3_errmsg(handle));
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (filter_mode) {
+               char filter_query[AUDIO_SVC_METADATA_LEN_MAX + 5] = { 0 };
+               snprintf(filter_query, sizeof(filter_query), "%s%%",
+                        filter_string);
+
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, 1, (char *)filter_query,
+                                      strlen(filter_query), NULL))) {
+                       audio_svc_error
+                           ("filter_query(%s) binding is failed (%d)",
+                            filter_query, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+       }
+
+       if (filter_mode2) {
+               char filter_query2[AUDIO_SVC_METADATA_LEN_MAX + 5] = { 0 };
+               snprintf(filter_query2, sizeof(filter_query2), "%s%%",
+                        filter_string2);
+
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, 1, (char *)filter_query2,
+                                      strlen(filter_query2), NULL))) {
+                       audio_svc_error
+                           ("filter_query(%s) binding is failed (%d)",
+                            filter_query2, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+       }
+
+       audio_svc_debug("[SQL query] : %s", query);
+
+       err = sqlite3_step(sql_stmt);
+       if (err != SQLITE_ROW) {
+               audio_svc_error("end of row [%s]", sqlite3_errmsg(handle));
+               SQLITE3_FINALIZE(sql_stmt);
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       *count = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_get_playlist_records(int offset, int rows,
+                                   const char *filter_string,
+                                   const char *filter_string2,
+                                   audio_svc_playlist_s *playlists)
+{
+       int err = -1;
+       char query[AUDIO_SVC_QUERY_SIZE] = { 0 };
+       char tail_query[70] = { 0 };
+       bool filter_mode = FALSE;
+       bool filter_mode2 = FALSE;
+       const char *filter_1 = " where name like ?";
+       const char *filter_2 = " and name like ?";
+       int idx = 0;
+       int idx_1 = 0;
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       sqlite3_stmt *sql_stmt = NULL;
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               audio_svc_debug("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (filter_string) {
+               if (strlen(filter_string) > 0) {
+                       filter_mode = TRUE;
+               }
+       }
+       if (filter_string2) {
+               if (strlen(filter_string2) > 0) {
+                       filter_mode2 = TRUE;
+               }
+       }
+
+       snprintf(query, sizeof(query), "select _id, name from %s",
+                AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS);
+
+       if (filter_mode) {
+               g_strlcat(query, filter_1, sizeof(query));
+       }
+       if (filter_mode2) {
+               if (filter_mode) {
+                       g_strlcat(query, filter_2, sizeof(query));
+               } else {
+                       g_strlcat(query, filter_1, sizeof(query));
+               }
+       }
+       snprintf(tail_query, sizeof(tail_query), " %s limit %d,%d", AUDIO_SVC_ORDER_BY_PLAYLIST_NAME, offset, rows);
+       g_strlcat(query, tail_query, sizeof(query));
+
+       audio_svc_debug("[SQL query] : %s", query);
+       err = sqlite3_prepare_v2(handle, query, -1, &sql_stmt, NULL);
+       if (SQLITE_OK != err) {
+               audio_svc_error("prepare error [%s]", sqlite3_errmsg(handle));
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (filter_mode) {
+               char filter_query[AUDIO_SVC_METADATA_LEN_MAX + 5] = "";
+               snprintf(filter_query, sizeof(filter_query), "%s%%",
+                        filter_string);
+
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, 1, (char *)filter_query,
+                                      strlen(filter_query), NULL))) {
+                       audio_svc_error
+                           ("filter_query(%s) binding is failed (%d)",
+                            filter_query, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+       }
+       if (filter_mode2) {
+               char filter_query2[AUDIO_SVC_METADATA_LEN_MAX + 5] = "";
+               snprintf(filter_query2, sizeof(filter_query2), "%s%%",
+                        filter_string2);
+
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, 2, (char *)filter_query2,
+                                      strlen(filter_query2), NULL))) {
+                       audio_svc_error
+                           ("filter_query(%s) binding is failed (%d)",
+                            filter_query2, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+       }
+
+       while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
+               playlists[idx].playlist_id = sqlite3_column_int(sql_stmt, 0);
+               _strncpy_safe(playlists[idx].name,
+                             (const char *)sqlite3_column_text(sql_stmt, 1),
+                             sizeof(playlists[idx].name));
+               idx++;
+       }
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       /* hjkim, 110303, add query to get thumbnail_path of playlists */
+       for (idx_1 = 0; idx_1 < idx; idx_1++) {
+               char *sql =
+                   sqlite3_mprintf
+                   ("select thumbnail_path from %s where audio_id= \
+                       (select audio_id from %s where playlist_id=%d and \
+                       play_order=(select min(a.play_order) from %s a, %s b where a.playlist_id=%d and b.audio_id=a.audio_id and b.valid=1 and b.category=%d))",
+                    AUDIO_SVC_DB_TABLE_AUDIO,
+                    AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP,
+                    playlists[idx_1].playlist_id,
+                    AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP,
+                    AUDIO_SVC_DB_TABLE_AUDIO, playlists[idx_1].playlist_id,
+                    AUDIO_SVC_CATEGORY_MUSIC);
+
+               ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+               if (ret == AUDIO_SVC_ERROR_DB_NO_RECORD) {
+                       audio_svc_debug("No item in playlist");
+                       continue;
+               }
+
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       audio_svc_error
+                           ("error when _audio_svc_get_playlist_records. ret = [%d]",
+                            ret);
+                       return ret;
+               }
+               _strncpy_safe(playlists[idx_1].thumbnail_path, (const char *)sqlite3_column_text(sql_stmt, 0), sizeof(playlists[idx_1].thumbnail_path));
+               
+               SQLITE3_FINALIZE(sql_stmt);
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_count_playlist_item_records(int playlist_id,
+                                          const char *filter_string,
+                                          const char *filter_string2,
+                                          int *count)
+{
+       int err = -1;
+       char query[AUDIO_SVC_QUERY_SIZE] = { 0 };
+       char filter_query[AUDIO_SVC_METADATA_LEN_MAX + 5] = { 0 };
+       char filter_query2[AUDIO_SVC_METADATA_LEN_MAX + 5] = { 0 };
+       bool filter_mode = FALSE;
+       bool filter_mode2 = FALSE;
+       int text_bind = 1;
+
+       sqlite3_stmt *sql_stmt = NULL;
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               audio_svc_debug("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (filter_string) {
+               if (strlen(filter_string) > 0) {
+                       snprintf(filter_query, sizeof(filter_query), "%%%s%%",
+                                filter_string);
+                       filter_mode = TRUE;
+               }
+       }
+       if (filter_string2) {
+               if (strlen(filter_string2) > 0) {
+                       snprintf(filter_query2, sizeof(filter_query2), "%%%s%%",
+                                filter_string2);
+                       filter_mode2 = TRUE;
+               }
+       }
+
+       snprintf(query, sizeof(query),
+                "select count(*) from %s a, %s b where a.playlist_id=%d and b.audio_id=a.audio_id and b.valid=1 and b.category=%d",
+                AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP,
+                AUDIO_SVC_DB_TABLE_AUDIO, playlist_id,
+                AUDIO_SVC_CATEGORY_MUSIC);
+
+       if (filter_mode) {
+               g_strlcat(query, " and b.title like ?", sizeof(query));
+       }
+       if (filter_mode2) {
+               g_strlcat(query, " and b.title like ?", sizeof(query));
+       }
+
+       err = sqlite3_prepare_v2(handle, query, -1, &sql_stmt, NULL);
+       if (err != SQLITE_OK) {
+               audio_svc_error("prepare error [%s]", sqlite3_errmsg(handle));
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (filter_mode) {
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, text_bind,
+                                      (char *)filter_query,
+                                      strlen(filter_query), NULL))) {
+                       audio_svc_error
+                           ("filter_query(%s) binding is failed (%d)",
+                            filter_query, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+               text_bind++;
+       }
+       if (filter_mode2) {
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, text_bind,
+                                      (char *)filter_query2,
+                                      strlen(filter_query2), NULL))) {
+                       audio_svc_error
+                           ("filter_query(%s) binding is failed (%d)",
+                            filter_query2, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+               text_bind++;
+       }
+
+       audio_svc_debug("[SQL query] : %s", query);
+
+       err = sqlite3_step(sql_stmt);
+       if (err != SQLITE_ROW) {
+               audio_svc_error("end of row [%s]", sqlite3_errmsg(handle));
+               SQLITE3_FINALIZE(sql_stmt);
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+       *count = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_get_playlist_item_records(int playlist_id,
+                                        const char *filter_string,
+                                        const char *filter_string2, int offset,
+                                        int rows,
+                                        audio_svc_playlist_item_s *track)
+{
+       char query[AUDIO_SVC_QUERY_SIZE] = { 0 };
+
+       char tail_query[70] = { 0 };
+       char filter_query[AUDIO_SVC_METADATA_LEN_MAX + 5] = { 0 };
+       char filter_query2[AUDIO_SVC_METADATA_LEN_MAX + 5] = { 0 };
+       bool filter_mode = FALSE;
+       bool filter_mode2 = FALSE;
+       int err = -1;
+       int len = -1;
+       int text_bind = 1;
+       int idx = 0;
+
+       sqlite3_stmt *sql_stmt = NULL;
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               audio_svc_debug("handle is NULL");
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       filter_mode = STRING_VALID(filter_string);
+       filter_mode2 = STRING_VALID(filter_string2);
+
+       if (filter_mode) {
+               snprintf(filter_query, sizeof(filter_query), "%%%s%%",
+                        filter_string);
+       }
+       if (filter_mode2) {
+               snprintf(filter_query2, sizeof(filter_query2), "%%%s%%",
+                        filter_string2);
+       }
+
+       char *result_field_for_playlist =
+           "a._id, b.audio_id, b.path, b.thumbnail_path, b.title, b.artist, b.duration, b.rating, a.play_order";
+       len =
+           snprintf(query, sizeof(query),
+                    "select %s from %s a, %s b where a.playlist_id=%d and b.audio_id=a.audio_id and b.valid=1 and b.category=%d ",
+                    result_field_for_playlist,
+                    AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP,
+                    AUDIO_SVC_DB_TABLE_AUDIO, playlist_id,
+                    AUDIO_SVC_CATEGORY_MUSIC);
+
+       if (len < 1 || len >= sizeof(query)) {
+               audio_svc_error("snprintf error occured or truncated");
+               return AUDIO_SVC_ERROR_INTERNAL;
+       } else {
+               query[len] = '\0';
+       }
+
+       if (filter_mode) {
+               snprintf(tail_query, sizeof(tail_query), " and b.title like ?");
+               g_strlcat(query, tail_query, sizeof(query));
+       }
+       if (filter_mode2) {
+               snprintf(tail_query, sizeof(tail_query), " and b.title like ?");
+               g_strlcat(query, tail_query, sizeof(query));
+       }
+       snprintf(tail_query, sizeof(tail_query),
+                "  order by a.play_order limit %d,%d", offset, rows);
+
+       g_strlcat(query, tail_query, sizeof(query));
+
+       audio_svc_debug("[SQL query] : %s", query);
+
+       err = sqlite3_prepare_v2(handle, query, -1, &sql_stmt, NULL);
+       if (err != SQLITE_OK) {
+               audio_svc_error("prepare error [%s]", sqlite3_errmsg(handle));
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (filter_mode) {
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, text_bind,
+                                      (char *)filter_query,
+                                      strlen(filter_query), NULL))) {
+                       audio_svc_error
+                           ("filter_query(%s) binding is failed (%d)",
+                            filter_query, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+               text_bind++;
+       }
+       if (filter_mode2) {
+               if (SQLITE_OK !=
+                   (err =
+                    sqlite3_bind_text(sql_stmt, text_bind,
+                                      (char *)filter_query2,
+                                      strlen(filter_query2), NULL))) {
+                       audio_svc_error
+                           ("filter_query(%s) binding is failed (%d)",
+                            filter_query2, err);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return AUDIO_SVC_ERROR_DB_INTERNAL;
+               }
+               text_bind++;
+       }
+
+       while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
+               track[idx].u_id =
+                   sqlite3_column_int(sql_stmt, AUDIO_SVC_PLAYLIST_ITEM_UID);
+               _strncpy_safe(track[idx].audio_id,
+                             (const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_PLAYLIST_ITEM_AUDIO_ID), sizeof(track[idx].audio_id));
+               _strncpy_safe(track[idx].pathname,
+                             (const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_PLAYLIST_ITEM_PATHNAME), sizeof(track[idx].pathname));
+               _strncpy_safe(track[idx].thumbnail_path,
+                             (const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_PLAYLIST_ITEM_THUMBNAIL_PATH), sizeof(track[idx].thumbnail_path));
+               _strncpy_safe(track[idx].title,
+                             (const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_PLAYLIST_ITEM_TITLE), sizeof(track[idx].title));
+               _strncpy_safe(track[idx].artist,
+                             (const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_PLAYLIST_ITEM_ARTIST), sizeof(track[idx].artist));
+               track[idx].duration = sqlite3_column_int(sql_stmt, AUDIO_SVC_PLAYLIST_ITEM_DURATION);
+               track[idx].rating = sqlite3_column_int(sql_stmt, AUDIO_SVC_PLAYLIST_ITEM_RATING);
+               track[idx].play_order = sqlite3_column_int(sql_stmt, AUDIO_SVC_PLAYLIST_ITEM_PLAY_ORDER);
+               
+               audio_svc_debug("u_id = %d, audio_id = %s, title = %s, pathname = %s, duration = %d, play_order = %d",
+                    track[idx].u_id, track[idx].audio_id, track[idx].title, track[idx].pathname, track[idx].duration, track[idx].play_order);
+
+               idx++;
+       }
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_count_playlist_records_by_name(const char *playlist_name,
+                                             int *count)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+       char *sql = sqlite3_mprintf("select count(*) from %s where name='%q'",
+                                   AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS,
+                                   playlist_name);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error
+                   ("error when _audio_svc_count_playlist_records_by_name. ret = [%d]",
+                    ret);
+               return ret;
+       }
+
+       *count = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_get_playlist_id_by_name(const char *playlist_name,
+                                      int *playlist_id)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       char *sql = sqlite3_mprintf("select _id from %s where name='%q'",
+                                   AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS,
+                                   playlist_name);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error
+                   ("error when _audio_svc_get_playlist_id_by_name. ret = [%d]",
+                    ret);
+               return ret;
+       }
+
+       *playlist_id = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_get_audio_id_by_uid(int uid, char *audio_id)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       char *sql = sqlite3_mprintf("select audio_id from %s where _id=%d",
+                                   AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP, uid);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error("error when _audio_svc_get_audio_id_by_uid. ret = [%d]", ret);
+               return ret;
+       }
+
+       _strncpy_safe(audio_id, (const char *)sqlite3_column_text(sql_stmt, 0), AUDIO_SVC_UUID_SIZE+1);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_get_playlist_name_by_playlist_id(int playlist_id,
+                                               char *playlist_name)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       char *sql = sqlite3_mprintf("select name from %s where _id =%d",
+                                   AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS,
+                                   playlist_id);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error
+                   ("error when _audio_svc_get_playlist_name_by_playlist_id. ret = [%d]",
+                    ret);
+               return ret;
+       }
+
+       _strncpy_safe(playlist_name,
+                     (const char *)sqlite3_column_text(sql_stmt, 0),
+                     AUDIO_SVC_PLAYLIST_NAME_SIZE);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_insert_playlist_item_record(int playlist_id, const char *audio_id)
+{
+       int err = -1;
+       int ret = AUDIO_SVC_ERROR_NONE;
+       char *sql = NULL;
+       int play_order = 0;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       /* get the max play_order */
+       sql =
+           sqlite3_mprintf
+           ("select max(play_order) from %s where playlist_id = %d",
+            AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP, playlist_id);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error
+                   ("error when _audio_svc_insert_playlist_item_record. ret = [%d]",
+                    ret);
+               return ret;
+       }
+
+       play_order = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       ++play_order;
+
+       /* insert the new record */
+       sql = sqlite3_mprintf("insert into %s ( playlist_id, audio_id, play_order) values (%d, '%q', %d)",
+            AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP, playlist_id, audio_id, play_order);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error(" It failed to insert item to playlist");
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_check_duplication_records_in_playlist(int playlist_id,
+                                                    const char *audio_id, int *count)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+       char *sql =
+           sqlite3_mprintf
+           ("select count(*) from %s where playlist_id=%d and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP, playlist_id, audio_id);
+
+       ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               audio_svc_error
+                   ("error when _audio_svc_check_duplication_records_in_playlist. ret = [%d]",
+                    ret);
+               return ret;
+       }
+
+       *count = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_delete_playlist_item_record_from_playlist_by_audio_id(int playlist_id, const char *audio_id)
+{
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf
+           ("delete from %s where playlist_id=%d and audio_id='%q'",
+            AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP, playlist_id, audio_id);
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error
+                   ("It failed to remove item from playlist by audio_id");
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_delete_playlist_item_record_from_playlist_by_uid(int playlist_id,
+                                                               int uid)
+{
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf("delete from %s where playlist_id=%d and _id=%d",
+                           AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP, playlist_id,
+                           uid);
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error
+                   ("It failed to remove item from playlist by uid");
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_delete_playlist_item_records_by_audio_id(const char *audio_id)
+{
+       int err = -1;
+       char *sql = sqlite3_mprintf("delete from %s where audio_id='%q'",
+                                   AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP,
+                                   audio_id);
+
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to delete items by audio_id");
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_update_item_play_order(int playlist_id, int uid,
+                                     int new_play_order)
+{
+       int err = -1;
+       char *sql =
+           sqlite3_mprintf
+           ("update %s set play_order=%d where _id=%d and playlist_id = %d",
+            AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP, new_play_order, uid,
+            playlist_id);
+       err = _audio_svc_sql_query(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               audio_svc_error("It failed to update play order");
+               if (err == AUDIO_SVC_ERROR_DB_CONNECT) {
+                       return err;
+               }
+               return AUDIO_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
diff --git a/src/audio/audio-svc-ta.c b/src/audio/audio-svc-ta.c
new file mode 100755 (executable)
index 0000000..2a4d577
--- /dev/null
@@ -0,0 +1,558 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <malloc.h>
+#include <string.h>
+#include <assert.h>
+#include <time.h>
+#include <sys/time.h>
+#include <sys/utsname.h>
+#include <sys/resource.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+#include "audio-svc-ta.h"
+
+/* internal func. */
+static void __free_cps(void);
+static int __get_cp_index(char *name);
+
+static void __free_accums(void);
+static int __get_accum_index(char *name);
+
+/* global var. */
+audio_svc_ta_checkpoint **mm_g_cps = NULL;
+static int mm_g_cp_index = 0;
+
+audio_svc_ta_accum_item **mm_g_accums = NULL;
+static int mm_g_accum_index = 0;
+static int mm_g_accum_longest_name = 0;
+static unsigned long mm_g_accum_first_time = 0xFFFFFFFF;
+static int mm_g_enable = 1;
+
+int audio_svc_ta_init(void)
+{
+       if (mm_g_accums)
+               return 0;
+
+       mm_g_cps =
+           (audio_svc_ta_checkpoint **) malloc(AUDIO_SVC_TA_MAX_CHECKPOINT *
+                                               sizeof(audio_svc_ta_checkpoint
+                                                      *));
+       if (!mm_g_cps)
+               return -1;
+
+       mm_g_accums =
+           (audio_svc_ta_accum_item **) malloc(AUDIO_SVC_TA_MAX_CHECKPOINT *
+                                               sizeof(audio_svc_ta_accum_item
+                                                      *));
+       if (!mm_g_accums)
+               return -1;
+
+       mm_g_accum_first_time = 0xFFFFFFFF;
+
+       return 0;
+}
+
+int audio_svc_ta_release(void)
+{
+       if (!mm_g_accums)
+               return 0;
+
+       __free_cps();
+       __free_accums();
+
+       mm_g_accum_first_time = 0xFFFFFFFF;
+
+       return 0;
+}
+
+void audio_svc_ta_set_enable(int enable)
+{
+       printf("AUDIO_SVC_TA : setting enable to %d\n", enable);
+       mm_g_enable = enable;
+}
+
+int audio_svc_ta_get_numof_checkpoints()
+{
+       return mm_g_cp_index;
+}
+
+char *audio_svc_ta_fmt(const char *fmt, ...)
+{
+       static char ta_buf[512];
+       va_list args;
+
+       memset(ta_buf, '\0', 512);
+
+       va_start(args, fmt);
+       vsnprintf(ta_buf, 512, fmt, args);
+       va_end(args);
+
+       return ta_buf;
+}
+
+int audio_svc_ta_add_checkpoint(char *name, int show, char *filename, int line)
+{
+       audio_svc_ta_checkpoint *cp = NULL;
+       struct timeval t;
+
+       if (!mm_g_enable)
+               return -1;
+
+       if (!mm_g_accums)
+               return 0;
+
+       if (mm_g_cp_index == AUDIO_SVC_TA_MAX_CHECKPOINT)
+               return -1;
+
+       if (!name)
+               return -1;
+
+       if (strlen(name) == 0)
+               return -1;
+
+       cp = (audio_svc_ta_checkpoint *)
+           malloc(sizeof(audio_svc_ta_checkpoint));
+       if (!cp)
+               return -1;
+
+       cp->name = (char *)malloc(strlen(name) + 1);
+       if (!cp->name) {
+               free(cp);
+               return -1;
+       }
+       strcpy(cp->name, name);
+
+       if (show)
+               printf("[CHECK-POINT] %s...(%s:%d)\n", name, filename, line);
+
+       gettimeofday(&t, NULL);
+       cp->timestamp = t.tv_sec * 1000000L + t.tv_usec;
+#ifdef AUDIO_SVC_TA_UNIT_MSEC
+       cp->timestamp = (cp->timestamp >= 1000) ? cp->timestamp / 1000 : 0;
+#endif
+
+       mm_g_cps[mm_g_cp_index] = cp;
+
+       mm_g_cp_index++;
+
+       return 0;
+}
+
+void audio_svc_ta_show_checkpoints(void)
+{
+       int i = 0;
+       if (!mm_g_accums)
+               return;
+
+       printf("BEGIN RESULT ============================\n");
+       for (i = 0; i < mm_g_cp_index; i++) {
+               printf("[%d] %s : %ld us.\n", i, mm_g_cps[i]->name,
+                      mm_g_cps[i]->timestamp);
+       }
+       printf("END RESULT   ============================\n");
+}
+
+void audio_svc_ta_show_diff(char *name1, char *name2)
+{
+       if (!mm_g_accums)
+               return;
+
+       printf("Time takes from [%s] to [%s] : %ld us.\n", name1, name2,
+              audio_svc_ta_get_diff(name1, name2));
+}
+
+unsigned long audio_svc_ta_get_diff(char *name1, char *name2)
+{
+       int cp1, cp2;
+
+       if (!mm_g_accums)
+               return 0;
+
+       /* fail if bad param. */
+       if (!name1 || !name2)
+               return -1;
+
+       /* fail if same. */
+       if (strcmp(name1, name2) == 0)
+               return -1;
+
+       /* get index */
+       if ((cp1 = __get_cp_index(name1)) == -1)
+               return -1;
+
+       if ((cp2 = __get_cp_index(name2)) == -1)
+               return -1;
+
+       /* NOTE : */
+       /* return value must be positive value. */
+       /* bcz the value of higher index of mm_g_cps always higher than lower one. */
+       return mm_g_cps[cp2]->timestamp - mm_g_cps[cp1]->timestamp;
+
+}
+
+static int __get_cp_index(char *name)
+{
+       int i;
+
+       assert(name);
+
+       /* find index */
+       for (i = 0; i < mm_g_cp_index; i++) {
+               if (strcmp(name, mm_g_cps[i]->name) == 0)
+                       return i;
+       }
+
+       return -1;
+}
+
+static int __get_accum_index(char *name)
+{
+       int i;
+
+       assert(name);
+
+       /* find index */
+       for (i = 0; i < mm_g_accum_index; i++) {
+               if (strcmp(name, mm_g_accums[i]->name) == 0)
+                       return i;
+       }
+
+       return -1;
+}
+
+static void __free_cps(void)
+{
+       int i = 0;
+
+       if (!mm_g_cps)
+               return;
+
+       for (i = 0; i < mm_g_cp_index; i++) {
+               if (mm_g_cps[i]) {
+                       if (mm_g_cps[i]->name)
+                               free(mm_g_cps[i]->name);
+
+                       free(mm_g_cps[i]);
+
+                       mm_g_cps[i] = NULL;
+               }
+       }
+
+       free(mm_g_cps);
+       mm_g_cps = NULL;
+
+       mm_g_cp_index = 0;
+}
+
+static void __free_accums(void)
+{
+       int i = 0;
+
+       if (!mm_g_accums)
+               return;
+
+       for (i = 0; i < mm_g_accum_index; i++) {
+               if (mm_g_accums[i]) {
+                       if (mm_g_accums[i]->name)
+                               free(mm_g_accums[i]->name);
+
+                       free(mm_g_accums[i]);
+
+                       mm_g_accums[i] = NULL;
+               }
+       }
+
+       mm_g_accum_index = 0;
+       mm_g_accum_longest_name = 0;
+
+       free(mm_g_accums);
+       mm_g_accums = NULL;
+}
+
+int audio_svc_ta_accum_item_begin(char *name, int show, char *filename,
+                                 int line)
+{
+       audio_svc_ta_accum_item *accum = NULL;
+       int index = 0;
+       int name_len = 0;
+       struct timeval t;
+
+       if (!mm_g_enable)
+               return -1;
+
+       if (!mm_g_accums)
+               return 0;
+
+       if (mm_g_accum_index == AUDIO_SVC_TA_MAX_ACCUM)
+               return -1;
+
+       if (!name)
+               return -1;
+
+       name_len = strlen(name);
+       if (name_len == 0)
+               return -1;
+
+       /* if 'name' is new one. create new item. */
+       if ((index = __get_accum_index(name)) == -1) {
+               accum =
+                   (audio_svc_ta_accum_item *)
+                   malloc(sizeof(audio_svc_ta_accum_item));
+               if (!accum)
+                       return -1;
+
+               /* clear first. */
+               memset(accum, 0, sizeof(audio_svc_ta_accum_item));
+               accum->elapsed_min = 0xFFFFFFFF;
+
+               accum->name = (char *)malloc(name_len + 1);
+               if (!accum->name) {
+                       free(accum);
+                       return -1;
+               }
+               strcpy(accum->name, name);
+
+               /* add it to list. */
+               mm_g_accums[mm_g_accum_index] = accum;
+               mm_g_accum_index++;
+
+               if (mm_g_accum_longest_name < name_len)
+                       mm_g_accum_longest_name = name_len;
+
+       } else {
+               accum = mm_g_accums[index];
+       }
+
+       /* verify pairs of begin, end. */
+       if (accum->on_estimate) {
+               printf("[%s] is not 'end'ed!\n", accum->name);
+               accum->num_unpair++;
+               return -1;
+       }
+       /* get timestamp */
+       gettimeofday(&t, NULL);
+       accum->timestamp = t.tv_sec * 1000000L + t.tv_usec;
+#ifdef AUDIO_SVC_TA_UNIT_MSEC
+       accum->timestamp =
+           (accum->timestamp >= 1000) ? accum->timestamp / 1000 : 0;
+#endif
+       accum->on_estimate = 1;
+
+       if (accum->first_start == 0) {  /* assum that timestamp never could be zero. */
+               accum->first_start = accum->timestamp;
+
+               if (mm_g_accum_first_time > accum->first_start)
+                       mm_g_accum_first_time = accum->first_start;
+       }
+
+       if (show)
+               printf("[ACCUM BEGIN] %s : %ld ---(%s:%d)\n", name,
+                      accum->timestamp, filename, line);
+
+       accum->num_calls++;
+
+       return 0;
+}
+
+int audio_svc_ta_accum_item_end(char *name, int show, char *filename, int line)
+{
+       audio_svc_ta_accum_item *accum = NULL;
+       unsigned int tval = 0;
+       int index = 0;
+       struct timeval t;
+
+       if (!mm_g_enable)
+               return -1;
+
+       if (!mm_g_accums)
+               return 0;
+
+       /* get time first for more accuracy. */
+       gettimeofday(&t, NULL);
+
+       if (mm_g_accum_index == AUDIO_SVC_TA_MAX_ACCUM)
+               return -1;
+
+       if (!name)
+               return -1;
+
+       if (strlen(name) == 0)
+               return -1;
+
+       /* varify the 'name' is already exist. */
+       if ((index = __get_accum_index(name)) == -1) {
+               printf("[%s] is not added before!\n", name);
+               return -1;
+       }
+
+       accum = mm_g_accums[index];
+
+       /* verify pairs of begin, end. */
+       if (!accum->on_estimate) {
+               printf("[%s] is not 'begin' yet!\n", accum->name);
+               accum->num_unpair++;
+               return -1;
+       }
+       /* get current timestamp. */
+       tval = t.tv_sec * 1000000L + t.tv_usec;
+#ifdef AUDIO_SVC_TA_UNIT_MSEC
+       tval = (tval >= 1000) ? tval / 1000 : 0;
+#endif
+
+       /* update last_end */
+       accum->last_end = tval;
+
+       /* make get elapsed time. */
+       tval = tval - accum->timestamp;
+
+       /* update min/max */
+       accum->elapsed_max =
+           tval > accum->elapsed_max ? tval : accum->elapsed_max;
+       accum->elapsed_min =
+           tval < accum->elapsed_min ? tval : accum->elapsed_min;
+
+       if (show)
+               printf("[ACCUM END] %s : %ld + %u ---(%s:%d)\n", name,
+                      accum->elapsed_accum, tval, filename, line);
+
+       /* add elapsed time */
+       accum->elapsed_accum += tval;
+       accum->on_estimate = 0;
+
+       return 0;
+}
+
+void __print_some_info(FILE *fp)
+{
+       if (!fp)
+               return;
+
+       fprintf(fp, "\nb~ b~ b~\n\n");
+
+       /* General infomation */
+       {
+               time_t t_val;
+               char hostname[256] = { '\0', };
+               char ctime_buf[256] = { '\0', };
+               struct utsname uts;
+               struct rusage r_usage;
+
+               fprintf(fp, "\n[[ General info ]]\n");
+
+               /* time and date */
+               time(&t_val);
+               fprintf(fp, "Date : %s", ctime_r(&t_val, ctime_buf));
+
+               /* system */
+               if (gethostname(hostname, 255) == 0 && uname(&uts) >= 0) {
+                       fprintf(fp, "Hostname : %s\n", hostname);
+                       fprintf(fp, "System : %s\n", uts.sysname);
+                       fprintf(fp, "Machine : %s\n", uts.machine);
+                       fprintf(fp, "Nodename : %s\n", uts.nodename);
+                       fprintf(fp, "Release : %s \n", uts.release);
+                       fprintf(fp, "Version : %s \n", uts.version);
+               }
+               /* process info. */
+               fprintf(fp, "Process priority : %d\n",
+                       getpriority(PRIO_PROCESS, getpid()));
+               getrusage(RUSAGE_SELF, &r_usage);
+               fprintf(fp,
+                       "CPU usage : User = %ld.%06ld, System = %ld.%06ld\n",
+                       r_usage.ru_utime.tv_sec, r_usage.ru_utime.tv_usec,
+                       r_usage.ru_stime.tv_sec, r_usage.ru_stime.tv_usec);
+
+       }
+
+       /* host environment variables */
+       {
+               extern char **environ;
+               char **env = environ;
+
+               fprintf(fp, "\n[[ Host environment variables ]]\n");
+               while (*env) {
+                       fprintf(fp, "%s\n", *env);
+                       env++;
+               }
+       }
+}
+
+void audio_svc_ta_accum_show_result(int direction)
+{
+       int i = 0;
+       char format[256];
+       FILE *fp = stderr;
+
+       if (!mm_g_accums)
+               return;
+
+       switch (direction) {
+       case AUDIO_SVC_TA_SHOW_STDOUT:
+               fp = stdout;
+               break;
+       case AUDIO_SVC_TA_SHOW_STDERR:
+               fp = stderr;
+               break;
+       case AUDIO_SVC_TA_SHOW_FILE:
+               {
+                       fp = fopen(AUDIO_SVC_TA_RESULT_FILE, "wt");
+                       if (!fp)
+                               return;
+               }
+       }
+       __print_some_info(fp);
+
+#ifdef AUDIO_SVC_TA_UNIT_MSEC
+       snprintf(format, sizeof(format),
+                "[%%3d] %%-%ds | \ttotal : %%4ld\tcalls : %%3ld\tavg : %%4ld\tmin : %%4ld\tmax : %%4ld\tstart : %%4lu\tend : %%4lu\tunpair : %%3ld\n",
+                mm_g_accum_longest_name);
+       fprintf(fp,
+               "BEGIN RESULT ACCUM============================ : NumOfItems : %d, unit(msec)\n",
+               mm_g_accum_index);
+#else
+       snprintf(format, sizeof(format),
+                "[%%3d] %%-%ds | \ttotal : %%ld\tcalls : %%ld\tavg : %%ld\tmin : %%ld\tmax : %%ld\tstart : %%lu\tend : %%lu\tunpair : %%ld\n",
+                mm_g_accum_longest_name);
+       fprintf(fp,
+               "BEGIN RESULT ACCUM============================ : NumOfItems : %d, unit(usec)\n",
+               mm_g_accum_index);
+#endif
+
+       for (i = 0; i < mm_g_accum_index; i++) {
+               /* prevent 'devide by zero' error */
+               if (mm_g_accums[i]->num_calls == 0)
+                       mm_g_accums[i]->num_calls = 1;
+
+               fprintf(fp, format, i, mm_g_accums[i]->name, mm_g_accums[i]->elapsed_accum, mm_g_accums[i]->num_calls, (mm_g_accums[i]->elapsed_accum == 0) ? 0 : (int)(mm_g_accums[i]->elapsed_accum / mm_g_accums[i]->num_calls),     /* Fix it! : devide by zero */
+                       mm_g_accums[i]->elapsed_min,
+                       mm_g_accums[i]->elapsed_max,
+                       mm_g_accums[i]->first_start - mm_g_accum_first_time,
+                       mm_g_accums[i]->last_end - mm_g_accum_first_time,
+                       mm_g_accums[i]->num_unpair);
+       }
+       fprintf(fp, "END RESULT ACCUM  ============================\n");
+
+       if (direction == AUDIO_SVC_TA_SHOW_FILE)
+               fclose(fp);
+}
+
diff --git a/src/audio/audio-svc-utils.c b/src/audio/audio-svc-utils.c
new file mode 100755 (executable)
index 0000000..0e6717e
--- /dev/null
@@ -0,0 +1,1144 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+/**
+ * This file defines structure and functions related to database.
+ *
+ * @file               audio-svc-utils.c
+ * @version    0.1
+ * @brief      This file defines utilities for Audio Service.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/vfs.h>
+#include <ctype.h>
+
+#include <dirent.h>
+
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <drm-service-types.h>
+#include <drm-service.h>
+
+#include <mm_file.h>
+#include "media-info-util.h"
+#include "audio-svc-debug.h"
+#include "audio-svc-error.h"
+#include "audio-svc-utils.h"
+#include "audio-svc.h"
+#include "audio-svc-types-priv.h"
+#include "md5_hash.h"
+
+#define AUDIO_SVC_PARENTAL_RATING_LEN          20
+#define AUDIO_SVC_FILE_EXT_LEN_MAX                             6                       /**<  Maximum file ext lenth*/
+
+typedef enum {
+       AUDIO_SVC_EXTRACTED_FIELD_NONE                  = 0x00000001,
+       AUDIO_SVC_EXTRACTED_FIELD_TITLE                         = AUDIO_SVC_EXTRACTED_FIELD_NONE << 1,
+       AUDIO_SVC_EXTRACTED_FIELD_DESC                  = AUDIO_SVC_EXTRACTED_FIELD_NONE << 2,
+       AUDIO_SVC_EXTRACTED_FIELD_COPYRIGHT             = AUDIO_SVC_EXTRACTED_FIELD_NONE << 3,
+       AUDIO_SVC_EXTRACTED_FIELD_AUTHOR                = AUDIO_SVC_EXTRACTED_FIELD_NONE << 4,
+       AUDIO_SVC_EXTRACTED_FIELD_ARTIST                        = AUDIO_SVC_EXTRACTED_FIELD_NONE << 5,
+       AUDIO_SVC_EXTRACTED_FIELD_GENRE                 = AUDIO_SVC_EXTRACTED_FIELD_NONE << 6,
+       AUDIO_SVC_EXTRACTED_FIELD_ALBUM                 = AUDIO_SVC_EXTRACTED_FIELD_NONE << 7,
+       AUDIO_SVC_EXTRACTED_FIELD_TRACKNUM              = AUDIO_SVC_EXTRACTED_FIELD_NONE << 8,
+       AUDIO_SVC_EXTRACTED_FIELD_YEAR                  = AUDIO_SVC_EXTRACTED_FIELD_NONE << 9,
+       AUDIO_SVC_EXTRACTED_FIELD_CATEGORY              = AUDIO_SVC_EXTRACTED_FIELD_NONE << 10,
+} audio_svc_extracted_field_e;
+
+static bool __audio_svc_get_file_ext (const char *file_path, char *file_ext);
+static int __save_thumbnail(void *image, int size, char *thumb_path);
+
+static bool __audio_svc_get_file_ext (const char *file_path, char *file_ext)
+{
+       int i = 0;
+
+       for (i = strlen(file_path); i >= 0; i--) {
+               if (file_path[i] == '.') {
+                       _strncpy_safe(file_ext, &file_path[i+1], AUDIO_SVC_FILE_EXT_LEN_MAX);
+                       return true;
+               }
+
+               if (file_path[i] == '/') {
+                       return false;
+               }
+       }
+       return false;
+}
+
+static int __save_thumbnail(void *image, int size, char *thumb_path)
+{
+       audio_svc_debug("start save thumbnail, path: %s", thumb_path);
+       if (!image) {
+               audio_svc_error("invalid image..");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       
+       struct statfs fs;
+       if (-1 == statfs(AUDIO_SVC_THUMB_PATH_PREFIX, &fs)) {
+               audio_svc_error("error in statfs");
+               return AUDIO_SVC_ERROR_INTERNAL;
+       }
+
+       long bsize_kbytes = fs.f_bsize >> 10;
+
+       if ((bsize_kbytes * fs.f_bavail) < 1024) {
+               audio_svc_error("not enought space...");
+               return AUDIO_SVC_ERROR_INTERNAL;
+       }
+
+       FILE *fp = NULL;
+       int nwrite = -1;
+       if (image != NULL && size > 0) {
+               fp = fopen(thumb_path, "w");
+
+               if (fp == NULL) {
+                       audio_svc_error("failed to open file");
+                       return AUDIO_SVC_ERROR_INTERNAL;
+               }
+               audio_svc_debug("image size = [%d]",  size);
+
+               nwrite = fwrite(image, 1, size, fp);
+               if (nwrite != size) {
+                       audio_svc_error("failed to write thumbnail");
+                       fclose(fp);
+                       return AUDIO_SVC_ERROR_INTERNAL;
+               }
+               fclose(fp);
+       }
+
+       audio_svc_debug("save thumbnail success!!");
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int _audio_svc_extract_metadata_audio(audio_svc_storage_type_e storage_type, const char *path, audio_svc_audio_item_s *item)
+{
+       MMHandleType content = 0;
+       MMHandleType tag = 0;
+       char *p = NULL;
+       void *image = NULL;
+       int size = -1;
+       int extracted_field = AUDIO_SVC_EXTRACTED_FIELD_NONE;
+       int mmf_error = -1;
+       bool thumb_extracted_from_drm = FALSE;
+       char *err_attr_name = NULL;
+       char *title = NULL;
+#if 0
+       bool extract_thumbnail = FALSE;
+       int album_id = -1;
+       char *thumbnail_path = NULL;
+#endif
+       int artwork_mime_size = -1;
+       
+       _strncpy_safe(item->pathname, path, sizeof(item->pathname));
+       item->storage_type = storage_type;
+
+       if (drm_svc_is_drm_file(item->pathname)) {
+               bool invalid_file = FALSE;
+
+               DRM_FILE_TYPE type = drm_svc_get_drm_type(item->pathname);
+
+               if (type == DRM_FILE_TYPE_OMA) {
+                       drm_dcf_header_t header_info;
+                       memset(&header_info, 0, sizeof(drm_dcf_header_t));
+                       audio_svc_debug("drm type is OMA");
+
+                       if (drm_svc_get_dcf_header_info(item->pathname, &header_info) != DRM_RESULT_SUCCESS) {
+                               audio_svc_debug("cannot get dcf header info. just get the title");              
+                               title = _audio_svc_get_title_from_filepath(item->pathname);
+                               if (title) {
+                                       _strncpy_safe(item->audio.title, title, sizeof(item->audio.title));
+                                       SAFE_FREE(title);
+                               } else {
+                                       audio_svc_error("Can't extract title from filepath");
+                                       return AUDIO_SVC_ERROR_INTERNAL;
+                               }
+
+                               _strncpy_safe(item->audio.album, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.album));
+                               _strncpy_safe(item->audio.artist, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.artist));
+                               _strncpy_safe(item->audio.genre, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.genre));
+                               _strncpy_safe(item->audio.author, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.author));
+                               _strncpy_safe(item->audio.year, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.year));
+                               
+                               return AUDIO_SVC_ERROR_NONE;
+                       }
+
+                       if (drm_svc_has_valid_ro(item->pathname, DRM_PERMISSION_PLAY) != DRM_RESULT_SUCCESS) {
+                               audio_svc_debug("no valid ro. can't extract meta data");
+                               invalid_file = TRUE;
+                       }
+
+                       if (header_info.version == DRM_OMA_DRMV1_RIGHTS) {
+                               audio_svc_debug("DRM V1");
+                               if (invalid_file) {
+
+                                       if (strlen(header_info.headerUnion.headerV1.contentName) > 0) {
+                                               _strncpy_safe(item->audio.title, header_info.headerUnion.headerV1.contentName, sizeof(item->audio.title));
+                                               extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_TITLE;
+                                               audio_svc_debug("extract title from DCF");
+                                       }
+
+                                       if (strlen(header_info.headerUnion.headerV1.contentDescription) > 0) {
+                                               _strncpy_safe(item->audio.description, header_info.headerUnion.headerV1.contentDescription, sizeof(item->audio.description));
+                                               extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_DESC;
+                                               audio_svc_debug("extract description from DCF");
+                                       }
+                               }
+                       } else if (header_info.version == DRM_OMA_DRMV2_RIGHTS) {
+                               drm_user_data_common_t metadata;
+                               int type_index = -1;
+
+                               audio_svc_debug("DRM V2");
+                               
+                               if (drm_svc_get_user_data_box_info(item->audio.title, DRM_UDTA_TITLE, &metadata) == DRM_RESULT_SUCCESS) {
+                                       _strncpy_safe(item->audio.title, metadata.subBox.title.str, sizeof(item->audio.title));
+                                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_TITLE;
+                                       audio_svc_debug("extract title from odf");
+                               }
+
+                               if (drm_svc_get_user_data_box_info(item->audio.description, DRM_UDTA_DESCRIPTION, &metadata) == DRM_RESULT_SUCCESS) {
+                                       _strncpy_safe(item->audio.description, metadata.subBox.desc.str, sizeof(item->audio.description));
+                                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_DESC;
+                               }
+
+                               if (drm_svc_get_user_data_box_info(item->audio.copyright, DRM_UDTA_COPYRIGHT, &metadata) == DRM_RESULT_SUCCESS) {
+                                       _strncpy_safe(item->audio.copyright, metadata.subBox.copyright.str, sizeof(item->audio.copyright));
+                                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_COPYRIGHT;
+                               }
+
+                               if (drm_svc_get_user_data_box_info(item->audio.author, DRM_UDTA_AUTHOR, &metadata) == DRM_RESULT_SUCCESS) {
+                                       _strncpy_safe(item->audio.author, metadata.subBox.author.str, sizeof(item->audio.author));
+                                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_AUTHOR;
+                               }
+
+                               if (drm_svc_get_user_data_box_info(item->audio.artist, DRM_UDTA_PERFORMER, &metadata) == DRM_RESULT_SUCCESS) {
+                                       _strncpy_safe(item->audio.artist, metadata.subBox.performer.str, sizeof(item->audio.artist));
+                                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_ARTIST;
+                               }
+
+                               if (drm_svc_get_user_data_box_info(item->audio.genre, DRM_UDTA_GENRE, &metadata) == DRM_RESULT_SUCCESS) {
+                                       _strncpy_safe(item->audio.genre, metadata.subBox.genre.str, sizeof(item->audio.genre));
+                                       audio_svc_debug("genre : %s", item->audio.genre);
+                                       if ((strcasecmp("Ringtone", metadata.subBox.genre.str) == 0) | (strcasecmp("Alert tone", metadata.subBox.genre.str) == 0)) {
+                                               item->category = AUDIO_SVC_CATEGORY_SOUND;
+                                       }
+                                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_GENRE;
+                               }
+
+                               if (drm_svc_get_user_data_box_info(item->audio.album, DRM_UDTA_ALBUM, &metadata) == DRM_RESULT_SUCCESS) {
+                                       _strncpy_safe(item->audio.album, metadata.subBox.album.albumTitle, sizeof(item->audio.album));
+                                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_ALBUM;
+                                       item->audio.track =  (int)metadata.subBox.album.trackNum;
+                               }
+
+                               if (drm_svc_get_user_data_box_info(item->audio.year, DRM_UDTA_RECODINGYEAR, &metadata) == DRM_RESULT_SUCCESS) {
+                                       _strncpy_safe(item->audio.year, _year_2_str(metadata.subBox.recodingYear.recodingYear), sizeof(item->audio.year));
+                                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_YEAR;
+                               }
+
+                               if (drm_svc_get_index_of_relative_contents(item->thumbname, DRM_CONTENTS_INDEX_ALBUMJACKET, &type_index) == DRM_RESULT_SUCCESS) {
+                                       char thumb_path[AUDIO_SVC_PATHNAME_SIZE+1] = {0};
+
+                                       if (drm_svc_make_multipart_drm_full_path(item->pathname, type_index, AUDIO_SVC_PATHNAME_SIZE, thumb_path) == DRM_TRUE) {
+
+                                               DRM_FILE_HANDLE hFile = DRM_HANDLE_NULL;
+
+                                               audio_svc_debug("drm image path : %s", thumb_path);
+
+                                               if (drm_svc_open_file(thumb_path, DRM_PERMISSION_ANY, &hFile) == DRM_RESULT_SUCCESS) {
+                                                       int thumb_size = 0;
+
+                                                       if (drm_svc_seek_file(hFile, 0, DRM_SEEK_END) != DRM_RESULT_SUCCESS) {
+                                                               goto DRM_SEEK_ERROR;
+                                                       }
+                                                       thumb_size = drm_svc_tell_file(hFile);
+
+                                                       if (drm_svc_seek_file(hFile, 0, DRM_SEEK_SET) != DRM_RESULT_SUCCESS) {
+                                                               goto DRM_SEEK_ERROR;
+                                                       }
+                                                       /* remove thumbnail extract routine in db creating time.
+                                                       audio_svc_debug("drm thumb size : %d", thumb_size);
+                                                       if (thumb_size > 0) {
+                                                               unsigned int readSize = 0;
+
+                                                               thumb_buffer = malloc(thumb_size);
+                                                               if (drm_svc_read_file(hFile, thumb_buffer,thumb_size, &readSize) != DRM_RESULT_SUCCESS) {
+                                                                       SAFE_FREE(thumb_buffer);
+                                                                       goto DRM_SEEK_ERROR;
+                                                               }
+
+                                                               __save_thumbnail(thumb_buffer, readSize, 1, item);
+                                                               SAFE_FREE(thumb_buffer);
+                                                               thumb_extracted_from_drm = TRUE;
+                                                       }
+                                                       */
+                                                       DRM_SEEK_ERROR:
+                                                               drm_svc_free_dcf_header_info(&header_info);
+                                                               drm_svc_close_file(hFile);
+                                               }
+                                       }
+                               }
+                       } else {
+                               audio_svc_debug("unsupported drm format");
+                               drm_svc_free_dcf_header_info(&header_info);
+                               title = _audio_svc_get_title_from_filepath(item->pathname);
+                               if (title) {
+                                       _strncpy_safe(item->audio.title, title, sizeof(item->audio.title));
+                                       SAFE_FREE(title);
+                               } else {
+                                       audio_svc_error("Can't extract title from filepath");
+                                       return AUDIO_SVC_ERROR_INTERNAL;
+                               }
+
+                               _strncpy_safe(item->audio.album, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.album));
+                               _strncpy_safe(item->audio.artist, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.artist));
+                               _strncpy_safe(item->audio.genre, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.genre));
+                               _strncpy_safe(item->audio.author, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.author));
+                               _strncpy_safe(item->audio.year, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.year));
+                               
+                               return AUDIO_SVC_ERROR_NONE;
+                       }
+
+                       if (invalid_file == TRUE) {
+                               if (!(extracted_field & AUDIO_SVC_EXTRACTED_FIELD_TITLE)) {
+                                       title = _audio_svc_get_title_from_filepath(item->pathname);
+                                       if (title) {
+                                               _strncpy_safe(item->audio.title, title, sizeof(item->audio.title));
+                                               extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_TITLE;
+                                               SAFE_FREE(title);
+                                       } else {
+                                               audio_svc_error("Can't extract title from filepath");
+                                               drm_svc_free_dcf_header_info(&header_info);
+                                               return AUDIO_SVC_ERROR_INTERNAL;
+                                       }
+
+                                       _strncpy_safe(item->audio.album, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.album));
+                                       _strncpy_safe(item->audio.artist, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.artist));
+                                       _strncpy_safe(item->audio.genre, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.genre));
+                                       _strncpy_safe(item->audio.author, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.author));
+                                       _strncpy_safe(item->audio.year, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.year));
+                               }
+                               
+                               drm_svc_free_dcf_header_info(&header_info);
+                               return AUDIO_SVC_ERROR_NONE;
+                       }
+               } else if (type == DRM_FILE_TYPE_PLAYREADY) {
+                       audio_svc_debug("drm type is PLAYREADY");
+                       if (drm_svc_has_valid_ro(item->pathname, DRM_PERMISSION_PLAY) != DRM_RESULT_SUCCESS) {
+                               audio_svc_debug("no valid ro. can't extract meta data");
+                               title = _audio_svc_get_title_from_filepath(item->pathname);
+                               if (title) {
+                                       _strncpy_safe(item->audio.title, title, sizeof(item->audio.title));
+                                       SAFE_FREE(title);
+                               } else {
+                                       audio_svc_error("Can't extract title from filepath");
+                                       return AUDIO_SVC_ERROR_INTERNAL;
+                               }
+
+                               _strncpy_safe(item->audio.album, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.album));
+                               _strncpy_safe(item->audio.artist, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.artist));
+                               _strncpy_safe(item->audio.genre, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.genre));
+                               _strncpy_safe(item->audio.author, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.author));
+                               _strncpy_safe(item->audio.year, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.year));
+                               
+                               return AUDIO_SVC_ERROR_NONE;
+                       }
+               } else {
+                       audio_svc_error("Not supported DRM type");
+                       title = _audio_svc_get_title_from_filepath(item->pathname);
+                       if (title) {
+                               _strncpy_safe(item->audio.title, title, sizeof(item->audio.title));
+                               SAFE_FREE(title);
+                       } else {
+                               audio_svc_error("Can't extract title from filepath");
+                               return AUDIO_SVC_ERROR_INTERNAL;
+                       }
+
+                       _strncpy_safe(item->audio.album, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.album));
+                       _strncpy_safe(item->audio.artist, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.artist));
+                       _strncpy_safe(item->audio.genre, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.genre));
+                       _strncpy_safe(item->audio.author, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.author));
+                       _strncpy_safe(item->audio.year, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.year));
+                       
+                       return AUDIO_SVC_ERROR_NONE;
+               }
+       }
+
+       mmf_error = mm_file_create_content_attrs(&content, item->pathname);
+
+       if (mmf_error == 0) {
+               int sample_rate = 0;
+               int channels = 0;
+
+               mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_BITRATE, &item->audio.bitrate, NULL);
+               if (mmf_error != 0) {
+                       SAFE_FREE(err_attr_name);
+                       audio_svc_debug("fail to get audio bitrate attr - err(%x)", mmf_error);
+               } else {
+                       audio_svc_debug("bit rate : %d", item->audio.bitrate);
+               }
+               mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_DURATION, &item->audio.duration, NULL);
+               if (mmf_error != 0) {
+                       SAFE_FREE(err_attr_name);
+                       audio_svc_debug("fail to get duration attr - err(%x)", mmf_error);
+               } else {
+                       audio_svc_debug("duration : %d", item->audio.duration);
+               }
+               mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_SAMPLERATE, &sample_rate, NULL);
+               if (mmf_error != 0) {
+                       SAFE_FREE(err_attr_name);
+                       audio_svc_debug("fail to get sample rate attr - err(%x)", mmf_error);
+               } else {
+                       audio_svc_debug("sample rate : %d", sample_rate);
+               }
+               mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_CHANNELS, &channels, NULL);
+               if (mmf_error != 0) {
+                       SAFE_FREE(err_attr_name);
+                       audio_svc_debug("fail to get audio channels attr - err(%x)", mmf_error);
+               } else {
+                       audio_svc_debug("channel : %d", channels);
+               }
+
+               /*
+                *      Set format string
+                *              example : 3GPP stereo HE-AAC 48kbps 44.1kHz
+                *              example : 128kbps 44.1kHz 2 Channels
+                *              example : 128kpbs 44.1kHz 2ch
+                */
+
+               if (item->audio.bitrate > 0 && sample_rate > 0) {
+                       snprintf(item->audio.format, sizeof(item->audio.format) - 1,
+                                       "%dkbps %.1fkHz %dch",
+                                       item->audio.bitrate / 1000, sample_rate / 1000.0, channels);
+               } else if (item->audio.bitrate > 0) {
+                       snprintf(item->audio.format, sizeof(item->audio.format) - 1,
+                                       "%dkbps %dch",
+                                       item->audio.bitrate / 1000, channels);
+               } else if (sample_rate > 0) {
+                       snprintf(item->audio.format, sizeof(item->audio.format) - 1,
+                                       "%.1fkHz %dch",
+                                       sample_rate / 1000.0, channels);
+               }
+
+               audio_svc_debug("format : %s", item->audio.format);
+               mmf_error = mm_file_destroy_content_attrs(content);
+               if (mmf_error != 0) {
+                       audio_svc_debug("fail to free content attr - err(%x)", mmf_error);
+               }
+       } else {
+               audio_svc_debug("no contents information");
+       }
+
+       mmf_error = mm_file_create_tag_attrs(&tag, item->pathname);
+
+       if (mmf_error == 0) {
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM, &p, &size, NULL);
+               if ((!(extracted_field & AUDIO_SVC_EXTRACTED_FIELD_ALBUM)) && mmf_error == 0 && size > 0) {
+                       _strncpy_safe(item->audio.album, p, sizeof(item->audio.album));
+                       audio_svc_debug("album[%d] : %s", size, item->audio.album);
+               } else {
+                       SAFE_FREE(err_attr_name);
+                       audio_svc_debug("album - unknown");
+                       _strncpy_safe(item->audio.album, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.album));
+               }
+
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTIST, &p, &size, NULL);
+               if ((!(extracted_field & AUDIO_SVC_EXTRACTED_FIELD_ARTIST)) && mmf_error == 0 && size > 0) {
+                       _strncpy_safe(item->audio.artist, p, sizeof(item->audio.artist));
+                       audio_svc_debug("artist[%d] : %s", size, item->audio.artist);
+               } else {
+                       SAFE_FREE(err_attr_name);
+                       audio_svc_debug("artist - unknown");
+                       _strncpy_safe(item->audio.artist, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.artist));
+               }
+
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_GENRE, &p, &size, NULL);
+               if ((!(extracted_field & AUDIO_SVC_EXTRACTED_FIELD_GENRE)) && mmf_error == 0 && size > 0) {
+                       _strncpy_safe(item->audio.genre, p, sizeof(item->audio.genre));
+                       audio_svc_debug("genre : %s", item->audio.genre);
+                       if ((strcasecmp("Ringtone", p) == 0) | (strcasecmp("Alert tone", p) == 0)) {
+                               item->category = AUDIO_SVC_CATEGORY_SOUND;
+                       }
+               } else {
+                       SAFE_FREE(err_attr_name);
+                       audio_svc_debug("genre - unknown");
+                       _strncpy_safe(item->audio.genre, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.genre));
+               }
+
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TITLE, &p, &size, NULL);
+               if ((!(extracted_field & AUDIO_SVC_EXTRACTED_FIELD_TITLE)) && mmf_error == 0 && size > 0 &&     (!isspace(*p))) {
+                       _strncpy_safe(item->audio.title, p, sizeof(item->audio.title));
+                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_TITLE;
+                       audio_svc_debug("extract title from content : %s", item->audio.title);
+                       audio_svc_debug("^^^^^^^^^^^^^^^ path = %s, title = %s, size = %d ^^^^^^^^^^^^^^", path, item->audio.title, size);
+               } else {
+                       SAFE_FREE(err_attr_name);
+                       char *title = NULL;             
+                       title = _audio_svc_get_title_from_filepath(item->pathname);
+                       if (title) {
+                               _strncpy_safe(item->audio.title, title, sizeof(item->audio.title));
+                               SAFE_FREE(title);
+                       } else {
+                               audio_svc_error("Can't extract title from filepath");
+                               return AUDIO_SVC_ERROR_INTERNAL;
+                       }
+               }
+
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DESCRIPTION, &p, &size, NULL);
+               if ((!(extracted_field & AUDIO_SVC_EXTRACTED_FIELD_DESC)) && mmf_error == 0 && size > 0) {
+                       _strncpy_safe(item->audio.description, p, sizeof(item->audio.description));
+                       audio_svc_debug("desc : %s", item->audio.description);
+               } else {
+                       SAFE_FREE(err_attr_name);
+               }
+
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_AUTHOR, &p, &size, NULL);
+               if ((!(extracted_field & AUDIO_SVC_EXTRACTED_FIELD_AUTHOR)) && mmf_error == 0 && size > 0) {
+                       _strncpy_safe(item->audio.author, p, sizeof(item->audio.author));
+                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_AUTHOR;
+                       audio_svc_debug("extract author from content : %s", item->audio.author);
+               } else {
+                       audio_svc_debug("author - unknown");
+                       SAFE_FREE(err_attr_name);
+                       _strncpy_safe(item->audio.author, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.author));
+               }
+
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TRACK_NUM, &p, &size, NULL);
+               if (mmf_error == 0 && size > 0) {
+                       item->audio.track = atoi(p);
+               } else {
+                       SAFE_FREE(err_attr_name);
+                       item->audio.track = -1;
+               }
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DATE, &p, &size, NULL);
+               if (!(extracted_field & AUDIO_SVC_EXTRACTED_FIELD_YEAR)) {
+                       if (mmf_error == 0 && size > 0) {
+                               _strncpy_safe(item->audio.year, p, sizeof(item->audio.year));
+                       } else {
+                               SAFE_FREE(err_attr_name);
+                               _strncpy_safe(item->audio.year, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.year));
+                       }
+               } else {
+                       SAFE_FREE(err_attr_name);
+               }
+
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_RATING, &p, &size, NULL);
+               if (mmf_error == 0 && size > 0) {
+                       _strncpy_safe(item->audio.parental_rating, p, sizeof(item->audio.parental_rating));
+               } else {
+                       SAFE_FREE(err_attr_name);
+               }
+
+               /* extract thumbnail image */
+               /*hm2007.kim 100122 - remove thumbnail extract routine while db creating.*/
+#if 0
+               album_id = _audio_svc_get_album_id(item->audio.album);
+               if (album_id < 0) {
+                       audio_svc_debug("album does not exist. So start to make album art");
+                       extract_thumbnail = TRUE;
+               } else {
+                       audio_svc_debug("album already exists. don't need to make album art");
+                       thumbnail_path = _audio_svc_get_thumbnail_path_by_album_id(album_id);
+                       _strncpy_safe(item->thumbname, thumbnail_path, sizeof(item->thumbname));
+                       SAFE_FREE(thumbnail_path);
+               }
+#endif
+               if ((!thumb_extracted_from_drm)/* && (extract_thumbnail == TRUE)*/) {
+                       mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTWORK, &image, &size, NULL);
+                       if (mmf_error != 0) {
+                               audio_svc_debug("fail to get tag artwork - err(%x)", mmf_error);
+                               SAFE_FREE(err_attr_name);
+                       } else {
+                               audio_svc_debug("artwork size1 [%d]", size);
+                       }
+
+                       mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTWORK_SIZE, &size, NULL);
+                       if (mmf_error != 0) {
+                               audio_svc_debug("fail to get artwork size - err(%x)", mmf_error);
+                               SAFE_FREE(err_attr_name);
+                       } else {
+                               audio_svc_debug("artwork size2 [%d]", size);
+                       }
+                       if (image != NULL && size > 0) {
+                               bool ret = FALSE;
+                               int result = AUDIO_SVC_ERROR_NONE;
+                               char thumb_path[AUDIO_SVC_PATHNAME_SIZE] = "\0";
+                               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTWORK_MIME, &p, &artwork_mime_size, NULL);
+                               if (mmf_error == 0 && artwork_mime_size > 0) {
+                                       ret = _audio_svc_get_thumbnail_path(storage_type, thumb_path, item->pathname, p);
+                                       if (ret == FALSE) {
+                                               audio_svc_error("fail to get thumb path..");
+                                               mmf_error = mm_file_destroy_tag_attrs(tag);
+                                               if (mmf_error != 0) {
+                                                       audio_svc_error("fail to free tag attr - err(%x)", mmf_error);
+                                               }
+                                       return AUDIO_SVC_ERROR_INTERNAL;
+                                       }       
+                               } else {
+                                       SAFE_FREE(err_attr_name);
+                               }
+
+                               if (!strlen(thumb_path)) {
+                                       audio_svc_error("fail to get thumb path..");
+                                       mmf_error = mm_file_destroy_tag_attrs(tag);
+                                       if (mmf_error != 0) {
+                                               audio_svc_error("fail to free tag attr - err(%x)", mmf_error);
+                                       }
+                                       return AUDIO_SVC_ERROR_INTERNAL;
+                               }
+
+                               result = __save_thumbnail(image, size, thumb_path);
+                               if (result != AUDIO_SVC_ERROR_NONE) {
+                                       mmf_error = mm_file_destroy_tag_attrs(tag);
+                                       if (mmf_error != 0) {
+                                               audio_svc_error("fail to free tag attr - err(%x)", mmf_error);
+                                       }
+                                       return result;
+                               }
+
+                               _strncpy_safe(item->thumbname, thumb_path, sizeof(item->thumbname));
+                       }
+               }
+
+               mmf_error = mm_file_destroy_tag_attrs(tag);
+               if (mmf_error != 0) {
+                       audio_svc_error("fail to free tag attr - err(%x)", mmf_error);
+               }
+       } else {
+               char *title = NULL;
+               audio_svc_error("no tag information");
+               
+               title = _audio_svc_get_title_from_filepath(item->pathname);
+               if (title) {
+                       _strncpy_safe(item->audio.title, title, sizeof(item->audio.title));
+                       SAFE_FREE(title);
+               } else {
+                       audio_svc_error("Can't extract title from filepath");
+                       return AUDIO_SVC_ERROR_INTERNAL;
+               }
+               
+               /* hjkim, 101112, in case of file size 0, MMFW Can't parsting tag info but add it to Music DB. */
+               _strncpy_safe(item->audio.album, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.album));
+               _strncpy_safe(item->audio.artist, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.artist));
+               _strncpy_safe(item->audio.genre, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.genre));
+               _strncpy_safe(item->audio.author, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.author));
+               _strncpy_safe(item->audio.year, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.year));
+       }
+       
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+bool _audio_svc_possible_to_extract_title_from_file(const char *path)
+{
+       MMHandleType tag = 0;
+       int err = -1;
+       int size = 0;
+       char *p = NULL;
+       char *err_attr_name = NULL;
+
+       if (drm_svc_is_drm_file(path)) {
+               DRM_FILE_TYPE type = drm_svc_get_drm_type(path);
+
+               if (type == DRM_FILE_TYPE_OMA) {
+                       drm_dcf_header_t header_info;
+                       bool ret = FALSE;
+                       memset(&header_info, 0, sizeof(drm_dcf_header_t));
+
+                       if (drm_svc_get_dcf_header_info(path, &header_info) == DRM_RESULT_SUCCESS) {
+                               if (header_info.version == DRM_OMA_DRMV1_RIGHTS) {
+
+                                       if (drm_svc_has_valid_ro(path, DRM_PERMISSION_ANY) != DRM_RESULT_SUCCESS) {
+                                               if (strlen(header_info.headerUnion.headerV1.contentName) > 0) {
+                                                       ret =  TRUE;
+                                               } else {
+                                                       ret = FALSE;
+                                               }
+                                       } else {
+                                               ret = FALSE;
+                                       }
+                               } else if (header_info.version == DRM_OMA_DRMV2_RIGHTS) {
+
+                                       drm_user_data_common_t metadata;
+
+                                       if (drm_svc_get_user_data_box_info(path, DRM_UDTA_TITLE, &metadata) == DRM_RESULT_SUCCESS) {
+                                               ret = TRUE;
+                                       } else {
+                                               ret = FALSE;
+                                       }                                       
+                               } else {
+                                       audio_svc_debug("unsupported drm format");
+                                       ret = FALSE;                                    
+                               }
+                               drm_svc_free_dcf_header_info(&header_info);
+                               return ret;
+                       }
+               } else if (type == DRM_FILE_TYPE_PLAYREADY) {
+                       audio_svc_debug("drm type is PLAYREADY");
+                       if (drm_svc_has_valid_ro(path, DRM_PERMISSION_PLAY) != DRM_RESULT_SUCCESS) {
+                               audio_svc_debug("no valid ro. can't extract meta data");
+                       }
+               } else {
+                       audio_svc_error("Not supported DRM type");
+                       return FALSE;
+               }
+       }
+
+       err = mm_file_create_tag_attrs(&tag, path);
+
+       if (err == 0) {
+               err = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TITLE, &p, &size, NULL);
+               if (err == 0 && size > 0) {
+                       mm_file_destroy_tag_attrs(tag);
+                       return TRUE;
+               } else {
+                       SAFE_FREE(err_attr_name);
+                       mm_file_destroy_tag_attrs(tag);
+               }
+       }
+
+       return FALSE;
+}
+
+char *_audio_svc_get_title_from_filepath (const char *path)
+{
+       char *filename = NULL;
+       char *title = NULL;
+       char    *ext = NULL;
+       int filename_len = -1;
+       int new_title_len = -1;
+
+       audio_svc_debug("title tag doesn't exist, so get from file path");
+       
+       if (!path) {
+               audio_svc_error("path is NULL");
+               return NULL;
+       }
+       
+       filename = g_path_get_basename(path);
+       if ((filename == NULL) || (strlen(filename) < 1)) {
+               audio_svc_error("wrong file name");
+               SAFE_FREE(filename);
+               return NULL;
+       }
+       
+       filename_len = strlen(filename);
+
+       ext = g_strrstr(filename, ".");
+       if (!ext) {
+               audio_svc_error("there is no file extention");
+               return filename;
+       }
+
+       new_title_len = filename_len - strlen(ext);
+       if (new_title_len < 1) {
+               audio_svc_error("title length is zero");
+               SAFE_FREE(filename);
+               return NULL;
+       }
+       
+       title = g_strndup(filename, new_title_len < AUDIO_SVC_PATHNAME_SIZE ? new_title_len : AUDIO_SVC_PATHNAME_SIZE-1);
+
+       SAFE_FREE(filename);
+
+       audio_svc_debug("extract title is [%s]", title);
+       
+       return title;
+}
+
+void _audio_svc_get_parental_rating(const char *path, char *parental_rating)
+{
+       MMHandleType tag = 0;
+       char *p = NULL;
+       int size = 0;
+       int mmf_error = -1;
+       char *err_attr_name = NULL;
+
+       if (mm_file_create_tag_attrs(&tag, path) == 0) {
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_RATING, &p, &size, NULL);
+               if (mmf_error == 0 && size > 1) {
+                       _strncpy_safe(parental_rating, p, AUDIO_SVC_PARENTAL_RATING_LEN);
+                       audio_svc_debug("parental rating : %s, %d", parental_rating, size);
+               } else {
+                       SAFE_FREE(err_attr_name);
+               }
+
+               mm_file_destroy_tag_attrs(tag);
+       }
+
+}
+
+int _audio_svc_remove_all_files_in_dir(const char *dir_path)
+{
+       struct dirent *entry = NULL;
+       struct stat st;
+       char filename[AUDIO_SVC_PATHNAME_SIZE] = {0};
+       DIR *dir = NULL;
+
+       dir = opendir(dir_path);
+       if (dir == NULL) {
+               audio_svc_error("%s is not exist", dir_path);
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       while ((entry = readdir(dir)) != NULL) {
+               if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
+                       continue;
+               }
+               snprintf(filename, sizeof(filename), "%s/%s", dir_path, entry->d_name);
+
+               if (stat(filename, &st) != 0) {
+                       continue;
+               }
+               if (S_ISDIR(st.st_mode)) {
+                       continue;
+               }
+               if (unlink(filename) != 0) {
+                       audio_svc_error("failed to remove : %s", filename);
+                       closedir(dir);
+                       return AUDIO_SVC_ERROR_INTERNAL;
+               }
+       }
+
+       closedir(dir);
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+bool _audio_svc_get_thumbnail_path(audio_svc_storage_type_e storage_type, char *thumb_path, const char *pathname, const char *img_format)
+{
+       char savename[AUDIO_SVC_PATHNAME_SIZE] = {0};
+       char file_ext[AUDIO_SVC_FILE_EXT_LEN_MAX + 1] = {0};
+       char *thumb_dir = NULL;
+       char hash[255 + 1];
+       char *thumbfile_ext = NULL;
+       
+       thumb_dir = (storage_type == AUDIO_SVC_STORAGE_PHONE) ? AUDIO_SVC_THUMB_PHONE_PATH : AUDIO_SVC_THUMB_MMC_PATH;
+
+       memset(file_ext, 0, sizeof(file_ext));
+       if (!__audio_svc_get_file_ext(pathname, file_ext)) {
+               audio_svc_error("get file ext fail");
+               return FALSE;
+       }
+
+       int err = -1;
+       err = mb_svc_generate_hash_code(pathname, hash, sizeof(hash));
+       if (err < 0) {
+               audio_svc_error("mb_svc_generate_hash_code failed : %d", err);
+               return FALSE;
+       }
+       
+       audio_svc_debug("img format is [%s]", img_format);
+
+       if((strstr(img_format, "jpeg") != NULL) || (strstr(img_format, "jpg") != NULL)) {
+               thumbfile_ext = "jpg";
+       } else if(strstr(img_format, "png") != NULL) {
+               thumbfile_ext = "png";
+       } else if(strstr(img_format, "gif") != NULL) {
+               thumbfile_ext = "gif";
+       } else if(strstr(img_format, "bmp") != NULL) {
+               thumbfile_ext = "bmp";
+       } else {
+               audio_svc_error("Not proper img format");
+               return FALSE;
+       }
+       
+       snprintf(savename, sizeof(savename), "%s/.%s-%s.%s", thumb_dir, file_ext, hash, thumbfile_ext);
+       _strncpy_safe(thumb_path, savename, AUDIO_SVC_PATHNAME_SIZE);
+       audio_svc_debug("thumb_path is [%s]", thumb_path);
+       
+       return TRUE;
+}
+
+int _audio_svc_get_drm_mime_type(const char *path, char *mime_type)
+{
+       drm_content_info_t contentInfo;
+
+       if (path == NULL) {
+               audio_svc_error("path is NULL");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (drm_svc_get_content_info(path, &contentInfo) == DRM_RESULT_SUCCESS) {
+               if (strlen(contentInfo.contentType) == 0) {
+                       audio_svc_error("contentType is NULL");
+                       return AUDIO_SVC_ERROR_INVALID_MEDIA;
+               } else {
+                       snprintf(mime_type, sizeof(contentInfo.contentType), "%s", (char *)contentInfo.contentType);
+               }
+       } else {
+               audio_svc_error("Error in drm_service");
+               return AUDIO_SVC_ERROR_INVALID_MEDIA;
+       }
+       
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+char *_year_2_str(int year)
+{
+
+       static char ret[AUDIO_SVC_METADATA_LEN_MAX];
+       if (year == -1 || year == 0) {
+               _strncpy_safe(ret, AUDIO_SVC_TAG_UNKNOWN, AUDIO_SVC_METADATA_LEN_MAX);
+       } else {
+               snprintf(ret, AUDIO_SVC_METADATA_LEN_MAX - 1, "%d", year);
+       }
+       return ret;
+}
+
+void _strncpy_safe(char *x_dst, const char *x_src, int max_len)
+{
+       if (!x_src || strlen(x_src) == 0) {
+               audio_svc_error("x_src is NULL");
+               return;
+       }
+
+       if (max_len < 1) {
+               audio_svc_error("length is Wrong");
+               return;
+       }
+       
+    strncpy(x_dst, x_src, max_len-1);
+       x_dst[max_len-1] = '\0';
+}
+
+void _strlcat_safe(char *x_dst, char *x_src, int max_len)
+{
+       if (!x_src || strlen(x_src) == 0) {
+               audio_svc_error("x_src is NULL");
+               return;
+       }
+
+       if (max_len < 1) {
+               audio_svc_error("length is Wrong");
+               return;
+       }
+       
+    g_strlcat(x_dst, x_src, max_len-1);
+       x_dst[max_len-1] = '\0';
+}
+
+bool _audio_svc_copy_file(const char *srcPath, const char *destPath)
+{
+       FILE *fs = NULL;
+       FILE *fd = NULL;
+       char buff[4096] = {0};
+       int n = 0;
+       int m = 0;
+       bool result = false;
+       bool remove_dest = false;
+
+       fs = fopen(srcPath, "rb");
+       if (fs == NULL) {
+               audio_svc_error("failed to open source file: %s", srcPath);
+               return false;
+       }
+
+
+       fd = fopen(destPath, "wb");
+       if (fd == NULL) {
+               audio_svc_error("failed to open dest file: %s", destPath);
+
+               fclose(fs);
+               return false;
+       }
+
+
+       while (1) {
+               result = feof(fs);
+               if (!result) {
+                       n = fread(buff, sizeof(char), sizeof(buff), fs);
+                       if (n > 0 && n <= sizeof(buff)) {
+                               m = fwrite(buff, sizeof(char), n, fd);
+                               if (m <= 0) {
+                                       audio_svc_debug("fwrite = %d \n", m);
+
+                                       result = false;
+                                       remove_dest = true;
+                                       goto CATCH;
+                               }
+                       } else {
+                               audio_svc_debug("fread = %d \n", n);
+                               result = true;
+                               goto CATCH;
+                       }
+               } else {
+                       result = true;
+                       goto CATCH;
+               }
+       }
+
+CATCH:
+       fflush(fd);
+       fsync(fileno(fd));
+       fclose(fd);
+       fclose(fs);
+
+       if (remove_dest) {
+               remove(destPath);
+               sync();
+       }
+
+       audio_svc_debug("copying file is successful");
+       return result;
+}
+
+bool _audio_svc_make_file(const char *path)
+{
+       FILE *fd = NULL;
+
+       fd = fopen(path, "w");
+       if (fd == NULL) {
+               audio_svc_error("failed to open file: [%s]", path);
+               return FALSE;
+       }
+
+       fclose(fd);
+       
+       return TRUE;
+}
+
+bool _audio_svc_remove_file(const char *path)
+{
+       int result = -1;
+       
+       result = remove(path);
+       if (result == 0) {
+               audio_svc_debug("success to remove file");
+               return TRUE;
+       } else {
+               audio_svc_error("fail to remove file result = %d", result);
+               return FALSE;
+       }
+}
+
+bool _audio_svc_make_directory(const char *path)
+{
+       int result = -1;
+       
+       /* Returns : 0 if the directory already exists, or was successfully created. Returns -1 if an error occurred, with errno set.  */
+       result = g_mkdir_with_parents(path, 0755);      
+       if (result == 0) {
+               audio_svc_debug("success to make directory");
+               return TRUE;
+       } else {
+               audio_svc_error("fail to make directory result = %d", result);
+               return FALSE;
+       }
+}
+
+unsigned int _audio_svc_print_elapse_time(int start_time, const char *log_msg)
+{
+       struct timeval  t;
+       unsigned int tval = 0;
+       gettimeofday(&t, NULL);
+       
+       tval = t.tv_sec*1000000L + t.tv_usec;
+
+       if (start_time == 0) {
+               printf("[%s] start [%u]\n", log_msg, tval);
+       } else {
+               printf("[%s] elapsed time [%u]\n", log_msg, tval - start_time);
+       }
+
+       return tval;
+}
+
+int _audio_svc_get_order_field_str(audio_svc_search_order_e order_field,
+                                                                       char* output_str,
+                                                                       int len)
+{
+       if (output_str == NULL) {
+               audio_svc_debug("output str is NULL");
+               return AUDIO_SVC_ERROR_INTERNAL;
+       }
+
+       switch(order_field) {
+               case AUDIO_SVC_ORDER_BY_TITLE_DESC:
+                       _strncpy_safe(output_str, "title COLLATE NOCASE DESC", len);
+                       break;
+               case AUDIO_SVC_ORDER_BY_TITLE_ASC:
+                       _strncpy_safe(output_str, "title COLLATE NOCASE ASC", len);
+                       break;
+               case AUDIO_SVC_ORDER_BY_ALBUM_DESC:
+                       _strncpy_safe(output_str, "album COLLATE NOCASE DESC", len);
+                       break;
+               case AUDIO_SVC_ORDER_BY_ALBUM_ASC:
+                       _strncpy_safe(output_str, "album COLLATE NOCASE ASC", len);
+                       break;
+               case AUDIO_SVC_ORDER_BY_ARTIST_DESC:
+                       _strncpy_safe(output_str, "artist COLLATE NOCASE DESC", len);
+                       break;
+               case AUDIO_SVC_ORDER_BY_ARTIST_ASC:
+                       _strncpy_safe(output_str, "artist COLLATE NOCASE ASC", len);
+                       break;
+               case AUDIO_SVC_ORDER_BY_GENRE_DESC:
+                       _strncpy_safe(output_str, "genre COLLATE NOCASE DESC", len);
+                       break;
+               case AUDIO_SVC_ORDER_BY_GENRE_ASC:
+                       _strncpy_safe(output_str, "genre COLLATE NOCASE ASC", len);
+                       break;
+               case AUDIO_SVC_ORDER_BY_AUTHOR_DESC:
+                       _strncpy_safe(output_str, "author COLLATE NOCASE DESC", len);
+                       break;
+               case AUDIO_SVC_ORDER_BY_AUTHOR_ASC:
+                       _strncpy_safe(output_str, "author COLLATE NOCASE ASC", len);
+                       break;
+               case AUDIO_SVC_ORDER_BY_PLAY_COUNT_DESC:
+                       _strncpy_safe(output_str, "played_count DESC", len);
+                       break;
+               case AUDIO_SVC_ORDER_BY_PLAY_COUNT_ASC:
+                       _strncpy_safe(output_str, "played_count ASC", len);
+                       break;
+               case AUDIO_SVC_ORDER_BY_ADDED_TIME_DESC:
+                       _strncpy_safe(output_str, "added_time DESC", len);
+                       break;
+               case AUDIO_SVC_ORDER_BY_ADDED_TIME_ASC:
+                       _strncpy_safe(output_str, "added_time ASC", len);
+                       break;
+               default: break;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+int _audio_svc_get_file_dir_modified_date(const char *full_path)
+{
+       struct stat statbuf = { 0 };
+       int fd = 0;
+       fd = stat(full_path, &statbuf);
+       if (fd == -1) {
+                audio_svc_debug("stat(%s) fails.", full_path);
+                return AUDIO_SVC_ERROR_INTERNAL;
+        }
+        return statbuf.st_mtime;
+}
+
diff --git a/src/audio/audio-svc.c b/src/audio/audio-svc.c
new file mode 100755 (executable)
index 0000000..68bcad1
--- /dev/null
@@ -0,0 +1,2710 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <unistd.h>
+#include <stdarg.h>
+#include <db-util.h>
+
+#include "media-info-env.h"
+#include "media-info-util.h"
+#include "audio-svc.h"
+#include "audio-svc-error.h"
+#include "audio-svc-debug.h"
+#include "audio-svc-utils.h"
+#include "audio-svc-music-table.h"
+#include "audio-svc-playlist-table.h"
+#include "audio-svc-types-priv.h"
+#include "audio-svc-db-utils.h"
+
+#define AUDIO_SVC_DATABASE_NAME        "/opt/dbspace/.media.db"
+
+static __thread int g_audio_svc_item_valid_data_cnt = 1;
+static __thread int g_audio_svc_item_valid_cur_data_cnt = 0;
+
+static __thread int g_audio_svc_move_item_data_cnt = 1;
+static __thread int g_audio_svc_move_item_cur_data_cnt = 0;
+
+static __thread int g_audio_svc_insert_item_data_cnt = 1;
+static __thread int g_audio_svc_insert_item_cur_data_cnt = 0;
+
+
+int audio_svc_open(void)
+{
+       int err = -1;
+       int tid = -1;
+
+       audio_svc_debug("");
+
+       err = _media_info_init_handle_tbl();
+       if (err < 0) {
+               audio_svc_debug("Error:_media_info_init_handle_tbl\n");
+               return AUDIO_SVC_ERROR_DB_CONNECT;
+       }
+
+       tid = _media_info_get_thread_id();
+       audio_svc_debug("Current thread id : %d", tid);
+
+       HandleTable *handle_table = NULL;
+       handle_table = _media_info_search_handle(tid);
+
+       if (handle_table == NULL) {
+               audio_svc_debug("A handle in thread [%d] does not exist. So now trying to make connection");
+               int *key_tid = NULL;
+
+               err = _media_info_insert_handle(&key_tid, tid, &handle_table);
+               if (err < 0) {
+                       audio_svc_error("Fail to insert handle");
+                       if (key_tid)    g_free(key_tid);
+                       if (handle_table)       g_free(handle_table);
+                       return AUDIO_SVC_ERROR_DB_CONNECT;
+               }
+
+               sqlite3 *handle = NULL;
+
+               if (db_util_open(MEDIA_INFO_DATABASE_NAME, &handle, DB_UTIL_REGISTER_HOOK_METHOD) != SQLITE_OK) {
+                       audio_svc_error("Unable to open database");
+                       if (handle) audio_svc_error("[sqlite] %s\n", sqlite3_errmsg(handle));
+                       if (key_tid)    g_free(key_tid);
+                       if (handle_table)       g_free(handle_table);
+                       return AUDIO_SVC_ERROR_DB_CONNECT;
+               }
+
+               handle_table->handle = handle;
+
+               /* Register Busy handler */
+               err = sqlite3_busy_handler(handle, _audio_svc_sql_busy_handler, NULL);
+               if (SQLITE_OK != err) {
+                       audio_svc_error("Fail to register busy handler\n");     
+                       if (handle) audio_svc_error("[sqlite] %s\n", sqlite3_errmsg(handle));   
+
+                       db_util_close(handle);
+                       handle = NULL;
+
+                       return AUDIO_SVC_ERROR_DB_CONNECT;
+               }
+
+       } else {
+               audio_svc_debug("A handle in thread [%d] exists. ");
+               _media_info_atomic_add_counting(handle_table);
+       }
+
+       audio_svc_debug("audio_svc_open succeed");
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_close(void)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int err = -1;
+       int tid = -1;
+       audio_svc_debug("");
+
+       tid = _media_info_get_thread_id();
+       audio_svc_debug("Current thread id : %d", tid);
+
+       HandleTable *handle_table = NULL;
+       handle_table = _media_info_search_handle(tid);
+
+       if (handle_table == NULL) {
+               audio_svc_error("handle_table is NULL");
+               return AUDIO_SVC_ERROR_DB_DISCONNECT;
+       } else {
+               audio_svc_debug("ref count in thread[%d] is %d", tid, handle_table->ref_cnt);
+
+               if (handle_table->ref_cnt > 1) {
+                       _media_info_atomic_sub_counting(handle_table);
+               } else {
+                       if (db_util_close(handle_table->handle) != SQLITE_OK) {
+                               audio_svc_error("error closing database: %s\n", sqlite3_errmsg(handle_table->handle));
+                               ret = AUDIO_SVC_ERROR_DB_DISCONNECT;
+                       }
+
+                       err = _media_info_remove_handle(tid);
+                       if (err < 0) {
+                               audio_svc_error
+                                   ("Error:_media_info_remove_handle\n");
+                               return AUDIO_SVC_ERROR_DB_DISCONNECT;
+                       }
+
+                       _media_info_finalize_handle_tbl();
+               }
+       }
+
+       audio_svc_debug("audio_svc_close succeed");
+       return ret;
+}
+
+int audio_svc_create_table(void)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       ret = _audio_svc_create_music_table();
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       ret = _audio_svc_create_playlist_table();
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       ret = _audio_svc_create_folder_table();
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_delete_all(audio_svc_storage_type_e storage_type)
+{
+       char * dirpath = NULL;
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       if (storage_type != AUDIO_SVC_STORAGE_PHONE
+           && storage_type != AUDIO_SVC_STORAGE_MMC) {
+               audio_svc_error("storage type should be phone or mmc");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _audio_svc_truncate_music_table(storage_type);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       /* 20111110, make each thumbnail */
+       /* 20110428, thumbnail path depends on th album ID. So Don't remove all file in special directory. */
+       dirpath = (storage_type == AUDIO_SVC_STORAGE_PHONE) ? AUDIO_SVC_THUMB_PHONE_PATH : AUDIO_SVC_THUMB_MMC_PATH;
+
+       /* remove thumbnails */
+       audio_svc_debug("dirpath [%s]", dirpath);
+       ret = _audio_svc_remove_all_files_in_dir(dirpath);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       /* update folder table */
+       ret = _audio_svc_delete_folder(storage_type, NULL);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+#if 0
+       ret = _audio_svc_check_and_update_albums_table(NULL);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+#endif
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_insert_item_start(int data_cnt)
+{
+       audio_svc_debug("Transaction data count : [%d]", data_cnt);
+
+       if(data_cnt < 1) {
+               audio_svc_error("data_cnt shuld be bigger than 1. data_cnt : [%d]", data_cnt);
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       
+       g_audio_svc_insert_item_data_cnt  = data_cnt;
+       g_audio_svc_insert_item_cur_data_cnt  = 0;
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_insert_item_end(void)
+{
+       audio_svc_debug_func();
+
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       if (g_audio_svc_insert_item_cur_data_cnt  > 0) {
+               
+               ret = _audio_svc_list_query_do(AUDIO_SVC_QUERY_INSERT_ITEM);
+       }
+
+       g_audio_svc_insert_item_data_cnt  = 1;
+       g_audio_svc_insert_item_cur_data_cnt  = 0;
+
+       return ret;
+}
+
+int audio_svc_insert_item(audio_svc_storage_type_e storage_type,
+                         const char *path, audio_svc_category_type_e category)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       if (storage_type != AUDIO_SVC_STORAGE_PHONE
+           && storage_type != AUDIO_SVC_STORAGE_MMC) {
+               audio_svc_error("storage type is incorrect(%d)", storage_type);
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!STRING_VALID(path)) {
+               audio_svc_error("path is NULL");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       audio_svc_debug("storage[%d], path[%s], category[%d]", storage_type, path, category);
+
+       if ((category != AUDIO_SVC_CATEGORY_MUSIC)
+           && (category != AUDIO_SVC_CATEGORY_SOUND)) {
+               audio_svc_error("invalid category condition");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       audio_svc_audio_item_s item;
+       memset(&item, 0, sizeof(audio_svc_audio_item_s));
+
+       item.category = category;
+       item.time_added = time(NULL);
+
+       ret = _audio_svc_extract_metadata_audio(storage_type, path, &item);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       if (g_audio_svc_insert_item_data_cnt == 1) {
+
+               return _audio_svc_insert_item_with_data(&item, FALSE);
+
+       }
+       else if(g_audio_svc_insert_item_cur_data_cnt  < (g_audio_svc_insert_item_data_cnt  - 1)) {
+
+               ret = _audio_svc_insert_item_with_data(&item, TRUE);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+               g_audio_svc_insert_item_cur_data_cnt ++;
+
+       }
+       else if (g_audio_svc_insert_item_cur_data_cnt  == (g_audio_svc_insert_item_data_cnt  - 1)) {
+
+               ret = _audio_svc_insert_item_with_data(&item, TRUE);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+               ret = _audio_svc_list_query_do(AUDIO_SVC_QUERY_INSERT_ITEM);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+               
+               g_audio_svc_insert_item_cur_data_cnt = 0;
+               
+       }
+       else {
+               audio_svc_debug("Error in audio_svc_insert_item");
+               return AUDIO_SVC_ERROR_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_get_item_by_path(const char *path, AudioHandleType * item_handle)
+{
+       if (!STRING_VALID(path)) {
+               audio_svc_error("file path is null");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       audio_svc_audio_item_s *item = (audio_svc_audio_item_s *) item_handle;
+       if (!item) {
+               audio_svc_error("item is null");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       memset(item, 0, sizeof(audio_svc_audio_item_s));
+
+       return _audio_svc_select_music_record_by_path(path, item);
+}
+
+int audio_svc_get_item_by_audio_id(const char *audio_id, AudioHandleType *item_handle)
+{
+       if (!STRING_VALID(audio_id)) {
+               audio_svc_error("invalid audio_id");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       
+       audio_svc_audio_item_s *item = (audio_svc_audio_item_s *) item_handle;
+
+       if (!item) {
+               audio_svc_error("item is null");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       memset(item, 0, sizeof(audio_svc_audio_item_s));
+
+       return _audio_svc_select_music_record_by_audio_id(audio_id, item);
+}
+
+int audio_svc_delete_item_by_path(const char *path)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       if (!STRING_VALID(path)) {
+               audio_svc_error("file path is null");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       audio_svc_audio_item_s item;
+       memset(&item, 0, sizeof(audio_svc_audio_item_s));
+
+       ret = _audio_svc_select_music_record_by_path(path, &item);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       ret = _audio_svc_delete_music_record_by_audio_id(item.audio_id);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       ret = _audio_svc_delete_playlist_item_records_by_audio_id(item.audio_id);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       ret = _audio_svc_check_and_update_folder_table(path);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+#if 0
+       ret = _audio_svc_check_and_update_albums_table(item.audio.album);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+#endif
+#if 0
+       if (strlen(item.thumbname) > 0) {
+               ret = _audio_svc_check_and_remove_thumbnail(item.thumbname);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+       }
+#endif
+       if (strlen(item.thumbname) > 0) {
+               if (_audio_svc_remove_file(item.thumbname) == FALSE) {
+                       audio_svc_error("fail to remove thumbnail file.");
+                       return AUDIO_SVC_ERROR_INTERNAL;
+               }
+       }
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_move_item_start(int data_cnt)
+{
+       audio_svc_debug("Transaction data count : [%d]", data_cnt);
+
+       if(data_cnt < 1) {
+               audio_svc_error("data_cnt shuld be bigger than 1. data_cnt : [%d]", data_cnt);
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       
+       g_audio_svc_move_item_data_cnt  = data_cnt;
+       g_audio_svc_move_item_cur_data_cnt  = 0;
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_move_item_end(void)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       audio_svc_debug_func();
+
+       if (g_audio_svc_move_item_cur_data_cnt  > 0) {
+
+               g_audio_svc_move_item_data_cnt  = 1;
+               g_audio_svc_move_item_cur_data_cnt  = 0;
+
+               ret = _audio_svc_list_query_do(AUDIO_SVC_QUERY_MOVE_ITEM);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+       }
+
+       g_audio_svc_move_item_data_cnt  = 1;
+       g_audio_svc_move_item_cur_data_cnt  = 0;
+
+       ret = _audio_svc_update_folder_table();
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+       
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+//old db was separated into phone and mmc table.
+//so when src_storage and dest_storage is not same, then need to remove old one and insert new one 
+//since audio_id in mmc table is started with over 5000001 . but don't need to do like this anymore.
+int audio_svc_move_item(audio_svc_storage_type_e src_storage,
+                       const char *src_path,
+                       audio_svc_storage_type_e dest_storage,
+                       const char *dest_path)
+{
+       char folder_id[AUDIO_SVC_UUID_SIZE+1] = {0,};
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       if (!STRING_VALID(src_path)) {
+               audio_svc_error("src_path is null");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!STRING_VALID(dest_path)) {
+               audio_svc_error("dest_path is null");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (src_storage != AUDIO_SVC_STORAGE_PHONE
+           && src_storage != AUDIO_SVC_STORAGE_MMC) {
+               audio_svc_error("storage type should be phone or mmc");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (dest_storage != AUDIO_SVC_STORAGE_PHONE
+           && dest_storage != AUDIO_SVC_STORAGE_MMC) {
+               audio_svc_error("storage type should be phone or mmc");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       audio_svc_debug("g_audio_svc_move_item_data_cnt =[%d], g_audio_svc_move_item_cur_data_cnt =[%d]", 
+                               g_audio_svc_move_item_data_cnt , g_audio_svc_move_item_cur_data_cnt );
+
+       if (g_audio_svc_move_item_data_cnt == 1) {
+               /* update path and storage type*/
+               ret = _audio_svc_update_path_and_storage_in_music_record(src_path, dest_path, dest_storage);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+               /* get folder_id */
+               ret = _audio_svc_get_and_append_folder_id_by_path(dest_path, dest_storage, folder_id);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+               /* update folder_id */
+               ret = _audio_svc_update_folder_id_in_music_record(dest_path, folder_id);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+               /* remove old folder path */
+               ret = _audio_svc_check_and_update_folder_table(src_path);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+       }
+       else if (g_audio_svc_move_item_cur_data_cnt  < (g_audio_svc_move_item_data_cnt  - 1)) {
+
+               ret = _audio_svc_get_and_append_folder_id_by_path(dest_path, dest_storage, folder_id);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+               
+               ret = _audio_svc_move_item_query_add(src_path, dest_path, dest_storage, folder_id);
+
+               g_audio_svc_move_item_cur_data_cnt ++;
+       }
+       else if (g_audio_svc_move_item_cur_data_cnt  == (g_audio_svc_move_item_data_cnt  - 1)) {
+
+               ret = _audio_svc_get_and_append_folder_id_by_path(dest_path, dest_storage, folder_id);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+               
+               ret = _audio_svc_move_item_query_add(src_path, dest_path, dest_storage, folder_id);
+
+               ret = _audio_svc_list_query_do(AUDIO_SVC_QUERY_MOVE_ITEM);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+               g_audio_svc_move_item_cur_data_cnt = 0;
+       }
+       else {
+               audio_svc_debug("Error in audio_svc_move_item");
+               return AUDIO_SVC_ERROR_INTERNAL;
+       }
+       
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_refresh_metadata(const char *audio_id)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       if (!STRING_VALID(audio_id)) {
+               audio_svc_error("invalid audio_id");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       
+       audio_svc_audio_item_s item;
+       memset(&item, 0, sizeof(audio_svc_audio_item_s));
+
+       ret = _audio_svc_select_music_record_by_audio_id(audio_id, &item);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       if (item.audio.duration > 0) {
+               audio_svc_debug("The item has already valid metadata");
+               return AUDIO_SVC_ERROR_NONE;
+       }
+
+       ret = _audio_svc_extract_metadata_audio(item.storage_type, item.pathname, &item);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       return _audio_svc_update_metadata_in_music_record(audio_id, &item);
+}
+
+int audio_svc_count_group_item(audio_svc_group_type_e group_type,
+                              const char *limit_string1,
+                              const char *limit_string2,
+                              const char *filter_string,
+                              const char *filter_string2, int *count)
+{
+       if (group_type < AUDIO_SVC_GROUP_BY_ALBUM
+           || group_type > AUDIO_SVC_GROUP_BY_COMPOSER) {
+               audio_svc_error("group type is wrong : %d", group_type);
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if ((group_type == AUDIO_SVC_GROUP_BY_ARTIST_ALBUM ||
+            group_type == AUDIO_SVC_GROUP_BY_GENRE_ARTIST ||
+            group_type == AUDIO_SVC_GROUP_BY_GENRE_ALBUM) &&
+           /* && (!limit_string1 || strlen(limit_string1) == 0)) */
+           (!limit_string1)) {
+               audio_svc_error("limit string1 should be entered");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if ((group_type == AUDIO_SVC_GROUP_BY_GENRE_ARTIST_ALBUM) &&
+           /* &&    (!limit_string2 || strlen(limit_string2) == 0)) */
+           (!limit_string2)) {
+               audio_svc_error("limit_string2 should be entered");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (count == NULL) {
+               audio_svc_error("invalid count condition");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_count_music_group_records(group_type, limit_string1,
+                                                   limit_string2,
+                                                   filter_string,
+                                                   filter_string2, count);
+}
+
+int audio_svc_get_group_item(audio_svc_group_type_e group_type,
+                            const char *limit_string1,
+                            const char *limit_string2,
+                            const char *filter_string,
+                            const char *filter_string2, int offset, int rows,
+                            AudioHandleType *result_records)
+{
+       audio_svc_group_item_s *result_groups =
+           (audio_svc_group_item_s *) result_records;
+
+       if (group_type < AUDIO_SVC_GROUP_BY_ALBUM
+           || group_type > AUDIO_SVC_GROUP_BY_COMPOSER) {
+               audio_svc_error("group type is wrong : %d", group_type);
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if ((group_type == AUDIO_SVC_GROUP_BY_ARTIST_ALBUM ||
+            group_type == AUDIO_SVC_GROUP_BY_GENRE_ARTIST ||
+            group_type == AUDIO_SVC_GROUP_BY_GENRE_ALBUM ||
+            group_type == AUDIO_SVC_GROUP_BY_GENRE_ARTIST_ALBUM) &&
+           /* && (!limit_string1 || strlen(limit_string1) == 0)) */
+           (!limit_string1)) {
+               audio_svc_error("limit_string1 should be entered");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if ((group_type == AUDIO_SVC_GROUP_BY_GENRE_ARTIST_ALBUM) &&
+           /* &&    (!limit_string2 || strlen(limit_string2) == 0)) */
+           (!limit_string2)) {
+               audio_svc_error("limit_string2 should be entered");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (offset < 0 || rows <= 0) {
+               audio_svc_error("offset(%d) or rows value(%d) is wrong", offset,
+                               rows);
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!result_records) {
+               audio_svc_error
+                   ("The memory for search records should be allocated ");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_get_music_group_records(group_type, limit_string1,
+                                                 limit_string2, filter_string,
+                                                 filter_string2, offset, rows,
+                                                 result_groups);
+
+}
+
+int audio_svc_count_list_item(audio_svc_track_type_e item_type,
+                             const char *type_string, const char *type_string2,
+                             const char *filter_string,
+                             const char *filter_string2, int *count)
+{
+       if (item_type < AUDIO_SVC_TRACK_ALL
+           || item_type > AUDIO_SVC_TRACK_BY_PLAYLIST) {
+               audio_svc_error("item type is wrong : %d", item_type);
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (((item_type >= AUDIO_SVC_TRACK_BY_ALBUM)
+            && (item_type <= AUDIO_SVC_TRACK_BY_COMPOSER)) && (!type_string)) {
+               audio_svc_error("type_string should be entered");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (((item_type == AUDIO_SVC_TRACK_BY_ARTIST_GENRE)
+            || (item_type == AUDIO_SVC_TRACK_BY_ARTIST_ALBUM))
+           && (!type_string2)) {
+               audio_svc_error("type_string2 should be entered");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (count == NULL) {
+               audio_svc_error("invalid count condition");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_count_music_track_records(item_type, type_string,
+                                                   type_string2, filter_string,
+                                                   filter_string2, count);
+}
+
+int audio_svc_get_list_item(audio_svc_track_type_e item_type,
+                           const char *type_string, const char *type_string2,
+                           const char *filter_string,
+                           const char *filter_string2, int offset, int rows,
+                           AudioHandleType *track)
+{
+       audio_svc_list_item_s *result_track = (audio_svc_list_item_s *) track;
+
+       if (item_type < AUDIO_SVC_TRACK_ALL
+           || item_type > AUDIO_SVC_TRACK_BY_PLAYLIST) {
+               audio_svc_error("track type is wrong : %d", item_type);
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (((item_type >= AUDIO_SVC_TRACK_BY_ALBUM)
+            && (item_type <= AUDIO_SVC_TRACK_BY_COMPOSER)) && (!type_string)) {
+               audio_svc_error("type_string should be entered");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (((item_type == AUDIO_SVC_TRACK_BY_ARTIST_GENRE)
+            || (item_type == AUDIO_SVC_TRACK_BY_ARTIST_ALBUM))
+           && (!type_string2)) {
+               audio_svc_error("type_string2 should be entered");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (offset < 0 || rows <= 0) {
+               audio_svc_error("offset(%d) or row value(%d) is wrong", offset,
+                               rows);
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!track) {
+               audio_svc_error
+                   ("The memory for search records should be allocated ");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       memset(result_track, 0, sizeof(audio_svc_list_item_s) * rows);
+
+       return _audio_svc_get_music_track_records(item_type, type_string,
+                                                 type_string2, filter_string,
+                                                 filter_string2, offset, rows,
+                                                 result_track);
+
+}
+
+int audio_svc_get_audio_id_by_path(const char *path, char *audio_id, size_t max_audio_id_length)
+{
+       if (!STRING_VALID(path)) {
+               audio_svc_error("file path is null");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (audio_id == NULL) {
+               audio_svc_error("invalid audio_id condition");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_search_audio_id_by_path(path, audio_id);
+}
+
+int audio_svc_get_thumbnail_path_by_path(const char *path, char *thumb_path,
+                                        size_t max_thumb_path_length)
+{
+       if (!STRING_VALID(path)) {
+               audio_svc_error("file path is null");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_get_thumbnail_path_by_path(path, thumb_path);
+}
+
+int audio_svc_add_playlist(const char *playlist_name, int *playlist_id)
+{
+       if (!STRING_VALID(playlist_name)) {
+               audio_svc_error("invalid playlist_name");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (playlist_id == NULL) {
+               audio_svc_error("invalid playlist_id");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_insert_playlist_record(playlist_name, playlist_id);
+}
+
+int audio_svc_delete_playlist(int playlist_id)
+{
+       if (playlist_id < 0) {
+               audio_svc_error("invalid playlist_id");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_delete_playlist_record(playlist_id);
+}
+
+int audio_svc_update_playlist_name(int playlist_id,
+                                  const char *new_playlist_name)
+{
+       if (playlist_id < 0) {
+               audio_svc_error("invalid playlist_id");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!STRING_VALID(new_playlist_name)) {
+               audio_svc_error("invalid playlist_name");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_update_playlist_record_by_name(playlist_id,
+                                                        new_playlist_name);
+}
+
+int audio_svc_count_playlist(const char *filter_string,
+                            const char *filter_string2, int *count)
+{
+       if (count == NULL) {
+               audio_svc_error("invalid count condition");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_count_playlist_records(filter_string, filter_string2,
+                                                count);
+}
+
+int audio_svc_get_playlist(const char *filter_string,
+                          const char *filter_string2, int offset, int rows,
+                          AudioHandleType *playlists)
+{
+       audio_svc_playlist_s *ret_playlists =
+           (audio_svc_playlist_s *) playlists;
+       if (offset < 0 || rows <= 0) {
+               audio_svc_error("offset(%d) or row value(%d) is wrong", offset,
+                               rows);
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!playlists) {
+               audio_svc_error
+                   ("The memory for search records should be allocated ");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_get_playlist_records(offset, rows, filter_string,
+                                              filter_string2, ret_playlists);
+}
+
+int audio_svc_count_playlist_item(int playlist_id, const char *filter_string,
+                                 const char *filter_string2, int *count)
+{
+       if (playlist_id < 0) {
+               audio_svc_error("invalid playlist_id");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (count == NULL) {
+               audio_svc_error("invalid count condition");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_count_playlist_item_records(playlist_id,
+                                                     filter_string,
+                                                     filter_string2, count);
+}
+
+int audio_svc_get_playlist_item(int playlist_id, const char *filter_string,
+                               const char *filter_string2, int offset,
+                               int rows, AudioHandleType *playlist_item)
+{
+       audio_svc_playlist_item_s *ret_playlist_item =
+           (audio_svc_playlist_item_s *) playlist_item;
+
+       if (offset < 0 || rows <= 0) {
+               audio_svc_error("offset(%d) or row value(%d) is wrong", offset,
+                               rows);
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!playlist_item) {
+               audio_svc_error
+                   ("The memory for search records should be allocated ");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       memset(ret_playlist_item, 0, sizeof(audio_svc_playlist_item_s) * rows);
+
+       return _audio_svc_get_playlist_item_records(playlist_id, filter_string,
+                                                   filter_string2, offset,
+                                                   rows, ret_playlist_item);
+}
+
+int audio_svc_get_playlist_id_by_playlist_name(const char *playlist_name,
+                                              int *playlist_id)
+{
+       if (!STRING_VALID(playlist_name)) {
+               audio_svc_error("invalid playlist_name");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (playlist_id == NULL) {
+               audio_svc_error("invalid playlist_id");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_get_playlist_id_by_name(playlist_name, playlist_id);
+}
+
+int audio_svc_get_playlist_name_by_playlist_id(int playlist_id,
+                                              char *playlist_name,
+                                              size_t max_playlist_name_length)
+{
+       if (playlist_id < 0) {
+               audio_svc_error("invalid playlist_id");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_get_playlist_name_by_playlist_id(playlist_id,
+                                                          playlist_name);
+}
+
+int audio_svc_count_playlist_by_name(const char *playlist_name, int *count)
+{
+       if (!STRING_VALID(playlist_name)) {
+               audio_svc_error("invalid playlist_name");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (count == NULL) {
+               audio_svc_error("invalid count condition");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_count_playlist_records_by_name(playlist_name, count);
+}
+
+int audio_svc_get_unique_playlist_name(const char *orig_name, char *unique_name,
+                                      size_t max_unique_name_length)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int count = -1;
+
+       char playlist_name[AUDIO_SVC_PLAYLIST_NAME_SIZE] = { 0 };
+
+       if (!STRING_VALID(orig_name)) {
+               audio_svc_error("orig_name is NULL");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       snprintf(playlist_name, sizeof(playlist_name), "%s_001", orig_name);
+       ret = audio_svc_count_playlist_by_name(playlist_name, &count);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       if (count > 0) {
+               int i = 1;
+               while (i < 1000) {
+                       count = -1;
+                       snprintf(unique_name, AUDIO_SVC_PLAYLIST_NAME_SIZE,
+                                "%s_%.3d", orig_name, i + 1);
+                       ret =
+                           audio_svc_count_playlist_by_name(unique_name,
+                                                            &count);
+                       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+                       if (count == 0) {
+                               return AUDIO_SVC_ERROR_NONE;
+                       } else {
+                               i++;
+                       }
+               }
+
+               return AUDIO_SVC_ERROR_MAKE_PLAYLIST_NAME_FAILED;
+
+       } else {
+               snprintf(unique_name, AUDIO_SVC_PLAYLIST_NAME_SIZE, "%s_%.3d", orig_name, 1);   /* hjkim, 101006, return My playlist_001 */
+               return AUDIO_SVC_ERROR_NONE;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_add_item_to_playlist(int playlist_id, const char *audio_id)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       
+       if (playlist_id < 0) {
+               audio_svc_error("invalid playlist idx");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!STRING_VALID(audio_id)) {
+               audio_svc_error("invalid audio_id");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       
+       ret = _audio_svc_insert_playlist_item_record(playlist_id, audio_id);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+       
+       if (playlist_id == AUDIO_SVC_FAVORITE_LIST_ID) {
+               ret = _audio_svc_update_favourite_in_music_record(audio_id, 1);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);            
+       }
+
+       return ret;
+}
+
+int audio_svc_check_duplicate_insertion_in_playlist(int playlist_id,
+                                                   const char *audio_id, int *count)
+{
+       if (playlist_id < 0) {
+               audio_svc_error("invalid playlist idx");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!STRING_VALID(audio_id)) {
+               audio_svc_error("invalid audio_id");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (count == NULL) {
+               audio_svc_error("invalid count condition");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_check_duplication_records_in_playlist(playlist_id, audio_id, count);
+}
+
+int audio_svc_update_playlist_item_play_order(int playlist_id, int uid,
+                                             int new_play_order)
+{
+       if (playlist_id < 0) {
+               audio_svc_error("invalid playlist id");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (new_play_order < 0) {
+               audio_svc_error("invalid play_order idx");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       if (uid <= 0) {
+               audio_svc_error("invalid uid");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_update_item_play_order(playlist_id, uid,
+                                                new_play_order);
+}
+
+int audio_svc_remove_item_from_playlist_by_uid(int playlist_id, int uid)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       char audio_id[AUDIO_SVC_UUID_SIZE + 1] = {0, };
+       
+       if (playlist_id < 0) {
+               audio_svc_error("invalid playlist idx");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (uid <= 0) {
+               audio_svc_error("invalid audio_id");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (playlist_id == AUDIO_SVC_FAVORITE_LIST_ID) {
+
+               ret = _audio_svc_get_audio_id_by_uid(uid, audio_id);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+               ret = _audio_svc_update_favourite_in_music_record(audio_id, 0);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+       }
+
+       ret = _audio_svc_delete_playlist_item_record_from_playlist_by_uid(playlist_id, uid);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       return ret;
+}
+
+int audio_svc_remove_item_from_playlist_by_audio_id(int playlist_id,
+                                                   const char *audio_id)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       
+       if (playlist_id < 0) {
+               audio_svc_error("invalid playlist idx");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!STRING_VALID(audio_id)) {
+               audio_svc_error("invalid audio_id");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _audio_svc_delete_playlist_item_record_from_playlist_by_audio_id(playlist_id, audio_id);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       if (playlist_id == AUDIO_SVC_FAVORITE_LIST_ID) {
+               ret = _audio_svc_update_favourite_in_music_record(audio_id, 0);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+       }
+
+       return ret;
+}
+
+int audio_svc_set_db_valid(audio_svc_storage_type_e storage_type, int valid)
+{
+       audio_svc_debug("storage:%d", storage_type);
+       if (storage_type != AUDIO_SVC_STORAGE_PHONE
+           && storage_type != AUDIO_SVC_STORAGE_MMC) {
+               audio_svc_debug("storage type should be phone or mmc");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return _audio_svc_update_valid_of_music_records(storage_type, valid);
+}
+
+int audio_svc_delete_invalid_items(audio_svc_storage_type_e storage_type)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       if (storage_type != AUDIO_SVC_STORAGE_PHONE 
+               && storage_type != AUDIO_SVC_STORAGE_MMC) {
+               audio_svc_debug("storage type should be phone or mmc");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       
+       ret = _audio_svc_delete_invalid_music_records(storage_type);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       ret = _audio_svc_update_folder_table();
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+#if 0
+       ret = _audio_svc_check_and_update_albums_table(NULL);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+#endif
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_set_item_valid_start(int data_cnt)
+{
+       audio_svc_debug("Transaction data count : [%d]", data_cnt);
+
+       if(data_cnt < 1) {
+               audio_svc_error("data_cnt shuld be bigger than 1. data_cnt : [%d]", data_cnt);
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       
+       g_audio_svc_item_valid_data_cnt  = data_cnt;
+       g_audio_svc_item_valid_cur_data_cnt  = 0;
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_set_item_valid_end(void)
+{
+       audio_svc_debug_func();
+
+       int ret = AUDIO_SVC_ERROR_NONE;
+       
+       if (g_audio_svc_item_valid_cur_data_cnt  > 0) {
+               
+               ret = _audio_svc_list_query_do(AUDIO_SVC_QUERY_SET_ITEM_VALID);
+
+       }
+
+       g_audio_svc_item_valid_data_cnt  = 1;
+       g_audio_svc_item_valid_cur_data_cnt  = 0;
+
+       return ret;
+}
+
+int audio_svc_set_item_valid(const char *path, int valid)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       
+       audio_svc_debug("path=[%s], valid=[%d]", path, valid);
+
+       if (!STRING_VALID(path)) {
+               audio_svc_error("path is NULL");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       
+#if 0  //original code
+       return _audio_svc_update_valid_in_music_record(path, valid);
+
+#else  //hjkim, 110909, stack up querys and commit it at once when query counts are same as g_audio_svc_item_valid_data_cnt 
+
+       audio_svc_debug("g_audio_svc_item_valid_data_cnt =[%d], g_audio_svc_item_valid_cur_data_cnt =[%d]", 
+                       g_audio_svc_item_valid_data_cnt , g_audio_svc_item_valid_cur_data_cnt );
+
+       if (g_audio_svc_item_valid_data_cnt  == 1) {
+               
+               return _audio_svc_update_valid_in_music_record(path, valid);
+               
+       } else if (g_audio_svc_item_valid_cur_data_cnt  < (g_audio_svc_item_valid_data_cnt  - 1)) {
+
+               ret = _audio_svc_update_valid_in_music_record_query_add(path, valid);
+
+               g_audio_svc_item_valid_cur_data_cnt ++; 
+               
+       } else if (g_audio_svc_item_valid_cur_data_cnt  == (g_audio_svc_item_valid_data_cnt  - 1)) {
+       
+               ret = _audio_svc_update_valid_in_music_record_query_add(path, valid);
+
+               ret = _audio_svc_list_query_do(AUDIO_SVC_QUERY_SET_ITEM_VALID);
+               audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+               g_audio_svc_item_valid_cur_data_cnt  = 0;
+               
+       } else {
+       
+               audio_svc_debug("Error in audio_svc_set_item_valid");
+               return AUDIO_SVC_ERROR_INTERNAL;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+#endif
+}
+
+int audio_svc_get_path_by_audio_id(const char *audio_id, char *path,
+                                  size_t max_path_length)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+
+       if (!STRING_VALID(audio_id)) {
+               audio_svc_error("invalid audio_id");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       
+       if (!path) {
+               audio_svc_error("path must be allocated...");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _audio_svc_get_path(audio_id, path);
+       audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_group_item_new(AudioHandleType **record, int count)
+{
+       if (count < 1) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       audio_svc_debug("count is [%d]", count);
+       audio_svc_group_item_s *grp_item =
+           (audio_svc_group_item_s *) malloc(count *
+                                             sizeof(audio_svc_group_item_s));
+       if (grp_item == NULL) {
+               return AUDIO_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       memset(grp_item, 0, count * sizeof(audio_svc_group_item_s));
+
+       *record = (AudioHandleType *) grp_item;
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_group_item_free(AudioHandleType *record)
+{
+       audio_svc_group_item_s *item = (audio_svc_group_item_s *) record;
+
+       if (!item) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       audio_svc_debug_func();
+       SAFE_FREE(item);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_group_item_get_val(AudioHandleType *record, int index,
+                                audio_svc_group_item_type_e first_field_name,
+                                ...)
+{
+       audio_svc_group_item_s *item = (audio_svc_group_item_s *) record;
+       va_list var_args;
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int field_name = -1;
+
+       if (!record) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (index < 0) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (first_field_name == -1) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       field_name = first_field_name;
+       va_start(var_args, first_field_name);
+
+       while (field_name >= 0) {
+               audio_svc_debug("field name = %d", field_name);
+               switch (field_name) {
+               case AUDIO_SVC_GROUP_ITEM_MAIN_INFO:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item[index].maininfo) == 0) {
+                                       audio_svc_debug("maininfo is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item[index].maininfo;
+                                       *size = strlen(item[index].maininfo);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_GROUP_ITEM_SUB_INFO:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item[index].subinfo) == 0) {
+                                       audio_svc_debug("subinfo is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item[index].subinfo;
+                                       *size = strlen(item[index].subinfo);
+                               }
+
+                               break;
+                       }
+               case AUDIO_SVC_GROUP_ITEM_RATING:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item[index].album_rating;
+                               break;
+                       }
+               case AUDIO_SVC_GROUP_ITEM_THUMBNAIL_PATH:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item[index].thumbnail_path) == 0) {
+                                       audio_svc_debug("thumb path is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item[index].thumbnail_path;
+                                       *size =
+                                           strlen(item[index].thumbnail_path);
+                               }
+
+                               break;
+                       }
+               default:
+                       {
+                               audio_svc_error("Invalid arguments");
+                               ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               break;
+                       }
+               }
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       audio_svc_error("error occured");
+                       va_end(var_args);
+                       return ret;
+               }
+               /* next field */
+               field_name = va_arg(var_args, int);
+       }
+
+       va_end(var_args);
+       return ret;
+}
+
+int audio_svc_group_item_get(AudioHandleType *record, int index,
+                            AudioHandleType **item)
+{
+       audio_svc_group_item_s *item_arr = (audio_svc_group_item_s *) record;
+
+       if (!item_arr) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       *item = (AudioHandleType *) &(item_arr[index]);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_list_item_new(AudioHandleType **record, int count)
+{
+       if (count < 1) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       audio_svc_debug("count is [%d]", count);
+       audio_svc_list_item_s *list_item =
+           (audio_svc_list_item_s *) malloc(count *
+                                            sizeof(audio_svc_list_item_s));
+       if (list_item == NULL) {
+               return AUDIO_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       memset(list_item, 0, count * sizeof(audio_svc_list_item_s));
+
+       *record = (AudioHandleType *) list_item;
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_list_item_free(AudioHandleType *record)
+{
+       audio_svc_list_item_s *item = (audio_svc_list_item_s *) record;
+
+       if (!item) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       audio_svc_debug_func();
+       SAFE_FREE(item);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_list_item_get_val(AudioHandleType *record, int index,
+                               audio_svc_list_item_type_e first_field_name,
+                               ...)
+{
+       audio_svc_list_item_s *item = (audio_svc_list_item_s *) record;
+       va_list var_args;
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int field_name = -1;
+
+       if (!record) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (index < 0) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (first_field_name == -1) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       field_name = first_field_name;
+       va_start(var_args, first_field_name);
+
+       while (field_name >= 0) {
+               switch (field_name) {
+               case AUDIO_SVC_LIST_ITEM_AUDIO_ID:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item[index].audio_id) == 0) {
+                                       audio_svc_error("audio_id is NULL");
+                                       *size = 0;
+                                       ret = AUDIO_SVC_ERROR_DB_NO_RECORD;
+                               } else {
+                                       *val = item[index].audio_id;
+                                       *size = strlen(item[index].audio_id);                           
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_LIST_ITEM_PATHNAME:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item[index].pathname) == 0) {
+                                       audio_svc_debug("path is NULL");
+                                       *size = 0;
+                                       ret = AUDIO_SVC_ERROR_DB_NO_RECORD;
+                               } else {
+                                       *val = item[index].pathname;
+                                       *size = strlen(item[index].pathname);
+                               }
+
+                               break;
+                       }
+               case AUDIO_SVC_LIST_ITEM_DURATION:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item[index].duration;
+                               break;
+                       }
+               case AUDIO_SVC_LIST_ITEM_RATING:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item[index].rating;
+                               break;
+                       }
+               case AUDIO_SVC_LIST_ITEM_THUMBNAIL_PATH:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item[index].thumbnail_path) == 0) {
+                                       audio_svc_debug("thumb path is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item[index].thumbnail_path;
+                                       *size =
+                                           strlen(item[index].thumbnail_path);
+                               }
+
+                               break;
+                       }
+               case AUDIO_SVC_LIST_ITEM_TITLE:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item[index].title) == 0) {
+                                       audio_svc_debug("title is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item[index].title;
+                                       *size = strlen(item[index].title);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_LIST_ITEM_ARTIST:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item[index].artist) == 0) {
+                                       audio_svc_debug("artist is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item[index].artist;
+                                       *size = strlen(item[index].artist);
+                               }
+
+                               break;
+                       }
+               default:
+                       {
+                               audio_svc_error("Invalid arguments");
+                               ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               break;
+                       }
+               }
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       audio_svc_error("error occured");
+                       va_end(var_args);
+                       return ret;
+               }
+               /* next field */
+               field_name = va_arg(var_args, int);
+       }
+
+       va_end(var_args);
+       return ret;
+}
+
+int audio_svc_list_item_get(AudioHandleType *record, int index,
+                           AudioHandleType **item)
+{
+       audio_svc_list_item_s *item_arr = (audio_svc_list_item_s *) record;
+
+       if (!item_arr) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       *item = (AudioHandleType *) &(item_arr[index]);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_playlist_new(AudioHandleType **record, int count)
+{
+       if (count < 1) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       audio_svc_debug("");
+
+       audio_svc_playlist_s *playlist =
+           (audio_svc_playlist_s *) malloc(count *
+                                           sizeof(audio_svc_playlist_s));
+       if (playlist == NULL) {
+               return AUDIO_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       memset(playlist, 0, count * sizeof(audio_svc_playlist_s));
+
+       *record = (AudioHandleType *) playlist;
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_playlist_free(AudioHandleType *record)
+{
+       audio_svc_playlist_s *item = (audio_svc_playlist_s *) record;
+
+       if (!item) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       SAFE_FREE(item);
+
+       return AUDIO_SVC_ERROR_NONE;
+
+}
+
+int audio_svc_playlist_get_val(AudioHandleType *playlists, int index,
+                              audio_svc_playlist_e first_field_name, ...)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       va_list var_args;
+       int field_name;
+       audio_svc_playlist_s *item = (audio_svc_playlist_s *) playlists;
+
+       if (!playlists) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (index < 0) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (first_field_name == -1) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       field_name = first_field_name;
+       va_start(var_args, first_field_name);
+
+       while (field_name >= 0) {
+               audio_svc_debug("field name = %d", field_name);
+               switch (field_name) {
+               case AUDIO_SVC_PLAYLIST_ID:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item[index].playlist_id;
+                               break;
+                       }
+               case AUDIO_SVC_PLAYLIST_NAME:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item[index].name) == 0) {
+                                       audio_svc_error("name is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item[index].name;
+                                       /* *size = AUDIO_SVC_PLAYLIST_NAME_SIZE; */
+                                       *size = strlen(item[index].name);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_PLAYLIST_THUMBNAIL_PATH:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item[index].thumbnail_path) == 0) {
+                                       audio_svc_error
+                                           ("thumbnail_path is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item[index].thumbnail_path;
+                                       *size =
+                                           strlen(item[index].thumbnail_path);
+                               }
+                               break;
+                       }
+               default:
+                       {
+                               audio_svc_error("Invalid arguments");
+                               ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               break;
+                       }
+               }
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       audio_svc_error("error occured");
+                       va_end(var_args);
+                       return ret;
+               }
+               /* next field */
+               field_name = va_arg(var_args, int);
+       }
+
+       va_end(var_args);
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_playlist_set_val(AudioHandleType *playlists, int index,
+                              audio_svc_playlist_e first_field_name, ...)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       va_list var_args;
+       int field_name;
+       audio_svc_playlist_s *item = (audio_svc_playlist_s *) playlists;
+
+       if (!playlists) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (index < 0) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (first_field_name == -1) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       field_name = first_field_name;
+       va_start(var_args, first_field_name);
+
+       while (field_name >= 0) {
+               audio_svc_debug("field name = %d", field_name);
+               switch (field_name) {
+               case AUDIO_SVC_PLAYLIST_NAME:
+                       {
+                               char *val = va_arg((var_args), char *);
+                               int size = va_arg((var_args), int);
+                               _strncpy_safe(item[index].name, val,
+                                             min(size + 1,
+                                                 sizeof(item[index].name)));
+                               break;
+                       }
+               default:
+                       {
+                               audio_svc_error("Invalid arguments");
+                               ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               break;
+                       }
+               }
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       audio_svc_error("error occured");
+                       va_end(var_args);
+                       return ret;
+               }
+               /* next field */
+               field_name = va_arg(var_args, int);
+       }
+
+       va_end(var_args);
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_playlist_get_item(AudioHandleType *record, int index,
+                               AudioHandleType **plst)
+{
+       if (!record) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       audio_svc_playlist_s *plst_arr = (audio_svc_playlist_s *) record;
+       *plst = (AudioHandleType *) &(plst_arr[index]);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_playlist_item_new(AudioHandleType **record, int count)
+{
+       if (count < 1) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       audio_svc_debug("");
+
+       audio_svc_playlist_item_s *plst_item =
+           (audio_svc_playlist_item_s *) malloc(count *
+                                                sizeof
+                                                (audio_svc_playlist_item_s));
+       if (plst_item == NULL) {
+               return AUDIO_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       memset(plst_item, 0, count * sizeof(audio_svc_playlist_item_s));
+
+       *record = (AudioHandleType *) plst_item;
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_playlist_item_free(AudioHandleType *record)
+{
+       audio_svc_playlist_item_s *item = (audio_svc_playlist_item_s *) record;
+
+       if (!item) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       audio_svc_debug_func();
+       SAFE_FREE(item);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_playlist_item_get_val(AudioHandleType *record, int index,
+                                   audio_svc_playlist_item_type_e
+                                   first_field_name, ...)
+{
+       audio_svc_playlist_item_s *item = (audio_svc_playlist_item_s *) record;
+       va_list var_args;
+       int ret = AUDIO_SVC_ERROR_NONE;
+       int field_name = -1;
+
+       if (!record) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (index < 0) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (first_field_name == -1) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       field_name = first_field_name;
+       va_start(var_args, first_field_name);
+
+       while (field_name >= 0) {
+               audio_svc_debug("field name = %d", field_name);
+               switch (field_name) {
+               case AUDIO_SVC_PLAYLIST_ITEM_UID:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item[index].u_id;
+                               break;
+                       }
+               case AUDIO_SVC_PLAYLIST_ITEM_AUDIO_ID:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item[index].audio_id) == 0) {
+                                       audio_svc_error("audio_id is NULL");
+                                       *size = 0;
+                                       ret = AUDIO_SVC_ERROR_DB_NO_RECORD;
+                               } else {
+                                       *val = item[index].audio_id;
+                                       *size = strlen(item[index].audio_id);                           
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_PLAYLIST_ITEM_PATHNAME:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item[index].pathname) == 0) {
+                                       audio_svc_debug("path is NULL");
+                                       *size = 0;
+                                       ret = AUDIO_SVC_ERROR_DB_NO_RECORD;
+                               } else {
+                                       *val = item[index].pathname;
+                                       *size = strlen(item[index].pathname);
+                               }
+
+                               break;
+                       }
+               case AUDIO_SVC_PLAYLIST_ITEM_DURATION:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item[index].duration;
+                               break;
+                       }
+               case AUDIO_SVC_PLAYLIST_ITEM_RATING:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item[index].rating;
+                               break;
+                       }
+               case AUDIO_SVC_PLAYLIST_ITEM_THUMBNAIL_PATH:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item[index].thumbnail_path) == 0) {
+                                       audio_svc_debug("thumb path is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item[index].thumbnail_path;
+                                       *size =
+                                           strlen(item[index].thumbnail_path);
+                               }
+
+                               break;
+                       }
+               case AUDIO_SVC_PLAYLIST_ITEM_TITLE:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item[index].title) == 0) {
+                                       audio_svc_debug("title is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item[index].title;
+                                       *size = strlen(item[index].title);
+                               }
+                               break;
+                       }
+
+               case AUDIO_SVC_PLAYLIST_ITEM_ARTIST:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item[index].artist) == 0) {
+                                       audio_svc_debug("artist is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item[index].artist;
+                                       *size = strlen(item[index].artist);
+                               }
+
+                               break;
+                       }
+               case AUDIO_SVC_PLAYLIST_ITEM_PLAY_ORDER:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item[index].play_order;
+                               break;
+                       }
+               default:
+                       {
+                               audio_svc_error("Invalid arguments");
+                               ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               break;
+                       }
+               }
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       audio_svc_error("error occured");
+                       va_end(var_args);
+                       return ret;
+               }
+               /* next field */
+               field_name = va_arg(var_args, int);
+       }
+
+       va_end(var_args);
+       return ret;
+}
+
+int audio_svc_playlist_item_get(AudioHandleType *record, int index,
+                               AudioHandleType **item)
+{
+       audio_svc_playlist_item_s *item_arr =
+           (audio_svc_playlist_item_s *) record;
+
+       if (!item_arr) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       *item = (AudioHandleType *) &(item_arr[index]);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_item_new(AudioHandleType **record)
+{
+       int count = 1;
+
+       audio_svc_debug("count is [%d]", count);
+       audio_svc_audio_item_s *item =
+           (audio_svc_audio_item_s *) malloc(count *
+                                             sizeof(audio_svc_audio_item_s));
+       if (item == NULL) {
+               return AUDIO_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       memset(item, 0, count * sizeof(audio_svc_audio_item_s));
+
+       *record = (AudioHandleType *) item;
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_item_free(AudioHandleType *record)
+{
+       audio_svc_audio_item_s *item = (audio_svc_audio_item_s *) record;
+
+       if (!item) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       audio_svc_debug_func();
+       SAFE_FREE(item);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_item_get_val(AudioHandleType *record,
+                          audio_svc_track_data_type_e first_field_name, ...)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       va_list var_args;
+       int field_name;
+       audio_svc_audio_item_s *item = (audio_svc_audio_item_s *) record;
+       audio_svc_debug_func();
+       if (!item) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (first_field_name == -1) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       field_name = first_field_name;
+       va_start(var_args, first_field_name);
+
+       while (field_name >= 0) {
+               audio_svc_debug("field name = %d", field_name);
+               switch (field_name) {
+               case AUDIO_SVC_TRACK_DATA_STORAGE:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item->storage_type;
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_AUDIO_ID:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item->audio_id) == 0) {
+                                       audio_svc_error("audio_id is NULL");
+                                       *size = 0;
+                                       ret = AUDIO_SVC_ERROR_DB_NO_RECORD;
+                               } else {
+                                       *size = strlen(item->audio_id);
+                                       *val = item->audio_id;
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_PLAYED_COUNT:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item->played_count;
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_PLAYED_TIME:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item->time_played;
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_ADDED_TIME:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item->time_added;
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_RATING:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item->rating;
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_CATEGORY:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item->category;
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_PATHNAME:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item->pathname) == 0) {
+                                       audio_svc_error("pah is NULL");
+                                       *size = 0;
+                                       ret = AUDIO_SVC_ERROR_DB_NO_RECORD;
+                               } else {
+                                       *size = strlen(item->pathname);
+                                       *val = item->pathname;
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_THUMBNAIL_PATH:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item->thumbname) == 0) {
+                                       audio_svc_debug("thumbname is NULL");
+                                       *size = 0;
+                               } else {
+                                       *size = strlen(item->thumbname);
+                                       *val = item->thumbname;
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_TITLE:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item->audio.title) == 0) {
+                                       audio_svc_debug("title is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item->audio.title;
+                                       *size = strlen(item->audio.title);
+                                       audio_svc_debug("title = [%s][%d]",
+                                                       *val, *size);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_ARTIST:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item->audio.artist) == 0) {
+                                       audio_svc_debug("artist is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item->audio.artist;
+                                       *size = strlen(item->audio.artist);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_ALBUM:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item->audio.album) == 0) {
+                                       audio_svc_debug("album is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item->audio.album;
+                                       *size = strlen(item->audio.album);
+                                       audio_svc_debug("album = %s", *val);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_GENRE:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item->audio.genre) == 0) {
+                                       audio_svc_debug("genre is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item->audio.genre;
+                                       *size = strlen(item->audio.genre);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_AUTHOR:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item->audio.author) == 0) {
+                                       audio_svc_debug("author is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item->audio.author;
+                                       *size = strlen(item->audio.author);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_COPYRIGHT:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item->audio.copyright) == 0) {
+                                       audio_svc_debug("copyright is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item->audio.copyright;
+                                       *size = strlen(item->audio.copyright);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_DESCRIPTION:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item->audio.description) == 0) {
+                                       audio_svc_debug("description is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item->audio.description;
+                                       *size = strlen(item->audio.description);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_FORMAT:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item->audio.format) == 0) {
+                                       audio_svc_debug("format is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item->audio.format;
+                                       *size = strlen(item->audio.format);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_DURATION:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item->audio.duration;
+                               break;
+                       }
+
+               case AUDIO_SVC_TRACK_DATA_BITRATE:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item->audio.bitrate;
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_YEAR:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item->audio.year) == 0) {
+                                       audio_svc_debug("year is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item->audio.year;
+                                       *size = strlen(item->audio.year);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_TRACK_NUM:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item->audio.track;
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_FAVOURATE:
+                       {
+                               int *val = va_arg((var_args), int *);
+                               *val = item->favourate;
+                               break;
+                       }
+               default:
+                       {
+                               audio_svc_error("Invalid arguments");
+                               ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               break;
+                       }
+               }
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       audio_svc_error("error occured");
+                       va_end(var_args);
+                       return ret;
+               }
+               /* next field */
+               field_name = va_arg(var_args, int);
+       }
+
+       va_end(var_args);
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_search_item_new(AudioHandleType **record, int count)
+{
+       audio_svc_debug("count is [%d]", count);
+
+       audio_svc_audio_item_s *item =
+           (audio_svc_audio_item_s *) malloc(count *
+                                             sizeof(audio_svc_audio_item_s));
+
+       if (item == NULL) {
+               return AUDIO_SVC_ERROR_OUT_OF_MEMORY;
+       }
+
+       memset(item, 0, count * sizeof(audio_svc_audio_item_s));
+
+       *record = (AudioHandleType *) item;
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_search_item_get(AudioHandleType *record, int index,
+                           AudioHandleType **item)
+{
+       audio_svc_audio_item_s *item_arr = (audio_svc_audio_item_s *) record;
+
+       if (!item_arr) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       *item = (AudioHandleType *) &(item_arr[index]);
+       if (*item == NULL) {
+               audio_svc_error("Index is invalid");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_search_item_free(AudioHandleType *record)
+{
+       audio_svc_audio_item_s *item = (audio_svc_audio_item_s *) record;
+
+       if (!item) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       audio_svc_debug_func();
+       SAFE_FREE(item);
+
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_update_item_metadata(const char *audio_id,
+                                  audio_svc_track_data_type_e first_field_name,
+                                  ...)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       va_list var_args;
+       int field_name = -1;
+
+       if (!STRING_VALID(audio_id)) {
+               audio_svc_error("invalid audio_id");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+       
+       if (first_field_name == -1) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       field_name = first_field_name;
+       va_start(var_args, first_field_name);
+
+       while (field_name >= 0) {
+               audio_svc_debug("field name = %d", field_name);
+               switch (field_name) {
+               case AUDIO_SVC_TRACK_DATA_PLAYED_COUNT:
+                       {
+                               int val = va_arg((var_args), int);
+                               if (val < 0) {
+                                       audio_svc_error("play count should be positive value");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       ret = _audio_svc_update_playcount_in_music_record(audio_id, val);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_PLAYED_TIME:
+                       {
+                               int val = va_arg((var_args), int);
+                               if (val < 0) {
+                                       audio_svc_error("play time should be positive value");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       ret = _audio_svc_update_playtime_in_music_record(audio_id, val);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_ADDED_TIME:
+                       {
+                               int val = va_arg((var_args), int);
+                               if (val < 0) {
+                                       audio_svc_error("added time should be positive value");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       ret = _audio_svc_update_addtime_in_music_record(audio_id, val);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_RATING:
+                       {
+                               int val = va_arg((var_args), int);
+                               if (val < AUDIO_SVC_RATING_NONE
+                                   || val > AUDIO_SVC_RATING_5) {
+                                       audio_svc_error("rating value should be between 0 and 5");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       ret = _audio_svc_update_rating_in_music_record(audio_id, val);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_TITLE:
+                       {
+                               char *val = va_arg((var_args), char *);
+                               int size = va_arg((var_args), int);
+
+                               /* title can not be NULL by UX */
+                               if (val == NULL) {
+                                       audio_svc_error("title can not be NULL");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else if (size >
+                                          AUDIO_SVC_METADATA_LEN_MAX - 1) {
+                                       audio_svc_error("text size should be shorter than AUDIO_SVC_METADATA_LEN_MAX");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       ret = _audio_svc_update_title_in_music_record(audio_id, val);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_ARTIST:
+                       {
+                               char *val = va_arg((var_args), char *);
+                               int size = va_arg((var_args), int);
+                               if (size > AUDIO_SVC_METADATA_LEN_MAX - 1) {
+                                       audio_svc_error("text size should be shorter than AUDIO_SVC_METADATA_LEN_MAX");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       if (val == NULL) {
+                                               val = AUDIO_SVC_TAG_UNKNOWN;
+                                       }
+                                       ret =_audio_svc_update_artist_in_music_record(audio_id, val);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_ALBUM:
+                       {
+                               char *val = va_arg((var_args), char *);
+                               int size = va_arg((var_args), int);
+                               if (size > AUDIO_SVC_METADATA_LEN_MAX - 1) {
+                                       audio_svc_error("text size should be shorter than AUDIO_SVC_METADATA_LEN_MAX");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       if (val == NULL) {
+                                               val = AUDIO_SVC_TAG_UNKNOWN;
+                                       }
+                                       ret = _audio_svc_update_album_in_music_record(audio_id, val);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_GENRE:
+                       {
+                               char *val = va_arg((var_args), char *);
+                               int size = va_arg((var_args), int);
+                               if (size > AUDIO_SVC_METADATA_LEN_MAX - 1) {
+                                       audio_svc_error("text size should be shorter than AUDIO_SVC_METADATA_LEN_MAX");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       if (val == NULL) {
+                                               val = AUDIO_SVC_TAG_UNKNOWN;
+                                       }
+                                       ret = _audio_svc_update_genre_in_music_record(audio_id, val);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_AUTHOR:
+                       {
+                               char *val = va_arg((var_args), char *);
+                               int size = va_arg((var_args), int);
+                               if (size > AUDIO_SVC_METADATA_LEN_MAX - 1) {
+                                       audio_svc_error("text size should be shorter than AUDIO_SVC_METADATA_LEN_MAX");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       if (val == NULL) {
+                                               val = AUDIO_SVC_TAG_UNKNOWN;
+                                       }
+                                       ret = _audio_svc_update_author_in_music_record(audio_id, val);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_DESCRIPTION:
+                       {
+                               char *val = va_arg((var_args), char *);
+                               int size = va_arg((var_args), int);
+                               if (size > AUDIO_SVC_METADATA_LEN_MAX - 1) {
+                                       audio_svc_error("text size should be shorter than AUDIO_SVC_METADATA_LEN_MAX");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       ret = _audio_svc_update_description_in_music_record(audio_id, val);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_YEAR:
+                       {
+                               int val = va_arg((var_args), int);
+                               if (val < 0) {
+                                       audio_svc_error("year should be positive value");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       ret = _audio_svc_update_year_in_music_record(audio_id, val);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_TRACK_NUM:
+                       {
+                               int val = va_arg((var_args), int);
+                               if (val < 0) {
+                                       audio_svc_error("track number should be positive value");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       ret = _audio_svc_update_track_num_in_music_record(audio_id, val);
+                               }
+                               break;
+                       }
+               case AUDIO_SVC_TRACK_DATA_ALBUM_RATING:
+                       {
+                               int val = va_arg((var_args), int);
+                               if (val < AUDIO_SVC_RATING_NONE
+                                   || val > AUDIO_SVC_RATING_5) {
+                                       audio_svc_error("rating value should be between 0 and 5");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       ret = _audio_svc_update_album_rating_in_music_record(audio_id, val);
+                               }
+                               break;
+                       }
+               default:
+                       {
+                               audio_svc_error("Invalid arguments");
+                               ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               break;
+                       }
+               }
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       audio_svc_error("invalid parameter");
+                       va_end(var_args);
+                       return ret;
+               }
+               /* next field */
+               field_name = va_arg(var_args, int);
+       }
+
+       va_end(var_args);
+       return AUDIO_SVC_ERROR_NONE;
+}
+
+int audio_svc_check_item_exist(const char *path)
+{
+       if (!STRING_VALID(path)) {
+               audio_svc_error("path is NULL");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (_audio_svc_count_record_with_path(path) > 0) {
+               audio_svc_debug("item is exist in database");
+               return AUDIO_SVC_ERROR_NONE;
+       } else {
+               audio_svc_debug("item is not exist in database");
+               return AUDIO_SVC_ERROR_DB_NO_RECORD;
+       }
+
+}
+
+int audio_svc_list_by_search(AudioHandleType *handle,
+                                                       audio_svc_search_order_e order_field,
+                                                       int offset,
+                                                       int count,
+                                                       audio_svc_serch_field_e first_field_name,
+                                                       ...)
+{
+       int ret = AUDIO_SVC_ERROR_NONE;
+       va_list var_args;
+       int field_name = -1;
+       int len = 0;
+       char query_where[AUDIO_SVC_QUERY_SIZE] = { 0 };
+       char search_str[AUDIO_SVC_METADATA_LEN_MAX] = { 0 };
+       char *condition_str = NULL;
+       
+       audio_svc_audio_item_s *item = (audio_svc_audio_item_s *)handle;
+
+       if (!item) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (offset < 0 || count <= 0) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (order_field < AUDIO_SVC_ORDER_BY_TITLE_DESC ||
+                       order_field > AUDIO_SVC_ORDER_BY_ADDED_TIME_ASC) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (first_field_name < AUDIO_SVC_SEARCH_TITLE || 
+                       first_field_name > AUDIO_SVC_SEARCH_AUTHOR) {
+               audio_svc_error("Invalid arguments");
+               return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       memset(query_where, 0x00, sizeof(query_where));
+       snprintf(query_where, sizeof(query_where), "valid=1 and ( 0 ");
+
+       field_name = first_field_name;
+       va_start(var_args, first_field_name);
+
+       while (field_name >= 0) {
+               audio_svc_debug("field name = %d", field_name);
+               memset(search_str, 0x00, sizeof(search_str));
+
+               switch (field_name) {
+               case AUDIO_SVC_SEARCH_TITLE:
+                       {
+                               char *val = va_arg((var_args), char *);
+                               int size = va_arg((var_args), int);
+
+                               if (val == NULL) {
+                                       audio_svc_error("title is NULL");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       _strncpy_safe(search_str, val,
+                                                     min(size + 1,
+                                                         sizeof(search_str)));
+                               }
+
+                               condition_str = sqlite3_mprintf(" or title like '%%%q%%' ", search_str);
+
+                               len =
+                                       g_strlcat(query_where, condition_str,
+                                               sizeof(query_where));
+                               if (len >= sizeof(query_where)) {
+                                       sqlite3_free(condition_str);
+                                       audio_svc_error("strlcat returns failure ( %d )", len);
+                                       return AUDIO_SVC_ERROR_INTERNAL;
+                               }
+                               sqlite3_free(condition_str);
+
+                               break;
+                       }
+               case AUDIO_SVC_SEARCH_ARTIST:
+                       {
+                               char *val = va_arg((var_args), char *);
+                               int size = va_arg((var_args), int);
+
+                               if (val == NULL) {
+                                       audio_svc_error("artist is NULL");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       _strncpy_safe(search_str, val,
+                                                     min(size + 1,
+                                                         sizeof(search_str)));
+                               }
+
+                               condition_str = sqlite3_mprintf(" or artist like '%%%q%%' ", search_str);
+
+                               len =
+                                       g_strlcat(query_where, condition_str,
+                                               sizeof(query_where));
+                               if (len >= sizeof(query_where)) {
+                                       sqlite3_free(condition_str);
+                                       audio_svc_error("strlcat returns failure ( %d )", len);
+                                       return AUDIO_SVC_ERROR_INTERNAL;
+                               }
+                               sqlite3_free(condition_str);
+
+                               break;
+                       }
+               case AUDIO_SVC_SEARCH_ALBUM:
+                       {
+                               char *val = va_arg((var_args), char *);
+                               int size = va_arg((var_args), int);
+
+                               if (val == NULL) {
+                                       audio_svc_error("album is NULL");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       _strncpy_safe(search_str, val,
+                                                     min(size + 1,
+                                                         sizeof(search_str)));
+                               }
+
+                               condition_str = sqlite3_mprintf(" or album like '%%%q%%' ", search_str);
+
+                               len =
+                                       g_strlcat(query_where, condition_str,
+                                               sizeof(query_where));
+                               if (len >= sizeof(query_where)) {
+                                       sqlite3_free(condition_str);
+                                       audio_svc_error("strlcat returns failure ( %d )", len);
+                                       return AUDIO_SVC_ERROR_INTERNAL;
+                               }
+                               sqlite3_free(condition_str);
+
+                               break;
+                       }
+               case AUDIO_SVC_SEARCH_GENRE:
+                       {
+                               char *val = va_arg((var_args), char *);
+                               int size = va_arg((var_args), int);
+
+                               if (val == NULL) {
+                                       audio_svc_error("genre is NULL");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       _strncpy_safe(search_str, val,
+                                                     min(size + 1,
+                                                         sizeof(search_str)));
+                               }
+
+                               condition_str = sqlite3_mprintf(" or genre like '%%%q%%' ", search_str);
+
+                               len =
+                                       g_strlcat(query_where, condition_str,
+                                               sizeof(query_where));
+                               if (len >= sizeof(query_where)) {
+                                       audio_svc_error("strlcat returns failure ( %d )", len);
+                                       return AUDIO_SVC_ERROR_INTERNAL;
+                               }
+
+                               break;
+                       }
+               case AUDIO_SVC_SEARCH_AUTHOR:
+                       {
+                               char *val = va_arg((var_args), char *);
+                               int size = va_arg((var_args), int);
+
+                               if (val == NULL) {
+                                       audio_svc_error("author is NULL");
+                                       ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       _strncpy_safe(search_str, val,
+                                                     min(size + 1,
+                                                         sizeof(search_str)));
+                               }
+
+                               condition_str = sqlite3_mprintf(" or author like '%%%q%%' ", search_str);
+
+                               len =
+                                       g_strlcat(query_where, condition_str,
+                                               sizeof(query_where));
+                               if (len >= sizeof(query_where)) {
+                                       sqlite3_free(condition_str);
+                                       audio_svc_error("strlcat returns failure ( %d )", len);
+                                       return AUDIO_SVC_ERROR_INTERNAL;
+                               }
+                               sqlite3_free(condition_str);
+
+                               break;
+                       }
+               default:
+                       {
+                               audio_svc_error("Invalid arguments");
+                               ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               break;
+                       }
+               }
+
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       audio_svc_error("invalid parameter");
+                       va_end(var_args);
+                       return ret;
+               }
+               /* next field */
+               field_name = va_arg(var_args, int);
+       }
+
+       va_end(var_args);
+       len = g_strlcat(query_where, ") ", sizeof(query_where));
+       if (len >= sizeof(query_where)) {
+               audio_svc_error("strlcat returns failure ( %d )", len);
+               return AUDIO_SVC_ERROR_INTERNAL;
+       }
+
+       return _audio_svc_list_search((audio_svc_audio_item_s *)handle, query_where, order_field, offset, count);
+}
+
diff --git a/src/common/media-info-debug.c b/src/common/media-info-debug.c
new file mode 100755 (executable)
index 0000000..3ceff96
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <unistd.h>
+#include <asm/unistd.h>
+#include <time.h>
+#include <sys/time.h>
+#include "media-info-debug.h"
+
+#ifdef _PERFORMANCE_CHECK_
+static long g_time_usec = 0L;
+#endif
+
+#ifdef _USE_LOG_FILE_
+static FILE *g_log_fp = NULL;
+static char _g_file_path[1024] = "\0";
+
+FILE *get_fp()
+{
+       return g_log_fp;
+}
+
+void mediainfo_init_file_debug()
+{
+       if (g_log_fp == NULL) {
+               snprintf(_g_file_path, sizeof(_g_file_path), "/tmp/%s",
+                        "media-info");
+               if (access(_g_file_path, R_OK == 0)) {
+                       remove(_g_file_path);
+               }
+
+               g_log_fp = fopen(_g_file_path, "a");
+       }
+}
+
+void mediainfo_close_file_debug()
+{
+       if (g_log_fp != NULL) {
+               fclose(g_log_fp);
+               g_log_fp = NULL;
+       }
+}
+
+#endif
+
+long mediainfo_get_debug_time(void)
+{
+#ifdef _PERFORMANCE_CHECK_
+       struct timeval time;
+       gettimeofday(&time, NULL);
+       return time.tv_sec * 1000000 + time.tv_usec;
+#else
+       return 0L;
+#endif
+}
+
+void mediainfo_reset_debug_time(void)
+{
+#ifdef _PERFORMANCE_CHECK_
+       struct timeval time;
+       gettimeofday(&time, NULL);
+       g_time_usec = time.tv_sec * 1000000 + time.tv_usec;
+#endif
+}
+
+void mediainfo_print_debug_time(char *time_string)
+{
+#ifdef _PERFORMANCE_CHECK_
+       struct timeval time;
+       double totaltime = 0.0;
+
+       gettimeofday(&time, NULL);
+       totaltime =
+           (double)(time.tv_sec * 1000000 + time.tv_usec -
+                    g_time_usec) / CLOCKS_PER_SEC;
+
+       mediainfo_dbg("time [%s] : %f \n", time_string, totaltime);
+#endif
+}
+
+void
+mediainfo_print_debug_time_ex(long start, long end, const char *func_name,
+                             char *time_string)
+{
+#ifdef _PERFORMANCE_CHECK_
+       double totaltime = 0.0;
+
+       totaltime = (double)(end - start) / CLOCKS_PER_SEC;
+
+       mediainfo_dbg("time [%s: %s] : %f \n", func_name, time_string,
+                     totaltime);
+#endif
+}
diff --git a/src/common/media-info-util.c b/src/common/media-info-util.c
new file mode 100755 (executable)
index 0000000..200dfa8
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <unistd.h>
+#include <asm/unistd.h>
+#include <pthread.h>
+#include <string.h>
+
+#include "media-info-util.h"
+#include "media-info-error.h"
+#include "media-info-debug.h"
+#include "media-svc.h"
+#include "audio-svc.h"
+#include "audio-svc-error.h"
+#include "uuid.h"
+
+static GHashTable *g_handle_table = NULL;
+pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+int _media_info_get_thread_id()
+{
+       return syscall(__NR_gettid);
+}
+
+int _media_info_init_handle_tbl()
+{
+       pthread_mutex_lock(&mutex);
+
+       if (g_handle_table == NULL)
+               g_handle_table = g_hash_table_new(g_int_hash, g_int_equal);
+
+       pthread_mutex_unlock(&mutex);
+
+       if (g_handle_table == NULL)
+               return -1;
+       else
+               return 0;
+}
+
+int _media_info_finalize_handle_tbl()
+{
+       pthread_mutex_lock(&mutex);
+
+       if (g_handle_table != NULL) {
+               int size = g_hash_table_size(g_handle_table);
+               if (size == 0) {
+                       g_hash_table_destroy(g_handle_table);
+                       g_handle_table = NULL;
+               } else
+                       mediainfo_dbg("handle table is not empty");
+       }
+
+       pthread_mutex_unlock(&mutex);
+
+       return 0;
+}
+
+int
+_media_info_insert_handle(int **tid_key, int tid, HandleTable ** handle_table)
+{
+       *tid_key = g_malloc(sizeof **tid_key);
+       **tid_key = tid;
+       *handle_table = g_malloc(sizeof **handle_table);
+
+       pthread_mutex_lock(&mutex);
+
+       g_hash_table_insert(g_handle_table, (gpointer) * tid_key,
+                           (gpointer) * handle_table);
+
+       (*handle_table)->ref_cnt = 1;
+
+       pthread_mutex_unlock(&mutex);
+
+       return 0;
+}
+
+int _media_info_remove_handle(int tid)
+{
+       int *key = NULL;
+       HandleTable *val = NULL;
+
+       pthread_mutex_lock(&mutex);
+
+       if (!g_hash_table_lookup_extended
+           (g_handle_table, &tid, (gpointer) & key, (gpointer) & val)) {
+               pthread_mutex_unlock(&mutex);
+               return -1;
+       } else {
+               if (g_hash_table_remove(g_handle_table, (gpointer) & tid))
+                       mediainfo_dbg("g_hash_table_remove done");
+               else
+                       mediainfo_dbg("g_hash_table_remove fails");
+
+               if (key)
+                       g_free(key);
+               if (val)
+                       g_free(val);
+
+               pthread_mutex_unlock(&mutex);
+               return 0;
+       }
+}
+
+HandleTable *_media_info_search_handle(int tid)
+{
+       pthread_mutex_lock(&mutex);
+
+       HandleTable *value =
+           (HandleTable *) g_hash_table_lookup(g_handle_table,
+                                               (gpointer) & tid);
+
+       pthread_mutex_unlock(&mutex);
+
+       return value;
+}
+
+sqlite3 *_media_info_get_proper_handle()
+{
+       int tid = _media_info_get_thread_id();
+       HandleTable *value =
+           (HandleTable *) g_hash_table_lookup(g_handle_table,
+                                               (gpointer) & tid);
+
+       if (value == NULL) {
+               return NULL;
+       } else {
+               return value->handle;
+       }
+}
+void _media_info_atomic_add_counting(HandleTable *handle_table)
+{
+       pthread_mutex_lock(&mutex);
+       handle_table->ref_cnt++;
+       pthread_mutex_unlock(&mutex);
+}
+
+
+void _media_info_atomic_sub_counting(HandleTable *handle_table)
+{
+       pthread_mutex_lock(&mutex);
+       handle_table->ref_cnt--;
+       pthread_mutex_unlock(&mutex);
+}
+
+char *_media_info_generate_uuid()
+{
+       uuid_t uuid_value;
+       static char uuid_unparsed[50];  
+
+       uuid_generate(uuid_value);
+       uuid_unparse(uuid_value, uuid_unparsed);
+
+       //mediainfo_dbg("UUID : %s", uuid_unparsed);
+       return uuid_unparsed;
+}
+
diff --git a/src/common/media-info.c b/src/common/media-info.c
new file mode 100755 (executable)
index 0000000..416fc4e
--- /dev/null
@@ -0,0 +1,278 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <errno.h>
+#include <unistd.h>
+#include <arpa/inet.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <util-func.h>
+#include "media-info.h"
+#include "media-info-debug.h"
+#include "media-info-env.h"
+#include "media-info-util.h"
+#include "media-svc.h"
+#include "audio-svc.h"
+#include "audio-svc-error.h"
+
+#define TIMEOUT_SEC            10
+
+int mediainfo_open(void)
+{
+       mediainfo_dbg("");
+       int err = -1;
+
+       err = minfo_init();
+       if (err < MB_SVC_ERROR_NONE) {
+               mediainfo_dbg("minfo_init falis");
+       }
+
+       err = audio_svc_open();
+       if (err < AUDIO_SVC_ERROR_NONE) {
+               mediainfo_dbg("audio_svc_open falis");
+       }
+
+       if (err < 0) return MEDIA_INFO_ERROR_DATABASE_CONNECT;
+
+       mediainfo_dbg("Success");
+       return err;
+}
+
+int mediainfo_close(void)
+{
+       mediainfo_dbg("");
+       int err = -1;
+
+       err = minfo_finalize();
+       if (err < MB_SVC_ERROR_NONE) {
+               mediainfo_dbg("minfo_finalize falis");
+       }
+
+       err = audio_svc_close();
+       if (err < AUDIO_SVC_ERROR_NONE) {
+               mediainfo_dbg("audio_svc_close falis");
+       }
+
+       if (err < 0) return MEDIA_INFO_ERROR_DATABASE_DISCONNECT;
+
+       mediainfo_dbg("Success");
+       return err;
+}
+
+int mediainfo_connect_db_with_handle(sqlite3 **db_handle)
+{
+       mediainfo_dbg("");
+       int err = -1;
+       err =
+           db_util_open(MEDIA_INFO_DATABASE_NAME, db_handle,
+                        DB_UTIL_REGISTER_HOOK_METHOD);
+
+       if (SQLITE_OK != err) {
+               *db_handle = NULL;
+
+               return MEDIA_INFO_ERROR_DATABASE_CONNECT;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int mediainfo_disconnect_db_with_handle(sqlite3 *db_handle)
+{
+       mediainfo_dbg("");
+       int err = -1;
+       err = db_util_close(db_handle);
+
+       if (SQLITE_OK != err) {
+               db_handle = NULL;
+
+               return MEDIA_INFO_ERROR_DATABASE_DISCONNECT;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+#define MINFO_REGISTER_PORT 1001
+
+static bool _mediainfo_is_valid_path(const char *path)
+{
+       if (path == NULL)
+               return false;
+
+       if (strncmp(path, MEDIAINFO_PHONE_ROOT_PATH, strlen(MEDIAINFO_PHONE_ROOT_PATH)) == 0) {
+               return true;
+       } else if (strncmp(path, MEDIAINFO_MMC_ROOT_PATH, strlen(MEDIAINFO_MMC_ROOT_PATH)) == 0) {
+               return true;
+       } else
+               return false;
+
+       return true;
+}
+
+DEPRECATED_API int mediainfo_register_file(const char *file_full_path)
+{
+       int exist;
+       int err;
+       int sockfd;
+       int recv_msg = MEDIA_INFO_ERROR_NONE;
+       int server_addr_size;
+       struct sockaddr_in server_addr;
+       struct timeval tv_timeout = { TIMEOUT_SEC, 0 };
+
+       if(!_mediainfo_is_valid_path(file_full_path)) {
+               mediainfo_dbg("Invalid path : %s", file_full_path);
+               return MEDIA_INFO_ERROR_INVALID_PATH;
+       }
+
+       exist = open(file_full_path, O_RDONLY);
+       if(exist < 0) {
+               mediainfo_dbg("Not exist path : %s", file_full_path);
+               return MEDIA_INFO_ERROR_INVALID_PATH;
+       }
+       close(exist);
+
+       sockfd = socket(PF_INET, SOCK_DGRAM, 0);
+       if(sockfd < 0)
+       {
+               mediainfo_dbg("socket create fail");
+               return MEDIA_INFO_ERROR_SOCKET_CONN;
+       }
+
+       /*add timeout : timeout is 10 sec.*/
+       if (setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv_timeout, sizeof(tv_timeout)) == -1) {
+               mediainfo_dbg("setsockopt failed");
+               return MEDIA_INFO_ERROR_SOCKET_CONN;
+       }
+
+       memset(&server_addr, 0, sizeof(server_addr));
+       server_addr.sin_family = AF_INET;
+       server_addr.sin_port = htons(MINFO_REGISTER_PORT);
+       server_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
+
+       err = sendto(sockfd, file_full_path, strlen(file_full_path), 0, (struct sockaddr*)&server_addr, sizeof(server_addr));
+       if (err < 0) {
+               mediainfo_dbg("sendto error");
+               perror("sendto error : ");
+               return MEDIA_INFO_ERROR_SOCKET_SEND;
+       } else {
+               mediainfo_dbg("SEND OK");
+       }
+
+       server_addr_size = sizeof(server_addr);
+       err = recvfrom(sockfd, &recv_msg, sizeof(recv_msg), 0 , (struct sockaddr*)&server_addr, (socklen_t *)&server_addr_size);
+       if (err < 0) {
+               if (errno == EWOULDBLOCK) {
+                       mediainfo_dbg("recvfrom timeout");
+                       return MEDIA_INFO_ERROR_SOCKET_RECEIVE_TIMEOUT;
+               } else {
+                       mediainfo_dbg("recvfrom error");
+                       perror("recvfrom error : ");
+                       return MEDIA_INFO_ERROR_SOCKET_RECEIVE;
+               }
+       } else {
+               mediainfo_dbg("RECEIVE OK");
+               mediainfo_dbg("client receive: %d", recv_msg);
+       }       
+       
+       close(sockfd);
+
+       return recv_msg;
+}
+
+DEPRECATED_API int mediainfo_list_new(minfo_list *list)
+{
+       *list = g_array_new(TRUE, TRUE, sizeof(char*));
+
+       return MB_SVC_ERROR_NONE;
+}
+
+DEPRECATED_API int mediainfo_list_add(minfo_list list, const char* file_full_path)
+{
+       mediainfo_dbg("");
+
+       if (!list) {
+               mediainfo_dbg("list == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!file_full_path) {
+               mediainfo_dbg("file_full_path == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       minfo_list ret_list = NULL;
+       char *path = strdup(file_full_path);
+
+       int len = list->len + 1;
+       int i;
+       char *data = NULL;
+
+       ret_list = g_array_append_val(list, path);
+       if(ret_list == NULL) {
+               mediainfo_dbg("g_array_append_val fails");
+               return MB_SVC_ERROR_UNKNOWN;
+       }
+
+       list = ret_list;
+
+       for(i = 0; i < len; i++) {
+               data = g_array_index(list, char*, i);
+               mediainfo_dbg("%d, %s", i, data);
+       }
+
+       return MB_SVC_ERROR_NONE;
+}
+
+DEPRECATED_API int mediainfo_list_free(minfo_list list)
+{
+       if (!list)
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+
+       int len = list->len + 1;
+       int i;
+       char *data = NULL;
+
+       for(i = 0; i < len; i++) {
+               data = g_array_index(list, char*, i);
+               free(data);
+       }
+
+       g_array_free(list, TRUE);
+
+       return MB_SVC_ERROR_NONE;
+}
+
+DEPRECATED_API int mediainfo_register_files(const minfo_list list)
+{
+       if (!list)
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+
+       int len = list->len + 1;
+       int i;
+       char *data;
+
+       for(i = 0; i < len; i++) {
+               data = g_array_index(list, char*, i);
+               mediainfo_register_file(data);
+       }
+
+       return MB_SVC_ERROR_NONE;
+}
diff --git a/src/include/audio/audio-svc-db-utils.h b/src/include/audio/audio-svc-db-utils.h
new file mode 100755 (executable)
index 0000000..ce274e5
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#ifndef _AUDIO_SVC_DB_UTILS_H_
+#define _AUDIO_SVC_DB_UTILS_H_
+
+
+/**
+ * @file               audio-svc-db-utils.h
+ * @version    0.1
+ * @brief      This file defines sqlite utilities for Audio Service.
+ */
+
+#include <sqlite3.h>
+#include <glib.h>
+
+#define SQLITE3_FINALIZE(x)       if(x  != NULL) {sqlite3_finalize(x);}
+
+int _audio_svc_sql_busy_handler(void *pData, int count);
+int _audio_svc_sql_query(const char *sql_str);
+int _audio_svc_sql_query_list(GList **query_list);
+int _audio_svc_sql_prepare_to_step(const char *sql_str, sqlite3_stmt** stmt);
+int _audio_svc_sql_begin_trans(void);
+int _audio_svc_sql_end_trans(void);
+int _audio_svc_sql_rollback_trans(void);
+void _audio_svc_sql_query_add(GList **query_list, char **query);
+void _audio_svc_sql_query_release(GList **query_list);
+
+
+
+#endif /*_AUDIO_SVC_DB_UTILS_H_*/
+
diff --git a/src/include/audio/audio-svc-debug.h b/src/include/audio/audio-svc-debug.h
new file mode 100755 (executable)
index 0000000..adce654
--- /dev/null
@@ -0,0 +1,84 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+\r
+#ifndef _AUDIO_SVC_DEBUG_H_\r
+#define _AUDIO_SVC_DEBUG_H_\r
+\r
+#ifndef DBG_PREFIX\r
+#define DBG_PREFIX             "AUDIO_SVC"\r
+#endif\r
+\r
+\r
+#include <stdio.h>\r
+#include <stdbool.h>\r
+#include <dlog.h>\r
+\r
+#ifdef LOG_TAG\r
+#undef LOG_TAG\r
+#endif\r
+\r
+#define LOG_TAG "AUDIO_SVC"\r
+\r
+#define audio_svc_debug(fmt, arg...) do{ if (TRUE) { \\r
+                               LOGD("[%s : %s-%d]\n"fmt"",__FILE__, __FUNCTION__, __LINE__,##arg);     \\r
+                       } } while (0)\r
+\r
+#define audio_svc_error(fmt, arg...) do{ if (TRUE) { \\r
+                               LOGE("[%s : %s-%d]\n"fmt"",__FILE__, __FUNCTION__, __LINE__,##arg);     \\r
+                       } } while (0)\r
+\r
+#define audio_svc_debug_func() do{ if (TRUE) { \\r
+                               LOGD("[%s : %s-%d]\n",__FILE__, __FUNCTION__, __LINE__);     \\r
+                       } } while (0)\r
+\r
+#define audio_svc_debug_time() do{ if (TRUE) { \\r
+                               LOGD("[%s]\n",__TIME__);     \\r
+                       } } while (0)\r
+\r
+#define audio_svc_ret_if(expr) do { \\r
+               if(expr) { \\r
+                       return; \\r
+               } \\r
+       } while (0)\r
+#define audio_svc_retv_if(expr, val) do { \\r
+               if(expr) { \\r
+                       return (val); \\r
+               } \\r
+       } while (0)\r
+\r
+#define audio_svc_retm_if(expr, fmt, arg...) do { \\r
+               if(expr) { \\r
+                       LOGE("[%s : %s-%d]\n"fmt"",__FILE__, __FUNCTION__, __LINE__,##arg);     \\r
+                       return; \\r
+               } \\r
+       } while (0)\r
+\r
+#define audio_svc_retvm_if(expr, val, fmt, arg...) do { \\r
+               if(expr) { \\r
+                       LOGE("[%s : %s-%d]\n"fmt"",__FILE__, __FUNCTION__, __LINE__,##arg);     \\r
+                       return (val); \\r
+               } \\r
+       } while (0)\r
+\r
+\r
+#endif /*_AUDIO_SVC_DEBUG_H_*/\r
diff --git a/src/include/audio/audio-svc-music-table.h b/src/include/audio/audio-svc-music-table.h
new file mode 100755 (executable)
index 0000000..cd6ed53
--- /dev/null
@@ -0,0 +1,100 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+\r
+#ifndef _AUDIO_SVC_MUSIC_TABLE_H_\r
+#define _AUDIO_SVC_MUSIC_TABLE_H_\r
+\r
+/**\r
+ * This file defines structure and functions related to database.\r
+ *\r
+ * @file               audio-svc-music-table.h\r
+ * @version    0.1\r
+ * @brief      This file defines the functions related to DB.\r
+ */\r
+\r
+#include "audio-svc-types.h"\r
+#include "audio-svc-types-priv.h"\r
+#include <stdbool.h>\r
+\r
+typedef struct{\r
+       char thumbnail_path[AUDIO_SVC_PATHNAME_SIZE];\r
+}mp_thumbnailpath_record_t;\r
+\r
+int _audio_svc_create_music_table(void);\r
+int _audio_svc_truncate_music_table(audio_svc_storage_type_e storage_type);\r
+int _audio_svc_create_folder_table(void);\r
+int _audio_svc_delete_folder(audio_svc_storage_type_e storage_type, const char *folder_id);\r
+int _audio_svc_select_music_record_by_audio_id(const char *audio_id, audio_svc_audio_item_s *item);\r
+int _audio_svc_select_music_record_by_path(const char *path, audio_svc_audio_item_s *item);\r
+int _audio_svc_delete_music_record_by_audio_id(const char *audio_id);\r
+int _audio_svc_update_metadata_in_music_record(const char *audio_id, audio_svc_audio_item_s *item);\r
+int _audio_svc_update_path_in_music_record(const char *src_path, const char *path, const char *title);\r
+int _audio_svc_update_path_and_storage_in_music_record(const char *src_path, const char *path, audio_svc_storage_type_e storage_type);\r
+int _audio_svc_update_folder_id_in_music_record(const char *path, const char *folder_id);\r
+int _audio_svc_update_thumb_path_in_music_record(const char *file_path, const char *path);\r
+int _audio_svc_update_rating_in_music_record( const char *audio_id, int changed_value);\r
+int _audio_svc_update_playtime_in_music_record(const char *audio_id, int changed_value);\r
+int _audio_svc_update_playcount_in_music_record(const char *audio_id, int changed_value);\r
+int _audio_svc_update_addtime_in_music_record(const char *audio_id, int changed_value);\r
+int _audio_svc_update_track_num_in_music_record(const char *audio_id, int changed_value);\r
+int _audio_svc_update_album_rating_in_music_record(const char *audio_id, int changed_value);\r
+int _audio_svc_update_year_in_music_record(const char *audio_id, int changed_value);\r
+int _audio_svc_update_title_in_music_record(const char *audio_id, const char * changed_value);\r
+int _audio_svc_update_artist_in_music_record(const char *audio_id, const char * changed_value);\r
+int _audio_svc_update_album_in_music_record(const char *audio_id, const char * changed_value);\r
+int _audio_svc_update_genre_in_music_record(const char *audio_id, const char * changed_value);\r
+int _audio_svc_update_author_in_music_record(const char *audio_id, const char * changed_value);\r
+int _audio_svc_update_description_in_music_record(const char *audio_id, const char * changed_value);\r
+int _audio_svc_update_favourite_in_music_record(const char *audio_id, int changed_value);\r
+int _audio_svc_count_music_group_records(audio_svc_group_type_e group_type, const char *limit_string1, const char *limit_string2, const char *filter_string, const char *filter_string2, int *count);\r
+int _audio_svc_get_music_group_records(audio_svc_group_type_e group_type, const char *limit_string1, const char *limit_string2, const char *filter_string, const char *filter_string2,int offset, int rows, audio_svc_group_item_s *group);\r
+int _audio_svc_count_music_track_records(audio_svc_track_type_e track_type, const char *type_string, const char *type_string2, const char *filter_string, const char *filter_string2, int *count);\r
+int _audio_svc_get_music_track_records(audio_svc_track_type_e track_type, const char *type_string, const char *type_string2, const char *filter_string, const char *filter_string2, int offset, int rows, audio_svc_list_item_s *track);\r
+int _audio_svc_search_audio_id_by_path(const char *path, char *audio_id);\r
+int _audio_svc_update_valid_of_music_records(audio_svc_storage_type_e storage_type, int valid);\r
+int _audio_svc_count_record_with_path(const char *path);\r
+int _audio_svc_delete_invalid_music_records(audio_svc_storage_type_e storage_type);\r
+int _audio_svc_update_valid_in_music_record(const char *path, int valid);\r
+int _audio_svc_update_valid_in_music_record_query_add(const char *path, int valid);\r
+int _audio_svc_move_item_query_add(const char *src_path, const char *path, audio_svc_storage_type_e storage_type, const char *folder_id);\r
+int _audio_svc_list_query_do(audio_svc_query_type_e query_type);\r
+int _audio_svc_get_path(const char *audio_id, char *path);\r
+int _audio_svc_delete_music_track_groups(audio_svc_group_type_e group_type, const char *type_string);\r
+int _audio_svc_check_and_update_folder_table(const char* path_name);\r
+int _audio_svc_check_and_update_albums_table(const char *album);\r
+int _audio_svc_insert_item_with_data(audio_svc_audio_item_s *item, bool stack_query);\r
+int _audio_svc_update_folder_table(void);\r
+int _audio_svc_get_thumbnail_path_by_path(const char *path, char *thumb_path);\r
+int _audio_svc_get_and_append_folder_id_by_path(const char *path, audio_svc_storage_type_e storage_type, char *folder_id);\r
+int _audio_svc_get_folder_id_by_foldername(const char *folder_name, char *folder_id);\r
+int _audio_svc_append_audio_folder(audio_svc_storage_type_e storage_type, const char *folder_id, const char *path_name, const char *folder_name, int modified_date);\r
+char * _audio_svc_get_thumbnail_path_by_album_id(int album_id);\r
+int _audio_svc_check_and_remove_thumbnail(const char * thumbnail_path);\r
+int _audio_svc_list_search(audio_svc_audio_item_s *item,\r
+                                                       char *where_query,\r
+                                                       audio_svc_search_order_e order_field,\r
+                                                       int offset,\r
+                                                       int count\r
+                                                       );\r
+\r
+#endif /*_AUDIO_SVC_MUSIC_TABLE_H_*/\r
diff --git a/src/include/audio/audio-svc-playlist-table.h b/src/include/audio/audio-svc-playlist-table.h
new file mode 100755 (executable)
index 0000000..b507601
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#ifndef _AUDIO_SVC_PLAYLIST_TABLE_H_
+#define _AUDIO_SVC_PLAYLIST_TABLE_H_
+
+
+/**
+ * This file defines structure and functions related to database for managing playlists.
+ *
+ * @file               audio-svc-playlist-table.h
+ * @version    0.1
+ */
+
+#include "audio-svc-types-priv.h"
+
+int _audio_svc_create_playlist_table(void);
+int _audio_svc_truncate_playlist_table(void);
+
+/* playlist table */
+
+/**
+* This function inserts new playlist record into playlist table.
+*/
+int _audio_svc_insert_playlist_record(const char *playlist_name, int *playlist_id);
+
+/**
+* This function deletes playlist record from playlist table.
+*/
+int _audio_svc_delete_playlist_record(int playlist_id);
+
+/**
+* This function update playlist record with new name
+*/
+int _audio_svc_update_playlist_record_by_name(int playlist_id, const char *new_playlist_name);
+
+/**
+* This function returns the number of total playlist records in the playlist table.
+*/
+int _audio_svc_count_playlist_records(const char *filter_string, const char *filter_string2, int *count);
+
+/**
+* This function retrieves playlist record without any condition in the playlist table.
+*/
+int _audio_svc_get_playlist_records(int offset, int rows, const char *filter_string, const char *filter_string2, audio_svc_playlist_s *playlists);
+
+int _audio_svc_count_playlist_item_records(int playlist_id, const char *filter_string, const char *filter_string2, int *count);
+int _audio_svc_get_playlist_item_records(int playlist_id, const char *filter_string, const char *filter_string2,int offset, int rows, audio_svc_playlist_item_s *track);
+
+/**
+* This function returns the number of playlist with playlist_name.
+* It is called when inserting a new playlist record to guarantee unique playlist name.
+* */
+int _audio_svc_count_playlist_records_by_name(const char *playlist_name, int * count);
+
+
+/*****************************************************************/
+/* playlist item table*/
+
+/**
+* This function inserts a new record with playlist index and audio_id into playlist item table.
+*/
+int _audio_svc_insert_playlist_item_record(int playlist_id, const char *audio_id);
+
+/**
+* This function removes item with audio_id from playlist.
+* It is possible to add a same track to a playlist several times.
+* So if user tries to remove one instance of track from playlist, this function should be called.
+*/
+int _audio_svc_delete_playlist_item_record_from_playlist_by_audio_id(int playlist_id, const char *audio_id);
+
+/**
+* When deleting a track, all instance of track will be removed from playlists
+*/
+int _audio_svc_delete_playlist_item_records_by_audio_id(const char *audio_id);
+int _audio_svc_delete_playlist_item_record_from_playlist_by_uid(int playlist_id, int uid);
+int _audio_svc_check_duplication_records_in_playlist(int playlist_id, const char *audio_id,  int * count);
+int _audio_svc_get_playlist_id_by_name(const char *playlist_name, int *playlist_id);
+int _audio_svc_get_playlist_name_by_playlist_id(int playlist_id, char *playlist_name);
+int _audio_svc_get_audio_id_by_uid(int uid, char *audio_id);
+int _audio_svc_update_item_play_order(int playlist_id, int uid, int new_play_order);
+
+#endif /*_AUDIO_SVC_PLAYLIST_TABLE_H_*/
\ No newline at end of file
diff --git a/src/include/audio/audio-svc-ta.h b/src/include/audio/audio-svc-ta.h
new file mode 100755 (executable)
index 0000000..81c1517
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _AUDIO_SVC_TA_H_
+#define _AUDIO_SVC_TA_H_
+
+
+#define ENABLE_AUDIO_SVC_TA
+#ifdef ENABLE_AUDIO_SVC_TA
+
+// defs.
+#define AUDIO_SVC_TA_MAX_CHECKPOINT    500
+#define AUDIO_SVC_TA_MAX_ACCUM         500
+
+typedef struct _audio_svc_ta_checkpoint
+{
+       unsigned long timestamp;
+       char* name;
+} audio_svc_ta_checkpoint;
+
+typedef struct _audio_svc_ta_accum_item
+{
+       unsigned long elapsed_accum;
+       unsigned long num_calls;
+       unsigned long elapsed_min;
+       unsigned long elapsed_max;
+       unsigned long first_start;
+       unsigned long last_end;
+
+       char* name;
+
+       unsigned long timestamp;
+       int on_estimate;
+       int num_unpair;
+} audio_svc_ta_accum_item;
+
+#define AUDIO_SVC_TA_SHOW_STDOUT       0
+#define AUDIO_SVC_TA_SHOW_STDERR       1
+#define AUDIO_SVC_TA_SHOW_FILE 2
+#define AUDIO_SVC_TA_RESULT_FILE "/tmp/audio-svc-ta.log"
+
+/////////////////////////////
+// COMMON
+int audio_svc_ta_init(void);
+int audio_svc_ta_release(void);
+void audio_svc_ta_set_enable(int enable);
+char* audio_svc_ta_fmt(const char* fmt, ...);
+
+/////////////////////////////
+// CHECK POINT
+int audio_svc_ta_add_checkpoint(char* name, int show, char* filename, int line);
+void audio_svc_ta_show_checkpoints(void);
+void audio_svc_ta_show_diff(char* name1, char* name2);
+
+int audio_svc_ta_get_numof_checkpoints();
+unsigned long audio_svc_ta_get_diff(char* name1, char* name2);
+//char* audio_svc_ta_get_name(int idx);
+
+
+/////////////////////////////
+// ACCUM ITEM
+int audio_svc_ta_accum_item_begin(char* name, int show, char* filename, int line);
+int audio_svc_ta_accum_item_end(char* name, int show, char* filename, int line);
+void audio_svc_ta_accum_show_result(int direction);
+
+// macro.
+#define AUDIO_SVC_TA_INIT()                                                    (       audio_svc_ta_init()                                                                             )
+#define AUDIO_SVC_TA_RELEASE()                                         (       audio_svc_ta_release()                                                                  )
+#define AUDIO_SVC_TA_SET_ENABLE(enable)                                (       audio_svc_ta_set_enable(enable)                                                 )
+
+// checkpoint handling
+#define AUDIO_SVC_TA_ADD_CHECKPOINT(name,show)         (       audio_svc_ta_add_checkpoint(name,show,__FILE__,__LINE__)                )
+#define AUDIO_SVC_TA_SHOW_CHECKPOINTS()                                (       audio_svc_ta_show_checkpoints()                                                 )
+#define AUDIO_SVC_TA_SHOW_DIFF(name1, name2)                   (       audio_svc_ta_show_diff(name1, name2)                                            )
+#define AUDIO_SVC_TA_GET_NUMOF_CHECKPOINTS()           (       audio_svc_ta_get_numof_checkpoints()                                            )
+#define AUDIO_SVC_TA_GET_DIFF(name1, name2)                    (       audio_svc_ta_get_diff(name1, name2)                                             )
+//#define AUDIO_SVC_TA_GET_NAME(idx)                           (       audio_svc_ta_get_name(idx)                                                      )
+
+// accum item handling
+#define AUDIO_SVC_TA_ACUM_ITEM_BEGIN(name,show)                (       audio_svc_ta_accum_item_begin(name,show,__FILE__,__LINE__)              )
+#define AUDIO_SVC_TA_ACUM_ITEM_END(name,show)          (       audio_svc_ta_accum_item_end(name,show,__FILE__,__LINE__)                )
+#define AUDIO_SVC_TA_ACUM_ITEM_SHOW_RESULT()           (       audio_svc_ta_accum_show_result(AUDIO_SVC_TA_SHOW_STDOUT)        )
+#define AUDIO_SVC_TA_ACUM_ITEM_SHOW_RESULT_TO(x)       (       audio_svc_ta_accum_show_result(x)                                                       )
+/*
+#define __audio_svc_ta__(name, x) \
+AUDIO_SVC_TA_ACUM_ITEM_BEGIN(name, 0); \
+x \
+AUDIO_SVC_TA_ACUM_ITEM_END(name, 0);
+
+#define __mm_tafmt__(fmt, args...)                     (       audio_svc_ta_audio_svc_ta_fmt(fmt, ##args)      )
+*/
+
+#else //#ifdef ENABLE_AUDIO_SVC_TA
+
+#define AUDIO_SVC_TA_INIT()
+#define AUDIO_SVC_TA_RELEASE()
+#define AUDIO_SVC_TA_SET_ENABLE(enable)
+
+// checkpoint handling
+#define AUDIO_SVC_TA_ADD_CHECKPOINT(name,show)
+#define AUDIO_SVC_TA_SHOW_CHECKPOINTS()
+#define AUDIO_SVC_TA_SHOW_DIFF(name1, name2)
+#define AUDIO_SVC_TA_GET_NUMOF_CHECKPOINTS()
+#define AUDIO_SVC_TA_GET_DIFF(name1, name2)
+//#define AUDIO_SVC_TA_GET_NAME(idx)
+
+// accum item handling
+#define AUDIO_SVC_TA_ACUM_ITEM_BEGIN(name,show)
+#define AUDIO_SVC_TA_ACUM_ITEM_END(name,show)
+#define AUDIO_SVC_TA_ACUM_ITEM_SHOW_RESULT()
+#define AUDIO_SVC_TA_ACUM_ITEM_SHOW_RESULT_TO(x)
+/*
+#define __audio_svc_ta__(name, x)
+#define __mm_tafmt__(fmt, args...)
+*/
+#endif //#ifdef ENABLE_AUDIO_SVC_TA
+
+#endif /*_AUDIO_SVC_TA_H_*/
+
diff --git a/src/include/audio/audio-svc-types-priv.h b/src/include/audio/audio-svc-types-priv.h
new file mode 100755 (executable)
index 0000000..6994102
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "audio-svc-types.h"
+
+#ifndef _AUDIO_SVC_TYPES_PRIV_H_
+#define _AUDIO_SVC_TYPES_PRIV_H_
+
+#define AUDIO_SVC_TAG_UNKNOWN                          "Unknown"
+#define AUDIO_SVC_MEDIA_PATH                                   "/opt/data/file-manager-service"                        /**<  Media path*/
+#define AUDIO_SVC_THUMB_PATH_PREFIX                    AUDIO_SVC_MEDIA_PATH"/.thumb"                   /**< Thumbnail path prefix*/
+#define AUDIO_SVC_THUMB_PHONE_PATH                     AUDIO_SVC_THUMB_PATH_PREFIX"/phone"     /**<  Phone thumbnail path*/
+#define AUDIO_SVC_THUMB_MMC_PATH                       AUDIO_SVC_THUMB_PATH_PREFIX"/mmc"               /**<  MMC thumbnail path*/
+#define AUDIO_SVC_QUERY_SIZE                                   4096                                                                    /**<  Length of db query */
+
+/**
+ * DB table information
+ */
+#define AUDIO_SVC_DB_TABLE_AUDIO                                               "audio_media"                   /**<  audio_media table. (old mp_music_phone table)*/
+#define AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS                     "audio_playlists"                       /**<  audio_playlists table*/
+#define AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP         "audio_playlists_map"           /**<  audio_playlists_map table*/
+#define AUDIO_SVC_DB_TABLE_ALBUMS                                      "albums"                                /**<  albums table*/
+#define AUDIO_SVC_DB_TABLE_ALBUM_ART                                   "album_art"                             /**<  album_art table*/
+#define AUDIO_SVC_DB_TABLE_AUDIO_FOLDER                                "audio_folder"                  /**<  audio_folder table*/
+
+#define AUDIO_SVC_CONTENT_TYPE                                         3                                               /**<  image-1, video-2, audio-3 */
+
+/**
+ * Audio meta data information
+ */
+typedef struct {
+       char            title[AUDIO_SVC_METADATA_LEN_MAX];                      /**< track title*/
+       char            artist[AUDIO_SVC_METADATA_LEN_MAX];             /**< artist name*/
+       char            album[AUDIO_SVC_METADATA_LEN_MAX];              /**< album name*/
+       char            genre[AUDIO_SVC_METADATA_LEN_MAX];              /**< genre of track*/
+       char            author[AUDIO_SVC_METADATA_LEN_MAX];             /**< author name*/
+       char            copyright[AUDIO_SVC_METADATA_LEN_MAX];          /**< copyright of track*/
+       char            description[AUDIO_SVC_METADATA_LEN_MAX];        /**< description of track*/
+       char            format[50];                                                                     /**< format of track*/
+       int             duration;                                                                       /**< duration of track*/
+       int             bitrate;                                                                                /**< bitrate of track*/
+       char            year[AUDIO_SVC_METADATA_LEN_MAX];                       /**< year of track*/
+       int             track;                                                                          /**< track number*/
+       int             album_rating;                                                           /**< rating of album*/
+       char            parental_rating[20];                                                    /**< parental rating*/
+} audio_svc_audio_meta_s;
+
+
+/**
+ * Audio data information
+ */
+typedef struct {
+       int             storage_type;                                                                   /**< Storage of media file : internal/external */
+       char            audio_id[AUDIO_SVC_PATHNAME_SIZE+1];            /**< Unique ID of item */
+       char            pathname[AUDIO_SVC_PATHNAME_SIZE];                      /**< Full path and file name of media file */
+       char            thumbname[AUDIO_SVC_PATHNAME_SIZE];             /**< Thumbnail image file path */
+       int             played_count;                                                           /**< played count */
+       int             time_played;                                                                    /**< last played time */
+       int             time_added;                                                                     /**< added time */
+       int             rating;                                                                         /**< user defined rating */
+       int             category;                                                                       /**< category. sound or music*/
+       int             favourate;                                                                      /**< favourate. o or 1 */
+       audio_svc_audio_meta_s          audio;                                  /**< meta data structure for audio files */
+} audio_svc_audio_item_s;
+
+
+#define SAFE_FREE(src)      { if(src) {free(src); src = NULL;}}
+
+/**
+ * Group item search result record
+ */
+typedef struct{
+       char maininfo[AUDIO_SVC_METADATA_LEN_MAX];                      /**< main info of group */
+       char subinfo[AUDIO_SVC_METADATA_LEN_MAX];                       /**< sub info of group */
+       char thumbnail_path[AUDIO_SVC_PATHNAME_SIZE];                   /**< Thumbnail image file path */
+       int album_rating;                                                                               /**< album rating*/
+}audio_svc_group_item_s;
+
+/**
+ * List item search result record
+ */
+typedef struct{
+       char     audio_id[AUDIO_SVC_PATHNAME_SIZE+1];                   /**< Unique ID of item */
+       char pathname[AUDIO_SVC_PATHNAME_SIZE];                 /**< Full path and file name of media file */
+       char title[AUDIO_SVC_METADATA_LEN_MAX];                         /**< title of track */
+       char artist[AUDIO_SVC_METADATA_LEN_MAX];                        /**< artist of track */
+       char thumbnail_path[AUDIO_SVC_PATHNAME_SIZE];                   /**< Thumbnail image file path */
+       int duration;                                                                                   /**< track duration*/
+       int rating;                                                                                     /**< track rating*/
+}audio_svc_list_item_s;
+
+/**
+ * Playlist record
+ */
+typedef struct{
+       int playlist_id;                                                                                /**< Unique ID of playlist*/
+       char name[AUDIO_SVC_METADATA_LEN_MAX];                  /**< playlist name*/
+       char thumbnail_path[AUDIO_SVC_PATHNAME_SIZE];                   /**< Thumbnail image file path */
+}audio_svc_playlist_s;
+
+typedef struct{
+       int u_id;                                                                                               /**< Unique ID of playlist item*/       
+       char     audio_id[AUDIO_SVC_PATHNAME_SIZE+1];                   /**< Unique Audio ID */
+       char pathname[AUDIO_SVC_PATHNAME_SIZE];                 /**< Full path and file name of media file */
+       char title[AUDIO_SVC_METADATA_LEN_MAX];                         /**< title of track */
+       char artist[AUDIO_SVC_METADATA_LEN_MAX];                        /**< artist of track */
+       char thumbnail_path[AUDIO_SVC_PATHNAME_SIZE];                   /**< Thumbnail image file path */
+       int duration;                                                                                   /**< track duration*/
+       int rating;                                                                                     /**< track rating*/
+       int play_order;                                                                         /**< Play order*/
+}audio_svc_playlist_item_s;
+
+typedef enum{
+       AUDIO_SVC_QUERY_INSERT_ITEM,
+       AUDIO_SVC_QUERY_SET_ITEM_VALID,
+       AUDIO_SVC_QUERY_MOVE_ITEM,
+}audio_svc_query_type_e;
+
+/**
+       @}
+ */
+
+#endif /*_AUDIO_SVC_TYPES_PRIV_H_*/
diff --git a/src/include/audio/audio-svc-utils.h b/src/include/audio/audio-svc-utils.h
new file mode 100755 (executable)
index 0000000..a9cb62b
--- /dev/null
@@ -0,0 +1,75 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+\r
+\r
+#ifndef _AUDIO_SVC_UTILS_H_\r
+#define _AUDIO_SVC_UTILS_H_\r
+\r
+\r
+/**\r
+ * @file               audio-svc-utils.h\r
+ * @version    0.1\r
+ * @brief      This file defines utilities for Audio Service.\r
+ */\r
+\r
+#include <stdlib.h>\r
+#include <stdio.h>\r
+#include <stdbool.h>\r
+#include <string.h>\r
+#include "audio-svc-types.h"\r
+#include "audio-svc-types-priv.h"\r
+\r
+\r
+#ifndef FALSE\r
+#define FALSE  0\r
+#endif\r
+#ifndef TRUE\r
+#define TRUE   1\r
+#endif\r
+\r
+#if !defined( min )\r
+    #define min(a, b) ((a)<(b)?(a):(b))\r
+#endif\r
+\r
+#define str_2_year(year)       ((!strcmp(year,  AUDIO_SVC_TAG_UNKNOWN) ) ? -1 : atoi(year))\r
+#define STRING_VALID(str)      \\r
+       ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)\r
+\r
+char * _year_2_str(int year);\r
+void _strncpy_safe(char *x_dst, const char *x_src, int max_len);\r
+void _strlcat_safe(char *x_dst, char *x_src, int max_len);\r
+void _audio_svc_get_parental_rating(const char *path, char *parental_rating);\r
+int _audio_svc_extract_metadata_audio(audio_svc_storage_type_e storage_type, const char *path, audio_svc_audio_item_s *item);\r
+int _audio_svc_remove_all_files_in_dir(const char *dir_path);\r
+int _audio_svc_get_drm_mime_type(const char *path, char *mime_type);\r
+bool _audio_svc_possible_to_extract_title_from_file(const char *path);\r
+bool _audio_svc_get_thumbnail_path(audio_svc_storage_type_e storage_type, char *thumb_path, const char *pathname, const char *img_format);\r
+bool _audio_svc_copy_file(const char* srcPath, const char* destPath);\r
+bool _audio_svc_make_file(const char* path);\r
+bool _audio_svc_remove_file(const char* path);\r
+bool _audio_svc_make_directory(const char* path);\r
+char * _audio_svc_get_title_from_filepath (const char *path);\r
+unsigned int _audio_svc_print_elapse_time(int start_time, const char* log_msg);\r
+int _audio_svc_get_order_field_str(audio_svc_search_order_e order_field, char* output_str, int len);\r
+int _audio_svc_get_file_dir_modified_date(const char *full_path);\r
+\r
+#endif /*_AUDIO_SVC_UTILS_H_*/\r
diff --git a/src/include/audio/md5_hash.h b/src/include/audio/md5_hash.h
new file mode 100755 (executable)
index 0000000..0a75d05
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#ifndef __MD5_HASH_H__
+#define __MD5_HASH_H__
+#include <stdint.h>
+#include <sys/types.h>
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief  Generate '\0'-terminated hashcode string of 'file'.
+ *         The hashcode consists of 32-byte [0-9a-f] chars.
+ *         You should not free returned result, it's internally
+ *         static allocated. You may need to make a copy of result
+ *         because the buffer will be modified by subsequent calling of
+ *         this function.
+ * @param file  Full pathname, or generally char string.
+ * @return  Generated hashcode string,
+ *          or NULL if parameter 'file' is NULL.
+ */
+char* _audio_svc_generate_hash(const char* file);
+
+/**
+ * @brief  Generate corresponding thumbnail file's full pathname.
+ *         You should not free returned result, it's internally
+ *         static allocated. You may need to make a copy of result
+ *         because the buffer will be modified by subsequent calling of
+ *         this function.
+ * @param full_pathname  Origin file full pathname.
+ * @return  Generated thumbnail file's full pathname, or
+ *          NULL if full_pathname is NULL or full_pathname is not valid
+ *          for file manager service.
+ */
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__MD5_HASH_H__*/
diff --git a/src/include/common/media-info-debug.h b/src/include/common/media-info-debug.h
new file mode 100755 (executable)
index 0000000..fcf95b4
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#ifndef _MEDIA_INFO_DEBUG_H_
+#define _MEDIA_INFO_DEBUG_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "Media-Info"
+
+#define mediainfo_dbg(fmt, arg...)      LOGD("[%s : %d] [%s] " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##arg)
+
+#ifdef _USE_LOG_FILE_
+void mediainfo_init_file_debug();
+void mediainfo_close_file_debug();
+FILE* get_fp();
+#define mediainfo_file_dbg(fmt,arg...)      fprintf( get_fp(), "[%s: %d] [%s]" fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##arg)
+
+#endif
+
+
+#ifdef _PERFORMANCE_CHECK_
+long
+mediainfo_get_debug_time(void);
+void
+mediainfo_reset_debug_time(void);
+void
+mediainfo_print_debug_time(char* time_string);
+void
+mediainfo_print_debug_time_ex(long start, long end, const char* func_name, char* time_string);
+#endif
+
+#endif /*_MEDIA_INFO_DEBUG_H_*/
diff --git a/src/include/common/media-info-env.h b/src/include/common/media-info-env.h
new file mode 100755 (executable)
index 0000000..b5415cd
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#ifndef _MEDIA_INFO_ENV_H_
+#define _MEDIA_INFO_ENV_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MEDIA_INFO_DATABASE_NAME "/opt/dbspace/.media.db"
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_MEDIA_INFO_ENV_H_*/
diff --git a/src/include/common/media-info-util.h b/src/include/common/media-info-util.h
new file mode 100755 (executable)
index 0000000..938d8c1
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#ifndef _MEDIA_INFO_UTIL_H_
+#define _MEDIA_INFO_UTIL_H_
+
+#include <string.h>
+#include <alloca.h>
+#include <sqlite3.h>
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "media-info-env.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MEDIAINFO_CATEGORY_UNKNOWN    0x00000000  /**< Default */
+#define MEDIAINFO_CATEGORY_ETC        0x00000001  /**< ETC category */
+#define MEDIAINFO_CATEGORY_IMAGE      0x00000002  /**< Image category */
+#define MEDIAINFO_CATEGORY_VIDEO      0x00000004  /**< Video category */
+#define MEDIAINFO_CATEGORY_MUSIC      0x00000008  /**< Music category */
+#define MEDIAINFO_CATEGORY_SOUND      0x00000010  /**< Sound category */
+#define MEDIAINFO_CATEGORY_DRM        0x00000020  /**< DRM category */
+
+typedef enum {
+       MEDIAINFO_PHONE,  /**< Phone storage */
+       MEDIAINFO_MMC     /**< MMC storage */
+} mediainfo_store_type;
+
+#define MEDIAINFO_PHONE_ROOT_PATH         "/opt/media"
+#define MEDIAINFO_MMC_ROOT_PATH           "/opt/storage/sdcard"
+
+
+typedef struct _handle_table {
+       int ref_cnt;
+       sqlite3* handle;
+} HandleTable;
+
+
+int
+_media_info_get_thread_id();
+
+/* To manage handles in each trhead, use GHashTable */
+int
+_media_info_init_handle_tbl();
+
+int
+_media_info_finalize_handle_tbl();
+
+int
+_media_info_insert_handle(int** tid_key, int tid, HandleTable** handle_table);
+
+int
+_media_info_remove_handle(int tid);
+
+HandleTable*
+_media_info_search_handle(int tid);
+
+sqlite3*
+_media_info_get_proper_handle();
+
+void
+_media_info_atomic_add_counting(HandleTable *handle_table);
+
+void
+_media_info_atomic_sub_counting(HandleTable *handle_table);
+
+char *_media_info_generate_uuid();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_MEDIA_INFO_UTIL_H_*/
diff --git a/src/include/visual/AGifFrameInfo.h b/src/include/visual/AGifFrameInfo.h
new file mode 100644 (file)
index 0000000..56da836
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _AGIFFRAMEINFO_H_
+#define _AGIFFRAMEINFO_H_
+
+typedef struct tagFrameInfo
+{
+       int height;
+       int     width;
+       unsigned int backcolor;
+       unsigned int ui_backcolor;
+       int imgCount;
+       int inputSize;
+
+       unsigned char *pEncodedData;
+       void *pOutBits;                                 
+
+       unsigned char *pPrevImg;                
+       unsigned int *pGlobal_table;    
+       unsigned short *pPrefix;                
+       unsigned char *pDstack; 
+       unsigned char *pSuffix;                 
+
+       int flag;
+       int size;
+       int useBuffer;
+       int bLoop;
+       int global_numcol;
+       int resizedwidth;
+       int resizedheight;
+       int logi_wdt;
+       int logi_hgt;
+       int offset;
+       int firstpos;  
+
+       unsigned short delay;
+
+#ifdef INTERNAL_IMGCODEC
+       unsigned int nRepeatCount;
+       unsigned int nLoopCount;        
+
+       unsigned char bOneFrame;
+#endif
+}AGifFrameInfo;
+
+#endif  //  _AGIFFRAMEINFO_H_ 
diff --git a/src/include/visual/IfegDecodeAGIF.h b/src/include/visual/IfegDecodeAGIF.h
new file mode 100644 (file)
index 0000000..9e3c121
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _IFEG_DECODE_GIF_H_
+#define _IFEG_DECODE_GIF_H_
+
+
+
+#include "AGifFrameInfo.h"
+#include "media-img-codec-common.h"
+
+
+
+#define MODE 0
+
+#define MAX_GIF_HEADER_SIZE 4096
+
+#if MODE == 2
+#define MAXBUFFMEMORY 330000
+#endif
+
+#define MAXWIDTH 4096
+#define MAXHEIGHT 4096
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+int FastImgGetNextFrameAGIF (AGifFrameInfo* pFrameData, BOOL bCenterAlign);
+AGifFrameInfo* FastImgCreateAGIFFrameData(unsigned int width, unsigned int height, unsigned char *pEncodedData, unsigned int file_size, unsigned int ui_backcolor, BOOL bLoop);
+void FastImgDestroyAGIFFrameData(AGifFrameInfo* pFrameData);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /*_IFEG_DECODER_H_*/
diff --git a/src/include/visual/media-img-codec-agif.h b/src/include/visual/media-img-codec-agif.h
new file mode 100644 (file)
index 0000000..2057b8a
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _IMGCODEC_AGIF_H_
+#define _IMGCODEC_AGIF_H_
+
+#include "IfegDecodeAGIF.h"
+
+#endif /*_IMGCODEC_AGIF_H_*/
+
diff --git a/src/include/visual/media-img-codec-common.h b/src/include/visual/media-img-codec-common.h
new file mode 100644 (file)
index 0000000..2ec020f
--- /dev/null
@@ -0,0 +1,304 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _IMGCODEC_COMMON_H_
+#define _IMGCODEC_COMMON_H_
+
+#include "media-img-codec-config.h"
+#include "media-img-codec-osal.h"
+#include <stdio.h>
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+//////////////////////////////////////////////////////////////
+
+/* Maximum Image File Size Supported */
+#define        IMG_MAX_IMAGE_FILE_SIZE                 (10 * 1024 * 1024)
+
+//////////////////////////////////////////////////////////////
+#define ImgDebug(type, fmt, arg...)    \
+       do { \
+               fprintf(stderr, "[Media-SVC]"fmt, ##arg);       \
+       }while(0)
+       
+#if 1
+#define SysRequireEx(expr, retValue)   \
+       if (!(expr)) {                                                                                                                                                  \
+               fprintf(stderr, "[Media-SVC][%s] INVALID_PARAM (%d lines in %s)\n",__FUNCTION__,  __LINE__, __FILE__);  \
+               return (retValue);                                                                                                                                      \
+       }
+#define SysDebug(X)            ImgDebug X      
+       
+#define SysAssert(expr)
+#else
+#define SysRequireEx(expr, retValue)
+#define SysDebug(expr, retValue)
+#define SysAssert(expr)
+#endif
+
+//////////////////////////////////////////////////////////////
+
+
+typedef enum
+{
+       IMG_INFO_DECODING_FAIL          =  0,
+       IMG_INFO_DECODING_SUCCESS       =  1,
+       IMG_INFO_AGIF_LAST_FRAME        =  2,
+       IMG_INFO_TOO_BIG_FILE_SIZE      = -1,
+       IMG_INFO_TOO_LARGE_SCALE        = -2,
+       IMG_INFO_TOO_BIG_PROGRESSIVE= -3,
+       IMG_INFO_UNKNOWN_FORMAT         = -4,
+       IMG_INFO_FILE_ERR                               = -5,
+       IMG_INFO_MEM_ALLOC_FAIL         = -6
+}ImgFastCodecInfo;
+
+
+
+typedef enum
+{
+       IMG_CODEC_UNKNOWN_TYPE = -2,
+       IMG_CODEC_BIG_PROGRESSIVE_JPEG = -1,
+       IMG_CODEC_NONE  = 0,
+       IMG_CODEC_GIF   = ( 1 << 0),
+       IMG_CODEC_PNG   = ( 1 << 1),
+       IMG_CODEC_WBMP  = ( 1 << 2),
+       IMG_CODEC_JPEG  = ( 1 << 3),
+       IMG_CODEC_BMP   = ( 1 << 4),
+       IMG_CODEC_TIF   = ( 1 << 5),
+       IMG_CODEC_AGIF  = ( 1 << 6),
+       IMG_CODEC_PROGRESSIVE_JPEG = ( 1 << 7),
+       IMG_CODEC_DRM    = ( 1 << 8),   
+} ImgCodecType;
+
+typedef        enum inputFlag
+{
+       IMG_RGB_888_OUTPUT              = 0x0001,
+       IMG_RGB_OUTPUT                  = 0x0002,
+       IMG_YUV_OUTPUT                  = 0x0005
+}ImgInputFlag;
+
+typedef        enum resize
+{
+       /* During resizing aspect ratio will be maintained */
+       IMG_RESIZE_MAINTAIN_ASPECT_RATIO        = 0x0001,
+       IMG_RESIZE                                                      = 0x0002
+} ImgResizeInput;
+
+
+typedef struct tagImgImageInfo
+{
+       unsigned int            width;
+       unsigned int            height;
+       unsigned int            numberOfFrame;
+       unsigned int            delay;  //deprecated.
+       unsigned int            bOrientation;   //deprecated.
+}ImgImageInfo;
+
+typedef struct tagImgBitmap
+{
+       int             width;
+       int             height;
+       UCHAR   bitsPerPixel;  /* For TIF  it should be 8 or 4 or 1 always
+                                                   * If coming directly from camera and
+                                                       * bitsperpixel is 16 then its assumed as 8
+                                                       * & color type as RGBC and compression
+                                                       * type as NO_COMP and encode it.
+                                                       */
+
+       void    *pBits;
+    BOOL       bChromaKeyFlag; /* Flag to indicate chroma key
+                                                        * Default: FALSE
+                                                        */
+       ULONG   chromaKey;              /* This is the colour which needs to be (or is) transparent.
+                                                        * This colour will be in 5, 5, 5 RGB format as below.
+                                                        * First 16 MS Bits 0, R (5), G (5), 0 (1), B (5)
+                                                        */
+    UCHAR      disposal;               /* Disposal action to take during
+                                                        *  display of current flag
+                                                        *  Default: 0
+                                                        */
+       USHORT  delay;                  /* Delay before display of
+                                                        *  next frame. Default: 0
+                                                        */
+       BOOL    inputFlag;      /* User input required befflag used
+                                                        * Default: FALSE
+                                                        */
+
+       BOOL    interlace;      /* Interlace indicator flag
+                                                        *  Default: FALSE
+                                                        */
+    BYTE       *pLocalColorMap;/* Local color palette pointer
+                                                        *  Default: NULL
+                                                        */
+                                                        /* For TIF :Should be given if  PALETTE color type.
+                                                         */
+    USHORT  localColorMapSize;
+                             /* Local color palette size */
+                                                        /* In TIF: Should be given if  PALETTE color type.
+                                                         */
+    void       *pAlphaChannel; /* An alpha channel, representing transparency
+                                                        * information on a per-pixel basis
+                                                        */
+       BYTE    colorType ;             /* Indicates the color type of image. It can be
+                                                        * GRAY, COLOR, PALETTED, GRAY_WITH_ALPHA_CHANNEL or
+                                                        * COLOR_WITH_ALPHA_CHANNEL
+                                                        */
+                                                        /* For TIF: IT could be TIF_COLORTYPE_BILEVEL,
+                                                         * TIF_COLORTYPE_GRAY ,TIF_COLORTYPE_RGB,
+                                                         * TIF_COLORTYPE_PALETTE or
+                                                         * TIF_COLORTYPE_RGBPALETTE.
+                                                         */
+       BYTE    filter ;                /* Type of filter to apply. Could be one of NONE,
+                                                        * SUB, UP, AVERAGE or PAETH
+                                                        */
+       BYTE    compressionMethod ; /* Type of compression in zLib to apply. Could be
+                                                                * one of NONE, FIXED or DYANMIC
+                                                                */
+                                                                /*  For TIF : IT could be TIF_COMP_NOCOMP ,
+                                                                 * TIF_COMP_PACKBIT or TIF_COMP_HUFFMAN (only for bilevel)
+                                                                 */
+
+       UCHAR   colorConversion;        /* Indicates whether color conversion has to
+                                                                * be done or not
+                                                                */
+                                                               /* For TIF :This represents  white is zero or
+                                                                * black is zero in case of bilevel & gray.
+                                                                */
+       UCHAR   downSampling;           /* Indicates whether down sampling needs to
+                                                                * be done or not
+                                                                */
+
+       UCHAR           downSamplingMethod[3];
+               /* Down sampling offsets for every component. Possible
+                * combinations are
+                *      1, 1, 1
+                *      1, 2, 1
+                *      1, 2, 2
+                */
+} ImgBitmap;
+
+typedef struct tagImgCodecColor
+{
+       UINT16  red;
+       UINT16  green;
+       UINT16  blue;
+} ImgCodecColor;
+
+
+typedef struct
+{
+    int                                width, height, bpp;
+
+    BOOL                       tRNSFlag;
+    ImgCodecColor      tRNSColor;
+
+    BOOL                       bKGDFlag;
+    ImgCodecColor      bKGDColor;
+
+    BOOL                       AlphaChannelFlag;
+    unsigned short     *pAlphaChannel;
+} ImgTrnsInfo;
+
+typedef struct tagImgBitmapElem ImgBitmapElem;
+
+struct tagImgBitmapElem
+{
+       int                                     x;
+       int                                     y;
+       ImgBitmap                       *pbmBitmap;
+       ImgBitmapElem           *pNext;
+};
+
+typedef struct gifDecode       ImgGIFFrame ;
+
+typedef struct tagImgImage
+{
+    int                                dataSize;                       /* Holds the total number of bytes required
+                                                                                * to hold the image
+                                                                                */
+    int                                width;
+    int                                height;
+
+    USHORT                     flag;                           /*      This contains flags as defined
+                                                                                *      in ImgCodecFlagType
+                                                                                */
+    ULONG                      backGroundColor;        /* The backgroundColor specifies a default background
+                                                                                * color to present the image against.
+                                                                                * Note that viewers are not bound to honor this color.
+                                                                                * A viewer can choose to use a different background.
+                                                                                */
+    BYTE                       *pGlobalColorMap;       /*      Global color palette pointer
+                                                                                *      Default: NULL
+                                                                                */
+    USHORT          globalColorMapSize; /* Local color palette size */
+    ULONG                      gamma;                          /* The value is encoded as a 4-byte unsigned integer,
+                                                                                * representing gamma times 100000. For example, a
+                                                                                * gamma of 0.45 would be stored as the integer 45000.
+                                                                                */
+       int                             bitmapCount;            /* This will hold the number of bitmaps in the
+                                                                                * ImgImage structure
+                                                                                */
+       BYTE                    function ;                      /* This will be set as TRUE if this structure is
+                                                                                * used for encoder
+                                                                                */
+
+       ImgBitmapElem   *pHead;
+       ImgBitmapElem   *pTail;
+
+
+       ULONG                   decodedSize ;   /* 1 => Same as in the encoded stream
+                                                                        * 0 => Resize to QQVGA if size is more
+                                                                        * than 176 x 144
+                                                                        */
+
+       BOOL                    memAllocEx ;    /* TRUE => MemAllocEx is used,
+                                                                        * FALSE => MemAlloc is used
+                                                                        */
+
+       USHORT                  loopCount ;             /* This will contain the number of times to repeat
+                                                                        * the animation
+                                                                        */
+       BOOL                    bLoopCount ;    /* If GIF LoopCount is present then this will be
+                                                                        * TRUE, otherwise it will be false
+                                                                        */
+
+       ImgGIFFrame             *pGifFrame ;    /* Stores the intermediate GIF Frame */
+
+       ImgInputFlag    inputFlag;
+       ImgResizeInput  resizeMethod ;
+
+       /* Flag to identify whether image is AGIF or not */
+       BOOL                    bAGIFImage ;
+       unsigned char   *pEncodedData ;
+       INT32                   cFileSize ;
+       BOOL                    bFirstFrame ;
+       BOOL                    bReservedMemoryFlag;
+       unsigned int    offset ;
+} ImgImage;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif         // _IMGCODEC_COMMON_H_
diff --git a/src/include/visual/media-img-codec-config.h b/src/include/visual/media-img-codec-config.h
new file mode 100644 (file)
index 0000000..069d4a3
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _IMGCODEC_CONFIG_H_
+#define _IMGCODEC_CONFIG_H_
+#define INTERNAL_IMGCODEC
+
+#endif         // _IMGCODEC_CONFIG_H_
diff --git a/src/include/visual/media-img-codec-osal.h b/src/include/visual/media-img-codec-osal.h
new file mode 100644 (file)
index 0000000..0c47148
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _IMGCODEC_OSAL_H_
+#define _IMGCODEC_OSAL_H_
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifndef BOOL
+
+#define BOOL   bool//unsigned short
+#endif
+
+#ifndef UCHAR
+
+#define UCHAR          unsigned char
+#endif
+
+#ifndef BYTE
+
+#define BYTE                   unsigned char
+#endif
+
+#ifndef USHORT
+
+#define USHORT         unsigned short 
+#endif
+
+#ifndef UINT16
+
+#define UINT16         unsigned short 
+#endif
+
+#ifndef UINT32
+
+#define UINT32         unsigned short 
+#endif
+
+#ifndef UINT
+
+#define UINT                   unsigned int
+#endif
+
+#ifndef INT32
+
+#define INT32          unsigned int 
+#endif
+
+#ifndef ULONG
+
+#define ULONG          unsigned long 
+#endif
+
+#ifndef TRUE
+#define TRUE           true
+#endif
+
+#ifndef FALSE
+#define        FALSE           false
+#endif
+
+#ifndef INVALID_HOBJ
+#define INVALID_HOBJ   (-1)
+#endif
+
+
+typedef void*                          HFile;
+
+#define        AcMemalloc              IfegMemAlloc    
+#define        AcMemfree               IfegMemFree
+#define        AcMemcmp                IfegMemcmp
+#define        AcMemset                IfegMemset
+#define        AcMemcpy                IfegMemcpy
+
+typedef struct
+{
+       ULONG           fileSize;                               // File size
+       ULONG*          startAddr;                      // Only used at LFS
+       ULONG           attribute;                      // file attribute like directory or file, hidden, readonly, system, ...
+       int                     iVol;                                   // positioned volume
+       ULONG           allocatedSize;          // real allocated size of file & directory in sub System
+} FmFileAttribute;
+
+void * IfegMemAlloc(unsigned int size);
+void   IfegMemFree(void* pMem);
+void * IfegMemcpy( void *dest, const void *src, unsigned int count );
+void * IfegMemset( void *dest, int c, unsigned int count );
+int            IfegMemcmp(const void* pMem1, const void* pMem2, size_t length);
+
+ULONG  IfegGetAvailableMemSize(void);
+
+HFile  DrmOpenFile(const char* szPathName);
+BOOL   DrmReadFile(HFile hFile, void* pBuffer, ULONG bufLen, ULONG* pReadLen);
+long   DrmTellFile(HFile hFile);
+BOOL   DrmSeekFile(HFile hFile, long position, long offset);
+BOOL   DrmGetFileAttributes(const char* szPathName, FmFileAttribute* pFileAttr);
+BOOL   DrmCloseFile(HFile hFile);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif         // _IMGCODEC_OSAL_H_
+
+
diff --git a/src/include/visual/media-img-codec-parser.h b/src/include/visual/media-img-codec-parser.h
new file mode 100644 (file)
index 0000000..0924e3c
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _IMGCODEC_PARSER_H_
+#define _IMGCODEC_PARSER_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define                MINIMUM_HEADER_BYTES    8
+
+#define                PNG_HEADER_LENGTH       8
+#define                JPG_HEADER_LENGTH       2
+#define                GIF_HEADER_LENGTH       3 
+#define                TIFF_HEADER_LENGTH      2
+#define                BMP_HEADER_LENGTH       2
+#define                TIFF_IMAGE_WIDTH        0x100
+#define                TIFF_IMAGE_HEIGHT       0x101
+
+ImgCodecType ImgGetInfo(unsigned char* pEncodedData, unsigned long fileSize, ImgImageInfo* imgInfo);
+ImgCodecType ImgGetInfoFile(const char*filePath, ImgImageInfo *imgInfo);
+ImgCodecType ImgGetInfoHFile(HFile hFile, unsigned long fileSize, ImgImageInfo* imgInfo);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+
diff --git a/src/include/visual/media-img-codec.h b/src/include/visual/media-img-codec.h
new file mode 100644 (file)
index 0000000..983eb59
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _IMGCODEC_H_
+#define _IMGCODEC_H_
+
+#include "media-img-codec-common.h"
+#include "media-img-codec-parser.h"
+#include "media-img-codec-agif.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+unsigned int* ImgGetFirstFrameAGIFAtSize(const char *szFileName, ImgImageInfo *image_info);
+
+int ImgConvertRGB565ToRGB888(void *pBuf_rgb565, void **pBuf_rgb888, int width, int height);
+
+
+AGifFrameInfo* ImgCreateAGIFFrame(const char *szFileName, unsigned int width, unsigned int height, unsigned int bgColor, BOOL bLoop);
+
+void                           ImgDestroyAGIFFrame(AGifFrameInfo* pFrameData);
+
+ImgFastCodecInfo       ImgGetNextAGIFFrame (AGifFrameInfo *gFrameData, BOOL bCenterAlign);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif         // _IMGCODEC_H_
diff --git a/src/include/visual/media-svc-api.h b/src/include/visual/media-svc-api.h
new file mode 100755 (executable)
index 0000000..ae12781
--- /dev/null
@@ -0,0 +1,1045 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/** 
+ * This file is  main header file of media service.
+ *
+ * @file               media-svc-api.h
+ * @author     Lin Chaolong(chaolong.lin@samsung.com)
+ * @version    1.0
+ * @brief              This file is header file api.
+ */
+
+/**
+* @ingroup MEDIA_SVC
+* @defgroup    MEDIA_SVC_API out-house media service API
+* @{
+*/
+
+#ifndef _MEDIA_SERVICE_API_H_
+#define _MEDIA_SERVICE_API_H_
+
+#include <glib.h>
+#include "media-svc-structures.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+* @fn    int  mb_svc_insert_file(char* file_full_path, mb_svc_media_type_t content_type);
+* This function insert file information into folder table, meida table, image_meta table/video_meta table and bookmark table
+*
+* @return                        This function returns 0 on success, and negative value on failure.
+* @param[in]                    file_full_path           the full path of file
+* @param[in]                    content_type      the file type, maybe video, image and so on
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+
+int
+mb_svc_insert_file(const char* file_full_path, minfo_file_type content_type);
+
+
+/**
+* @fn    int  mb_svc_delete_file(char* file_full_path, mb_svc_media_type_t type);
+* This function deletes file information from folder table,media table and related tables
+*
+* @return                        This function returns 0 on success, and negative value on failure.
+* @param[in]                     file_full_path           full path of file
+* @exception                     None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+
+int 
+mb_svc_delete_file(const char* file_full_path);
+
+/**
+* @fn    int  mb_svc_update_file(char* old_file_full_path, char *new_file_full_path, mb_svc_media_type_t type);
+* This function updates file information for media table, image_meta table/video_meta table
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    old_file_full_path           full path of old file
+* @param[in]                    new_file_full_path           full path of updated file
+* @param[in]                    type                         file type,maybe image,video and so on
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+
+int 
+mb_svc_update_file(const char* old_file_full_path, const char *new_file_full_path, minfo_file_type content_type);
+
+/**
+* @fn    int  mb_svc_rename_file(char *old_file_full_path, char *new_file_full_path, mb_svc_media_type_t type, char* thumb_path);
+* This function updates media table due to file name is changed
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    old_file_full_path           full path of old file
+* @param[in]                    new_file_full_path           full path of renamed file
+* @param[in]                    type                         file type,maybe image,video and so on
+* @param[out]                   thumb_path                   new file thumb path
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+
+int 
+mb_svc_rename_file(const char *old_file_full_path, const char *new_file_full_path, minfo_file_type content_type, char* thumb_path);
+
+/**
+* @fn    int  mb_svc_move_file(char *old_file_full_path, char *new_file_full_path, mb_svc_media_type_t type, char* thumb_path);
+* This function updates media table and folder table due to the file is moved
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    old_file_full_path           old full path of file
+* @param[in]                    new_file_full_path           new full path of file
+* @param[in]                    type                         file type, maybe image,video and so on
+* @param[out]                   thumb_path                   new file thumb path
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+
+int 
+mb_svc_move_file(const char *old_file_full_path, const char *new_file_full_path, minfo_file_type content_type, char* thumb_path);
+
+/**
+* @fn    int  mb_svc_move_file_by_id(const char *src_media_id, const char *dst_cluster_id);
+* This function moves a media to destination cluster
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    src_media_id           id of source media
+* @param[in]                    dst_cluster_id        id of destination cluster
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+
+int 
+mb_svc_move_file_by_id(const char *src_media_id, const char *dst_cluster_id);
+
+/**
+* @fn    int  mb_svc_copy_file(char *old_file_full_path, char *new_file_full_path, mb_svc_media_type_t type, char* thumb_path);        
+* This function updates folder table, media table and image_meta/video_meta table
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    old_file_full_path           old full path of file
+* @param[in]                    new_file_full_path           new full path of file
+* @param[in]                    type                         file type,may be image,video and so on
+* @param[out]                   thumb_path                   new file thumb path
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_copy_file(const char *old_file_full_path, const char *new_file_full_path, minfo_file_type content_type, char* thumb_path);
+
+/**
+* @fn    int  mb_svc_copy_file_by_id(const char *src_media_id, const char *dst_cluster_id);    
+* This function copy a media to the destination cluster.
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    src_media_id           id of source media
+* @param[in]                    dst_cluster_id        id of destination cluster
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_copy_file_by_id(const char *src_media_id, const char *dst_cluster_id);
+
+/**
+* @fn    int  mb_svc_update_cluster_name(const char *cluster_id, const char* new_name);
+* This function update a name of the cluster.
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    cluster_id           id of cluster
+* @param[in]                    new_name               new name of the cluster
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_update_cluster_name(const char *cluster_id, const char* new_name);
+
+void
+mb_svc_sync_files_to_db_with_path(char* dir_full_path);
+
+int
+mb_svc_insert_items();
+
+int
+mb_svc_insert_file_batch(const char *file_full_path, minfo_file_type content_type);
+
+//clock_t 
+long mb_svc_get_clock(void);
+
+
+/**
+* @fn      int mb_svc_initialize();
+* This function connects to media service. 
+*
+* @return                        This function returns 0 on success, and error code on failure.
+* @exception                    None.
+* @remark                        E.g.  
+*                                                             
+*                                                          
+*/
+int mb_svc_initialize();
+/**
+* @fn      int mb_svc_finalize();
+* This function disconnects to media service. 
+*
+* @return                        This function returns 0 on success, and error code on failure.
+* @exception                    None.
+* @remark                        E.g.  
+*                                                             
+*                                                          
+*/
+int mb_svc_finalize();
+
+/**
+* @fn      int mb_svc_get_folder_media_list(int folder_id, int file_type, int favoriate, GList** p_record_list);
+* This function gets folder media list from media table via folder ID. 
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    folder_id        folder id of media file  
+* @param[in]                    file_type         file type (0--image, 1--video, 2--image+video)
+* @param[in]                    favoriate        favoriate image or video 
+* @param[out]                  p_record_list     list of media file obtained
+* @exception                    None.
+* @remark                        list record type is   mb_svc_media_record_s.
+*                                                             
+*                                                          
+*/
+
+int mb_svc_get_folder_media_list(int folder_id, minfo_file_type content_type, int favorite,GList** p_record_list);
+
+
+
+/**
+* @fn      int  mb_svc_get_video_record_by_media_id(int media_id, mb_svc_video_meta_record_s* video_meta_record);
+* This function gets a video record  from video meta table via media ID.
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    media_id        media id of video file
+* @param[out]                  video_meta_record     video record obtained
+* @exception                    None.
+* @remark                        E.g.
+*
+*
+*/
+
+int  mb_svc_get_video_record_by_media_id(const char *media_id, mb_svc_video_meta_record_s* video_meta_record);
+
+/**
+* @fn      int  mb_svc_get_image_record_by_media_id(int media_id, mb_svc_image_meta_record_s* image_meta_record);
+* This function gets a image record  from image meta table via media ID.
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    media_id        media id of video file
+* @param[out]                  image_meta_record     image record obtained
+* @exception                    None.
+* @remark                        E.g.
+*
+*
+*/
+int  mb_svc_get_image_record_by_media_id(const char *media_id, mb_svc_image_meta_record_s* image_meta_record);
+
+/**
+* @fn      int mb_svc_get_video_list(int folder_id, int favoriate, GList** p_record_list);
+* This function gets all the video file in some folder via folder ID. 
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    folder_id        folder id of media file  
+* @param[in]                    favoriate        favoriate video
+* @param[out]                  p_record_list     list of media video file obtained
+* @exception                    None.
+* @remark                        list record type is   mb_svc_video_meta_record_s.
+*                                                             
+*                                                          
+*/
+int mb_svc_get_video_list(int folder_id, int favorite, GList** p_record_list);
+
+/**
+* @fn     int  mb_svc_get_folder_fullpath_by_folder_id( int folder_id, char* folder_fullpath); 
+* This function gets some folder's full path. 
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    folder_id                      folder ID
+* @param[out]                  folder_fullpath         folder  path
+* @max_length[in]             max_length               the maximum length of the @p folder_fullpath
+* @exception                    None.
+* @remark                        E.g.  
+*                                                             
+*                                                          
+*/
+int 
+mb_svc_get_folder_fullpath_by_folder_id(const char *folder_id, char* folder_fullpath, int max_length);
+
+
+/**
+* @fn     int  mb_svc_get_folder_id_by_full_path( const char* folder_full_path,int* folder_id, int max_length);        
+* This function gets some folder's full path. 
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                   folder_fullpath         folder  path
+* @param[out]                  folder_id                       folder ID
+* @exception                    None.
+* @remark                        E.g.  
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_get_folder_id_by_full_path( const char* folder_full_path, char *folder_id, int max_length);
+
+/**
+* @fn     int  mb_svc_get_folder_id_by_web_album_id(const char* web_album_id,int* folder_id);  
+* This function could get folder id of a cluster, using its web album ID. 
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    web_album_id           web album ID of a web cluster.
+* @param[out]                  folder_id                       folder ID
+* @exception                    None.
+* @remark                        E.g.  
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_get_folder_id_by_web_album_id(const char* web_album_id, char *folder_id);
+
+
+/**
+* @fn    int mb_svc_get_media_fullpath(const char *folder_id, char* media_display_name, char* media_fullpath);
+* This function gets some media file's full path. 
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    folder_id        folder ID
+* @param[in]                    media_display_name        meida file name
+* @param[out]                  media_fullpath     media file  path
+* @exception                    None.
+* @remark                        E.g.  
+*                                                             
+*                                                          
+*/
+int mb_svc_get_media_fullpath(const char *folder_id, char* media_display_name, char* media_fullpath);
+
+
+
+/**
+* @fn     int mb_svc_get_media_image_item_list(int folder_id, int media_type, int favoriate, GList** p_item_list)
+* This function gets all the media item or image item from  record of media table  
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    folder_id        folder id 
+* @param[in]                    favoriate       favoriate media 
+* @param[out]                  p_item_list     media item list
+* @exception                    None.
+* @remark                        This function provide general API to get image, or both video and image list.  
+*                                              Different list correpsonding to different item type.
+*                                              image list item type is mb_svc_image_item_t.
+*                                              media(video and image) list item type is mb_svc_media_item_t.
+
+*                                                             
+*                                                          
+*/
+int mb_svc_get_media_image_item_list(int folder_id, minfo_file_type content_type, int favorite, GList** p_item_list);
+
+
+/**
+* @fn     int mb_svc_get_video_item_list(int folder_id, int favoriate, GList** p_item_list)
+* This function gets video item from  record of media table  
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    folder_id        folder id 
+* @param[in]                    media_type        media type 
+* @param[in]                    favoriate       favoriate media 
+* @param[out]                  p_item_list    video item list
+* @exception                    None.
+* @remark                        list item type is mb_svc_video_item_t.
+*                                                             
+*                                                          
+*/
+int mb_svc_get_video_item_list(int folder_id, int favorite, GList** p_item_list);
+
+/**
+* @fn     int mb_svc_get_media_item_list(int folder_id, int media_type, int favoriate, GList** p_item_list)
+* This function gets all the media item or image item or video item from  record of media table  
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    folder_id        folder id 
+* @param[in]                    media_type        media type 
+* @param[in]                    favoriate       favoriate media 
+* @param[out]                  p_item_list     media item list
+* @exception                    None.
+* @remark                        This function provide general API to get video, or image, or both video and image list.  
+*                                              Different list correpsonding to different item type.
+*                                              video list item type is mb_svc_video_item_t.
+*                                              image list item type is mb_svc_image_item_t.
+*                                              media(video and image) list item type is mb_svc_media_item_t.
+*                                                             
+*                                                          
+*/
+int mb_svc_get_media_item_list(int folder_id, minfo_file_type content_type, int favorite, GList** p_item_list);
+
+/**
+* @fn     int mb_svc_get_all_favorite_media_item_list(int media_type, GList** p_item_list);
+* This function gets all the favorite media item or image item or video item from  record of media table  
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    media_type        media type 
+* @param[out]                  p_item_list     media item list
+* @exception                    None.
+* @remark                        list item type is mb_svc_media_item_t.
+*                                                             
+*                                                          
+*/
+int 
+mb_svc_get_all_favorite_media_item_list(minfo_file_type content_type, GList** p_item_list);
+
+
+
+/**
+* @fn   int mb_svc_get_media_record_cnt_by_folder_id (int folder_id, int* count);
+* This function gets record count in some folder  
+*
+* @return                        This function returns record count.
+* @param[in]                    folder_id        folder id 
+* @param[out]                  count             returned count of records
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+int mb_svc_get_media_record_cnt_by_folder_id(int folder_id, int* count);
+
+/**
+* @fn   int mb_svc_get_folder_list(GList** p_record_list);
+* This function gets all the folders  
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[out]                  p_record_list     folder record list
+* @exception                    None.
+* @remark                        list record type is   mb_svc_folder_record_s.
+*
+*
+*/
+int mb_svc_get_folder_list(GList** p_record_list);
+
+/**
+* @fn  int mb_svc_get_folder_item_list(GList** p_item_list);
+* This function gets all the folder items 
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[out]                  p_record_list     folder item list
+* @exception                    None.
+* @remark                        list item type is mb_svc_folder_item_t. 
+*                                                             
+*                                                          
+*/
+int mb_svc_get_folder_item_list(GList** p_item_list);
+
+/**
+* @fn    int  mb_svc_get_bookmark_record_by_id(int record_id, mb_svc_bookmark_record_s* record);
+* This function gets the bookmark  
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    record_id        bookmark ID 
+* @param[out]                  record     record returned
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+int  mb_svc_get_bookmark_record_by_id(int record_id, mb_svc_bookmark_record_s* record);
+
+/**
+* @fn    int  mb_svc_get_media_tag_by_id(int _id, mb_svc_tag_record_s *mtag_record);
+* This function gets the tag record according to its ID
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    _id                    tag record ID 
+* @param[out]                  mtag_record     tag record returned
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_get_media_tag_by_id(int _id, mb_svc_tag_record_s *mtag_record);
+
+
+/**
+* @fn    int mb_svc_get_bookmark_record_by_media_id(int media_id, mb_svc_bookmark_record_s* bookmark_record);
+* This function gets the bookmark  
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    media_id        media ID 
+* @param[out]                  record          record returned
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int  
+mb_svc_get_bookmark_record_by_media_id(int media_id, mb_svc_bookmark_record_s* bookmark_record);
+
+
+
+/**
+* @fn   int  mb_svc_get_image_list_by_location(double longitude, double latitude, GList** p_record_list);
+* This function gets all the image records at some location  
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    longitude        longitude 
+* @param[in]                    latitude        latitude 
+* @param[out]                  p_record_list    image record list
+* @exception                    None.
+* @remark                        list record type is   mb_svc_image_meta_record_s.
+*
+*
+*/
+int  mb_svc_get_image_list_by_location(double longitude, double latitude, GList** p_record_list);
+
+/**
+* @fn   int  mb_svc_get_video_list_by_location(double longitude, double latitude, GList** p_record_list);
+* This function gets all the video records at some location  
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    longitude        longitude 
+* @param[in]                    latitude        latitude 
+* @param[out]                  p_record_list    video record list
+* @exception                    None.
+* @remark                        list record type is   mb_svc_video_meta_record_s.
+*
+*
+*/
+int  mb_svc_get_video_list_by_location(double longitude, double latitude, GList** p_record_list);
+
+/**
+* @fn   int mb_svc_get_media_item_list_by_location(double longitude, double latitude, int media_type, int favoriate, GList** p_item_list);
+
+* This function gets all the media item at some location  
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    longitude        longitude 
+* @param[in]                    latitude        latitude 
+* @param[in]                    media_type        media type 
+* @param[in]                    favoriate        favoriate media 
+* @param[out]                  p_item_list     media item list
+* @exception                    None.
+* @remark                        list item type is mb_svc_media_location_item_t.
+*                                                             
+*                                                          
+*/
+int mb_svc_get_media_item_list_by_location(double longitude, double latitude, minfo_file_type content_type, int favorite, GList** p_item_list);
+
+
+/**
+* @fn   int  mb_svc_get_web_streaming_record_by_folder_id(int folder_id, GList** p_record_list);
+* This function gets the web streaming records list mapped to folder ID . 
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    folder_id    folder ID
+* @param[out]                  p_record_list    web streaming record list
+* @exception                    None.
+* @remark                        E.g.  
+*                                                             
+*                                                          
+*/
+int  mb_svc_get_web_streaming_record_by_folder_id(int folder_id, GList** p_record_list);
+
+/**
+* @fn   int  mb_svc_get_web_album_list_by_web_account(char *web_account,GList** p_record_list);
+* This function gets the web streaming records list via web account 
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    web_account   web account
+* @param[out]                  p_record_list    web streaming record list
+* @exception                    None.
+* @remark                        list record type is   mb_svc_web_streaming_record_s.
+*
+*
+*/
+int  mb_svc_get_web_album_list_by_web_account(char *web_account,GList** p_record_list);
+
+/**
+* @fn   int  mb_svc_get_web_streaming_item_by_web_account(char *web_account,GList** p_item_list);
+* This function gets the web streaming item list via web account 
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    web_account   web account
+* @param[out]                  p_item_list    web streaming item list
+* @exception                    None.
+* @remark                        list item type is mb_svc_web_streaming_item_t.
+*                                                             
+*                                                          
+*/
+int  mb_svc_get_web_streaming_item_by_web_account(char *web_account,GList** p_item_list);
+
+/**
+* @fn    int  mb_svc_update_favorite_by_media_id(const char *media_id, int favorite);
+* This function update rate field of media record
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    folder_id    folder id
+* @param[in]                    display_name    file name
+* @param[in]                    favorite    favorite
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int
+mb_svc_update_favorite_by_media_id(const char *media_id, int favorite);
+
+/**
+* @fn    int  mb_svc_get_media_record_by_fid_name(int folder_id, char* display_name, mb_svc_media_record_s* m_record);
+* This function gets media record by folder id and file name
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    folder_id     folder id
+* @param[in]                    display_name  file name
+* @param[out]                   m_record      media record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_get_media_record_by_fid_name(const char *folder_id, const char* display_name, mb_svc_media_record_s* m_record);
+
+/**
+* @fn    int  mb_svc_get_folder_content_count_by_folder_id(int folder_id);
+* This function gets matched media record count with specified folder id
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    folder_id           specified folder_id field in media table
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_get_folder_content_count_by_folder_id(const char *folder_id);
+
+/**
+* @fn    int  mb_svc_media_iter_start(int folder_id, mb_svc_media_list_filter* filter, minfo_folder_type folder_type, int valid,  GList* p_folder_id_list, mb_svc_iterator_s* mb_svc_iterator );
+* This function gets media record iterator
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    folder_id             specified folder_id field in media table
+* @param[in]                    filter                specified filter qualification to get matched record
+* @param[in]                    folder_type       specified foler type
+* @param[in]                    valid                 valid or invalid
+* @param[out]                   mb_svc_iterator       pointer to media record iterator
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_media_iter_start(int folder_id, minfo_item_filter* filter, minfo_folder_type folder_type, int valid, GList* p_folder_id_list, mb_svc_iterator_s* mb_svc_iterator);
+
+/**
+* @fn    int  mb_svc_media_iter_start_new(int folder_id, mb_svc_media_list_filter* filter, minfo_folder_type folder_type, int valid,  GList* p_folder_id_list, mb_svc_iterator_s* mb_svc_iterator );
+* This function gets media record iterator
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    folder_id             specified folder_id field in media table
+* @param[in]                    filter                specified filter qualification to get matched record
+* @param[in]                    folder_type       specified foler type
+* @param[in]                    valid                 valid or invalid
+* @param[out]                   mb_svc_iterator       pointer to media record iterator
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_media_iter_start_new(const char *folder_id, minfo_item_filter* filter, minfo_folder_type folder_type, int valid, GList* p_folder_id_list, mb_svc_iterator_s* mb_svc_iterator);
+
+/**
+* @fn    int  mb_svc_media_search_iter_start(minfo_search_field_t search_field, const char *search_str, const minfo_item_filter filter, mb_svc_iterator_s *mb_svc_iterator );
+* This function gets media record iterator
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    search_field             specified field to search
+* @param[in]                    search_str       specified string to search
+* @param[in]                    folder_type       specified foler type
+* @param[in]                    filter                specified filter qualification to get matched record
+* @param[out]                   mb_svc_iterator       pointer to media record iterator
+* @exception                    None.
+*/
+
+int 
+mb_svc_media_search_iter_start(minfo_search_field_t search_field, const char *search_str, minfo_folder_type folder_type, minfo_item_filter filter, mb_svc_iterator_s *mb_svc_iterator);
+
+/**
+* @fn    int  mb_svc_media_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_media_record_s *record);
+* This function gets next media record
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    mb_svc_iterator             pointer to media record iterator
+* @param[out]                   record                      pointer to next media record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_media_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_media_record_s *record);
+
+/**
+* @fn    int  mb_svc_folder_iter_start(minfo_cluster_filter* cluster_filter, mb_svc_iterator_s* mb_svc_iterator);
+* This function gets folder record iterator
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    cluster_filter             pointer to filter qualification to get matched folder record
+* @param[out]                   mb_svc_iterator            pointer to folder record iterator
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_folder_iter_start(minfo_cluster_filter* cluster_filter, mb_svc_iterator_s* mb_svc_iterator);
+
+/**
+* @fn    int  mb_svc_folder_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_folder_record_s *record);
+* This function gets next folder record
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    mb_svc_iterator             pointer to folder record iterator
+* @param[out]                   record                      pointer to next folder record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_folder_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_folder_record_s *record);
+
+/**
+* @fn    int  mb_svc_iter_finish(mb_svc_iterator_s* mb_svc_iterator);
+* This function finalize iterator usage
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    mb_svc_iterator             pointer to folder record iterator
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_iter_finish(mb_svc_iterator_s* mb_svc_iterator);
+
+/**
+* @fn    int  mb_svc_get_media_record_by_id(int media_id,mb_svc_media_record_s *media_record);
+* This function gets media record matched with field _id
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    media_id                    specified fielde "_id" in media table
+* @param[out]                   media_record                pointer to matched media record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int
+mb_svc_get_media_record_by_id(const char *media_id, mb_svc_media_record_s *media_record);
+
+/**
+* @fn    int  mb_svc_get_folder_record_by_id(const char *folder_id, mb_svc_folder_record_s *folder_record);
+* This function gets folder record matched with field _id
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    folder_id                   specified "_id" in folder table
+* @param[out]                   folder_record               pointer to matched folder record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int
+mb_svc_get_folder_record_by_id(const char *folder_id, mb_svc_folder_record_s *folder_record);
+
+/**
+* @fn    int  mb_svc_get_video_id_by_media_id(int media_id, int* video_id);    
+* This function gets video record id by media_id filed in video_meta table
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    media_id             specified media_id field
+* @param[out]                   video_id             pointer to field "_id" in video_meta record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int  
+mb_svc_get_id_by_media_id(int media_id, char* table_name, int* video_id);      
+
+/**
+* @fn    int  mb_svc_delete_folder(const char *folder_id, minfo_store_type storage_type);
+* This function delete folder record,matched media record,image_meta record or video_meta record and bookmark record by field "_id"
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    folder_id            specified "_id" field in folder table
+* @param[in]                    store_type         specified "store_type" field in folder table
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int
+mb_svc_delete_folder(const char *folder_id, minfo_store_type storage_type);
+
+/**
+* @fn    int  mb_svc_webstreaming_iter_start(mb_svc_iterator_s* mb_svc_iterator);
+* This function gets webstreaming record iterator
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[out]                   mb_svc_iterator      pointer to webstreaming record iterator
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_webstreaming_iter_start(mb_svc_iterator_s* mb_svc_iterator);
+
+/**
+* @fn    int  mb_svc_webstreaming_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_web_streaming_record_s *webstreaming_record);
+* This function gets next webstreaming record
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    mb_svc_iterator            pointer to webstreaming record iterator
+* @param[out]                   webstreaming_record        pointer to next webstreaming record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_webstreaming_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_web_streaming_record_s *webstreaming_record);
+
+
+/**
+* @fn    int  mb_svc_bookmark_iter_start(mb_svc_iterator_s* mb_svc_iterator);
+* This function gets bookmark record iterator
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    media_id                  media_id
+* @param[out]                   mb_svc_iterator            pointer to bookmark record iterator
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_bookmark_iter_start(const char *media_id, mb_svc_iterator_s* mb_svc_iterator);
+
+
+/**
+* @fn    int  mb_svc_bookmark_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_bookmark_record_s *record);
+* This function gets next bookmark record
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    mb_svc_iterator             pointer to bookmark record iterator
+* @param[out]                   record                      pointer to next bookmark record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int
+mb_svc_bookmark_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_bookmark_record_s *record);
+
+/**
+* @fn    mb_svc_tag_iter_start(const char *tag_name, int media_id, mb_svc_iterator_s* mb_svc_iterator);
+* This function gets tag record iterator, according tag_name, if any, or media_id.
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    tag_name                  tag name
+* @param[in]                    media_id                  media_id
+* @param[out]                   mb_svc_iterator            pointer to bookmark record iterator
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_tag_iter_start(const char *tag_name, const char *media_id, mb_svc_iterator_s* mb_svc_iterator);
+
+/**
+* @fn    mb_svc_tag_iter_with_filter_start(const char *tag_name, int media_id, minfo_tag_filter, filter, mb_svc_iterator_s* mb_svc_iterator);
+* This function gets tag record iterator, according tag_name, if any, or media_id.
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    tag_name                  tag name
+* @param[in]                    media_id                  media_id
+* @param[in]                    filter                    minfo_tag_filter
+* @param[out]                   mb_svc_iterator            pointer to bookmark record iterator
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_tag_iter_with_filter_start(const char *tag_name, minfo_tag_filter filter, mb_svc_iterator_s* mb_svc_iterator);
+
+/**
+* @fn    int  mb_svc_tag_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_tag_record_s *record);
+* This function gets next tag record
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    mb_svc_iterator             pointer to tag record iterator
+* @param[out]                   record                      pointer to next tag record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_tag_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_tag_record_s *record);
+
+int 
+mb_svc_media_id_list_by_tag_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_tag_record_s *record);
+
+int 
+mb_svc_delete_record_tag(const char *tag_name, const char *media_id);
+
+int 
+mb_svc_rename_record_tag(const char* src_tagname, const char* dst_tag_name);
+
+int 
+mb_svc_rename_record_tag_by_id(const char *media_id, const char* src_tagname, const char* dst_tag_name);
+
+int
+mb_svc_get_tagid_by_tagname(const char* tag_name);
+
+int 
+mb_svc_add_web_streaming_folder(char *folder_id);
+
+int 
+mb_svc_get_web_streaming_folder_id();
+
+int
+mb_svc_get_web_streaming_folder_uuid(char *folder_uuid, int max_length);
+
+int
+mb_svc_get_media_id_by_full_path(const char* file_full_path, char *media_id);
+
+int
+mb_svc_get_media_id_by_http_url(const char* http_url, char* media_id);
+
+int
+mb_svc_get_media_record_by_full_path(const char* file_full_path, mb_svc_media_record_s* record);
+
+int  
+mb_svc_get_web_album_cluster_record(int sns_type, const char* name, const char *account_id, const char *album_id, mb_svc_folder_record_s* folder_record);
+
+int
+mb_svc_delete_invalid_media_records(const minfo_store_type storage_type);
+
+int
+mb_svc_get_folder_name_by_id(const char *folder_id, char *folder_name, int max_length);
+
+int 
+mb_svc_get_folder_list_by_web_account_id(char *web_account, GList** p_record_list);
+
+int 
+mb_svc_geo_media_iter_start(const char *folder_id,
+                                               minfo_folder_type store_filter,
+                                               minfo_item_filter* filter,
+                                               mb_svc_iterator_s* mb_svc_iterator,
+                                               double min_longitude, 
+                                               double max_longitude, 
+                                               double min_latitude, 
+                                               double max_latitude );
+
+int
+mb_svc_get_all_item_count(int *cnt);
+
+int
+mb_svc_get_media_count_by_tagname(const char* tagname, int* count);
+
+int
+mb_svc_delete_tagmap_by_media_id(const char *media_id);
+
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/**
+ * @}
+ */
+
+
+#endif /*_MEDIA_SERVICE_API_H_*/
+
diff --git a/src/include/visual/media-svc-db-util.h b/src/include/visual/media-svc-db-util.h
new file mode 100755 (executable)
index 0000000..78f721a
--- /dev/null
@@ -0,0 +1,199 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/** 
+ * This file defines synchronize apis for phone explorer.
+ *
+ * @file               media-svc-db-util.h
+ * @author             Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version    1.0
+ * @brief      This file defines in-house apis for media service.
+ */
+
+ /**
+  * @ingroup MEDIA_SVC
+  * @defgroup MEDIA_SVC_DB_UTIL in-house media service API
+  * @{
+  */
+
+
+#ifndef _MEDIA_SVC_DB_UTIL_H_
+#define _MEDIA_SVC_DB_UTIL_H_
+       
+#include <glib.h>
+       
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+*  query strings
+*/
+#define MB_SVC_TABLE_EXIST_QUERY_STRING  "select name from sqlite_master where name='%s';"
+#define MB_SVC_TABLE_DROP_QUERY_STRING   "DROP TABLE %s;"
+#define MB_SVC_RECORD_DELETE_QUERY_STRING   "DELETE FROM %s WHERE _id = %d;"
+#define MB_SVC_TABLE_DELETE_QUERY_STRING  "DELETE FROM %s ;"
+#define MB_SVC_TABLE_COUNT_QUERY_STRING  "SELECT count(*) FROM %s"
+#define MB_SVC_TABLE_COUNT_MEDIA "SELECT count(*) FROM %s "
+
+#define MB_SVC_TABLE_SELECT_BOOKMARK_BY_BID_QUERY_STRING   "SELECT _id, media_uuid, marked_time, thumbnail_path FROM %s WHERE _id=%d;"
+#define MB_SVC_TABLE_SELECT_WEB_CLUSTER_RECORD_QUERY_STRING   "SELECT uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s WHERE sns_type = %d AND folder_name = '%q' AND web_account_id = '%q';"
+#define MB_SVC_TABLE_SELECT_WEB_ALBUM_CLUSTER_RECORD_QUERY_STRING   "SELECT uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s WHERE sns_type = %d AND folder_name = '%q' AND web_account_id = '%q' AND web_album_id = '%q';"
+#define MB_SVC_TABLE_SELECT_MEDIA_ID_BY_HTTP_URL "SELECT uuid FROM %s WHERE http_url = '%q';"
+#define MB_SVC_UPDATE_FOLDER_PATH_TABLE "UPDATE %s SET path = REPLACE( path, '%q', '%q');"
+#define MB_SVC_UPDATE_FOLDER_MODIFIED_DATE_TABLE "UPDATE %s SET modified_date = %d where path like '%q';"
+#define MB_SVC_TABLE_SELECT_WEBSTREAMING_RECORD_BY_ID  "SELECT _id, title, duration, url, thumb_path FROM %s WHERE _id=%d;"
+
+#define MB_SVC_TABLE_SELECT_TAG_BY_TID_QUERY_STRING   "SELECT _id, tag_name FROM %s WHERE _id=%d;"
+#define MB_SVC_TABLE_UPDATE_TAG_NAME_QUERY_STRING  "UPDATE %s SET tag_name='%s' WHERE tag_name='%s';"
+#define MB_SVC_TABLE_UPDATE_TAG_NAME_QUERY_STRING_BY_TAG_ID  "UPDATE %s SET tag_name='%q' WHERE _id=%d;"
+#define MB_SVC_TABLE_UPDATE_TAG_MAP_QUERY_STRING_BY_TAG_ID  "UPDATE %s SET tag_id=%d WHERE tag_id=%d;"
+#define MB_SVC_TABLE_SELECT_TAG_COUNT_QUERY_STRING "SELECT _id from %s where tag_name='%q'"
+
+#define MB_SVC_TABLE_DELETE_TAG_MAP_BY_TAGNAME "DELETE FROM %s WHERE tag_id=%d"
+#define MB_SVC_TABLE_DELETE_TAG_BY_TAGID "DELETE FROM %s WHERE _id=%d"
+#define MB_SVC_TABLE_SELECT_MEDIA_CNT_BY_TAGID "SELECT count(*) FROM %s WHERE tag_id=%d"
+
+/* SELECT Query for uuid */
+#define MB_SVC_TABLE_SELECT_MEDIA_BY_MEDIA_UUID  "SELECT uuid, path, folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url FROM %s WHERE uuid = '%s' AND valid = 1;"
+#define MB_SVC_TABLE_SELECT_FOLDER_RECORD_BY_UUID  "SELECT uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s WHERE uuid = '%s';"
+#define MB_SVC_TABLE_SELECT_VIDEO_BY_MUUID  "SELECT _id, media_uuid, album, artist, title, description, youtube_category, last_played_time, duration, longitude, latitude, width, height, datetaken FROM %s WHERE media_uuid = '%s';"
+#define MB_SVC_TABLE_SELECT_IMAGE_BY_MUUID  "SELECT _id, media_uuid, longitude, latitude, description, width, height, orientation, datetaken FROM %s WHERE media_uuid='%s';"
+#define MB_SVC_TABLE_SELECT_BOOKMARK_ALL_BY_MUUID  "SELECT _id, media_uuid, marked_time, thumbnail_path FROM %s where media_uuid = '%s';"
+#define MB_SVC_TABLE_SELECT_MEDIA_BY_PATH  "SELECT uuid, path, folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url FROM %s WHERE path = '%q';"
+#define MB_SVC_FOLDER_CONTENT_COUNT_BY_FUUID   "SELECT count(*) FROM %s WHERE folder_uuid = '%s'"
+#define MB_SVC_SELECT_MEDIA_RECORD_BY_FOLDER_UUID_AND_DISPLAY_NAME   "SELECT uuid, path, folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url FROM %s WHERE folder_uuid = '%s' AND display_name = '%q';"
+#define MB_SVC_TABLE_SELECT_FOLDER_URI_BY_FUUID  "SELECT path, folder_name, storage_type FROM %s WHERE uuid = '%s';"
+#define MB_SVC_TABLE_SELECT_FOLDER_BY_PATH_INFO   "SELECT uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s WHERE path = '%q' AND folder_name = '%q' AND storage_type = %d;"
+#define MB_SVC_TABLE_SELECT_FOLDER_UUID_BY_WEB_ALBUM_ID_QUERY_STRING   "SELECT uuid FROM %s WHERE web_album_id = '%q';"
+#define MB_SVC_TABLE_SELECT_FOLDER_UUID_BY_WEB_STREAMING  "SELECT uuid FROM %s WHERE storage_type = %d;"
+#define MB_SVC_TABLE_SELECT_FOLDER_UUID_BY_PATH_INFO   "SELECT uuid FROM %s WHERE path = '%q' AND folder_name = '%q' AND storage_type = %d;"
+#define MB_SVC_SELECT_MEDIA_UUID_BY_FOLDER_UUID_AND_DISPLAY_NAME   "SELECT uuid FROM %s WHERE folder_uuid = '%s' AND display_name = '%q';"
+#define MB_SVC_TABLE_SELECT_FOLDER_NAME_BY_UUID  "SELECT folder_name FROM %s WHERE uuid = '%s';"
+#define MB_SVC_SELECT_ALL_ITEM_COUNT "select count(*) from %s as m INNER JOIN visual_folder AS f ON m.folder_uuid = f.uuid and f.lock_status=0 and m.valid=1 and f.storage_type!=2;"
+#define MB_SVC_TABLE_SELECT_FOLDER_NAME_BY_UUID  "SELECT folder_name FROM %s WHERE uuid = '%s';"
+#define MB_SVC_TABLE_SELECT_FOLDER_ALL_QUERY_STRING  "SELECT uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s "
+#define MB_SVC_SELECT_MEDIA_RECORD_BY_FOLDER_ID_AND_DISPLAY_NAME   "SELECT uuid, path, folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url FROM %s WHERE folder_uuid = '%s' AND display_name = '%q';"
+#define MB_SVC_SELECT_ALL_MEDIA  "SELECT m.uuid, m.path, folder_uuid, display_name, content_type, rating, m.modified_date, thumbnail_path, http_url FROM %s as m INNER JOIN visual_folder AS f ON "
+#define MB_SVC_SELECT_FOLDER_BY_PATH "SELECT uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s where valid=1 and path='%q' or path like '%q';"
+#define MB_SVC_SELECT_MEDIA_ID_BY_FOLDER_UUID_AND_DISPLAY_NAME   "SELECT uuid FROM %s WHERE folder_uuid = '%s' AND display_name = '%q';"
+#define MB_SVC_SELECT_INVALID_MEDIA_LIST "SELECT m.uuid, m.path, folder_uuid, display_name, content_type, rating, m.modified_date, thumbnail_path, http_url FROM visual_media as m INNER JOIN visual_folder AS f ON   f.uuid = m.folder_uuid and m.valid=0 and f.storage_type=%d"
+
+#define MB_SVC_TABLE_SELECT_GEO_LIST  "SELECT a.uuid, path, folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url from ( SELECT m.uuid, path, folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url, valid FROM %s AS m INNER JOIN ( SELECT media_uuid from image_meta where longitude between %f and %f and latitude between %f and %f union select media_uuid from video_meta where longitude between %f and %f and latitude between %f and %f) AS meta ON meta.media_uuid = m.uuid ) a, (select uuid, lock_status from visual_folder where valid=1 %s ) b where a.folder_uuid = b.uuid and a.valid=1 "
+
+#define MB_SVC_TABLE_SELECT_TAG_ALL_QUERY_STRING_BY_TAG_NAME_WITH_LOCK_STATUS "SELECT t._id, tm.media_uuid from ( select _id, tag_name from visual_tag WHERE tag_name='%s' ORDER BY tag_name ASC  ) t, ( select media_uuid, tag_id from visual_tag_map ) tm, ( select uuid, folder_uuid from visual_media) m, ( select uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.uuid = tm.media_uuid and m.folder_uuid = f.uuid and f.lock_status=%d;"
+
+#define MB_SVC_TABLE_SELECT_TAG_ALL_QUERY_STRING_WITH_LOCK_STATUS "select t._id, t.tag_name from ( select _id, tag_name from visual_tag ORDER BY tag_name ASC ) t, ( select media_uuid, tag_id from visual_tag_map ) tm, ( select uuid, folder_uuid from visual_media) m, ( select uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.uuid = tm.media_uuid and m.folder_uuid = f.uuid and f.lock_status=%d UNION SELECT _id, tag_name from visual_tag ORDER BY tag_name ASC;"
+
+#define MB_SVC_TABLE_SELECT_TAG_ALL_QUERY_STRING_BY_MEDIA_ID_WITH_LOCK_STATUS  "select t._id, t.tag_name from ( select _id, tag_name from visual_tag ORDER BY tag_name ASC ) t, ( select media_uuid, tag_id from visual_tag_map where media_uuid='%s') tm, ( select uuid, folder_uuid from visual_media) m, ( select uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.uuid = tm.media_uuid and m.folder_uuid = f.uuid and f.lock_status=%d;"
+
+#define MB_SVC_TABLE_SELECT_TAG_ALL_QUERY_STRING_BY_TAG_NAME_WITH_LOCK_STATUS_AND_FILTER "SELECT t._id, tm.media_uuid from ( select _id, tag_name from visual_tag WHERE tag_name='%s' ORDER BY tag_name ASC  ) t, ( select media_uuid, tag_id from visual_tag_map ) tm, ( select uuid, folder_uuid, content_type from visual_media) m, ( select uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.uuid = tm.media_uuid and m.folder_uuid = f.uuid and f.lock_status=%d %s ;"
+
+#define MB_SVC_TABLE_SELECT_COUNT_BY_TAG_NAME_WITH_LOCK_STATUS "SELECT count(*) from ( select _id, tag_name from visual_tag WHERE tag_name='%s' ORDER BY tag_name ASC  ) t, ( select media_uuid, tag_id from visual_tag_map ) tm, ( select uuid, folder_uuid from visual_media) m, ( select uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.uuid = tm.media_uuid and m.folder_uuid = f.uuid and f.lock_status=%d;"
+
+/* UPDATE Query for uuid */
+#define MB_SVC_UPDATE_VIDEO_META_TABLE "UPDATE %s SET %s='%q', %s='%q', %s='%q', %s='%q', %s='%q', %s='%q', %s=%d, %s=%d, %s=%f, %s=%f, %s=%d, %s=%d, %s=%d WHERE _id = %d;"
+#define MB_SVC_UPDATE_IMAGE_META_TABLE "UPDATE %s SET %s='%q', %s=%f, %s=%f, %s='%q', %s=%d, %s=%d, %s=%d, %s=%d WHERE _id = %d;"
+#define MB_SVC_UPDATE_MEDIA_TABLE "UPDATE %s SET %s='%q', %s='%q', %s='%q', %s=%d, %s=%d, %s=%d, %s='%q', %s='%q' WHERE uuid = '%s';"
+#define MB_SVC_UPDATE_MEDIA_THUMB_PATH   "UPDATE %s SET thumbnail_path = '%q' WHERE uuid = '%s';"
+#define MB_SVC_UPDATE_MEDIA_FAVORITE_BY_ID   "UPDATE %s SET rating = %d WHERE uuid = '%s';"
+#define MB_SVC_UPDATE_MEDIA_DATE_BY_ID   "UPDATE %s SET modified_date = %d WHERE uuid = '%s';"
+#define MB_SVC_UPDATE_FOLDER_ALBUM_STATUS   "UPDATE %s SET lock_status = ? WHERE uuid = ?;"
+#define MB_SVC_UPDATE_VALID_BY_UUID   "UPDATE %s SET valid = %d WHERE uuid = '%s';"
+#define MB_SVC_UPDATE_FOLDER_TABLE "UPDATE %s SET %s='%q', %s='%q', %s=%d, %s='%q', %s=%d, %s=%d, %s=%d WHERE uuid = '%s';"
+#define MB_SVC_UPDATE_META_WIDTH_HEIGHT "UPDATE %s SET %s=%d, %s=%d WHERE media_uuid = '%s';"
+#define MB_SVC_TABLE_UPDATE_TAG_MAP_QUERY_STRING_BY_TAG_ID_AND_MEDIA_ID  "UPDATE %s SET tag_id=%d WHERE media_uuid='%s' and tag_id=%d;"
+
+/* INSERT Query for uuid */
+#define MB_SVC_INSERT_FOLDER_TABLE "INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s) VALUES ('%q', '%q', '%q', %d, '%q', %d, %d, %d, '%q', %d );"
+#define MB_SVC_INSERT_IMAGE_META_TABLE "INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s) VALUES ( '%q', %f, %f, '%q', %d, %d, %d, %d );"
+#define MB_SVC_INSERT_MEDIA_TABLE "INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s ) VALUES ( '%q', '%q', '%q', '%q', %d, %d, %d, '%q', '%q', %d );"
+#define MB_SVC_INSERT_TAG_TABLE "INSERT INTO %s (%s, %s) VALUES ( %d, '%q' );"
+#define MB_SVC_INSERT_TAG_MAP_TABLE "INSERT INTO %s (%s, %s, %s) VALUES ( %d, '%q', %d );"
+#define MB_SVC_INSERT_VIDEO_META_TABLE "INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) VALUES ( '%q', '%q', '%q','%q', '%q','%q', %d, %d, %f, %f, %d, %d, %d );"
+#define MB_SVC_INSERT_BOOKMARK_TABLE "INSERT INTO %s (%s, %s, %s) VALUES ( '%q', %d,'%q' );"
+#define MB_SVC_INSERT_WEB_STREAMING_TABLE "INSERT INTO %s (%s, %s, %s, %s, %s, %s) VALUES ( %d, '%s', '%q', %d, '%q'. '%q' );"
+
+/* DELETE Query for uuid */
+#define MB_SVC_RECORD_DELETE_BY_UUID   "DELETE FROM %s WHERE uuid = '%s';"
+#define MB_SVC_DELETE_MEDIA_RELATED_INFO_BY_MEDIA_UUID   "DELETE FROM %s WHERE media_uuid = '%s' ;"
+#define MB_SVC_DELETE_MEDIA_BY_FOLDER_ID_AND_DISPLAY_NAME   "DELETE FROM %s WHERE folder_uuid = '%s' AND display_name = '%q';"
+#define MB_SVC_TABLE_DELETE_TAG_MAP_BY_TAGNAME_MEDIA_UUID "DELETE FROM %s WHERE media_uuid='%s' and tag_id=%d"
+#define MB_SVC_TABLE_DELETE_TAG_MAP_BY_MEDIA_UUID "DELETE FROM %s WHERE media_uuid='%s'"
+
+/**
+* @fn    int  mb_svc_query_sql_gstring(GString *query_string);
+* This function executes the inputted GString sql statement
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    query_string           pointer to GString sql statement
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_query_sql_gstring(GString *query_string);
+
+
+/**
+* @fn    int  mb_svc_query_sql(char *query_str);
+* This function executes inputted sql string
+*
+* @return                       This function returns 0 on success, and negative value on failure.
+* @param[in]                    query_str           pointer to sql string
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_query_sql(char *query_str);
+
+int 
+mb_svc_sqlite3_begin_trans(void);
+
+int 
+mb_svc_sqlite3_commit_trans(void);
+
+int 
+mb_svc_sqlite3_rollback_trans(void);
+
+void
+mb_svc_sql_list_add(GList **list, char **sql);
+
+void
+mb_svc_sql_list_release(GList **sql_list);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /*_MEDIA_SVC_DB_UTIL_H_*/
+
+/**
+* @}
+*/
+
+
diff --git a/src/include/visual/media-svc-db.h b/src/include/visual/media-svc-db.h
new file mode 100755 (executable)
index 0000000..06615a8
--- /dev/null
@@ -0,0 +1,669 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/** 
+ * This file defines synchronize apis for phone explorer.
+ *
+ * @file               media-svc-db.h
+ * @author             Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version    1.0
+ * @brief      This file defines in-house apis for media service.
+ */
+
+ /**
+  * @ingroup MEDIA_SVC
+  * @defgroup MEDIA_SVC_DB in-house media service API
+  * @{
+  */
+
+
+#ifndef _MEDIA_SVC_DB_H_
+#define _MEDIA_SVC_DB_H_
+
+#include "media-svc-structures.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//table name macros
+#define MB_SVC_TBL_NAME_BOOKMARK               "video_bookmark"
+#define MB_SVC_TBL_NAME_FOLDER                 "visual_folder"
+#define MB_SVC_TBL_NAME_WEB_STREAMING  "web_streaming"
+#define MB_SVC_TBL_NAME_MEDIA                  "visual_media"
+#define MB_SVC_TBL_NAME_VIDEO_META             "video_meta"
+#define MB_SVC_TBL_NAME_IMAGE_META             "image_meta"
+#define MB_SVC_TBL_NAME_TAG_MAP                        "visual_tag_map"
+#define MB_SVC_TBL_NAME_TAG                            "visual_tag"
+
+//default query string len
+#define MB_SVC_DEFAULT_QUERY_SIZE  1023 * 3
+
+#define MB_SVC_DATABASE_NAME   "/opt/dbspace/.media.db"
+#define MB_SVC_TABLE_NAME_MAX_LEN 1024
+#define DELETE_FOLDER_RECORD_IF_NO_FILE_IN    //if folder contains no files, delete folder record.
+
+
+/**
+* @fn    int  mb_svc_connect_db(sqlite3** handle);
+* This function connects to database server and creates tables, such as bookmark,folder and so on
+*
+* @param[out]                    handle           DB handle connected
+* @return                        This function returns 0 on success, and negative value on failure.
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_connect_db(sqlite3** handle);
+
+/**
+* @fn    int int mb_svc_disconnect_db(sqlite3* handle);
+* This function disconnects with database server
+*
+* @param[in]                    handle           DB handle to disconnect
+* @return                        This function returns 0 on success, and negative value on failure.
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_disconnect_db(sqlite3* handle);
+
+/**
+* @fn    int  _mb_svc_truncate_tbl();
+* This function truncates all created tables, such as bookmark,folder and so on
+*
+* @return                        This function returns 0 on success, and negative value on failure.
+* @exception                     None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int _mb_svc_truncate_tbl();
+
+/**
+* @fn    int  mb_svc_delete_record_bookmark_by_id(int id);
+* This function deletes specified bookmark record by field "_id"
+*
+* @return                        This function returns 0 on success, and negative value on failure.
+* @param[in]                    id           bookmark record id
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_delete_record_bookmark_by_id(int id);
+
+/**
+* @fn    int  int mb_svc_delete_record_folder_by_id(const char *id);
+* This function deletes specified folder record by id
+*
+* @return                        This function returns 0 on success, and negative value on failure.
+* @param[in]                    id           folder record id
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_delete_record_folder_by_id(const char *id);
+
+/**
+* @fn    int  mb_svc_delete_record_web_streaming_by_id(int id);
+* This function deletes specified webstreaming record by id
+*
+* @return                        This function returns 0 on success, and negative value on failure.
+* @param[in]                    id           webstreaming record id
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_delete_record_web_streaming_by_id(int id);
+
+/**
+* @fn    int mb_svc_delete_record_media_by_id(const char *id);
+* This function deletes specified media record by id
+*
+* @return                        This function returns 0 on success, and negative value on failure.
+* @param[in]                    id          media record id
+ * @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_delete_record_media_by_id(const char *id);
+
+/**
+* @fn    int mb_svc_delete_record_video_meta_by_id(int id);
+* This function deletes specified video_meta record
+*
+* @return                        This function returns 0 on success, and negative value on failure.
+* @param[in]                    id          video_meta record id
+ * @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_delete_record_video_meta_by_id(int id);
+
+/**
+* @fn    int mb_svc_update_record_folder(mb_svc_folder_record_s *record);
+* This function updates folder record
+*
+* @return                        This function returns 0 on success, and negative value on failure.
+* @param[in]                    record      pointer to new folder record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_update_record_folder(mb_svc_folder_record_s *record);
+
+/**
+* @fn    int  mb_svc_update_record_media(mb_svc_media_record_s *record);
+* This function updates media record
+*
+* @return                        This function returns 0 on success, and negative value on failure.
+* @param[in]                    record      pointer to new media record
+* @exception                    None.
+* @remark
+*
+*
+*/
+
+int mb_svc_update_record_media(mb_svc_media_record_s *record);
+
+/**
+* @fn    int mb_svc_update_record_video_meta(mb_svc_video_meta_record_s *record);
+* This function updates video_meta record
+*
+* @return                        This function returns 0 on success, and negative value on failure.
+* @param[in]                    record      pointer to new video_meta record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_update_record_video_meta(mb_svc_video_meta_record_s *record);
+
+/**
+* @fn    int mb_svc_update_record_image_meta(mb_svc_image_meta_record_s *record);
+* This function updates image_meta record
+*
+* @return                        This function returns 0 on success, and negative value on failure.
+* @param[in]                    record      pointer to new image_meta record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_update_record_image_meta(mb_svc_image_meta_record_s *record);
+
+/**
+* @fn    int mb_svc_insert_record_bookmark(mb_svc_bookmark_record_s *record);
+* This function inserts record into bookmark table
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    record           pointer to inserted record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+
+int mb_svc_insert_record_bookmark(mb_svc_bookmark_record_s *record);
+
+/**
+* @fn    mb_svc_insert_record_folder(mb_svc_folder_record_s *record);
+* This function inserts record into folder table
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    record      pointer to folder record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_insert_record_folder(mb_svc_folder_record_s *record);
+
+/**
+* @fn    int mb_svc_insert_record_web_streaming(mb_svc_web_streaming_record_s *record);
+* This function inserts record into webstreaming table
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    record      pointer to web streaming reocrd
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_insert_record_web_streaming(mb_svc_web_streaming_record_s *record);
+
+/**
+* @fn    int  mb_svc_insert_record_media(mb_svc_media_record_s *record);
+* This function inserts record into media table
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    record      pointer to media record
+* exception                    None.
+* @remark
+*
+*
+*/
+
+int mb_svc_insert_record_media(mb_svc_media_record_s *record, minfo_store_type storage_type);
+
+/**
+* @fn    int  mb_svc_insert_record_video_meta(mb_svc_video_meta_record_s *record, minfo_store_type storage_type);
+* This function insert record into video_meta table
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    record      pointer to video_meta record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_insert_record_video_meta(mb_svc_video_meta_record_s *record, minfo_store_type storage_type);
+
+/**
+* @fn    int  mb_svc_insert_record_image_meta(mb_svc_image_meta_record_s *record, minfo_store_type storage_type);
+* This function inserts record into image_meta table
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    record       pointer to image_meta record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_insert_record_image_meta(mb_svc_image_meta_record_s *record, minfo_store_type storage_type);
+
+/**
+* @fn    int  mb_svc_load_record_bookmark(sqlite3_stmt* stmt, mb_svc_bookmark_record_s * record);
+* This function gets bookmark record
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    stmt           sql stmt
+* @param[out]                   record      pointer to bookmark record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+
+int mb_svc_load_record_bookmark(sqlite3_stmt* stmt, mb_svc_bookmark_record_s * record);
+
+/**
+* @fn    int  mb_svc_load_record_folder(sqlite3_stmt* stmt, mb_svc_folder_record_s * record);
+* This function gets folder record
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    stmt           sql stmt
+* @param[out]                   record      pointer to folder record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_load_record_folder(sqlite3_stmt* stmt, mb_svc_folder_record_s * record);
+
+/**
+* @fn    int mb_svc_load_record_web_streaming(sqlite3_stmt* stmt, mb_svc_web_streaming_record_s * record);
+* This function gets web streaming record
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    stmt        sql stmt
+* @param[out]                  record      pointer to web streaming record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_load_record_web_streaming(sqlite3_stmt* stmt, mb_svc_web_streaming_record_s * record);
+
+/**
+* @fn    int  mb_svc_load_record_media(sqlite3_stmt* stmt, mb_svc_media_record_s * record);
+* This function gets media record
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    stmt        sql stmt
+* @param[out]                   record      pointer to media record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_load_record_media(sqlite3_stmt* stmt, mb_svc_media_record_s * record);
+
+/**
+* @fn    int mb_svc_load_record_video_meta(sqlite3_stmt* stmt, mb_svc_video_meta_record_s * record);
+* This function gets video_meta record
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    stmt        sql stmt
+* @param[out]                   record      pointer to video_meta record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_load_record_video_meta(sqlite3_stmt* stmt, mb_svc_video_meta_record_s * record);
+
+/**
+* @fn    int  mb_svc_load_record_image_meta(sqlite3_stmt* stmt, mb_svc_image_meta_record_s * record);
+* This function gets folder record by path information
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    stmt        sql stmt
+* @param[out]                   record      pointer to image_meta record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int mb_svc_load_record_image_meta(sqlite3_stmt* stmt, mb_svc_image_meta_record_s * record);
+
+/**
+* @fn    int  mb_svc_insert_record_tag(mb_svc_tag_record_s *record);
+* This function inserts tag record which should be filled up the corresponding value
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    record        pointer to tag record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_insert_record_tag(mb_svc_tag_record_s *record);
+
+/**
+* @fn    int  mb_svc_insert_record_tag_map(const char *media_id, int tag_id);
+* This function inserts tag_map record which should be filled up the corresponding value
+*
+* @return                       This function returns 0 on success, and -1 on failure.
+* @param[in]                    media_id       
+* @param[in]                    tag_id        
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_insert_record_tag_map(const char *media_id, int tag_id);
+
+/**
+* @fn    int  mb_svc_load_record_tag(sqlite3_stmt* stmt, mb_svc_tag_record_s * record);
+* This function gets tag record by tag name, if any, or media_id
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    stmt        sql stmt
+* @param[out]                   record      pointer to tag record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_load_record_tag(sqlite3_stmt* stmt, mb_svc_tag_record_s * record);
+
+/**
+* @fn    int  mb_svc_load_record_tagmap(sqlite3_stmt* stmt, mb_svc_tag_record_s * record);
+* This function gets tag record by tag name, if any, or media_id
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    stmt        sql stmt
+* @param[out]                   record      pointer to tag record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+int 
+mb_svc_load_record_tagmap(sqlite3_stmt* stmt, mb_svc_tag_record_s * record);
+
+/**
+* @fn    int  mb_svc_update_thumb_path_by_id(const char *media_id, const char* thumb_path);
+* This function updates thumb path for media record
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    media_id           media id
+* @param[in]                    thumb_path  new thumb path
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+
+int mb_svc_update_thumb_path_by_id(const char *media_id, const char* thumb_path);
+
+/**
+* @fn    int  mb_svc_delete_record_media(const char *folder_id, char* display_name);
+* This function deletes media record
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    folder_id           folder id in media record field
+* @param[in]                    display_name  file name
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+
+int 
+mb_svc_delete_record_media(const char *folder_id, char* display_name);
+
+
+/**
+* @fn    int mb_svc_delete_bookmark_meta_by_media_id(const char *media_id , mb_svc_media_type_t file_type);
+* This function deletes media related record in other tables
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    media_id           media id
+* @param[in]                    file_type   media file type, maybe image,video and so on
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_delete_bookmark_meta_by_media_id(const char *media_id , minfo_file_type content_type);
+
+/**
+* @fn    int  mb_svc_update_favorite_by_id(const char *media_id, int favorite);
+* This function updates favorite field in media record
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    media_id           media id
+* @param[in]                    favorite  favorite field in media record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+
+int 
+mb_svc_update_favorite_by_id(const char *media_id, int favorite);
+
+/**
+* @fn    int mb_svc_delete_record_image_meta_by_id(int id);
+* This function gets folder record by path information
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    id          image_meta record id
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_delete_record_image_meta_by_id(int id);
+
+
+/**
+* @fn    int  mb_svc_update_date_by_id(const char *media_id, int date);
+* This function updates favorite field in media record
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    media_id           media id
+* @param[in]                    date  modified date in media record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+int 
+mb_svc_update_date_by_id(const char *media_id, int date );
+
+/**
+* @fn    int  mb_svc_get_web_streaming_record_by_id(int webstreaming_id, mb_svc_web_streaming_record_s *webstreaming_record);
+* This function gets webstreaming record by id
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    webstreaming_id           web streaming record id
+* @param[out]                   webstreaming_record      pointer to webstreaming record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/                                                                                      
+int
+mb_svc_get_web_streaming_record_by_id(int webstreaming_id,
+                                                                               mb_svc_web_streaming_record_s *webstreaming_record);
+int
+mb_svc_set_media_records_as_valid(const minfo_store_type storage_type, int valid);
+
+int
+mb_svc_update_album_lock_status(const char *folder_id, int lock, minfo_store_type storage_type );
+
+int
+mb_svc_load_record_folder_name(sqlite3_stmt* stmt, char * folder_name, int max_length);
+
+int
+mb_svc_update_record_folder_path(char* old_path, char* new_path);
+
+int
+mb_svc_update_folder_modified_date(char* path, int date);
+
+int 
+mb_svc_update_width_and_height(const char *media_id, minfo_file_type content_type, int width, int height);
+
+int
+mb_svc_set_folder_as_valid_sql_add(const char *folder_id, int valid);
+
+int
+mb_svc_set_item_as_valid_sql_add(const char *full_path, int valid);
+
+int
+mb_svc_set_item_as_valid();
+
+int
+mb_svc_insert_record_folder_sql(mb_svc_folder_record_s *record, char **sql);
+
+int
+mb_svc_insert_record_image_meta_sql(mb_svc_image_meta_record_s *record,
+                               minfo_store_type storage_type,
+                               char **sql);
+
+int
+mb_svc_insert_record_media_sql(mb_svc_media_record_s *record,
+                                       minfo_store_type storage_type,
+                                       char **sql);
+
+int
+mb_svc_insert_record_video_meta_sql(mb_svc_video_meta_record_s *record,
+                               minfo_store_type storage_type,
+                               char **sql);
+
+int
+mb_svc_update_record_folder_sql(mb_svc_folder_record_s *record, char **sql);
+
+int
+mb_svc_update_record_media_sql(mb_svc_media_record_s *record, char **sql);
+
+int
+mb_svc_update_thumb_path_sql(const char *media_id, const char *thumb_path, char **sql);
+
+int 
+mb_svc_delete_record_folder_sql(const char *folder_id, char **sql);
+
+int
+mb_svc_delete_record_media_sql(const char *media_id, char **sql);
+
+int
+mb_svc_delete_record_image_meta_sql(const char *media_id, char **sql);
+
+int
+mb_svc_delete_record_video_meta_sql(const char *media_id, char **sql);
+
+int
+mb_svc_delete_tagmap_by_media_id_sql(const char *media_id, char **sql);
+
+int
+mb_svc_delete_bookmark_meta_by_media_id_sql(const char *media_id, char **sql);
+
+int
+mb_svc_update_width_and_height_sql(const char *media_id, minfo_file_type content_type,
+                              int width, int height, char **sql);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /*_MEDIA_SVC_DB_H_*/
+
+/**
+* @}
+*/
diff --git a/src/include/visual/media-svc-debug.h b/src/include/visual/media-svc-debug.h
new file mode 100755 (executable)
index 0000000..0c2e071
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/** 
+ * This file defines synchronize apis for phone explorer.
+ *
+ * @file               media-svc-debug.h
+ * @author             Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version    1.0
+ * @brief      This file defines in-house apis for media service.
+ */
+
+ /**
+  * @ingroup MEDIA_SVC
+  * @defgroup MEDIA_SVC_DEBUG in-house media service API
+  * @{
+  */
+
+
+
+#ifndef _MEDIA_SVC_DEBUG_H_
+#define _MEDIA_SVC_DEBUG_H_
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlog.h>
+
+
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "Media-SVC"
+
+#ifndef DEBUG_PREFIX
+#define DEBUG_PREFIX "Media-SVC"
+#endif
+
+//#define MB_SVC_LOG_FILE  "/opt/mb-svc.log"
+
+#define MB_DEBUG
+
+#ifdef MB_DEBUG
+
+
+#ifndef LOG_TAG
+
+
+#ifdef MB_SVC_LOG_FILE
+#define pb_svc_debug(fmt, arg...)      \
+       {       \
+               FILE *fp;       \
+               fp = fopen(MB_SVC_LOG_FILE, "a");       \
+               fprintf(fp, "[%s] ", DEBUG_PREFIX);     \
+               fprintf(fp, fmt, ##arg);        \
+               fclose(fp);     \
+               fprintf(stderr, "[%s] ", DEBUG_PREFIX); \
+               fprintf(stderr, fmt, ##arg);    \
+       }
+
+#else /*MB_SVC_LOG_FILE*/
+#define mb_svc_debug(fmt, arg...)      \
+{      \
+       fprintf(stderr, "[%s] ", DEBUG_PREFIX); \
+       fprintf(stderr, fmt, ##arg);    \
+}
+#endif /*MB_SVC_LOG_FILE*/
+
+
+#else /*LOG_TAG*/
+#include <unistd.h>
+#include <asm/unistd.h>
+#include <pthread.h>
+static pid_t gettid(void)
+{
+       return syscall(__NR_gettid);
+}
+
+#define mb_svc_debug(fmt, arg...)       LOGD("[%d] [%s : %d] " fmt "\n", gettid(), __FUNCTION__, __LINE__, ##arg)
+
+
+
+#endif /*LOG_TAG*/
+
+#else /*MB_DEBUG*/
+
+#define mb_svc_debug(fmt, arg...)
+
+#endif /*MB_DEBUG*/
+
+#endif /*_MEDIA_SVC_DEBUG_H_*/
+
+/**
+* @}
+*/
+
+
diff --git a/src/include/visual/media-svc-structures.h b/src/include/visual/media-svc-structures.h
new file mode 100755 (executable)
index 0000000..459ae3c
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file defines global data structrues and micros of media service.
+ *
+ * @file               media-svc-structures.h
+ * @author             Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version    1.0
+ * @brief      This file defines global data structrue and micros of internal media service.
+ */
+ /**
+ * @ingroup MEDIA_SVC
+ * @defgroup MEDIA_SVC_TYPE global variables
+ * @{
+ */
+
+#ifndef _MEDIA_SVC_STRUCTURES_H_
+#define _MEDIA_SVC_STRUCTURES_H_
+
+#include <sqlite3.h>
+#include "minfo-types.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /*__cplusplus*/
+
+#define MB_SVC_UUID_LEN_MAX                    36
+#define MB_SVC_FILE_NAME_LEN_MAX               255 * 3                                                                 /**< File name max length */
+#define MB_SVC_FILE_PATH_LEN_MAX               4095 * 3                                                                /**< File path max length  */
+#define MB_SVC_DIR_NAME_LEN_MAX                MB_SVC_FILE_NAME_LEN_MAX                                /**< Directory name max length*/
+#define MB_SVC_DIR_PATH_LEN_MAX                MB_SVC_FILE_PATH_LEN_MAX                                /**< Directory path max length */
+#define MB_SVC_FILE_EXT_LEN_MAX        6                                                                               /**< file extention max length */
+#define MB_SVC_ARRAY_LEN_MAX                   255                                                                             /**< array max length */
+#define MB_SVC_NO_RECORD_ANY_MORE      1
+
+#define USEC_PER_SEC                                   1000000    // 1s = 1000000us
+
+/*
+* @struct mb_svc_iterator_s
+* This structure defines the mb_svc_iterator_s.
+*/
+typedef struct {
+    sqlite3_stmt* stmt ;               /**< statement */
+    int total_count;            /**< total count */
+    int current_position;       /**< current count */
+}mb_svc_iterator_s;
+
+
+/* media svc item structure definitions */
+
+/*
+* @struct mb_svc_bookmark_record_s
+* This structure defines the mb_svc_bookmark_record_s.
+*/
+typedef struct {
+       int _id;                                                                                /**< Bookmark id.  Prime Key */
+       char media_uuid[MB_SVC_UUID_LEN_MAX+1];                 /**< media UUID */
+       int marked_time;                                                                                /**< Bookmark time*/
+       char thumbnail_path[MB_SVC_FILE_PATH_LEN_MAX+1];        /**< thumbnail path */
+}mb_svc_bookmark_record_s;
+
+
+/* DB record of folder, usecase: Album view */
+
+/*
+* @struct mb_svc_folder_record_s
+* This structure defines the mb_svc_folder_record_s.
+*/
+typedef struct {
+       char uuid[MB_SVC_UUID_LEN_MAX+1];                                       /**< UUID */
+       char uri[MB_SVC_DIR_PATH_LEN_MAX+1];                            /**< folder path */
+       char display_name[MB_SVC_FILE_NAME_LEN_MAX+1] ;         /**< folder name */
+       int modified_date;                                                                      /**< The modified time of folder */
+       char web_account_id[MB_SVC_ARRAY_LEN_MAX+1];            /**< web count ID in web streaming table */
+       char web_album_id[MB_SVC_ARRAY_LEN_MAX+1];              /**< web count ID in web streaming table */
+       minfo_store_type storage_type;                                          /**< file storage type, in phone, mmc, web, or web streaming*/
+       int sns_type;                                                                                   /**< web account type */
+       int lock_status;                                                                                /**< status for album lock */
+}mb_svc_folder_record_s;
+
+
+/* DB record of web_streaming, usecase: streaming album view */
+
+/*
+* @struct mb_svc_web_streaming_record_s
+* This structure defines the mb_svc_web_streaming_record_s.
+*/
+typedef struct {
+       int _id;                                                                                        /**< web streaming id.  Prime Key */
+       char folder_uuid[MB_SVC_UUID_LEN_MAX+1];                /**< folder UUID */
+       char title[MB_SVC_FILE_NAME_LEN_MAX+1];                 /**< title of web streaming*/
+       int duration;                                                                           /**< duration of web streaming */
+       char url[MB_SVC_FILE_PATH_LEN_MAX+1];                   /**< url  */
+       char thumb_path[MB_SVC_FILE_PATH_LEN_MAX+1];    /**< thumbnail path */
+}mb_svc_web_streaming_record_s;
+
+
+/* DB record of media */
+
+/*
+* @struct mb_svc_media_record_s
+* This structure defines the mb_svc_media_record_s.
+*/
+typedef struct {
+       char media_uuid[MB_SVC_UUID_LEN_MAX+1];                                 /**< UUID */
+       char path[MB_SVC_FILE_PATH_LEN_MAX+1];                          /**< path */
+       char folder_uuid[MB_SVC_UUID_LEN_MAX+1];                        /**< folder UUID */
+       char display_name[MB_SVC_FILE_NAME_LEN_MAX+1];          /**< media name */
+       minfo_file_type content_type;                                                   /**< media type,   1:image, 2:video*/
+       bool rate;                                                                                      /**< favoriate option */
+       int modified_date;                                                              /**< modified time */
+       char thumbnail_path[MB_SVC_FILE_PATH_LEN_MAX+1];        /**< thumbail path */
+       char http_url[MB_SVC_DIR_PATH_LEN_MAX +1];                      /**< http url */
+}mb_svc_media_record_s;
+
+
+/*     DB record of video meta */
+
+/*
+* @struct mb_svc_video_meta_record_s
+* This structure defines the mb_svc_video_meta_record_s.
+*/
+typedef struct {
+       int _id;                                                                                        /**< video meta id.  Prime Key */
+       char media_uuid[MB_SVC_UUID_LEN_MAX+1];         /**< media UUID */
+       char album[MB_SVC_FILE_NAME_LEN_MAX+1];         /**< album */
+       char artist[MB_SVC_ARRAY_LEN_MAX+1];                            /**< artist */
+       char title[MB_SVC_FILE_NAME_LEN_MAX+1];                 /**< title */
+       char description[MB_SVC_ARRAY_LEN_MAX+1];               /**< description */
+       char youtube_category[MB_SVC_ARRAY_LEN_MAX+1];  /**< youtube_category */
+       int last_played_time;                                                           /**< last palyed time*/
+       int duration;                                                                           /**< duration */
+       double longitude;                                                                       /**< longitude */
+       double latitude;                                                                        /**< latitude */
+       int width;                                                                              /**< width */
+       int height;                                                                             /**< height */
+       int datetaken;                                                                  /**< datetaken */
+}mb_svc_video_meta_record_s;
+
+
+
+/*     DB record of video_bookmark, usecase: bookmark in the video player. */
+
+/*
+* @struct mb_svc_image_meta_record_s
+* This structure defines the mb_svc_image_meta_record_s.
+*/
+typedef struct {
+       int _id;                                                                                /**< video meta id.  Prime Key */
+       char media_uuid[MB_SVC_UUID_LEN_MAX+1]; /**< media UUID */
+       double longitude;                                                               /**< longitude */
+       double latitude;                            /**< latitude */
+       char description[MB_SVC_ARRAY_LEN_MAX+1];   /**< description */ 
+       int width;                                                                                              /**< width */
+       int height;                                                                                             /**< height */
+       int orientation;                                                                                        /**< orientation */
+       int datetaken;                                                                                  /**< datetaken */
+}mb_svc_image_meta_record_s;
+
+
+/*
+* @struct mb_svc_tag_record_s
+* This structure defines the mb_svc_tag_record_s.
+*/
+typedef struct {
+       int _id;                                    /**< video meta id.  Prime Key */
+       char media_uuid[MB_SVC_UUID_LEN_MAX+1];         /**< media UUID */
+       char tag_name[MB_SVC_ARRAY_LEN_MAX+1];          /**< description */ 
+}mb_svc_tag_record_s;
+
+
+#ifdef __cplusplus
+}
+#endif /*__cplusplus*/
+
+
+/**
+* @}
+*/
+
+
+#endif /*_MEDIA_SVC_STRUCTURES_H_*/
diff --git a/src/include/visual/media-svc-thumb.h b/src/include/visual/media-svc-thumb.h
new file mode 100755 (executable)
index 0000000..415027e
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+ * This file includes API sets for syncronization with other module.
+ *
+ * @file               mb-svc-thumb.h
+ * @author             Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version            1.0
+ * @brief              Thumbnail management APIs.
+ */
+
+/**
+* @ingroup MEDIA-SVC
+* @defgroup    MEDIA_SVC_THUMB error code table
+* @{
+*/
+
+#ifndef _MB_SVC_THUMB_H_
+#define _MB_SVC_THUMB_H_
+
+#include "media-svc-structures.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MB_SVC_THUMB_PATH                              "/opt/data/file-manager-service"
+#define MB_SVC_THUMB_PHONE_PATH                        MB_SVC_THUMB_PATH"/.thumb/phone"
+#define MB_SVC_THUMB_MMC_PATH                  MB_SVC_THUMB_PATH"/.thumb/mmc"
+#define DEFAULT_IMAGE_THUMB                            MB_SVC_THUMB_PATH"/.thumb/thumb_default.png"
+#define DEFAULT_VIDEO_THUMB                            MB_SVC_THUMB_PATH"/.thumb/thumb_default.png"
+
+
+/**
+ * @fn  int 
+ _mb_svc_thumb_generate_hash_name(char *file_full_path, char* thumb_hash_path, size_t max_thumb_path);
+ * @brief  generate thumbnail path to value  media record thumbnail_path field
+* @return error code.
+ */
+int 
+_mb_svc_thumb_generate_hash_name(const char *file_full_path, char* thumb_hash_path, size_t max_thumb_path);
+
+
+/**
+ * @fn int mb_svc_image_create_thumb(char *file_fullpath, char* thumb_path_hash, bool force, mb_svc_image_meta_record_s *img_meta_record);
+ * @brief  generate thumbnail path for image file
+* @return error code.
+ */
+
+int 
+mb_svc_image_create_thumb(const char *file_fullpath, char* thumb_path_hash, size_t max_thumb_length, bool force, mb_svc_image_meta_record_s *img_meta_record);
+
+
+/**
+ * @fn int mb_svc_image_create_thumb_new(char *file_fullpath, char* thumb_path_hash, mb_svc_image_meta_record_s *img_meta_record);
+ * @brief  generate thumbnail path for image file
+* @return error code.
+ */
+
+int 
+mb_svc_image_create_thumb_new(const char *file_fullpath, char* thumb_path_hash, size_t max_thumb_length, mb_svc_image_meta_record_s *img_meta_record);
+
+/**
+ * @fn int mb_svc_video_create_thumb(char *file_fullpath, char* thumb_path_hash);
+ * @brief  generate thumbnail path for video file
+* @return error code.
+*/
+int 
+mb_svc_video_create_thumb(const char *file_fullpath, char* thumb_path_hash, size_t max_thumb_length);
+
+/**
+* @fn    int  mb_svc_get_video_meta(char* file_full_path, mb_svc_video_meta_record_s *video_record);
+* This function gets video_meta record by filefull path
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    file_full_path           file full path
+* @param[out]                   video_record      pointer to vidoe_meta record
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/     
+
+int
+mb_svc_get_video_meta(const char* file_full_path, mb_svc_video_meta_record_s *video_record);
+
+
+/**
+* @fn    int mb_svc_get_image_meta(char* file_full_path, mb_svc_image_meta_record_s *image_record, bool *thumb_done);
+* This function gets image_meta record by filefull path
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    file_full_path           file full path
+* @param[out]                   record by filefull path      pointer to image_meta record
+* @param[out]                   thumb_done                             Flag whether thumbnail is generated or not
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/     
+
+int
+mb_svc_get_image_meta(const char* file_full_path, mb_svc_image_meta_record_s *image_record, bool *thumb_done);
+
+/**
+* @brief  Delete thumbnail file of original file.
+* @param  file_full_path  original file.
+* @return 0 ok, -1 failed.
+*/
+int
+_mb_svc_thumb_delete(const char* file_full_path);
+
+/**
+* @brief  Delete a specified thumbnail file directly.
+* @param  file_full_path  the fullpath of thumbnail file.
+* @return 0 ok, -1 failed.
+*/
+int
+_mb_svc_thumb_rm(char *file_full_path);
+
+
+/**
+* @brief  Copy thumbnail of src to the one of dest.
+* @param[in]   src_file_full_path    src original file.
+* @param[in]   dest_file_full_path   dest original file.
+* @param[out]  dest_thumb_path       thumbnail file of dest orignal file.
+* @return  0 ok, -1 failed.
+*/
+int
+_mb_svc_thumb_copy(const char* src_file_full_path,
+                                                               const char* dest_file_full_path,
+                                                               char* dest_thumb_path);
+
+/**
+* @brief  Move thumbnail of src to the one of dest.
+* @param[in]   src_file_full_path    src original file.
+* @param[in]   dest_file_full_path   dest original file.
+* @param[out]  dest_thumb_path       thumbnail file of dest orignal file.
+* @return  0 ok, -1 failed.
+*/
+int
+_mb_svc_thumb_move(const char* src_file_full_path,
+                                                               const char* dest_file_full_path,
+                                                               char* dest_thumb_path);
+
+/**
+* @brief  Rename thumbnail of src to the one of dest.
+* @param[in]   src_file_full_path    src original file.
+* @param[in]   dest_file_full_path   dest original file.
+* @param[out]  dest_thumb_path       thumbnail file of dest orignal file.
+* @return  0 ok, -1 failed.
+*/
+int
+_mb_svc_thumb_rename(const char* src_file_full_path,
+                                                               const char* dest_file_full_path,
+                                                               char* dest_thumb_path);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /*_MEDIA_SVC_THUMB_H_*/
+
+/**
+* @}
+*/
+
diff --git a/src/include/visual/media-svc-util.h b/src/include/visual/media-svc-util.h
new file mode 100755 (executable)
index 0000000..41e59b7
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/** 
+ * This file defines the error code of media service
+ *
+ * @file               media-svc-util.h
+ * @author             Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version    1.0
+ * @brief      This file defines the error code of media service 
+ */
+
+/**
+* @ingroup MEDIA-SVC
+* @defgroup    MEDIA_SVC_UTIL error code table
+* @{
+*/
+
+
+#ifndef _MEDIA_SVC_UTIL_H_
+#define _MEDIA_SVC_UTIL_H_
+       
+#include <glib.h>
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MB_SVC_PATH_PHONE      "/opt/media"    /**< File path prefix of files stored in phone */
+#define MB_SVC_PATH_MMC        "/opt/storage/sdcard"   /**< File path prefix of files stored in mmc card */
+
+
+/**
+* @fn    int _mb_svc_get_file_display_name (const char* file_path, char* file_name);
+* This function gets file name by file full path
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    file_path           file full path
+* @param[out]                   file_name      file name
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/     
+
+bool   
+_mb_svc_get_file_display_name (const char* file_path, char* file_name);
+
+ /**
+ * @fn   int _mb_svc_get_file_parent_path(const char* file_path, char* parent_path);
+ * This function gets file parent path
+ *
+ * @return                                               This function returns 0 on success, and -1 on failure.
+ * @param[in]                                   file_path                file full path
+ * @param[out]                                  parent_path      file parent path
+ * @exception                                   None.
+ * @remark                                               
+ *                                                                                                                        
+ *                                                                                                                     
+ */  
+
+bool
+_mb_svc_get_file_parent_path(const char* file_path, char* parent_path);
+
+/**
+* @fn    int _mb_svc_get_dir_display_name (const char* dir_path, char* dir_name);
+* This function gets directory name
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    dir_path           directory path
+* @param[out]                   dir_name     directory name
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/     
+bool   
+_mb_svc_get_dir_display_name (const char* dir_path, char* dir_name);
+
+/**
+* @fn    int _mb_svc_get_dir_parent_path(const char* dir_path, char* parent_path);
+* This function gets directory parent path
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    dir_path           directory path
+* @param[out]                   parent_path      directory parent path
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/      
+bool
+_mb_svc_get_dir_parent_path(const char* dir_path, char* parent_path);
+
+/**
+* @fn    int _mb_svc_get_file_dir_modified_date(const char* full_path);
+* This function gets file modified date
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    full_path           file full path
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/     
+
+int 
+_mb_svc_get_file_dir_modified_date(const char* full_path);
+
+/**
+* @fn    int _mb_svc_get_store_type_by_full(const char* full_path);
+* This function gets file store type
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    full_path           file full path
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/      
+int
+_mb_svc_get_store_type_by_full(const char* full_path);
+
+/**
+* @fn    int _mb_svc_get_rel_path_by_full(const char* full_path, char* path);
+* This function gets file relative path
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    full_path           file full path
+* @param[out]                   path     file relative path
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/       
+int
+_mb_svc_get_rel_path_by_full(const char* full_path, char* path);
+
+/**
+* @fn    int _mb_svc_get_file_ext (const char* file_path, char* file_ext);
+* This function gets file extension
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    file_path           file full path
+* @param[out]                   file_ext       pointer to file extention
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/      
+bool
+_mb_svc_get_file_ext (const char* file_path, char* file_ext);
+
+/**
+* @fn    int _mb_svc_glist_free(GList** glist, bool is_free_element);
+* This function frees glist and maybe free each items in glist
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    glist           the glist to be freed
+* @param[in]                 is_free_element    falg to declare if to free items in glist
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/     
+
+bool
+_mb_svc_glist_free(GList** glist, bool is_free_element);
+
+/**
+* @fn    int _mb_svc_get_file_type(char* file_full_path);
+* This function gets file type
+*
+* @return                        This function returns 0 on success, and -1 on failure.
+* @param[in]                    file_full_path           file full path
+ * @exception                    None.
+* @remark
+*
+*
+*/
+
+int
+_mb_svc_get_file_type(const char* file_full_path);
+
+bool
+_mb_svc_get_path_by_full(const char* full_path, char* path, int max_length);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /*_MEDIA_SVC_UTIL_H_*/
+
+/**
+* @}
+*/
+
diff --git a/src/include/visual/minfo-bookmark.h b/src/include/visual/minfo-bookmark.h
new file mode 100755 (executable)
index 0000000..6d2d216
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/** 
+ * This file defines synchronize apis for phone explorer.
+ *
+ * @file               minfo-bookmark.h
+ * @author             Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version    1.0
+ * @brief      This file defines in-house apis for media service.
+ */
+
+ /**
+  * @addtogroup MINFO_TYPES
+  * @{
+  */
+
+#include "minfo-types.h"
+
+#ifndef _MINFO_BOOKMARK_H_
+#define _MINFO_BOOKMARK_H_
+
+#define MINFO_TYPE_MBOOKMARK           (0x55554)
+#define MINFO_MBOOKMARK(obj)           ((Mbookmark*)(obj))
+#define MINFO_MBOOKMARK_GET_TYPE(obj)  ((obj)->gtype)
+#define IS_MINFO_MBOOKMARK(obj)          (MINFO_TYPE_MBOOKMARK == MINFO_MBOOKMARK_GET_TYPE(MINFO_MBOOKMARK(obj)))
+
+/**
+* @fn    Mbookmark*  minfo_mbookmark_new(int id);
+* This function creates mbookmark minfo
+*
+* @return                        This function returns mbookmark minfo
+* @param[in]                     id          new mbookmark   id
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+Mbookmark* 
+minfo_mbookmark_new(int id);
+
+/**
+* @fn    void minfo_mbookmark_destroy(Mbookmark* bookmark);
+* This function destroies mbookmark minfo
+*
+* @param[in]                    bookmark           pointer to Mbookmark minfo
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+void
+minfo_mbookmark_destroy(Mbookmark* bookmark);
+
+/**
+* @}
+*/
+
+
+#endif /*_MINFO_BOOKMARK_H_*/
+
+
diff --git a/src/include/visual/minfo-cluster.h b/src/include/visual/minfo-cluster.h
new file mode 100755 (executable)
index 0000000..34bac8a
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/** 
+ * This file defines synchronize apis for phone explorer.
+ *
+ * @file               minfo-cluster.h
+ * @author             Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version    1.0
+ * @brief      This file defines in-house apis for media service.
+ */
+
+ /**
+  * @addtogroup MINFO_TYPES
+  * @{
+  */
+
+#include "minfo-types.h"
+
+#ifndef _MINFO_CLUSTER
+#define _MINFO_CLUSTER
+
+#define MINFO_TYPE_MCLUSTER            (0x55549)
+#define MINFO_MCLUSTER(obj)            ((Mcluster*)(obj))
+#define MINFO_MCLUSTER_GET_TYPE(obj)   ((obj)->gtype)
+#define IS_MINFO_MCLUSTER(obj)          (MINFO_TYPE_MCLUSTER == MINFO_MCLUSTER_GET_TYPE(MINFO_MCLUSTER(obj)))
+
+
+/**
+* @fn    Mcluster* minfo_mcluster_new(int id);
+* This function creates mcluster item
+*
+* @return                        This function returns mcluster item
+* @param[in]                    id          new mcluster id
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+Mcluster* 
+minfo_mcluster_new(const char *uuid);
+
+/**
+* @fn    void minfo_mcluster_destroy(Mcluster* cluster);
+* This function destroies mcluster minfo
+*
+* @param[in]                    cluster    cluster minfo
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+void
+minfo_mcluster_destroy(Mcluster* cluster);
+
+/**
+* @}
+*/
+
+
+#endif /*_MINFO_CLUSTER_H_*/
+
+
+
diff --git a/src/include/visual/minfo-item.h b/src/include/visual/minfo-item.h
new file mode 100755 (executable)
index 0000000..b1f2a3c
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/** 
+ * This file defines synchronize apis for phone explorer.
+ *
+ * @file               minfo-item.h
+ * @author             Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version    1.0
+ * @brief      This file defines in-house apis for media service.
+ */
+
+ /**
+  * @addtogroup MINFO_TYPES
+  * @{
+  */
+
+#ifndef _MINFO_ITEM_H_
+#define _MINFO_ITEM_H_
+
+#include "minfo-types.h"
+#include "media-svc-structures.h"
+
+#define MINFO_TYPE_MITEM               (0x55550)
+#define MINFO_MITEM(obj)               ((Mitem*)(obj))
+#define MINFO_MITEM_GET_TYPE(obj)      ((obj)->gtype)
+#define IS_MINFO_MITEM(obj)                    (MINFO_TYPE_MITEM == MINFO_MITEM_GET_TYPE(MINFO_MITEM(obj)))
+
+/**
+* @fn    Mitem* minfo_mitem_new(int id, mb_svc_media_record_s *p_md_record);
+* This function creates mitem minfo
+*
+* @return                        This function returns mitem minfo
+* @param[in]                    id          new mitem id
+* @param[in]                    p_md_record          input media record from db if any
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+__attribute__((deprecated))
+Mitem* 
+minfo_mitem_new(const char *uuid); 
+
+Mitem*
+minfo_media_item_new   (const char *uuid, mb_svc_media_record_s *p_md_record);
+
+
+/**
+* @fn    void minfo_mitem_destroy(Mitem* item);
+* This function destroies mitem minfo
+*
+* @param[in]                    item           pointer to mitem minfo
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+void
+minfo_mitem_destroy(Mitem* item);
+
+/**
+* @}
+*/
+
+
+#endif /*_MINFO_ITEM_H_*/
+
+
+
diff --git a/src/include/visual/minfo-meta.h b/src/include/visual/minfo-meta.h
new file mode 100755 (executable)
index 0000000..03adbbf
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/** 
+ * This file defines synchronize apis for phone explorer.
+ *
+ * @file               minfo-meta.h
+ * @author             Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version    1.0
+ * @brief      This file defines in-house apis for media service.
+ */
+
+ /**
+  * @addtogroup MINFO_TYPES
+  * @{
+  */
+
+#include "minfo-types.h"
+#include "media-svc-structures.h"
+
+#ifndef _MINFO_META_H_
+#define _MINFO_META_H_
+
+/*---------------------------------Mvideo-----------------------------------------------------------------*/
+#define MINFO_TYPE_MVIDEO              (0x55553)
+#define MINFO_MVIDEO(obj)                      ((Mvideo*)(obj))
+#define MINFO_MVIDEO_GET_TYPE(obj)     ((obj)->gtype)
+#define IS_MINFO_MVIDEO(obj)                   (MINFO_TYPE_MVIDEO == MINFO_MVIDEO_GET_TYPE(MINFO_MVIDEO(obj)))
+
+Mvideo* 
+minfo_mvideo_new(const char *id);
+
+void
+minfo_mvideo_destroy(Mvideo* video);
+
+/*---------------------------------Mimage-----------------------------------------------------------------*/
+
+#define MINFO_TYPE_MIMAGE              (0x55552)
+#define MINFO_MIMAGE(obj)                      ((Mimage*)(obj))
+#define MINFO_MIMAGE_GET_TYPE(obj)     ((obj)->gtype)
+#define IS_MINFO_MIMAGE(obj)        (MINFO_TYPE_MIMAGE == MINFO_MIMAGE_GET_TYPE(MINFO_MIMAGE(obj)))
+
+Mimage* 
+minfo_mimage_new(const char *id);
+
+void
+minfo_mimage_destroy(Mimage* image);
+
+
+/*---------------------------------Mmeta-----------------------------------------------------------------*/
+
+
+#define MINFO_TYPE_MMETA               (0x55551)
+#define MINFO_MMETA(obj)                       ((Mmeta*)(obj))
+#define MINFO_MMETA_GET_TYPE(obj)              ((obj)->gtype)
+#define IS_MINFO_MMETA(obj)             (MINFO_TYPE_MMETA == MINFO_MMETA_GET_TYPE(MINFO_MMETA(obj)))
+
+
+/**
+* @fn    Mmeta* minfo_mmeta_new(int id, mb_svc_media_record_s *p_md_record);
+* This function news mmeta minfo
+*
+* @return                        This function returns mmeta minfo
+* @param[in]                    id          new mmeta id
+* @param[in]                    p_md_record          input media record from db if any
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+Mmeta* 
+minfo_mmeta_new(const char *media_uuid, mb_svc_media_record_s *p_md_record);
+
+/**
+* @fn    void minfo_mmeta_destroy(Mmeta* item);
+* This function destroies mmeta minfo
+*
+* @param[in]                    item        pointer to mmeta minfo
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+void
+minfo_mmeta_destroy(Mmeta* item);
+
+
+/**
+* @}
+*/
+
+
+#endif /*_MINFO_META_H_*/
+
+
+
diff --git a/src/include/visual/minfo-streaming.h b/src/include/visual/minfo-streaming.h
new file mode 100755 (executable)
index 0000000..b5db51a
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/** 
+ * This file defines synchronize apis for phone explorer.
+ *
+ * @file               minfo-streaming.h
+ * @author             Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version    1.0
+ * @brief      This file defines in-house apis for media service.
+ */
+
+ /**
+  * @addtogroup MINFO_TYPES
+  * @{
+  */
+
+
+#ifndef _MINFO_STREAMING_H_
+#define _MINFO_STREAMING_H_
+
+
+#define MINFO_TYPE_MSTREAMING          (0x55548)
+#define MINFO_MSTREAMING(obj)          ((Mbookmark*)(obj))
+#define MINFO_MSTREAMING_GET_TYPE(obj) ((obj)->gtype)
+#define IS_MINFO_MSTREAMING(obj)          (MINFO_TYPE_MSTREAMING == MINFO_MSTREAMING_GET_TYPE(MINFO_MSTREAMING(obj)))
+
+/**
+* @struct _Mstreaming
+* This structure defines _Mstreaming, same with Mstreaming
+*/
+
+struct _Mstreaming
+{
+       int gtype;
+       
+       unsigned int _id;                                       /**< web streaming id */
+       unsigned int cluster_id;                        /**< cluster id */
+       char *http_url;                                         /**< http url */
+       char *thumb_url;                                        /**< thumbnail full path */
+       unsigned int duration;                          /**< durantion */
+       char *title;                                            /**< title */
+       char *description;                                      /**< description */
+};
+
+typedef struct _Mstreaming     Mstreaming;
+
+
+/**
+* @fn    Mstreaming*  minfo_mstreaming_new(int id);
+* This function creates mstreaming minfo
+*
+* @return                        This function returns mstreaming minfo
+* @param[in]                    id          new mstreaming id
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+Mstreaming* 
+minfo_mstreaming_new(int id);
+
+
+/**
+* @fn    void minfo_mstreaming_destroy(Mstreaming* item);
+* This function destroies mstreaming minfo
+*
+* @param[in]                    item        pointor to mstreaming minfo
+* @exception                    None.
+* @remark                        
+*                                                             
+*                                                          
+*/
+
+void
+minfo_mstreaming_destroy(Mstreaming* item);
+
+
+/**
+* @}
+*/
+
+
+#endif /*_MINFO_STREAMING__H_*/
+
+
+
diff --git a/src/include/visual/minfo-tag.h b/src/include/visual/minfo-tag.h
new file mode 100755 (executable)
index 0000000..803893b
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file defines synchronize apis for phone explorer.
+ *
+ * @file               minfo-tag.h
+ * @author             Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version    1.0
+ * @brief      This file defines in-house apis for media service.
+ */
+
+ /**
+  * @addtogroup MINFO_TYPES
+  * @{
+  */
+
+#ifndef _MINFO_TAG_H_
+#define _MINFO_TAG_H_
+
+#include "minfo-types.h"
+#include "media-svc-structures.h"
+
+#define MINFO_TYPE_MTAG                (0x55555)
+#define MINFO_MTAG(obj)                ((Mtag*)(obj))
+#define MINFO_MTAG_GET_TYPE(obj)       ((obj)->gtype)
+#define IS_MINFO_MTAG(obj)                     (MINFO_TYPE_MTAG == MINFO_MTAG_GET_TYPE(MINFO_MTAG(obj)))
+
+/**
+* @fn    Mtag* minfo_media_tag_new     (int id, mb_svc_tag_record_s *p_tag_record);
+* This function creates Mtag minfo
+*
+* @return                        This function returns mtag minfo
+* @param[in]                    id          new mtag id
+* @param[in]                    p_tag_record          input tag record from db if any
+* @exception                    None.
+* @remark
+*
+*
+*/
+
+Mtag*
+minfo_media_tag_new    (int id, mb_svc_tag_record_s *p_tag_record);
+
+
+/**
+* @fn    void minfo_media_tag_destroy(Mtag* i_tag);
+* This function destroies Mtag minfo
+*
+* @param[in]                    i_tag           pointer to Mtag minfo
+* @exception                    None.
+* @remark
+*
+*
+*/
+
+void
+minfo_media_tag_destroy(Mtag* i_tag);
+
+
+/**
+* @}
+*/
+
+
+#endif /*_MINFO_TAG_H_*/
+
+
+
+
diff --git a/src/visual/IfegDecodeAGIF.c b/src/visual/IfegDecodeAGIF.c
new file mode 100644 (file)
index 0000000..9cde3dc
--- /dev/null
@@ -0,0 +1,4170 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "media-svc-debug.h"
+#include "media-img-codec-common.h"
+#include "IfegDecodeAGIF.h"
+
+
+
+#define MAX_CODES   4096
+
+int __FastImgGetNextFrameAGIF_NoBuffer (AGifFrameInfo *pFrameData, BOOL bCenterAlign);
+int __FastImgGetNextFrameAGIF_UseBuffer (AGifFrameInfo *pFrameData, BOOL bCenterAlign);
+
+int image_left_pos_N = 0;      /* left position of image in Logical screeen */
+int image_top_pos_N = 0;
+
+AGifFrameInfo *FastImgCreateAGIFFrameData(unsigned int width, unsigned int height, unsigned char *pEncodedData, unsigned int file_size, unsigned int ui_backcolor, BOOL bLoop)
+{
+       int header_temp;
+       int backcolor_index;
+       unsigned int image_backcolor;
+       unsigned int backcolor_parsing;
+       unsigned int transcolor_565 = 0;
+       int transparent = 0;
+       int transIndex = 0;
+       int local_color_table_flag;
+
+       int inputPos = 0;
+       int inputPos_temp = 0;
+
+    AGifFrameInfo *pFrameData;
+       if (0 == (pFrameData = IfegMemAlloc(sizeof(AGifFrameInfo)))) {
+               return 0;
+       }
+
+       IfegMemset(pFrameData, 0, sizeof(AGifFrameInfo));
+
+       inputPos += 13;
+       
+       pFrameData->logi_wdt = pEncodedData[6] | (pEncodedData[7]<<8);
+       pFrameData->logi_hgt = pEncodedData[8] | (pEncodedData[9]<<8);
+#ifdef INTERNAL_IMGCODEC
+       mb_svc_debug("logi_wdt:%d, logi_hgt:%d\n", pFrameData->logi_wdt, pFrameData->logi_hgt);
+#else
+       mb_svc_debug("logi_wdt:%d, logi_hgt:%d\n", pFrameData->logi_wdt, pFrameData->logi_hgt);
+       if ((pFrameData->logi_wdt > MAXWIDTH) || (pFrameData->logi_hgt > MAXHEIGHT)) {
+               if (pFrameData) {
+                               IfegMemFree(pFrameData);
+                               pFrameData = 0;
+               }
+               return 0;
+       }
+#endif
+
+       /* save nReapeatCount assigned by content */
+
+       if ((pEncodedData[10]&0x80) == 0x80) {
+               header_temp = 3 * (1<<((pEncodedData[10] & 0x07) + 1));
+       } else {
+               header_temp = 0;
+       }
+       
+       if (file_size > 30+header_temp && pEncodedData[14+header_temp] == 0xFF) {
+               pFrameData->nLoopCount = pEncodedData[30+header_temp]<<8 | pEncodedData[29+header_temp];
+       } else if (file_size > 30+8+header_temp && pEncodedData[14+8+header_temp] == 0xFF) {
+               pFrameData->nLoopCount = pEncodedData[30+8+header_temp]<<8 | pEncodedData[29+8+header_temp];
+       } else {
+               pFrameData->nLoopCount = -1;
+       }
+       
+       pFrameData->nRepeatCount = 0;
+
+       mb_svc_debug("10st data :  0x%x , global color table num : %d\n", pEncodedData[10], header_temp);
+       mb_svc_debug("13: 0x%x ,14: 0x%x, 15: 0x%x, nRepeatCount : %d, nLoopCount : %d\n", pEncodedData[13+header_temp], pEncodedData[14+header_temp], pEncodedData[15+header_temp], pFrameData->nRepeatCount, pFrameData->nLoopCount);
+
+       backcolor_index = pEncodedData[11];
+
+       if (pEncodedData[14+header_temp] == 0xF9) {
+               inputPos_temp = 14+header_temp+17;
+               transparent = pEncodedData[16+header_temp] & 0x01;
+               transIndex =    pEncodedData[19+header_temp];
+               local_color_table_flag = pEncodedData[30+header_temp] & 0x80;
+
+               if (local_color_table_flag == 0x80) {
+                       transcolor_565 = ((pEncodedData[inputPos_temp+transIndex*3]>>3)<<11)|((pEncodedData[inputPos_temp+transIndex*3+1]>>2)<<5)|(pEncodedData[inputPos_temp+transIndex*3+2]>>3);              
+               } else {
+                       transcolor_565 = ((pEncodedData[13+transIndex*3]>>3)<<11)|((pEncodedData[13+transIndex*3+1]>>2)<<5)|(pEncodedData[13+transIndex*3+2]>>3);                               
+               }
+
+               backcolor_parsing = (unsigned short)((pEncodedData[inputPos+backcolor_index*3] >> 3)<<11) | ((pEncodedData[inputPos+backcolor_index*3+1] >> 2)<<5) | (pEncodedData[inputPos+backcolor_index*3+2] >> 3);
+       } else if (pEncodedData[14+19+header_temp] == 0xF9) {
+               inputPos_temp = 14+19+header_temp+17;
+               transparent = pEncodedData[35+header_temp] & 0x01;
+               transIndex = pEncodedData[38+header_temp];
+               local_color_table_flag = pEncodedData[49+header_temp] & 0x80;
+
+               if (local_color_table_flag == 0x80) {
+                       transcolor_565 = ((pEncodedData[inputPos_temp+transIndex*3]>>3)<<11)|((pEncodedData[inputPos_temp+transIndex*3+1]>>2)<<5)|(pEncodedData[inputPos_temp+transIndex*3+2]>>3);              
+               } else {
+                       transcolor_565 = ((pEncodedData[13+transIndex*3]>>3)<<11)|((pEncodedData[13+transIndex*3+1]>>2)<<5)|(pEncodedData[13+transIndex*3+2]>>3);                               
+               }
+
+               backcolor_parsing = (unsigned short)((pEncodedData[inputPos+backcolor_index*3] >> 3)<<11) | ((pEncodedData[inputPos+backcolor_index*3+1] >> 2)<<5) | (pEncodedData[inputPos+backcolor_index*3+2] >> 3);
+       } else if ((pEncodedData[10]&0x80) != 0x80) { /* global color table */
+               backcolor_parsing = ui_backcolor;
+       } else {
+               backcolor_parsing = (unsigned short)((pEncodedData[inputPos+backcolor_index*3] >> 3)<<11) | ((pEncodedData[inputPos+backcolor_index*3+1] >> 2)<<5) | (pEncodedData[inputPos+backcolor_index*3+2] >> 3);
+       }
+
+    /* graphic extension block */
+       if (pEncodedData[14+header_temp] == 0xF9 || pEncodedData[14+19+header_temp] == 0xF9) {
+
+               if (transparent == 1 && backcolor_index == transIndex) {
+                       image_backcolor =  ui_backcolor;
+               } else if (transparent == 1 && backcolor_index != transIndex) {
+                       image_backcolor = backcolor_parsing;
+               } else {
+                       image_backcolor =  backcolor_parsing;           
+               }
+       } else {
+               image_backcolor =  backcolor_parsing;   
+       }
+
+#if MODE == 0
+       if (0 == (pFrameData->pPrevImg = IfegMemAlloc(sizeof(unsigned char)*width*height*2))) {
+               if (pFrameData) {
+                       IfegMemFree(pFrameData);
+                       pFrameData = 0;
+               }
+               return 0;
+       }
+       pFrameData->useBuffer = 0;
+#endif
+
+#if MODE == 1
+       if (0 == (pFrameData->pPrevImg = IfegMemAlloc(sizeof(unsigned int)*pFrameData->logi_wdt*pFrameData->logi_hgt))) {
+               if (pFrameData) {
+                       IfegMemFree(pFrameData);
+                       pFrameData = 0;
+               }
+               return 0;
+       }
+       pFrameData->useBuffer = 1;
+#endif
+
+
+#if MODE == 2
+       if (((pFrameData->logi_wdt <= width) && (pFrameData->logi_hgt <= height))) {
+               if (0 ==  (pFrameData->pPrevImg = IfegMemAlloc(sizeof(unsigned char)*width*height*2))) {
+                       if (pFrameData) {
+                               IfegMemFree(pFrameData);
+                               pFrameData = 0;
+                       }
+                       return 0;
+               }
+               pFrameData->useBuffer = 0;
+       } else {
+               if (0 ==  (pFrameData->pPrevImg = IfegMemAlloc(sizeof(unsigned int)*pFrameData->logi_wdt*pFrameData->logi_hgt))) {
+                       if (pFrameData) {
+                               IfegMemFree(pFrameData);
+                               pFrameData = 0;
+                       }
+                       return 0;
+               }
+               pFrameData->useBuffer = 1;
+       }
+#endif
+
+       if (0 == (pFrameData->pOutBits = IfegMemAlloc(sizeof(unsigned char)*width*height*2))) {
+               if (pFrameData->pPrevImg) {
+                       IfegMemFree(pFrameData->pPrevImg);
+                       pFrameData->pPrevImg = 0;
+               }
+               if (pFrameData) {
+                       IfegMemFree(pFrameData);
+                       pFrameData = 0;
+               }
+               return 0;
+       }
+
+       pFrameData->inputSize = file_size;
+       pFrameData->pEncodedData = pEncodedData;
+
+       if (0 == (pFrameData->pGlobal_table = IfegMemAlloc(sizeof(unsigned int)*256))) {
+               if (pFrameData->pPrevImg) {
+                       IfegMemFree(pFrameData->pPrevImg);
+                       pFrameData->pPrevImg = 0;
+               }
+
+               if (pFrameData->pOutBits) {
+                       IfegMemFree(pFrameData->pOutBits);
+                       pFrameData->pOutBits = 0;
+               }
+
+               if (pFrameData) {
+                       IfegMemFree(pFrameData);
+                       pFrameData = 0;
+               }
+               return 0;
+       }
+
+       if (0 == (pFrameData->pPrefix = IfegMemAlloc(sizeof(unsigned short)*4097))) {
+               if (pFrameData->pPrevImg) {
+                       IfegMemFree(pFrameData->pPrevImg);
+                       pFrameData->pPrevImg = 0;
+               }
+               if (pFrameData->pOutBits) {
+                       IfegMemFree(pFrameData->pOutBits);
+                       pFrameData->pOutBits = 0;
+               }
+               if (pFrameData->pGlobal_table) {
+                       IfegMemFree(pFrameData->pGlobal_table);
+                       pFrameData->pGlobal_table = 0;
+               }
+               if (pFrameData) {
+                       IfegMemFree(pFrameData);
+                       pFrameData = 0;
+               }
+               return 0;
+       }
+
+       if (0 == (pFrameData->pDstack = IfegMemAlloc(sizeof(unsigned char)*4097))) {
+               if (pFrameData->pPrevImg) {
+                       IfegMemFree(pFrameData->pPrevImg);
+                       pFrameData->pPrevImg = 0;
+               }
+               if (pFrameData->pOutBits) {
+                       IfegMemFree(pFrameData->pOutBits);
+                       pFrameData->pOutBits = 0;
+               }
+               if (pFrameData->pGlobal_table) {
+                       IfegMemFree(pFrameData->pGlobal_table);
+                       pFrameData->pGlobal_table = 0;
+               }
+               if (pFrameData->pPrefix) {
+                       IfegMemFree(pFrameData->pPrefix);
+                       pFrameData->pPrefix = 0;
+               }
+               if (pFrameData) {
+                       IfegMemFree(pFrameData);
+                       pFrameData = 0;
+               }
+               return 0;
+       }
+
+       if (0 == (pFrameData->pSuffix = IfegMemAlloc(sizeof(unsigned char)*4097))) {
+               if (pFrameData->pPrevImg) {
+                       IfegMemFree(pFrameData->pPrevImg);
+                       pFrameData->pPrevImg = 0;
+               }
+               if (pFrameData->pOutBits) {
+                       IfegMemFree(pFrameData->pOutBits);
+                       pFrameData->pOutBits = 0;
+               }
+               if (pFrameData->pGlobal_table) {
+                       IfegMemFree(pFrameData->pGlobal_table);
+                       pFrameData->pGlobal_table = 0;
+               }
+               if (pFrameData->pPrefix) {
+                       IfegMemFree(pFrameData->pPrefix);
+                       pFrameData->pPrefix = 0;
+               }
+               if (pFrameData->pDstack) {
+                       IfegMemFree(pFrameData->pDstack);
+                       pFrameData->pDstack = 0;
+               }
+               if (pFrameData) {
+                       IfegMemFree(pFrameData);
+                       pFrameData = 0;
+               }
+               return 0;
+       }
+
+       pFrameData->width = width;
+       pFrameData->height = height;
+       pFrameData->imgCount = -1;
+       pFrameData->offset = 0;
+       pFrameData->backcolor = image_backcolor;
+       pFrameData->ui_backcolor = ui_backcolor;
+       pFrameData->delay = 10;
+       pFrameData->bLoop = bLoop;
+       return pFrameData;
+}
+
+void FastImgDestroyAGIFFrameData(AGifFrameInfo *pFrameData)
+{
+       if (pFrameData == NULL) {
+               return;
+       }
+       
+       if (pFrameData->pPrevImg) {
+               IfegMemFree(pFrameData->pPrevImg);
+               pFrameData->pPrevImg = 0;
+       }
+
+       if (pFrameData->pEncodedData) {
+               IfegMemFree(pFrameData->pEncodedData);
+               pFrameData->pEncodedData = 0;
+       }
+       if (pFrameData->pOutBits) {
+               IfegMemFree(pFrameData->pOutBits);
+               pFrameData->pOutBits = 0;
+       }
+
+       if (pFrameData->pGlobal_table) {
+               IfegMemFree(pFrameData->pGlobal_table);
+               pFrameData->pGlobal_table = 0;
+       }
+
+       if (pFrameData->pPrefix) {
+               IfegMemFree(pFrameData->pPrefix);
+               pFrameData->pPrefix = 0;
+       }
+
+       if (pFrameData->pDstack) {
+               IfegMemFree(pFrameData->pDstack);
+               pFrameData->pDstack = 0;
+       }
+
+       if (pFrameData->pSuffix) {
+               IfegMemFree(pFrameData->pSuffix);
+               pFrameData->pSuffix = 0;
+       }
+
+       if (pFrameData) {
+               IfegMemFree(pFrameData);
+               pFrameData = 0;
+       }
+}
+
+/* macro */
+#define __get_next_code_first_nbits_left_0(pInputStream) \
+{\
+       {\
+               if (navail_bytes == 0) {\
+                       navail_bytes = (pInputStream)[inputPos++];\
+                       if ((inputPos + navail_bytes) > filesize) {\
+                               if (decoderline) {\
+                                       IfegMemFree(decoderline);\
+                                       decoderline = 0;\
+                               } \
+                               if (pDecBuf) {\
+                                       IfegMemFree(pDecBuf);\
+                                       pDecBuf = 0;\
+                               } \
+                               return -1;\
+                       } \
+               } \
+               b1 = (pInputStream)[inputPos++];\
+               ret = b1;\
+               nbits_left = 8;\
+               --navail_bytes;\
+       } \
+}
+
+#define __get_next_code_first_nbits_left_not_0(pInputStream) \
+{\
+       {\
+               ret = b1 >> (8 - nbits_left); \
+       } \
+}
+
+#define __get_next_code_first_while(pInputStream) \
+{\
+       while (curr_size > nbits_left) {\
+               if (navail_bytes == 0) {\
+                       navail_bytes = (pInputStream)[inputPos++];\
+                       if ((inputPos + navail_bytes) > filesize) {\
+                               if (decoderline) {\
+                                       IfegMemFree(decoderline);\
+                                       decoderline = 0;\
+                               } \
+                               if (pDecBuf) {\
+                                       IfegMemFree(pDecBuf);\
+                                       pDecBuf = 0;\
+                               } \
+                               return -1;\
+                       } \
+               } \
+               b1 = (pInputStream)[inputPos++];\
+               ret |= b1 << nbits_left;\
+               nbits_left += 8;\
+               --navail_bytes;\
+       } \
+       nbits_left -= curr_size;\
+       ret &= (1<<curr_size)-1;\
+       c = ret;\
+}
+
+#define __get_next_code_second_nbits_left_0(pInputStream) \
+{\
+       {\
+               b1 = (pInputStream)[inputPos++];\
+               ret = b1;\
+               nbits_left = 8;\
+               --navail_bytes;\
+       } \
+}
+
+#define __get_next_code_second_nbits_left_not_0(pInputStream) \
+{\
+       {\
+               ret = b1 >> (8 - nbits_left);\
+       } \
+}
+
+#define __get_next_code_second_while(pInputStream) \
+{\
+       while (curr_size > nbits_left) {\
+               b1 = (pInputStream)[inputPos++];\
+               ret |= b1 << nbits_left;\
+               nbits_left += 8;\
+               --navail_bytes;\
+       } \
+       nbits_left -= curr_size;\
+       ret &= (1 << curr_size)-1;\
+       c = ret;\
+}
+
+int FastImgGetNextFrameAGIF(AGifFrameInfo *pFrameData, BOOL bCenterAlign)
+{
+       if (pFrameData->useBuffer) {
+               return __FastImgGetNextFrameAGIF_UseBuffer(pFrameData, bCenterAlign);
+       } else {
+               return __FastImgGetNextFrameAGIF_NoBuffer(pFrameData, bCenterAlign);
+       }
+}
+
+int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAlign)
+{
+       unsigned int *pImage32, *pImage32_2;
+       unsigned short *pImage16;
+       unsigned char *sp;
+       unsigned char *bufptr;
+       unsigned int code, fc, oc, bufcnt;
+       unsigned char buffer[16];
+       unsigned char val1;
+       unsigned char *buf;
+       unsigned int *pDacbox;
+       unsigned char *decoderline = 0;
+       unsigned int size;
+
+       unsigned int c = 0;
+       unsigned int clear;
+       unsigned int ending;
+       unsigned int newcodes;
+       unsigned int top_slot;
+       unsigned int slot;
+
+       int     numcolors;
+       int     i, j, k;
+       int     rowcount;
+       int orgwdt_1, orgwdt, orghgt;
+       int decwdt, dechgt;
+       int len;
+       int inter_step, interLaced;
+       int transparent = 0;
+       int startloc = 0;
+       int transIndex = 0;
+       int spCount = 0;
+       int logi_wdt;           /* logical screen width */
+       int logi_hgt;
+       int logi_image_size;
+       int image_backcolor;
+       int ui_backcolor;
+       int backcolor;
+       int image_left_pos;     /* left position of image in Logical screeen */
+       int image_top_pos;
+       int disposal_method = 0;
+       int margin_wdt1_2, margin_hgt1_2;
+       int inputPos;
+
+       unsigned int dacbox[256];
+
+       /* Variable for Resize */
+       unsigned int a_x, a_y;
+       unsigned int b_x, b_y;
+       unsigned int c_x, c_y;
+       unsigned int d_x, d_y;
+       int out_x = 0, out_y = 0;
+       int d1, d2;
+       int flag = 0;
+       unsigned int end;
+
+       int count = 0;
+
+       unsigned char *pDecBuf = 0;
+
+       int expected_width = pFrameData->width;
+       int expected_height = pFrameData->height;
+       int resized_width;
+       int resized_height;
+
+       /* macro */
+       register unsigned int curr_size;
+       register int navail_bytes = 0;
+       register unsigned int nbits_left = 0;
+       register unsigned int b1 = 0;
+       register unsigned int ret;
+
+       /* parameter */
+       int filesize = pFrameData->inputSize;
+       unsigned int *global_dacbox = pFrameData->pGlobal_table;
+       register unsigned char *pInputStream = pFrameData->pEncodedData;
+       void *pOutBits = pFrameData->pOutBits;
+       unsigned short *prefix = pFrameData->pPrefix;                   
+       unsigned char *dstack = pFrameData->pDstack;                    
+       unsigned char *suffix = pFrameData->pSuffix;            
+
+       inputPos = pFrameData->offset;
+
+       IfegMemset(prefix, 0, sizeof(unsigned short)*(MAX_CODES+1));
+       IfegMemset(dstack, 0, sizeof(unsigned char)*(MAX_CODES+1));
+       IfegMemset(suffix, 0, sizeof(unsigned char)*(MAX_CODES+1));
+
+       image_backcolor = pFrameData->backcolor;
+       ui_backcolor = pFrameData->ui_backcolor;
+
+       backcolor = image_backcolor;
+
+       if (pFrameData->imgCount == -1) {
+               /* Input stream index set to 0 */
+               inputPos = 0;
+               inter_step = 1;
+               interLaced = 0; 
+               transparent = 0; 
+
+               /* read a GIF HEADER */
+               IfegMemcpy(buffer, pInputStream, 13);
+               inputPos += 13;
+
+               /* wheather GIF file or not */
+               if (buffer[0] != 'G' || buffer[1] != 'I' || buffer[2] != 'F' ||
+                       buffer[3] < '0' || buffer[3] > '9' ||
+                       buffer[4] < '0' || buffer[4] > '9' ||
+                       buffer[5] < 'A' || buffer[5] > 'z') {
+                       if (decoderline != 0) {
+                               IfegMemFree(decoderline);
+                               decoderline = 0;
+                       }
+                       if (pDecBuf != 0) {
+                               IfegMemFree(pDecBuf);
+                               pDecBuf = 0;
+                       }
+                       return -1;
+               }
+
+               /* Regard the width/height of image block as the size of thumbnails. */
+               pFrameData->logi_wdt = logi_wdt = expected_width;
+               pFrameData->logi_hgt = logi_hgt = expected_height;
+
+               logi_image_size = logi_wdt * logi_hgt;
+
+               /* ouput resized image size */
+               if (logi_wdt <= expected_width && logi_hgt <= expected_height) {
+                       resized_width = logi_wdt;
+                       resized_height = logi_hgt;
+                       pFrameData->flag = flag = 1;
+               } else {
+                       if ((logi_wdt/(float)expected_width) >= (logi_hgt/(float)expected_height)) {
+                               resized_height = logi_hgt * expected_width / logi_wdt;
+                               resized_width = expected_width;
+                       } else {
+                               resized_width = logi_wdt * expected_height / logi_hgt;
+                               resized_height = expected_height;
+                       }
+               }
+               if (!resized_width || !resized_height) {
+                       if (pDecBuf != 0) {
+                               IfegMemFree(pDecBuf);
+                               pDecBuf = 0;
+                       }
+                       return 0;
+               }
+
+               /* ouput resized image size */
+               pFrameData->resizedwidth = resized_width;
+               pFrameData->resizedheight = resized_height;
+
+               /* Color Resolution */
+               IfegMemset(global_dacbox, 0, 1024);
+               numcolors = (buffer[10] & 0x7) + 1;
+               if ((buffer[10] & 0x80) == 0) { /* Global color table */
+                       global_dacbox[0] = 0x000000;
+                       global_dacbox[1] = 0x3f3f3f;
+                       numcolors = 2;
+               } else { /* Global color table */
+                       numcolors = 1 << numcolors;
+
+                       /* Make color table */
+                       for (i = 0 ; i < numcolors; i++) {
+                               global_dacbox[i] = ((pInputStream[inputPos++] >> 2)<<16);
+                               global_dacbox[i] |= ((pInputStream[inputPos++] >> 2)<<8);
+                               global_dacbox[i] |= (pInputStream[inputPos++] >> 2);
+                       }
+               }
+
+               /* Background Color */
+               pImage16 = (unsigned short *)pFrameData->pPrevImg;
+               for (i = 0; i < expected_width * expected_height; i++) {
+                       *pImage16++ = ui_backcolor;
+               }
+
+               if (numcolors > 16) {
+                       numcolors = 256;
+               }
+               if (numcolors > 2 && numcolors < 16) {
+                       numcolors = 16;
+               }
+
+               pFrameData->global_numcol = numcolors;
+               pFrameData->imgCount++;
+               pFrameData->firstpos = inputPos;
+       } else {
+
+               logi_wdt = pFrameData->logi_wdt;
+               logi_hgt = pFrameData->logi_hgt;
+               resized_width = pFrameData->resizedwidth;
+               resized_height = pFrameData->resizedheight;
+
+               flag = pFrameData->flag ;
+
+               numcolors = pFrameData->global_numcol;
+       }
+
+
+       while (1) {
+               if (inputPos > filesize) {
+                       if (decoderline) {
+                               IfegMemFree(decoderline);
+                               decoderline = 0;
+                       }
+                       if (pDecBuf) {
+                               IfegMemFree(pDecBuf);
+                               pDecBuf = 0;
+                       }
+                       pFrameData->imgCount = 0;
+                       pFrameData->offset = pFrameData->firstpos;
+
+                       if (pFrameData->bLoop) {
+                               /* Background Color */
+                               pImage16 = (unsigned short *)pFrameData->pPrevImg;
+                               for (i = 0; i < expected_width * expected_height; i++) {
+                                       *pImage16++ = ui_backcolor;
+                               }
+                               return 1;
+                       } else {
+                               return 0;
+                       }
+               }
+
+               switch (pInputStream[inputPos++]) {
+               case 0x3b: /* End of the GIF dataset */
+                       if (decoderline) {
+                               IfegMemFree(decoderline);
+                               decoderline = 0;
+                       }
+                       if (pDecBuf) {
+                               IfegMemFree(pDecBuf);
+                               pDecBuf = 0;
+                       }
+                       if (pFrameData->imgCount == 0) {
+                               return -1;
+                       }
+                       pFrameData->imgCount = 0;
+                       pFrameData->offset = pFrameData->firstpos;
+
+#ifdef INTERNAL_IMGCODEC
+                       pFrameData->nRepeatCount++;
+                       mb_svc_debug("(no_buffer) bLoop : %d, nRepeatCount : %d, nLoopCount : %d" , pFrameData->bLoop, pFrameData->nRepeatCount , pFrameData->nLoopCount);
+
+                       if (pFrameData->nLoopCount == -1) {                     
+                               break;
+                       } else if (pFrameData->bLoop || (pFrameData->nRepeatCount <= pFrameData->nLoopCount) || (pFrameData->nLoopCount == 0)) {
+                           /* Background Color */
+                               pImage16 = (unsigned short *)pFrameData->pPrevImg;
+
+                               for (i = 0; i < expected_width * expected_height; i++) {
+                                       *pImage16++ = ui_backcolor;
+                               }
+                               
+                               inputPos = pFrameData->offset;
+                               continue;
+                       } else {
+                               /* if there is last frame and bLoop is FALSE, return 2. */
+                               return 2;
+                       }
+#else
+                       if (pFrameData->bLoop) {
+                               /* Background Color */
+                               pImage16 = (unsigned short *)pFrameData->pPrevImg;
+                               for (i = 0; i < expected_width * expected_height; i++) {
+                                       *pImage16++ = backcolor;
+                               }
+                               return 1;
+                       } else {
+                               return 0;
+                       }
+#endif
+                       break;
+               case 0x21: /* Extension Block */
+                       switch (pInputStream[inputPos++]) {
+                       case 0xf9: /* Graphic control extension block */
+                               if (4 != pInputStream[inputPos++]) { /* data length : fixed 4 bytes */
+                                       if (decoderline != 0) {
+                                               IfegMemFree(decoderline);
+                                               decoderline = 0;
+                                       }
+                                       if (pDecBuf != 0) {
+                                               IfegMemFree(pDecBuf);
+                                               pDecBuf = 0;
+                                       }
+                                       return -1;
+                               }
+
+                               disposal_method = ((pInputStream[inputPos] & 0x1c) >> 2);
+                               transparent = pInputStream[inputPos++] & 0x01;  /* does it use? 1:on 0:off */
+                               pFrameData->delay = (pInputStream[inputPos] | (pInputStream[inputPos+1] << 8))*10;
+                               inputPos += 2; /* Delay time (skip) */
+                               transIndex = pInputStream[inputPos++]; 
+                               inputPos++; /* block end */
+                               break;
+
+                       case 0x01: /* Plain Text block */
+                               while ((i = pInputStream[inputPos++]) > 0) {/* get the data length */
+                                       inputPos += i;
+                                       if (inputPos > filesize) {
+                                               if (decoderline) {
+                                                       IfegMemFree(decoderline);
+                                                       decoderline = 0;
+                                               }
+                                               if (pDecBuf) {
+                                                       IfegMemFree(pDecBuf);
+                                                       pDecBuf = 0;
+                                               }
+                                               return -1;
+                                       }
+                               }
+                               break;
+
+                       case 0xfe: /* Comment Extension block */
+                               while ((i = pInputStream[inputPos++]) > 0) { /* get the data length */
+                                       inputPos += i;
+                                       if (inputPos > filesize) {
+                                               if (decoderline) {
+                                                       IfegMemFree(decoderline);
+                                                       decoderline = 0;
+                                               }
+                                               if (pDecBuf) {
+                                                       IfegMemFree(pDecBuf);
+                                                       pDecBuf = 0;
+                                               }
+                                               return -1;
+                                       }
+                               }
+                               break;
+
+                       case 0xff: /* Appliation Extension block */
+                               while ((i = pInputStream[inputPos++]) > 0) {    /* get the data length */
+                                       inputPos += i;
+                                       if (inputPos > filesize) {
+                                               if (decoderline) {
+                                                       IfegMemFree(decoderline);
+                                                       decoderline = 0;
+                                               }
+
+                                               if (pDecBuf) {
+                                                       IfegMemFree(pDecBuf);
+                                                       pDecBuf = 0;
+                                               }
+                                               return -1;
+                                       }
+                               }
+                               break;
+
+                       default:
+                               break;
+                       }
+                       break;
+
+               case 0x2c: /* Start of an image object. Read the image description. */
+
+                       /* initialize */
+                       IfegMemcpy(pOutBits, pFrameData->pPrevImg, expected_width * expected_height * 2);
+                       pDacbox = global_dacbox;
+
+                       IfegMemcpy(buffer, pInputStream+inputPos, 9);
+                       inputPos += 9;
+
+                       image_left_pos = (buffer[0] | (buffer[1]<<8));
+                       image_top_pos = (buffer[2] | (buffer[3]<<8));
+                       orgwdt_1 = orgwdt = (buffer[4] | (buffer[5] << 8));
+                       orghgt = (buffer[6] | (buffer[7] << 8));
+
+#ifdef INTERNAL_IMGCODEC
+#else
+                       if ((orgwdt > MAXWIDTH) || (orghgt > MAXHEIGHT)) {
+                               if (decoderline != 0) {
+                                       IfegMemFree(decoderline);
+                                       decoderline = 0;
+                               }
+                               if (pDecBuf != 0) {
+                                       IfegMemFree(pDecBuf);
+                                       pDecBuf = 0;
+                               }
+                               return -1;
+                       }
+#endif
+
+                       /* Interlaced check */
+                       interLaced = buffer[8] & 0x40;
+                       if (interLaced) {
+                               startloc = -8;
+                       }
+
+                       inter_step = 1;
+
+                       if (decoderline) {
+                               IfegMemFree(decoderline);
+                       }
+                       decoderline = (unsigned char *)IfegMemAlloc(orgwdt);
+                       if (!decoderline) {
+                               if (decoderline != 0) {
+                                       IfegMemFree(decoderline);
+                                       decoderline = 0;
+                               }
+                               if (pDecBuf != 0) {
+                                       IfegMemFree(pDecBuf);
+                                       pDecBuf = 0;
+                               }
+                               return 0;
+                       }
+                       IfegMemset(decoderline, 0, orgwdt);
+
+                       decwdt = ((orgwdt * resized_width+logi_wdt-1) / logi_wdt);
+                       dechgt = ((orghgt * resized_height+logi_hgt-1) / logi_hgt);
+                       
+                       if (!decwdt || !dechgt) {
+                               if (decoderline != 0) {
+                                       IfegMemFree(decoderline);
+                                       decoderline = 0;
+                               }
+                               if (pDecBuf != 0) {
+                                       IfegMemFree(pDecBuf);
+                                       pDecBuf = 0;
+                               }
+                               return 0;
+                       }
+
+                       if (pDecBuf) {
+                               IfegMemFree(pDecBuf);
+                       }
+                       pDecBuf = (unsigned char *)IfegMemAlloc(decwdt * dechgt * 4);
+                       if (!pDecBuf) {
+                               if (decoderline != 0) {
+                                       IfegMemFree(decoderline);
+                                       decoderline = 0;
+                               }
+                               if (pDecBuf != 0) {
+                                       IfegMemFree(pDecBuf);
+                                       pDecBuf = 0;
+                               }
+                               return 0;
+                       }
+                       IfegMemset(pDecBuf, 0, decwdt * dechgt * 4);
+
+                       /* assign out_888_image plane */
+                       pImage32 = (unsigned int *)(pDecBuf);
+
+                       /* Initialize */
+                       a_x = orgwdt>>2, a_y = orghgt>>2;
+                       b_x = ((orgwdt*3)>>2), b_y = orghgt>>2;
+                       c_x = orgwdt>>2, c_y = ((orghgt*3)>>2);
+                       d_x = ((orgwdt*3)>>2), d_y = ((orghgt*3)>>2);
+
+                       end = dechgt * orghgt;
+                       out_x = 0, out_y = -dechgt;
+
+                       /* Color Resolution */
+                       if ((buffer[8] & 0x80) == 0) { /* Logical color table  */
+                               /* use global table */
+                       } else { /* Logical color table */
+                               IfegMemset(dacbox, 0, 1024);
+
+                               numcolors = (buffer[8] & 0x7) + 1;
+                               numcolors = 1 << numcolors;
+
+                               count = 0;
+
+                               /* Make color table */
+                               for (i = 0 ; i < numcolors; i++) {
+                                       dacbox[i] = ((pInputStream[inputPos++] >> 2)<<16);
+                                       dacbox[i] |= ((pInputStream[inputPos++] >> 2)<<8);
+                                       dacbox[i] |= (pInputStream[inputPos++] >> 2);
+                               }
+                               pDacbox = dacbox;
+                       }
+
+                       if (numcolors > 16) {
+                               numcolors = 256;
+                       }
+                       if (numcolors > 2 && numcolors < 16) {
+                               numcolors = 16;
+                       }
+
+                       /****************************************************************************
+                       decoder(WDT, pInputStream, pBitmapElem->pBits);
+                       int decoder(int linewidth, UCHAR* pInputStream, UCHAR *pBitmapElem->pBits)
+                       ****************************************************************************/
+
+                       size = pInputStream[inputPos++];
+                       if (size < 2 || 9 < size) {
+                               if (decoderline != 0) {
+                                       IfegMemFree(decoderline);
+                                       decoderline = 0;
+                               }
+                               if (pDecBuf != 0) {
+                                       IfegMemFree(pDecBuf);
+                                       pDecBuf = 0;
+                               }
+                               return -1;
+                       }
+
+                       rowcount = oc = fc = 0;
+                       buf = decoderline;
+                       sp = dstack;
+                       bufptr = buf;
+                       bufcnt = orgwdt_1;
+
+                       /************************
+                       init_exp(size);
+                       int init_exp(int size)
+                       ************************/
+                       curr_size = size + 1;
+                       top_slot = 1 << curr_size;
+                       clear = 1 << size;
+                       ending = clear + 1;
+                       slot = newcodes = ending + 1;
+                       navail_bytes = nbits_left = 0;
+                       /************************/
+
+
+                       /* __get_next_code(pInputStream) */
+                       if (navail_bytes < 2) {
+                               if (nbits_left == 0) {
+                                       __get_next_code_first_nbits_left_0(pInputStream)
+                               } else
+                                       __get_next_code_first_nbits_left_not_0(pInputStream)
+
+                               __get_next_code_first_while(pInputStream)
+                       } else {
+                               if (nbits_left == 0) 
+                                       __get_next_code_second_nbits_left_0(pInputStream)
+                               else
+                                       __get_next_code_second_nbits_left_not_0(pInputStream)
+                               
+                               __get_next_code_second_while(pInputStream)
+                       }               
+                       
+                       if (c == ending) {
+                               break;
+                       }
+                       /**********************************************************/
+
+                       if (c == clear) {
+                               curr_size = size + 1;
+                               slot = newcodes;
+                               top_slot = 1 << curr_size;
+
+                               do {
+                                       /* __get_next_code(pInputStream); */
+                                       if (navail_bytes < 2) {
+                                               if (nbits_left == 0)
+                                                       __get_next_code_first_nbits_left_0(pInputStream)
+                                               else
+                                                       __get_next_code_first_nbits_left_not_0(pInputStream)
+
+                                               __get_next_code_first_while(pInputStream)
+                                       } else {
+                                               if (nbits_left == 0) 
+                                                       __get_next_code_second_nbits_left_0(pInputStream)
+                                               else
+                                                       __get_next_code_second_nbits_left_not_0(pInputStream)
+
+                                               __get_next_code_second_while(pInputStream)
+                                       }
+                       
+                               } while (c == clear);
+
+                               if (c == ending) {
+                                       break;
+                               }
+
+                               if (c >= slot) {
+                                       c = 0;
+                               }
+
+                               oc = fc = c;
+                               *sp++ = (unsigned char)c;
+                       } else {
+                               if (c >= slot) {
+                                       c = 0;
+                               }
+
+                               oc = fc = c;
+                               *sp++ = (unsigned char)c;
+                       }
+
+                       while (rowcount < orghgt) {
+                               if ((sp - dstack) > 0) {
+                                       spCount = sp - dstack;
+                               }
+                               /* Now that we've pushed the decoded string (in reverse order)
+                               * onto the stack, lets pop it off and put it into our decode
+                               * buffer...  And when the decode buffer is full, write another
+                               * line...
+                               */
+                               while (sp > dstack) {
+                                       --sp;
+                                       *bufptr++ = *sp;
+
+                                       if (--bufcnt == 0) {
+
+                                               /********************************************************************************
+                                               if ((ret = put_line(rowcount++, bufptr - buf, WDT, buf, pBitmapElem->pBits)) < 0)
+                                               ********************************************************************************/
+                                               rowcount++;
+                                               len = bufptr - buf;
+                                               if (len >= orgwdt) {
+                                                       len = orgwdt;
+                                               }
+
+                                               if (interLaced == 0) { /* interlaced image */
+                                                       if (!flag) {
+                                                               out_x = 0, out_y += dechgt;
+                                                       }
+                                               } else {  /* interlaced image */
+                                                       if (inter_step == 1) {
+                                                               startloc += 8;
+                                                       } else if (inter_step == 2) {
+                                                               startloc += 8;
+                                                       } else if (inter_step == 3) {
+                                                               startloc += 4;
+                                                       } else if (inter_step == 4) {
+                                                               startloc += 2;
+                                                       }
+
+                                                       if (startloc >= orghgt) {
+                                                               inter_step++;
+                                                               if (inter_step == 2) {
+                                                                       startloc = 4;
+                                                               } else if (inter_step == 3) {
+                                                                       startloc = 2;
+                                                               } else if (inter_step == 4) {
+                                                                       startloc = 1;
+                                                               }
+                                                       }
+
+                                                       /* gif to rgb 565 */
+                                                       if (flag) {
+                                                               pImage32 = (unsigned int *)(pDecBuf) + startloc * decwdt;
+                                                       } else {
+                                                               out_x = 0, out_y = startloc * dechgt;
+                                                               a_x = orgwdt>>2;
+                                                               b_x = ((orgwdt*3)>>2);
+                                                               c_x = orgwdt>>2;
+                                                               d_x = ((orgwdt*3)>>2);
+                                                               if (out_y <= (orghgt >> 2)) {
+                                                                       a_y = orghgt>>2;
+                                                                       b_y = orghgt>>2;
+                                                                       c_y = ((orghgt*3)>>2);
+                                                                       d_y = ((orghgt*3)>>2);
+                                                               } else {
+                                                                       if (((out_y%orghgt) - (orghgt>>2)) > 0) {
+                                                                               a_y = ((out_y/orghgt)+1) * orghgt + (orghgt>>2);
+                                                                       } else if (((out_y%orghgt) - (orghgt>>2)) < 0 || !(out_y%orghgt)) {
+                                                                               a_y = ((out_y/orghgt)) * orghgt + (orghgt>>2);
+                                                                       } else {
+                                                                               a_y = out_y;
+                                                                       }
+
+                                                                       if (((out_y % orghgt) - ((orghgt * 3) >> 2)) > 0) {
+                                                                               c_y = ((out_y/orghgt)+1) * orghgt + ((orghgt*3)>>2);
+                                                                       } else if (((out_y%orghgt) - ((orghgt*3)>>2)) < 0 || !(out_y%orghgt)) {
+                                                                               c_y = ((out_y/orghgt)) * orghgt + ((orghgt * 3) >> 2);
+                                                                       } else {
+                                                                               c_y = out_y;
+                                                                       }
+                                                                       b_y = a_y, d_y = c_y;
+                                                               }
+                                                       }
+                                               }
+
+                                               if (transparent == 1) {
+                                                       if (flag) {
+                                                               for (i = 0; i < len; i++) {
+                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                       if (val1 == transIndex) {
+                                                                               *pImage32++ = 0x4000000; /* Set *pImage32 MSB 1 */
+                                                                       } else {
+                                                                               *pImage32++ = pDacbox[val1]<<2;
+                                                                       }
+                                                               }
+                                                       } else {
+                                                               if (c_y < end) {
+                                                                       d1 = a_y - out_y;
+                                                                       d2 = c_y - out_y;
+                                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
+                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/orghgt) * decwdt;
+                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/orghgt) * decwdt;
+
+                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                       d1 = a_x - out_x;
+                                                                                       d2 = b_x - out_x;
+
+                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                               if (val1 == transIndex) {
+                                                                                                       *(pImage32 + (a_x/orgwdt)) += 0x1000000;
+                                                                                                       *(pImage32_2 + (c_x/orgwdt)) += 0x1000000;
+                                                                                                       a_x += orgwdt, c_x += orgwdt;
+                                                                                               } else {
+                                                                                                       *(pImage32 + (a_x/orgwdt)) += pDacbox[val1];
+                                                                                                       *(pImage32_2 + (c_x/orgwdt)) += pDacbox[val1];
+                                                                                                       a_x += orgwdt, c_x += orgwdt;
+                                                                                               }
+                                                                                       }
+                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                               if (val1 == transIndex) {
+                                                                                                       *(pImage32 + (b_x/orgwdt)) += 0x1000000;
+                                                                                                       *(pImage32_2 + (d_x/orgwdt)) += 0x1000000;
+                                                                                                       b_x += orgwdt, d_x += orgwdt;
+                                                                                               } else {
+                                                                                                       *(pImage32 + (b_x/orgwdt)) += pDacbox[val1];
+                                                                                                       *(pImage32_2 + (d_x/orgwdt)) += pDacbox[val1];
+                                                                                                       b_x += orgwdt, d_x += orgwdt;
+                                                                                               }
+                                                                                       }
+                                                                                       out_x += decwdt;
+                                                                               }
+                                                                               if (!interLaced) {
+                                                                                       a_x = orgwdt>>2, a_y += orghgt;
+                                                                                       b_x = ((orgwdt*3)>>2), b_y += orghgt;
+                                                                                       c_x = orgwdt>>2, c_y += orghgt;
+                                                                                       d_x = ((orgwdt*3)>>2), d_y += orghgt;
+                                                                               }
+                                                                       } else if (0 <= d1 && d1 < dechgt) {
+                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/orghgt) * decwdt;
+
+                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                       d1 = a_x - out_x;
+                                                                                       d2 = b_x - out_x;
+                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                               if (val1 == transIndex) {
+                                                                                                       *(pImage32 + (a_x/orgwdt)) += 0x1000000;
+                                                                                                       a_x += orgwdt;
+                                                                                               } else {
+                                                                                                       *(pImage32 + (a_x/orgwdt)) += pDacbox[val1];
+                                                                                                       a_x += orgwdt;
+                                                                                               }
+                                                                                       } if (0 <= d2 && d2 < decwdt) {
+                                                                                               if (val1 == transIndex) {
+                                                                                                       *(pImage32 + (b_x/orgwdt)) += 0x1000000;
+                                                                                                       b_x += orgwdt;
+                                                                                               } else {
+                                                                                                       *(pImage32 + (b_x/orgwdt)) += pDacbox[val1];
+                                                                                                       b_x += orgwdt;
+                                                                                               }
+                                                                                       }
+                                                                                       out_x += decwdt;
+                                                                               }
+                                                                               if (!interLaced) {
+                                                                                       a_x = orgwdt>>2, a_y += orghgt;
+                                                                                       b_x = ((orgwdt*3)>>2), b_y += orghgt;
+                                                                               }
+                                                                       } else if (0 <= d2 && d2 < dechgt) {
+                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/orghgt) * decwdt;
+                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                       d1 = c_x - out_x;
+                                                                                       d2 = d_x - out_x;
+                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                               if (val1 == transIndex) {
+                                                                                                       *(pImage32_2 + (c_x/orgwdt)) += 0x1000000;
+                                                                                                       c_x += orgwdt;
+                                                                                               } else {
+                                                                                                       *(pImage32_2 + (c_x/orgwdt)) += pDacbox[val1];
+                                                                                                       c_x += orgwdt;
+                                                                                               }
+                                                                                       }
+                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                               if (val1 == transIndex) {
+                                                                                                       *(pImage32_2 + (d_x/orgwdt)) += 0x1000000;
+                                                                                                       d_x += orgwdt;
+                                                                                               } else {
+                                                                                                       *(pImage32_2 + (d_x/orgwdt)) += pDacbox[val1];
+                                                                                                       d_x += orgwdt;
+                                                                                               }
+                                                                                       }
+                                                                                       out_x += decwdt;
+                                                                               }
+                                                                               if (!interLaced) {
+                                                                                       c_x = orgwdt>>2, c_y += orghgt;
+                                                                                       d_x = ((orgwdt*3)>>2), d_y += orghgt;
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                               } else {
+                                                       if (flag) {
+                                                               for (i = 0; i < len; i++) {
+                                                                       val1 = buf[i] & (numcolors-1);
+                                                                       *pImage32++ = pDacbox[val1]<<2;
+                                                               }
+                                                       } else {
+                                                               if (c_y < end) {
+                                                                       d1 = a_y - out_y;
+                                                                       d2 = c_y - out_y;
+                                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
+                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/orghgt) * decwdt;
+                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/orghgt) * decwdt;
+                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                       d1 = a_x - out_x;
+                                                                                       d2 = b_x - out_x;
+                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                               *(pImage32 + (a_x/orgwdt)) += pDacbox[val1];
+                                                                                               *(pImage32_2 + (c_x/orgwdt)) += pDacbox[val1];
+                                                                                               a_x += orgwdt, c_x += orgwdt;
+                                                                                       }
+                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                               *(pImage32 + (b_x/orgwdt)) += pDacbox[val1];
+                                                                                               *(pImage32_2 + (d_x/orgwdt)) += pDacbox[val1];
+                                                                                               b_x += orgwdt, d_x += orgwdt;
+                                                                                       }
+                                                                                       out_x += decwdt;
+                                                                               }
+                                                                               if (!interLaced) {
+                                                                                       a_x = orgwdt>>2, a_y += orghgt;
+                                                                                       b_x = ((orgwdt*3)>>2), b_y += orghgt;
+                                                                                       c_x = orgwdt>>2, c_y += orghgt;
+                                                                                       d_x = ((orgwdt*3)>>2), d_y += orghgt;
+                                                                               }
+                                                                       } else if (0 <= d1 && d1 < dechgt) {
+                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/orghgt) * decwdt;
+                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                       d1 = a_x - out_x;
+                                                                                       d2 = b_x - out_x;
+                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                               *(pImage32 + (a_x/orgwdt)) += pDacbox[val1];
+                                                                                               a_x += orgwdt;
+                                                                                       }
+                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                               *(pImage32 + (b_x/orgwdt)) += pDacbox[val1];
+                                                                                               b_x += orgwdt;
+                                                                                       }
+                                                                                       out_x += decwdt;
+                                                                               }
+                                                                               if (!interLaced) {
+                                                                                       a_x = orgwdt>>2, a_y += orghgt;
+                                                                                       b_x = ((orgwdt*3)>>2), b_y += orghgt;
+                                                                               }
+                                                                       } else if (0 <= d2 && d2 < dechgt) {
+                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/orghgt) * decwdt;
+                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                       d1 = c_x - out_x;
+                                                                                       d2 = d_x - out_x;
+                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                               *(pImage32_2 + (c_x/orgwdt)) += pDacbox[val1];
+                                                                                               c_x += orgwdt;
+                                                                                       }
+                                                                                       if (0 <= d2 && d2 < decwdt) {
+                                                                                               *(pImage32_2 + (d_x/orgwdt)) += pDacbox[val1];
+                                                                                               d_x += orgwdt;
+                                                                                       }
+                                                                                       out_x += decwdt;
+                                                                               }
+
+                                                                               if (!interLaced) {
+                                                                                       c_x = orgwdt>>2, c_y += orghgt;
+                                                                                       d_x = ((orgwdt*3)>>2), d_y += orghgt;
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                                               bufptr = buf;
+                                                               bufcnt = orgwdt_1;
+                                       }
+                               }
+
+                               if (rowcount == orghgt) {
+                                       break;
+                               }
+
+                               /* __get_next_code(pInputStream) */
+                               if (navail_bytes < 2) {
+                                       if (nbits_left == 0)
+                                               __get_next_code_first_nbits_left_0(pInputStream)
+                                       else
+                                               __get_next_code_first_nbits_left_not_0(pInputStream)
+                                       __get_next_code_first_while(pInputStream)
+                               } else {
+                                       if (nbits_left == 0) 
+                                               __get_next_code_second_nbits_left_0(pInputStream)
+                                       else
+                                               __get_next_code_second_nbits_left_not_0(pInputStream)
+
+                                       __get_next_code_second_while(pInputStream)
+                               }
+
+                               if (c == ending) {
+                                       break;
+                               }
+                               /*************************************************************/
+
+                               if (c == clear) {
+                                       curr_size = size + 1;
+                                       slot = newcodes;
+                                       top_slot = 1 << curr_size;
+
+                                       do {
+                                               /* __get_next_code(pInputStream); */
+                                               if (navail_bytes < 2) {
+                                                       if (nbits_left == 0)
+                                                               __get_next_code_first_nbits_left_0(pInputStream)
+                                                       else
+                                                               __get_next_code_first_nbits_left_not_0(pInputStream)
+                                                       __get_next_code_first_while(pInputStream)
+                                               } else {
+                                                       if (nbits_left == 0) 
+                                                               __get_next_code_second_nbits_left_0(pInputStream)
+                                                       else
+                                                               __get_next_code_second_nbits_left_not_0(pInputStream)
+
+                                                       __get_next_code_second_while(pInputStream)
+                                               }               
+                                       } while (c == clear);
+
+                                       if (c == ending) {
+                                               break;
+                                       }
+
+                                       if (c >= slot) {
+                                               c = 0;
+                                       }
+
+                                               oc = fc = c;
+                                               *sp++ = (unsigned char)c;
+                                       } else {
+                                               code = c;
+
+                                               if (code >= slot) {
+                                                       code = oc;
+                                                       *sp++ = (unsigned char)fc;
+                                               }
+                                               while (code >= newcodes) {
+                                                       *sp++ = suffix[code];
+                                                       code = prefix[code];
+                                               }
+
+                                               *sp++ = (unsigned char)code;
+                                               spCount++;
+                                               if (slot < top_slot) {
+                                                       fc = code;
+                                                       suffix[slot] = (unsigned char)fc;
+                                                       prefix[slot++] = oc;
+                                                       oc = c;
+                                               }
+                                               if (slot >= top_slot) {
+                                                       if (curr_size < 12) {
+                                                               top_slot <<= 1;
+                                                               ++curr_size;
+                                                       }
+                                               }
+                                       }
+                               }
+                               /*************************************************************/
+
+                               if (bCenterAlign) {
+                                       margin_wdt1_2 = (expected_width - resized_width)>>1;
+                                       margin_hgt1_2 = (expected_height - resized_height)>>1;
+                               } else {
+                                       margin_wdt1_2 = 0;
+                                       margin_hgt1_2 = 0;
+                               }
+
+                               pImage32 = (unsigned int *)(pDecBuf);
+
+                               /* Only make a first image frame as a thumbnail */
+                               image_left_pos = 0;
+                               image_top_pos = 0;
+                               len = decwdt;
+
+                               if (orgwdt > logi_wdt) {
+                                       decwdt = resized_width;
+                               }
+                               if (orghgt > logi_hgt) {
+                                       dechgt = resized_height;
+                               }
+
+                               if ((image_left_pos + decwdt) > resized_width) {
+                                       decwdt = resized_width - image_left_pos;
+                                       if (decwdt < 0) {
+                                               decwdt = 0;
+                                       }
+                               }
+                               if ((image_top_pos+dechgt) > resized_height) {
+                                       dechgt = resized_height - image_top_pos;
+                                       if (dechgt < 0) {
+                                               dechgt = 0;
+                                       }
+                               }
+
+                               if (pFrameData->imgCount == 0) {
+                                       for (i = 0, k = margin_hgt1_2; i < resized_height; i++) {
+                                               pImage16 = (unsigned short *)((unsigned char *)pOutBits + ((margin_wdt1_2 + expected_width * k) << 1));
+                                               for (j = 0; j < resized_width; j++) {
+                                                       *pImage16++ = backcolor;
+                                               }
+                                               k++;
+                                       }
+                                       if (transparent == 1) {
+                                       for (i = 0, k = image_top_pos+margin_hgt1_2; i < dechgt; i++) {
+                                               pImage16 = (unsigned short *)((unsigned char *)pOutBits + ((image_left_pos+margin_wdt1_2 + expected_width * k) << 1));
+                                               for (j = 0; j < decwdt; j++) {
+                                                       *pImage16++ = ui_backcolor;                                     
+                                               }
+                                               k++; 
+                                       }
+                                       }
+                               }
+                               
+                               for (i = 0, k = image_top_pos+margin_hgt1_2; i < dechgt; i++) {
+                                       pImage16 = (unsigned short *)((unsigned char*)pOutBits + ((image_left_pos+margin_wdt1_2 + (expected_width) * k) << 1));
+                                       pImage32 = (unsigned int *)(pDecBuf) + (i * len);
+
+                                       for (j = 0; j < decwdt; j++) {
+                                               if ((*pImage32>>24) == 0) {
+                                                       *(pImage16++) = ((*pImage32 & 0xf80000) >> 8) | ((*pImage32 & 0xfc00) >> 5) | ((*pImage32 & 0xf8) >> 3);
+                                               } else if ((*pImage32 >> 24) == 4) {
+                                                       pImage16++;
+                                               } else if ((*pImage32 >> 24) == 3) {
+                                                       *pImage16 =
+                                                               (((*pImage32 & 0xf80000) >> 8)+(((((*pImage16) & 0xf800) * 3) >> 2) & 0xf800)) |
+                                                               (((*pImage32 & 0xfc00) >> 5)+(((((*pImage16) & 0x07c0) * 3) >> 2) & 0x07c0)) |
+                                                               (((*pImage32 & 0xf8) >> 3)+((((*pImage16) & 0x001f) * 3) >> 2));
+                                                       pImage16++;
+                                               } else if ((*pImage32 >> 24) == 1) {
+                                                       *pImage16 =
+                                                               (((*pImage32 & 0xf80000) >> 8)+((((*pImage16) & 0xf800) >> 2) & 0xf800)) |
+                                                               (((*pImage32 & 0xfc00) >> 5)+((((*pImage16) & 0x07c0) >> 2) & 0x07c0)) |
+                                                               (((*pImage32 & 0xf8) >> 3)+((((*pImage16) & 0x001f) >> 2)));
+                                                       pImage16++;
+                                               } else {
+                                                       *pImage16 =
+                                                               (((*pImage32 & 0xf80000) >> 8)+((((*pImage16) & 0xf800) >> 1) & 0xf800)) |
+                                                               (((*pImage32 & 0xfc00) >> 5)+((((*pImage16) & 0x07c0) >> 1) & 0x07c0)) |
+                                                               (((*pImage32 & 0xf8) >> 3)+((((*pImage16) & 0x001f) >> 1)));
+                                                       pImage16++;
+                                               }
+                                               pImage32++;
+                                       }
+                                       k++;
+                               }
+
+                               switch (disposal_method) {
+                                       /* No disposal specified. The decoder is not required to take any action */
+                               case 0:
+
+                                       /* Do not dispose. The graphic is to be left in place. */
+                               case 1:
+                                       IfegMemcpy(pFrameData->pPrevImg, pOutBits, expected_width * expected_height * 2);
+                                       break;
+
+                                       /* Restore to background color. The area used by the graphic must be restored to the background color. */
+                               case 2:
+                                       IfegMemcpy(pFrameData->pPrevImg, pOutBits, expected_width * expected_height * 2);
+
+                                       if (transparent == 1) {
+                                       for (i = 0, k = image_top_pos+margin_hgt1_2; i < dechgt; i++) {
+                                               pImage16 = (unsigned short *)((pFrameData->pPrevImg) + ((image_left_pos+margin_wdt1_2 + expected_width * k) << 1));
+                                               for (j = 0; j < decwdt; j++) {
+                                                       *pImage16++ = ui_backcolor;                                     
+                                               }
+                                               k++; 
+                                       }
+                                       } else {
+                                       for (i = 0, k = image_top_pos+margin_hgt1_2; i < dechgt; i++) {
+                                               pImage16 = (unsigned short *)((pFrameData->pPrevImg) + ((image_left_pos+margin_wdt1_2 + expected_width * k) << 1));
+                                               for (j = 0; j < decwdt; j++) {
+                                                       *pImage16++ = image_backcolor;                                  
+                                               }
+                                               k++; 
+                                       }
+                                       }
+                                       break;
+
+                                       /* Restore to previous. The decoder is required to restore the area overwritten by the graphic with what was there prior to rendering the graphic.*/
+                               case 3:
+                                       break;
+
+                               default:
+                                       IfegMemcpy(pFrameData->pPrevImg, pOutBits, expected_width * expected_height * 2);
+                                       /* same with case 1 */
+                                       break;
+                               }
+
+                               if (decoderline) {
+                                       IfegMemFree(decoderline);
+                                       decoderline = 0;
+                               }
+                               if (pDecBuf) {
+                                       IfegMemFree(pDecBuf);
+                                       pDecBuf = 0;
+                               }
+
+                               pFrameData->offset = inputPos;
+                               pFrameData->imgCount++;
+
+                               return 1;
+
+                               break;
+
+                               default:
+                                       break;
+
+               }
+       }
+}
+
+
+/* use buffer */
+int __FastImgGetNextFrameAGIF_UseBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAlign)
+{
+       unsigned int *pImage32, *pImage32_2, *backGround;
+       unsigned short *pImage16;
+       unsigned char   *sp;
+       unsigned char   *bufptr;
+       unsigned int    code, fc, oc, bufcnt;
+       unsigned char                   buffer[16];
+       unsigned char                   val1;
+       unsigned char                   *buf;
+       unsigned int                    *pDacbox;
+       unsigned char                   *decoderline = 0;
+       unsigned int size;
+       unsigned int c = 0;
+
+       unsigned int clear;
+       unsigned int ending;
+       unsigned int newcodes;
+       unsigned int top_slot;
+       unsigned int slot;
+
+       int     numcolors;
+       int     i, j, k;
+       int     rowcount;
+       int orgwdt_1, orgwdt, orghgt;
+       int decwdt, dechgt;
+       int len;
+       int inter_step, interLaced, intercount;
+       int transparent = 0;
+       int startloc = 0;
+       int backgroundIndex = 0;
+       int transIndex = 0;
+       int spCount = 0;
+       int logi_wdt;           /* logical screen width */
+       int logi_hgt;
+       int logi_image_size;
+       int ui_backcolor565;
+       int backcolor565;
+
+       int ui_backcolor888;
+       int backcolor888;
+
+       int image_left_pos;     /* left position of image in Logical screeen */
+       int image_top_pos;
+       int disposal_method = 0;
+       int margin_wdt1_2, margin_hgt1_2;
+
+       int inputPos;
+
+
+       unsigned int dacbox[256];
+
+       /* Variable for Resize */
+
+       unsigned int a_x, a_y;
+       unsigned int b_x, b_y;
+       unsigned int c_x, c_y;
+       unsigned int d_x, d_y;
+       int out_x = 0, out_y = 0;
+       int d1, d2;
+       int flag = 0;
+       unsigned int end;
+
+       int count = 0;
+
+       unsigned char *pDecBuf = 0;
+
+       int expected_width = pFrameData->width;
+       int expected_height = pFrameData->height;
+       int resized_width;
+       int resized_height;
+
+       /* macro */
+       register unsigned int curr_size;
+       register int navail_bytes = 0;
+       register unsigned int nbits_left = 0;
+       register unsigned int b1 = 0;
+       register unsigned int ret;
+
+       /* parameter */
+       unsigned int *global_dacbox = pFrameData->pGlobal_table;
+       unsigned char *pInputStream = pFrameData->pEncodedData;
+       void *pOutBits = pFrameData->pOutBits;
+       unsigned short *prefix = pFrameData->pPrefix;                   
+       unsigned char *dstack = pFrameData->pDstack;            
+       unsigned char *suffix = pFrameData->pSuffix;            
+       int filesize = pFrameData->inputSize;
+
+       inputPos = pFrameData->offset;
+
+       IfegMemset(prefix, 0, sizeof(unsigned short)*(MAX_CODES+1));
+       IfegMemset(dstack, 0, sizeof(unsigned char)*(MAX_CODES+1));
+       IfegMemset(suffix, 0, sizeof(unsigned char)*(MAX_CODES+1));
+
+       ui_backcolor565 = pFrameData->ui_backcolor;
+       ui_backcolor888 = 
+               ((ui_backcolor565&0xf800) << 6)|
+               ((ui_backcolor565&0x7e0) << 3)|
+               ((ui_backcolor565&0x1f) << 1);
+
+       backcolor565 = pFrameData->backcolor;
+       backcolor888 = 
+               ((backcolor565&0xf800) << 6)|
+               ((backcolor565&0x7e0) << 3)|
+               ((backcolor565&0x1f) << 1);
+
+       backGround = (unsigned int *)pFrameData->pPrevImg;
+
+       intercount = 0;
+
+       if (pFrameData->imgCount == -1) {
+               /* Input stream index set to 0 */
+               inputPos = 0;
+               inter_step = 1;
+               interLaced = 0; 
+               transparent = 0;
+
+               /* read a GIF HEADER */
+               IfegMemcpy(buffer, pInputStream, 13);
+               inputPos += 13;
+
+               /* wheather GIF file or not */
+               if (buffer[0] != 'G' || buffer[1] != 'I' || buffer[2] != 'F' ||
+                       buffer[3] < '0' || buffer[3] > '9' ||
+                       buffer[4] < '0' || buffer[4] > '9' ||
+                       buffer[5] < 'A' || buffer[5] > 'z') {
+                       if (pDecBuf != 0) {
+                               IfegMemFree(pDecBuf);
+                               pDecBuf = 0;
+                       }
+                       return -1;
+               }
+
+               /* get Logical width, height */
+               pFrameData->logi_wdt = logi_wdt = buffer[6] | (buffer[7] << 8);
+               pFrameData->logi_hgt = logi_hgt = buffer[8] | (buffer[9] << 8);
+
+               logi_image_size = logi_wdt * logi_hgt;
+
+               /* ouput resized image size */
+               if (logi_wdt <= expected_width && logi_hgt <= expected_height) {
+                       resized_width = logi_wdt;
+                       resized_height = logi_hgt;
+                       pFrameData->flag = flag = 1;
+               } else {
+                       if ((logi_wdt/(float)expected_width) >= (logi_hgt/(float)expected_height)) {
+                               resized_height = logi_hgt * expected_width / logi_wdt;
+                               resized_width = expected_width;
+                       } else {
+                               resized_width = logi_wdt * expected_height / logi_hgt;
+                               resized_height = expected_height;
+                       }
+               }
+               if (!resized_width || !resized_height) {
+                       if (decoderline != 0) {
+                               IfegMemFree(decoderline);
+                               decoderline = 0;
+                       }
+                       if (pDecBuf != 0) {
+                               IfegMemFree(pDecBuf);
+                               pDecBuf = 0;
+                       }
+                       return 0;
+               }
+
+               /* ouput resized image size */
+               pFrameData->resizedwidth = resized_width;
+               pFrameData->resizedheight = resized_height;
+
+               /* Color Resolution */
+               IfegMemset(global_dacbox, 0, 1024);
+               numcolors = (buffer[10] & 0x7) + 1;
+               if ((buffer[10] & 0x80) == 0) {  /* Global color table */
+                       global_dacbox[0] = 0x000000;
+                       global_dacbox[1] = 0x3f3f3f;
+                       numcolors = 2;
+               } else { /* Global color table */
+                       numcolors = 1 << numcolors;
+
+                       /* Make color table */
+                       for (i = 0; i < numcolors; i++) {
+                               global_dacbox[i] = ((pInputStream[inputPos++] >> 2) << 16);
+                               global_dacbox[i] |= ((pInputStream[inputPos++] >> 2) << 8);
+                               global_dacbox[i] |= (pInputStream[inputPos++] >> 2);
+                       }
+               }
+
+               backgroundIndex = buffer[11];
+               /* Background Color */
+               backcolor888 = global_dacbox[backgroundIndex];
+               backcolor565 = pFrameData->backcolor = (((backcolor888 & 0xff0000) >> 17) << 11) | (((backcolor888 & 0x00ff00) >> 8) << 5) | (((backcolor888 & 0xff) >> 1));
+
+               pImage16 = pOutBits;
+
+               ui_backcolor565 = pFrameData->ui_backcolor ;
+               for (i = 0; i < expected_width * expected_height; i++) {
+                       *pImage16++ = ui_backcolor565;
+               }
+
+               pImage32 = (unsigned int *)pFrameData->pPrevImg;
+
+               if (numcolors > 16)     {
+                       numcolors = 256;
+               }
+               if (numcolors > 2 && numcolors < 16) {
+                       numcolors = 16;
+               }
+               pFrameData->global_numcol = numcolors;
+               pFrameData->imgCount++;
+               pFrameData->firstpos = inputPos;
+       } else {
+               logi_wdt = pFrameData->logi_wdt;
+               logi_hgt = pFrameData->logi_hgt;
+               resized_width = pFrameData->resizedwidth;
+               resized_height = pFrameData->resizedheight;
+               flag = pFrameData->flag ;
+
+               numcolors = pFrameData->global_numcol;
+       }
+
+       /* still gif image (image_cnt = 1) */
+       while (1) {
+               if (inputPos > filesize) {
+
+                       if (decoderline) {
+                               IfegMemFree(decoderline);
+                               decoderline = 0;
+                       }
+                       if (pDecBuf) {
+                               IfegMemFree(pDecBuf);
+                               pDecBuf = 0;
+                       }
+                       pFrameData->imgCount = 0;
+                       pFrameData->offset = pFrameData->firstpos;
+
+                       if (pFrameData->bLoop) {
+                               return 1;
+                       } else {
+                               return 0;
+                       }
+               }
+
+               switch (pInputStream[inputPos++]) {
+               case 0x3b:/* End of the GIF dataset */
+                       if (decoderline) {
+                               IfegMemFree(decoderline);
+                               decoderline = 0;
+                       }
+                       if (pDecBuf) {
+                               IfegMemFree(pDecBuf);
+                               pDecBuf = 0;
+                       }
+                       if (pFrameData->imgCount == 0) {
+                               return -1;
+                       }
+                       pFrameData->imgCount = 0;
+                       pFrameData->offset = pFrameData->firstpos;
+#ifdef INTERNAL_IMGCODEC
+                       pFrameData->nRepeatCount++;
+
+                       if (pFrameData->nLoopCount == -1) {                     
+                               break;
+                       } else if (pFrameData->bLoop || (pFrameData->nRepeatCount <= pFrameData->nLoopCount) || (pFrameData->nLoopCount == 0)) {
+                               inputPos = pFrameData->offset;
+                               continue;
+                       } else {
+                               return 2;
+                       }
+#else
+                       if (pFrameData->bLoop) {
+                               return 1;
+                       } else {
+                               return 0;
+                       }
+
+#endif
+                       break;
+               case 0x21: /* Extension Block */
+                       switch (pInputStream[inputPos++]) {
+                       case 0xf9: /* Graphic control extension block */
+                               if (4 != pInputStream[inputPos++]) { /* data length : fixed 4 bytes */
+                                       if (decoderline != 0) {
+                                               IfegMemFree(decoderline);
+                                               decoderline = 0;
+                                       }
+                                       if (pDecBuf != 0) {
+                                               IfegMemFree(pDecBuf);
+                                               pDecBuf = 0;
+                                       }
+                                       return -1;
+                               }
+
+                               disposal_method = ((pInputStream[inputPos] & 0x1c) >> 2);
+                               transparent = pInputStream[inputPos++] & 0x01;  /* does it use? 1:on 0:off */
+                               pFrameData->delay = (pInputStream[inputPos] | (pInputStream[inputPos+1] << 8))*10;
+                               inputPos += 2; /* Delay time (skip) */
+                               transIndex = pInputStream[inputPos++];
+                               inputPos++; /* block end */
+                               
+                               if (backgroundIndex == transIndex && transparent == 1) {
+                                       backcolor888 = 0x1000000;
+                                       backcolor565 = pFrameData->ui_backcolor;
+                               }
+
+                               break;
+                       case 0x01: /* Plain Text block */
+                               while ((i = pInputStream[inputPos++]) > 0) {    /* get the data length */
+                                       inputPos += i;
+                                       if (inputPos > filesize) {
+                                               if (decoderline) {
+                                                       IfegMemFree(decoderline);
+                                                       decoderline = 0;
+                                               }
+                                               if (pDecBuf) {
+                                                       IfegMemFree(pDecBuf);
+                                                       pDecBuf = 0;
+                                               }
+                                               return -1;
+                                       }
+                               }
+                               break;
+                       case 0xfe: /* Comment Extension block */
+                               while ((i = pInputStream[inputPos++]) > 0) {    /* get the data length */
+                                       inputPos += i;
+                                       if (inputPos > filesize) {
+                                               if (decoderline) {
+                                                       IfegMemFree(decoderline);
+                                                       decoderline = 0;
+                                               }
+                                               if (pDecBuf) {
+                                                       IfegMemFree(pDecBuf);
+                                                       pDecBuf = 0;
+                                               }
+                                               return -1;
+                                       }
+                               }
+                               break;
+                       case 0xff: /* Appliation Extension block */
+
+                               while ((i = pInputStream[inputPos++]) > 0) {    /* get the data length */
+                                       inputPos += i;
+                                       if (inputPos > filesize) {
+                                               if (decoderline) {
+                                                       IfegMemFree(decoderline);
+                                                       decoderline = 0;
+                                               }
+                                               if (pDecBuf) {
+                                                       IfegMemFree(pDecBuf);
+                                                       pDecBuf = 0;
+                                               }
+                                               return -1;
+                                       }
+                               }
+                               break;
+                       default:
+                               break;
+                       }
+
+                       break;
+
+                       case 0x2c: /* Start of an image object. Read the image description. */
+
+                               /* initialize */
+                               pDacbox = global_dacbox;
+
+                               IfegMemcpy(buffer, pInputStream+inputPos, 9);
+                               inputPos += 9;
+
+                               if (pFrameData->imgCount == 0) {
+                                       image_left_pos_N = (buffer[0] | (buffer[1] << 8)); 
+                                       image_top_pos_N = (buffer[2] | (buffer[3] << 8));       
+                               
+                                       image_left_pos = image_left_pos_N;
+                                       image_top_pos = image_top_pos_N;
+                               }
+                               image_left_pos = (buffer[0] | (buffer[1] << 8));
+                               image_top_pos = (buffer[2] | (buffer[3] << 8));
+                               orgwdt_1 = orgwdt = (buffer[4] | (buffer[5] << 8));
+                               orghgt = (buffer[6] | (buffer[7] << 8));
+
+
+#ifdef INTERNAL_IMGCODEC
+#else
+                               if ((orgwdt > MAXWIDTH) || (orghgt > MAXHEIGHT)) {
+                                       if (decoderline != 0) {
+                                               IfegMemFree(decoderline);
+                                               decoderline = 0;
+                                       }
+                                       if (pDecBuf != 0) {
+                                               IfegMemFree(pDecBuf);
+                                               pDecBuf = 0;
+                                       }
+                                       return -1;
+                               }
+#endif
+
+                               /* Initialize */
+                               a_x = logi_wdt >> 2, a_y = logi_hgt >> 2;
+                               b_x = ((logi_wdt*3) >> 2), b_y = logi_hgt >> 2;
+                               c_x = logi_wdt >> 2, c_y = ((logi_hgt*3) >> 2);
+                               d_x = ((logi_wdt*3) >> 2), d_y = ((logi_hgt*3) >> 2);
+
+                               /* Interlaced check */
+                               interLaced = buffer[8] & 0x40;
+                               if (interLaced) {
+                                       startloc = -8+image_top_pos;
+                               }
+
+                               inter_step = 1;
+
+                               if (decoderline) {
+                                       IfegMemFree(decoderline);
+                               }
+                               decoderline = (unsigned char *)IfegMemAlloc(orgwdt);
+                               if (!decoderline) {
+                                       if (decoderline != 0) {
+                                               IfegMemFree(decoderline);
+                                               decoderline = 0;
+                                       }
+                                       if (pDecBuf != 0) {
+                                               IfegMemFree(pDecBuf);
+                                               pDecBuf = 0;
+                                       }
+                                       return 0;
+                               }
+                               IfegMemset(decoderline, 0, orgwdt);
+
+                               decwdt = resized_width;
+                               dechgt = resized_height;
+
+                               if (!decwdt || !dechgt) {
+                                       if (decoderline != 0) {
+                                               IfegMemFree(decoderline);
+                                               decoderline = 0;
+                                       }
+                                       if (pDecBuf != 0) {
+                                               IfegMemFree(pDecBuf);
+                                               pDecBuf = 0;
+                                       }
+                                       return 0;
+                               }
+
+                               if (pDecBuf) {
+                                       IfegMemFree(pDecBuf);
+                               }
+                               pDecBuf = (unsigned char *)IfegMemAlloc(decwdt * dechgt * 4);
+                               if (!pDecBuf) {
+                                       if (decoderline != 0) {
+                                               IfegMemFree(decoderline);
+                                               decoderline = 0;
+                                       }
+                                       if (pDecBuf != 0) {
+                                               IfegMemFree(pDecBuf);
+                                               pDecBuf = 0;
+                                       }
+                                       return 0;
+                               }
+
+                               IfegMemset(pDecBuf, 0, decwdt * dechgt * 4);
+
+                               /* assign out_888_image plane */
+                               pImage32 = (unsigned int *)(pDecBuf);
+
+                               end = dechgt * logi_hgt;
+                               out_x = 0, out_y = -dechgt;
+
+                               /* Color Resolution */
+                               if ((buffer[8] & 0x80) == 0) { /* Logical color table  */
+                                       ;/* use global table */
+                               } else { /* Logical color table */
+                                       IfegMemset(dacbox, 0, 1024);
+
+                                       numcolors = (buffer[8] & 0x7) + 1;
+                                       numcolors = 1 << numcolors;
+
+                                       count = 0;
+
+                                       /* Make color table */
+                                       for (i = 0; i < numcolors; i++) {
+                                               dacbox[i] = ((pInputStream[inputPos++] >> 2) << 16);
+                                               dacbox[i] |= ((pInputStream[inputPos++] >> 2) << 8);
+                                               dacbox[i] |= (pInputStream[inputPos++] >> 2);
+                                       }
+                                       pDacbox = dacbox;
+                               }
+
+                               if (numcolors > 16) {
+                                       numcolors = 256;
+                               }
+                               if (numcolors > 2 && numcolors < 16) {
+                                       numcolors = 16;
+                               }
+
+                               if (logi_wdt < (image_left_pos + orgwdt)) {
+                                       if (image_left_pos > logi_wdt) {
+                                               image_left_pos = logi_wdt;
+                                       }
+                                       orgwdt = logi_wdt - image_left_pos;
+                                       flag = 0;
+                               }
+                               if (logi_hgt < (image_top_pos + orghgt)) {
+                                       flag = 0;
+                               }
+
+                               if (pFrameData->imgCount == 0) {
+                                       if (disposal_method == 3) {
+                                               pImage32 = (unsigned int *)pFrameData->pPrevImg;
+                                               for (i = 0; i < logi_wdt * logi_hgt; i++) {
+                                                       *pImage32++ = 0x1000000;
+                                               }       
+                                       } else {
+                                               pImage32 = (unsigned int *)pFrameData->pPrevImg;
+                                               for (i = 0; i < logi_wdt * logi_hgt; i++) {
+                                                       *pImage32++ = backcolor888;
+                                               }       
+                                       }
+                                       if (transparent == 1) {
+                                               /* Background Color */
+                                               pImage32 = (unsigned int *)pFrameData->pPrevImg;
+                                               pImage32 += image_top_pos * logi_wdt + image_left_pos;
+                                               if (logi_hgt < (image_top_pos + orghgt)) {
+                                                       for (i = 0; i < logi_hgt - image_top_pos; i++) {
+                                                               for (j = 0; j < orgwdt; j++) {
+                                                                       pImage32[j] = 0x1000000;  /* set ui color */
+                                                               }
+                                                               pImage32 += logi_wdt;
+                                                       }
+                                               } else {
+                                                       for (i = 0; i < orghgt; i++) {
+                                                               for (j = 0; j < orgwdt; j++) {
+                                                                       pImage32[j] = 0x1000000;  /* set ui color */
+                                                               }
+                                                               pImage32 += logi_wdt;
+                                                       }
+                                               }
+                                       }
+                               }
+
+                               /* assign out_888_image plane */
+                               pImage32 = (unsigned int *)(pDecBuf);
+
+                               for (rowcount = 0; rowcount < image_top_pos; rowcount++) {
+                                       if (flag) {
+                                               for (i = 0; i < logi_wdt; i++) {
+                                                       *pImage32++ = backGround[i] << 2;
+                                               }
+                                       } else {
+                                               out_x = 0, out_y += dechgt;
+                                               if (c_y < end) {
+                                                       d1 = a_y - out_y;
+                                                       d2 = c_y - out_y;
+                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
+                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
+                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
+                                                               for (i = 0; i < logi_wdt; i++) {
+                                                                       d1 = a_x - out_x;
+                                                                       d2 = b_x - out_x;
+                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                       }
+                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                       }
+                                                                       out_x += decwdt;
+                                                               }
+                                                               a_x = logi_wdt >> 2, a_y += logi_hgt;
+                                                               b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
+                                                               c_x = logi_wdt >> 2, c_y += logi_hgt;
+                                                               d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
+                                                       } else if (0 <= d1 && d1 < dechgt) {
+                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
+                                                               for (i = 0; i < logi_wdt; i++) {
+                                                                       d1 = a_x - out_x;
+                                                                       d2 = b_x - out_x;
+                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                               a_x += logi_wdt;
+                                                                       }
+                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                               b_x += logi_wdt;
+                                                                       }
+                                                                       out_x += decwdt;
+                                                               }
+                                                               a_x = logi_wdt >> 2, a_y += logi_hgt;
+                                                               b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
+                                                       } else if (0 <= d2 && d2 < dechgt) {
+                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
+                                                               for (i = 0; i < logi_wdt; i++) {
+                                                                       d1 = c_x - out_x;
+                                                                       d2 = d_x - out_x;
+                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                               c_x += logi_wdt;
+                                                                       }
+                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                               d_x += logi_wdt;
+                                                                       }
+                                                                       out_x += decwdt;
+                                                               }
+                                                               c_x = logi_wdt >> 2, c_y += logi_hgt;
+                                                               d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
+                                                       }
+                                               }
+                                       }
+                                       backGround += logi_wdt;
+                               }
+
+
+                               /***************************************************************************
+                               decoder(WDT, pInputStream, pBitmapElem->pBits); //this does the grunt work              
+                               int decoder(int linewidth, UCHAR* pInputStream, UCHAR *pBitmapElem->pBits)                      
+                               ***************************************************************************/
+
+                               size = pInputStream[inputPos++];
+                               if (size < 2 || 9 < size) {
+                                       if (decoderline != 0) {
+                                               IfegMemFree(decoderline);
+                                               decoderline = 0;
+                                       }
+                                       if (pDecBuf != 0) {
+                                               IfegMemFree(pDecBuf);
+                                               pDecBuf = 0;
+                                       }
+                                       return -1;
+                               }
+                               rowcount = oc = fc = 0;
+                               buf = decoderline;
+                               sp = dstack;
+                               bufptr = buf;
+                               bufcnt = orgwdt_1;
+
+                               /************************
+                               init_exp(size);         
+                               int init_exp(int size)
+                               ************************/
+                               curr_size = size + 1;
+                               top_slot = 1 << curr_size;
+                               clear = 1 << size;
+                               ending = clear + 1;
+                               slot = newcodes = ending + 1;
+                               navail_bytes = nbits_left = 0;
+                               /************************/
+
+
+                               /* __get_next_code(pInputStream) */
+                               if (navail_bytes < 2) {
+                                       if (nbits_left == 0)
+                                               __get_next_code_first_nbits_left_0(pInputStream)
+                                       else
+                                               __get_next_code_first_nbits_left_not_0(pInputStream)
+                                       __get_next_code_first_while(pInputStream)
+                               } else {
+                                       if (nbits_left == 0) 
+                                               __get_next_code_second_nbits_left_0(pInputStream)
+                                       else
+                                               __get_next_code_second_nbits_left_not_0(pInputStream)
+
+                                       __get_next_code_second_while(pInputStream)
+                               }
+                               if (c == ending) {
+                                       break;
+                               }
+
+                               if (c == clear) {
+                                       curr_size = size + 1;
+                                       slot = newcodes;
+                                       top_slot = 1 << curr_size;
+
+                                       do {
+                                               /* __get_next_code(pInputStream); */
+                                               if (navail_bytes < 2) {
+                                                       if (nbits_left == 0)
+                                                               __get_next_code_first_nbits_left_0(pInputStream)
+                                                       else
+                                                               __get_next_code_first_nbits_left_not_0(pInputStream)
+                                                       __get_next_code_first_while(pInputStream)
+                                               } else {
+                                                       if (nbits_left == 0) 
+                                                               __get_next_code_second_nbits_left_0(pInputStream)
+                                                       else
+                                                               __get_next_code_second_nbits_left_not_0(pInputStream)
+
+                                                       __get_next_code_second_while(pInputStream)
+                                               }               
+                                       } while (c == clear);
+
+                                       if (c == ending) {
+                                               break;
+                                       }
+
+                                       if (c >= slot) {
+                                               c = 0;
+                                       }
+
+                                       oc = fc = c;
+                                       *sp++ = (unsigned char)c;
+                               } else {
+                                       if (c >= slot) {
+                                               c = 0;
+                                       }
+
+                                       oc = fc = c;
+                                       *sp++ = (unsigned char)c;
+                               }
+
+                               switch (disposal_method) {
+
+                                       /* Restore to previous. The decoder is required to restore the area overwritten by the graphic with what was there prior to rendering the graphic. */
+                               case 3:
+                                       while (rowcount < orghgt) {
+                                               if ((sp - dstack) > 0) {
+                                                       spCount = sp - dstack;
+                                               }
+                                               /* Now that we've pushed the decoded string (in reverse order)
+                                               * onto the stack, lets pop it off and put it into our decode
+                                               * buffer...  And when the decode buffer is full, write another
+                                               * line...
+                                               */
+                                               while (sp > dstack) {
+                                                       --sp;
+                                                       *bufptr++ = *sp;
+
+                                                       if (--bufcnt == 0) {
+                                                               /**********************************************************************************
+                                                               if ((ret = put_line(rowcount++, bufptr - buf, WDT, buf, pBitmapElem->pBits)) < 0)
+                                                               **********************************************************************************/
+                                                               rowcount++;
+                                                               len = bufptr - buf;
+                                                               if (len >= orgwdt) {
+                                                                       len = orgwdt;
+                                                               }
+
+                                                               if (interLaced == 0) { /* interlaced image */
+                                                                       if (!flag) {
+                                                                               out_x = 0, out_y += dechgt;
+                                                                       }
+                                                               } else { /* interlaced image */
+                                                                       if (inter_step == 1) {
+                                                                               startloc += 8;
+                                                                               intercount++;
+                                                                       } else if (inter_step == 2) {
+                                                                               startloc += 8;
+                                                                               intercount++;
+                                                                       } else if (inter_step == 3) {
+                                                                               startloc += 4;
+                                                                               intercount++;
+                                                                       } else if (inter_step == 4) {
+                                                                               startloc += 2;
+                                                                               intercount++;
+                                                                       }
+
+                                                                       if (startloc >= orghgt+image_top_pos) {
+                                                                               inter_step++;
+                                                                               if (inter_step == 2) {
+                                                                                       startloc = 4+image_top_pos;
+                                                                               } else if (inter_step == 3) {
+                                                                                       startloc = 2+image_top_pos;
+                                                                               } else if (inter_step == 4) {
+                                                                                       startloc = 1+image_top_pos;
+                                                                               }
+                                                                       }
+
+                                                                       backGround = (unsigned int *)(pFrameData->pPrevImg + ((startloc * logi_wdt) << 2));
+                                                                       /* gif to rgb 565 */
+                                                                       if (flag) {
+                                                                               pImage32 = (unsigned int *)(pDecBuf) + startloc * decwdt;
+                                                                       } else {
+                                                                               out_x = 0, out_y = startloc * dechgt;
+                                                                               a_x = logi_wdt >> 2;
+                                                                               b_x = ((logi_wdt*3) >> 2);
+                                                                               c_x = logi_wdt >> 2;
+                                                                               d_x = ((logi_wdt*3) >> 2);
+                                                                               if (out_y <= (logi_hgt >> 2)) {
+                                                                                       a_y = logi_hgt >> 2;
+                                                                                       b_y = logi_hgt >> 2;
+                                                                                       c_y = ((logi_hgt*3) >> 2);
+                                                                                       d_y = ((logi_hgt*3) >> 2);
+                                                                               } else {
+                                                                                       if (((out_y % logi_hgt) - (logi_hgt >> 2)) > 0) {
+                                                                                               a_y = ((out_y/logi_hgt)+1) * logi_hgt + (logi_hgt >> 2);
+                                                                                       } else if (((out_y % logi_hgt) - (logi_hgt >> 2)) < 0 || !(out_y%logi_hgt)) {
+                                                                                               a_y = ((out_y/logi_hgt)) * logi_hgt + (logi_hgt>>2);
+                                                                                       } else {
+                                                                                               a_y = out_y;
+                                                                                       }
+
+                                                                                       if (((out_y % logi_hgt) - ((logi_hgt*3) >> 2)) > 0) {
+                                                                                               c_y = ((out_y/logi_hgt+1) * logi_hgt + ((logi_hgt*3) >> 2));
+                                                                                       } else if (((out_y % logi_hgt) - ((logi_hgt*3) >> 2)) < 0 || !(out_y % logi_hgt)) {
+                                                                                               c_y = ((out_y/logi_hgt)) * logi_hgt + ((logi_hgt*3) >> 2);
+                                                                                       } else {
+                                                                                               c_y = out_y;
+                                                                                       }
+                                                                                       b_y = a_y, d_y = c_y;
+                                                                               }
+                                                                       }
+                                                               }
+
+                                                               if (transparent == 1) {
+                                                                       if (flag) {
+                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                       *pImage32++ = backGround[i]<<2;
+                                                                               }
+                                                                               for (i = 0; i < len; i++) {
+                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                       if (val1 == transIndex) {
+                                                                                               *pImage32++ = backGround[i+image_left_pos] << 2;
+                                                                                       } else {
+                                                                                               *pImage32++ = pDacbox[val1] << 2;
+                                                                                       }
+                                                                               }
+                                                                               for (i = orgwdt+image_left_pos; i < logi_wdt; i++) {
+                                                                                       *pImage32++ = backGround[i] << 2;
+                                                                               }
+                                                                       } else {
+                                                                               if (c_y < end) {
+                                                                                       d1 = a_y - out_y;
+                                                                                       d2 = c_y - out_y;
+                                                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
+                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
+                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
+
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                               }
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                               }
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+
+                                                                                               if (!interLaced) {
+                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
+                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
+                                                                                                       c_x = logi_wdt>>2, c_y += logi_hgt;
+                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
+                                                                                               }
+                                                                                       } else if (0 <= d1 && d1 < dechgt) {
+                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       a_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       a_x += logi_wdt;
+                                                                                                               }
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       b_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       b_x += logi_wdt;
+                                                                                                               }
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               if (!interLaced) {
+                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
+                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
+                                                                                               }
+                                                                                       } else if (0 <= d2 && d2 < dechgt) {
+                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       c_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       c_x += logi_wdt;
+                                                                                                               }
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       d_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       d_x += logi_wdt;
+                                                                                                               }
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               if (!interLaced) {
+                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
+                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
+                                                                                               }
+                                                                                       }
+                                                                               }
+                                                                       }
+                                                               } else {
+                                                                       if (flag) {
+                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                       *pImage32++ = backGround[i] << 2;
+                                                                               }
+                                                                               for (i = 0; i < len; i++) {
+                                                                                       val1 = buf[i] & (numcolors - 1);
+                                                                                       *pImage32++ = pDacbox[val1] << 2;
+                                                                               }
+                                                                               for (i = orgwdt+image_left_pos; i < logi_wdt; i++) {
+                                                                                       *pImage32++ = backGround[i] << 2;
+                                                                               }
+                                                                       } else {
+                                                                               if (c_y < end) {
+                                                                                       d1 = a_y - out_y;
+                                                                                       d2 = c_y - out_y;
+                                                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
+                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
+                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+
+                                                                                               }
+                                                                                               if (!interLaced) {
+                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
+                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
+                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
+                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
+                                                                                               }
+                                                                                       } else if (0 <= d1 && d1 < dechgt) {
+                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+
+                                                                                               }
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               a_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               b_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+
+                                                                                               }
+                                                                                               if (!interLaced) {
+                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
+                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
+                                                                                               }
+                                                                                       } else if (0 <= d2 && d2 < dechgt) {
+                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+
+                                                                                               }
+                                                                                               if (!interLaced) {
+                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
+                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
+                                                                                               }
+                                                                                       }
+                                                                               }
+                                                                       }
+                                                               }
+
+                                                               backGround += logi_wdt;
+                                                               bufptr = buf;
+                                                               bufcnt = orgwdt_1;
+                                                       }
+                                               }
+
+                                               if (rowcount == orghgt) {
+                                                       break;
+                                               }
+                                               /* __get_next_code(pInputStream) */
+                                               if (navail_bytes < 2) {
+                                                       if (nbits_left == 0)
+                                                               __get_next_code_first_nbits_left_0(pInputStream)
+                                                       else
+                                                               __get_next_code_first_nbits_left_not_0(pInputStream)
+                                                       __get_next_code_first_while(pInputStream)
+                                               } else {
+                                                       if (nbits_left == 0) 
+                                                               __get_next_code_second_nbits_left_0(pInputStream)
+                                                       else
+                                                               __get_next_code_second_nbits_left_not_0(pInputStream)
+
+                                                       __get_next_code_second_while(pInputStream)
+                                               }               
+
+                                                       if (c == ending) {
+                                                               break;
+                                                       }
+
+                                                       if (c == clear) {
+                                                               curr_size = size + 1;
+                                                               slot = newcodes;
+                                                               top_slot = 1 << curr_size;
+
+                                                               do {
+                                                                       /* __get_next_code(pInputStream); */
+                                                                       if (navail_bytes < 2) {
+                                                                               if (nbits_left == 0)
+                                                                                       __get_next_code_first_nbits_left_0(pInputStream)
+                                                                               else
+                                                                                       __get_next_code_first_nbits_left_not_0(pInputStream)
+                                                                               __get_next_code_first_while(pInputStream)
+                                                                       } else {
+                                                                               if (nbits_left == 0) 
+                                                                                       __get_next_code_second_nbits_left_0(pInputStream)
+                                                                               else
+                                                                                       __get_next_code_second_nbits_left_not_0(pInputStream)
+
+                                                                               __get_next_code_second_while(pInputStream)
+                                                                       }               
+                                                               } while (c == clear);
+
+                                                               if (c == ending) {
+                                                                       break;
+                                                               }
+
+                                                               if (c >= slot) {
+                                                                       c = 0;
+                                                               }
+
+                                                               oc = fc = c;
+
+                                                               *sp++ = (unsigned char)c;
+                                                       } else {
+                                                               code = c;
+
+                                                               if (code >= slot) {
+                                                                       code = oc;
+                                                                       *sp++ = (unsigned char)fc;
+                                                               }
+
+                                                               while (code >= newcodes) {
+                                                                       *sp++ = suffix[code];
+                                                                       code = prefix[code];
+                                                               }
+
+                                                               *sp++ = (unsigned char)code;
+                                                               spCount++;
+                                                               if (slot < top_slot) {
+                                                                       fc = code;
+                                                                       suffix[slot] = (unsigned char)fc;
+                                                                       prefix[slot++] = oc;
+                                                                       oc = c;
+                                                               }
+                                                               if (slot >= top_slot) {
+                                                                       if (curr_size < 12) {
+                                                                               top_slot <<= 1;
+                                                                               ++curr_size;
+                                                                       }
+                                                               }
+                                                       }
+                                       }
+                                       break;
+
+                                       /* Restore to background color. The area used by the graphic must be restored to the background color. */
+                               case 2:
+                                       while (rowcount < orghgt) {
+                                               if ((sp - dstack) > 0) {
+                                                       spCount = sp - dstack;
+                                               }
+                                               while (sp > dstack) {
+                                                       --sp;
+                                                       *bufptr++ = *sp;
+
+                                                       if (--bufcnt == 0) {
+                                                               /********************************************************************************
+                                                               if ((ret = put_line(rowcount++, bufptr - buf, WDT, buf, pBitmapElem->pBits)) < 0)
+                                                               ********************************************************************************/
+                                                               rowcount++;
+                                                               len = bufptr - buf;
+                                                               if (len >= orgwdt) {
+                                                                       len = orgwdt;
+                                                               }
+
+                                                               if (interLaced == 0) { /* interlaced image */
+                                                                       if (!flag) {
+                                                                               out_x = 0, out_y += dechgt;
+                                                                       }
+                                                               } else { /* interlaced image */
+                                                                       if (inter_step == 1) {
+                                                                               startloc += 8;
+                                                                       } else if (inter_step == 2) {
+                                                                               startloc += 8;
+                                                                       } else if (inter_step == 3) {
+                                                                               startloc += 4;
+                                                                       } else if (inter_step == 4) {
+                                                                               startloc += 2;
+                                                                       }
+
+                                                                       if (startloc >= orghgt + image_top_pos) {
+                                                                               inter_step++;
+                                                                               if (inter_step == 2) {
+                                                                                       startloc = 4 + image_top_pos;
+                                                                               } else if (inter_step == 3) {
+                                                                                       startloc = 2+image_top_pos;
+                                                                               } else if (inter_step == 4) {
+                                                                                       startloc = 1+image_top_pos;
+                                                                               }
+                                                                       }
+                                                                       backGround = (unsigned int *)(pFrameData->pPrevImg + ((startloc * logi_wdt) << 2));
+                                                                       /* gif to rgb 565 */
+                                                                       if (flag) {
+                                                                               pImage32 = (unsigned int *)(pDecBuf) + startloc * decwdt;
+                                                                       } else {
+                                                                               out_x = 0, out_y = startloc * dechgt;
+                                                                               a_x = logi_wdt >> 2;
+                                                                               b_x = ((logi_wdt*3) >> 2);
+                                                                               c_x = logi_wdt>>2;
+                                                                               d_x = ((logi_wdt*3) >> 2);
+                                                                               if (out_y <= (logi_hgt >> 2)) {
+                                                                                       a_y = logi_hgt>>2;
+                                                                                       b_y = logi_hgt>>2;
+                                                                                       c_y = ((logi_hgt*3)>>2);
+                                                                                       d_y = ((logi_hgt*3)>>2);
+                                                                               } else {
+                                                                                       if (((out_y % logi_hgt) - (logi_hgt >> 2)) > 0) {
+                                                                                               a_y = ((out_y/logi_hgt)+1) * logi_hgt + (logi_hgt >> 2);
+                                                                                       } else if (((out_y%logi_hgt) - (logi_hgt >> 2)) < 0 || !(out_y%logi_hgt)) {
+                                                                                               a_y = ((out_y/logi_hgt)) * logi_hgt + (logi_hgt >> 2);
+                                                                                       } else {
+                                                                                               a_y = out_y;
+                                                                                       }
+
+                                                                                       if (((out_y%logi_hgt) - ((logi_hgt*3) >> 2)) > 0) {
+                                                                                               c_y = ((out_y/logi_hgt+1) * logi_hgt + ((logi_hgt*3) >> 2));
+                                                                                       } else if (((out_y%logi_hgt) - ((logi_hgt*3) >> 2)) < 0 || !(out_y%logi_hgt)) {
+                                                                                               c_y = ((out_y/logi_hgt)) * logi_hgt + ((logi_hgt*3) >> 2);
+                                                                                       } else {
+                                                                                               c_y = out_y;
+                                                                                       }
+                                                                                       b_y = a_y, d_y = c_y;
+                                                                               }
+                                                                       }
+                                                               }
+
+                                                               if (transparent == 1) {
+                                                                       if (flag) {
+                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                       *pImage32++ = backGround[i] << 2;
+                                                                               }
+                                                                               for (i = 0; i < len; i++) {
+                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                       if (val1 == transIndex) {
+                                                                                               *pImage32++ = backGround[i+image_left_pos] << 2; 
+                                                                                               backGround[i+image_left_pos] = 0x1000000;
+                                                                                       } else {
+                                                                                               *pImage32++ = pDacbox[val1] << 2;
+                                                                                               backGround[i+image_left_pos] = 0x1000000;
+                                                                                       }
+                                                                               }
+                                                                               for (i = orgwdt+image_left_pos; i < logi_wdt; i++) {
+                                                                                       *pImage32++ = backGround[i] << 2;
+                                                                               }
+                                                                       } else {
+                                                                               if (c_y < end) {
+                                                                                       d1 = a_y - out_y;
+                                                                                       d2 = c_y - out_y;
+                                                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
+                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
+                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
+
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                               }
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                               }
+                                                                                                       }
+                                                                                                       backGround[i+image_left_pos] = 0x1000000;
+                                                                                                       out_x += decwdt;
+                                                                                               }
+
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+
+                                                                                               if (!interLaced) {
+                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
+                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
+                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
+                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
+                                                                                               }
+                                                                                       } else if (0 <= d1 && d1 < dechgt) {
+                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       a_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       a_x += logi_wdt;
+                                                                                                               }
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       b_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       b_x += logi_wdt;
+                                                                                                               }
+                                                                                                       }
+                                                                                                       backGround[i+image_left_pos] = 0x1000000;
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {                                                                    
+                                                                                               d1 = a_x - out_x;
+                                                                                               d2 = b_x - out_x;
+                                                                                               if (0 <= d1 && d1 < decwdt) {
+                                                                                                       *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                       a_x += logi_wdt;
+                                                                                               }
+                                                                                               if (0 <= d2  && d2 < decwdt) {
+                                                                                                       *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                       b_x += logi_wdt;
+                                                                                               }
+                                                                                               out_x += decwdt;
+
+                                                                                               }
+                                                                                               if (!interLaced) {
+                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
+                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
+                                                                                               }
+                                                                                       } else if (0 <= d2 && d2 < dechgt) {
+                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       c_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       c_x += logi_wdt;
+                                                                                                               }
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       d_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       d_x += logi_wdt;
+                                                                                                               }
+                                                                                                       }
+                                                                                                       backGround[i+image_left_pos] = 0x1000000;
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               if (!interLaced) {
+                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
+                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
+                                                                                               }
+                                                                                       }
+                                                                               }
+                                                                       }
+                                                               } else {
+                                                                       if (flag) {
+                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                       *pImage32++ = backGround[i]<<2;
+                                                                               }
+                                                                               for (i = 0; i < len; i++) {
+                                                                                       val1 = buf[i] & (numcolors-1);
+                                                                                       *pImage32++ = pDacbox[val1] << 2;
+                                                                                       backGround[i+image_left_pos] = backcolor888;
+                                                                               }
+                                                                               for (i = orgwdt+image_left_pos; i < logi_wdt; i++) {
+                                                                                       *pImage32++ = backGround[i] << 2;
+                                                                               }
+                                                                       } else {
+                                                                               if (c_y < end) {
+                                                                                       d1 = a_y - out_y;
+                                                                                       d2 = c_y - out_y;
+                                                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
+                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
+                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                               backGround[i+image_left_pos] = backcolor888;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                               backGround[i+image_left_pos] = backcolor888;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+
+                                                                                               }
+                                                                                               if (!interLaced) {
+                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
+                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
+                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
+                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
+                                                                                               }
+                                                                                       } else if (0 <= d1 && d1 < dechgt) {
+                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+
+                                                                                               }
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               a_x += logi_wdt;
+                                                                                                               backGround[i+image_left_pos] = backcolor888;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               b_x += logi_wdt;
+                                                                                                               backGround[i+image_left_pos] = backcolor888;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+
+                                                                                               }
+                                                                                               if (!interLaced) {
+                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
+                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
+                                                                                               }
+                                                                                       } else if (0 <= d2 && d2 < dechgt) {
+                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               c_x += logi_wdt;
+                                                                                                               backGround[i+image_left_pos] = backcolor888;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               d_x += logi_wdt;
+                                                                                                               backGround[i+image_left_pos] = backcolor888;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               if (!interLaced) {
+                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
+                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
+                                                                                               }
+                                                                                       }
+                                                                               }
+                                                                       }
+                                                               }
+
+                                                               backGround += logi_wdt;
+                                                               bufptr = buf;
+                                                               bufcnt = orgwdt_1;
+                                                       }
+                                               }
+
+                                               if (rowcount == orghgt) {
+                                                       break;
+                                               }
+                                               /* __get_next_code(pInputStream) */
+                                               if (navail_bytes < 2) {
+                                                       if (nbits_left == 0)
+                                                               __get_next_code_first_nbits_left_0(pInputStream)
+                                                       else
+                                                               __get_next_code_first_nbits_left_not_0(pInputStream)
+                                                       __get_next_code_first_while(pInputStream)
+                                               } else {
+                                                       if (nbits_left == 0) 
+                                                               __get_next_code_second_nbits_left_0(pInputStream)
+                                                       else
+                                                               __get_next_code_second_nbits_left_not_0(pInputStream)
+
+                                                       __get_next_code_second_while(pInputStream)
+                                               }               
+                                                       if (c == ending) {
+                                                               break;
+                                                       }
+
+                                                       if (c == clear) {
+                                                               curr_size = size + 1;
+                                                               slot = newcodes;
+                                                               top_slot = 1 << curr_size;
+
+                                                               do {
+                                                                       /* __get_next_code(pInputStream); */
+                                                                       if (navail_bytes < 2) {
+                                                                               if (nbits_left == 0)
+                                                                                       __get_next_code_first_nbits_left_0(pInputStream)
+                                                                               else
+                                                                                       __get_next_code_first_nbits_left_not_0(pInputStream)
+                                                                               __get_next_code_first_while(pInputStream)
+                                                                       } else {
+                                                                               if (nbits_left == 0)
+                                                                                       __get_next_code_second_nbits_left_0(pInputStream)
+                                                                               else
+                                                                                       __get_next_code_second_nbits_left_not_0(pInputStream)
+
+                                                                               __get_next_code_second_while(pInputStream)
+                                                                       }               
+                                                               } while (c == clear);
+
+                                                               if (c == ending) {
+                                                                       break;
+                                                               }
+
+                                                               if (c >= slot) {
+                                                                       c = 0;
+                                                               }
+
+                                                               oc = fc = c;
+
+                                                               *sp++ = (unsigned char)c;
+                                                       } else {
+                                                               code = c;
+
+                                                               if (code >= slot) {
+                                                                       code = oc;
+                                                                       *sp++ = (unsigned char)fc;
+                                                               }
+
+                                                               while (code >= newcodes) {
+                                                                       *sp++ = suffix[code];
+                                                                       code = prefix[code];
+                                                               }
+
+                                                               *sp++ = (unsigned char)code;
+                                                               spCount++;
+                                                               if (slot < top_slot) {
+                                                                       fc = code;
+                                                                       suffix[slot] = (unsigned char)fc;
+                                                                       prefix[slot++] = oc;
+                                                                       oc = c;
+                                                               }
+                                                               if (slot >= top_slot) {
+                                                                       if (curr_size < 12) {
+                                                                               top_slot <<= 1;
+                                                                               ++curr_size;
+                                                                       }
+                                                               }
+                                                       }
+
+                                       }
+
+                                       break;
+
+
+                                       /* No disposal specified. The decoder is not required to take any action */
+                               case 0:
+
+                                       /* Do not dispose. The graphic is to be left in place. */
+                               case 1:
+
+                               default:
+                                       while (rowcount < orghgt) {
+                                               if ((sp - dstack) > 0) {
+                                                       spCount = sp - dstack;
+                                               }
+                                               /* Now that we've pushed the decoded string (in reverse order)
+                                               * onto the stack, lets pop it off and put it into our decode
+                                               * buffer...  And when the decode buffer is full, write another
+                                               * line...
+                                               */
+                                               while (sp > dstack) {
+                                                       --sp;
+                                                       *bufptr++ = *sp;
+
+                                                       if (--bufcnt == 0) {
+                                                               /**********************************************************************************
+                                                               if ((ret = put_line(rowcount++, bufptr - buf, WDT, buf, pBitmapElem->pBits)) < 0)
+                                                               **********************************************************************************/
+                                                               rowcount++;
+                                                               len = bufptr - buf;
+                                                               if (len >= orgwdt) {
+                                                                       len = orgwdt;
+                                                               }
+
+                                                               if (interLaced == 0) { /* interlaced image  */
+                                                                       if (!flag) {
+                                                                               out_x = 0, out_y += dechgt;
+                                                                       }
+                                                               } else { /* interlaced image */
+                                                                       if (inter_step == 1) {
+                                                                               startloc += 8;
+                                                                               intercount++;
+                                                                       } else if (inter_step == 2) {
+                                                                               startloc += 8;
+                                                                               intercount++;
+                                                                       } else if (inter_step == 3) {
+                                                                               startloc += 4;
+                                                                               intercount++;
+                                                                       } else if (inter_step == 4) {
+                                                                               startloc += 2;
+                                                                               intercount++;
+                                                                       }
+
+                                                                       if (startloc >= orghgt+image_top_pos) {
+                                                                               inter_step++;
+                                                                               if (inter_step == 2) {
+                                                                                       startloc = 4+image_top_pos;
+                                                                               } else if (inter_step == 3) {
+                                                                                       startloc = 2+image_top_pos;
+                                                                               } else if (inter_step == 4) {
+                                                                                       startloc = 1+image_top_pos;
+                                                                               }
+                                                                       }
+
+                                                                       backGround = (unsigned int *)(pFrameData->pPrevImg + ((startloc * logi_wdt) << 2));
+                                                                       /* gif to rgb 565 */
+                                                                       if (flag) {
+                                                                               pImage32 = (unsigned int *)(pDecBuf) + startloc * decwdt;
+                                                                       } else {
+                                                                               out_x = 0, out_y = startloc * dechgt;
+                                                                               a_x = logi_wdt >> 2;
+                                                                               b_x = ((logi_wdt*3) >> 2);
+                                                                               c_x = logi_wdt >> 2;
+                                                                               d_x = ((logi_wdt*3) >> 2);
+                                                                               if (out_y <= (logi_hgt >> 2)) {
+                                                                                       a_y = logi_hgt >> 2;
+                                                                                       b_y = logi_hgt >> 2;
+                                                                                       c_y = ((logi_hgt*3) >> 2);
+                                                                                       d_y = ((logi_hgt*3) >> 2);
+                                                                               } else {
+                                                                                       if (((out_y%logi_hgt) - (logi_hgt >> 2)) > 0) {
+                                                                                               a_y = ((out_y/logi_hgt)+1) * logi_hgt + (logi_hgt >> 2);
+                                                                                       } else if (((out_y%logi_hgt) - (logi_hgt >> 2)) < 0 || !(out_y%logi_hgt)) {
+                                                                                               a_y = ((out_y/logi_hgt)) * logi_hgt + (logi_hgt >> 2);
+                                                                                       } else {
+                                                                                               a_y = out_y;
+                                                                                       }
+
+                                                                                       if (((out_y%logi_hgt) - ((logi_hgt*3) >> 2)) > 0) {
+                                                                                               c_y = ((out_y/logi_hgt+1) * logi_hgt + ((logi_hgt*3) >> 2));
+                                                                                       } else if (((out_y%logi_hgt) - ((logi_hgt*3) >> 2)) < 0 || !(out_y%logi_hgt)) {
+                                                                                               c_y = ((out_y/logi_hgt)) * logi_hgt + ((logi_hgt*3) >> 2);
+                                                                                       } else {
+                                                                                               c_y = out_y;
+                                                                                       }
+                                                                                       b_y = a_y, d_y = c_y;
+                                                                               }
+                                                                       }
+                                                               }
+
+                                                               if (transparent == 1) {
+                                                                       if (flag) {
+                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                       *pImage32++ = backGround[i] << 2;
+                                                                               }
+                                                                               for (i = 0; i < len; i++) {
+                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                       if (val1 == transIndex) {
+                                                                                               *pImage32++ = backGround[i+image_left_pos] << 2; /* Set *pImage32 MSB 1 */
+                                                                                       } else {
+                                                                                               *pImage32++ = pDacbox[val1] << 2;
+                                                                                               backGround[i+image_left_pos] = pDacbox[val1];
+                                                                                       }
+                                                                               }
+                                                                               for (i = orgwdt+image_left_pos; i < logi_wdt; i++) {
+                                                                                       *pImage32++ = backGround[i] << 2;
+                                                                               }
+                                                                       } else {
+                                                                               if (c_y < end) {
+                                                                                       d1 = a_y - out_y;
+                                                                                       d2 = c_y - out_y;
+                                                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
+                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
+                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
+
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                                       backGround[i+image_left_pos] = pDacbox[val1];
+                                                                                                               }
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                                       backGround[i+image_left_pos] = pDacbox[val1];
+                                                                                                               }
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+
+                                                                                               if (!interLaced) {
+                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
+                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
+                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
+                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
+                                                                                               }
+                                                                                       } else if (0 <= d1 && d1 < dechgt) {
+                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       a_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       a_x += logi_wdt;
+                                                                                                                       backGround[i+image_left_pos] = pDacbox[val1];
+                                                                                                               }
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       b_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       b_x += logi_wdt;
+                                                                                                                       backGround[i+image_left_pos] = pDacbox[val1];
+                                                                                                               }
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {                    
+                                                                                               d1 = a_x - out_x;
+                                                                                               d2 = b_x - out_x;
+                                                                                               if (0 <= d1 && d1 < decwdt) {
+                                                                                                       *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                       a_x += logi_wdt;
+                                                                                               }
+                                                                                               if (0 <= d2  && d2 < decwdt) {
+                                                                                                       *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                       b_x += logi_wdt;
+                                                                                               }
+                                                                                               out_x += decwdt;
+
+                                                                                               }
+                                                                                               if (!interLaced) {
+                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
+                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
+                                                                                               }
+                                                                                       } else if (0 <= d2 && d2 < dechgt) {
+                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       c_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       c_x += logi_wdt;
+                                                                                                                       backGround[i+image_left_pos] = pDacbox[val1];
+                                                                                                               }
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               if (val1 == transIndex) {
+                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += backGround[i+image_left_pos];
+                                                                                                                       d_x += logi_wdt;
+                                                                                                               } else {
+                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
+                                                                                                                       d_x += logi_wdt;
+                                                                                                                       backGround[i+image_left_pos] = pDacbox[val1];
+                                                                                                               }
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               if (!interLaced) {
+                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
+                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
+                                                                                               }
+                                                                                       }
+                                                                               }
+                                                                       }
+                                                               } else {
+                                                                       if (flag) {
+                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                       *pImage32++ = backGround[i] << 2;
+                                                                               }
+                                                                               for (i = 0; i < len; i++) {
+                                                                                       val1 = buf[i] & (numcolors-1);
+                                                                                       *pImage32++ = pDacbox[val1] << 2;
+                                                                                       backGround[i+image_left_pos] = pDacbox[val1];
+                                                                               }
+                                                                               for (i = orgwdt+image_left_pos; i < logi_wdt; i++) {
+                                                                                       *pImage32++ = backGround[i] << 2;
+                                                                               }
+                                                                       } else {
+                                                                               if (c_y < end) {
+                                                                                       d1 = a_y - out_y;
+                                                                                       d2 = c_y - out_y;
+                                                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
+                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
+                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+
+                                                                                               }
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                               backGround[i+image_left_pos] = pDacbox[val1];
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                               backGround[i+image_left_pos] = pDacbox[val1];
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+
+                                                                                               }
+                                                                                               if (!interLaced) {
+                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
+                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
+                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
+                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
+                                                                                               }
+                                                                                       } else if (0 <= d1 && d1 < dechgt) {
+                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+
+                                                                                               }
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               a_x += logi_wdt;
+                                                                                                               backGround[i+image_left_pos] = pDacbox[val1];
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               b_x += logi_wdt;
+                                                                                                               backGround[i+image_left_pos] = pDacbox[val1];
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
+                                                                                                       d1 = a_x - out_x;
+                                                                                                       d2 = b_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                                                               a_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                                                               b_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               if (!interLaced) {
+                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
+                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
+                                                                                               }
+                                                                                       } else if (0 <= d2 && d2 < dechgt) {
+                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
+                                                                                               for (i = 0; i < image_left_pos; i++) {
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = 0; i < orgwdt; i++) {
+                                                                                                       val1 = buf[i] & (numcolors-1);
+
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               c_x += logi_wdt;
+                                                                                                               backGround[i+image_left_pos] = pDacbox[val1];
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
+                                                                                                               d_x += logi_wdt;
+                                                                                                               backGround[i+image_left_pos] = pDacbox[val1];
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+                                                                                               }
+                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
+                                                                                                       d1 = c_x - out_x;
+                                                                                                       d2 = d_x - out_x;
+                                                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                                                               c_x += logi_wdt;
+                                                                                                       }
+                                                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                                                               d_x += logi_wdt;
+                                                                                                       }
+                                                                                                       out_x += decwdt;
+
+                                                                                               }
+                                                                                               if (!interLaced) {
+                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
+                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
+                                                                                               }
+                                                                                       }
+                                                                               }
+                                                                       }
+                                                               }
+
+                                                               backGround += logi_wdt;
+                                                               bufptr = buf;
+                                                               bufcnt = orgwdt_1;
+                                                       }
+                                               }
+                                               if (rowcount == orghgt) {
+                                                       break;
+                                               }
+                                               /* __get_next_code(pInputStream) */
+                                               if (navail_bytes < 2) {
+                                                       if (nbits_left == 0)
+                                                               __get_next_code_first_nbits_left_0(pInputStream)
+                                                       else
+                                                               __get_next_code_first_nbits_left_not_0(pInputStream)
+                                                       __get_next_code_first_while(pInputStream)
+                                               } else {
+                                                       if (nbits_left == 0) 
+                                                               __get_next_code_second_nbits_left_0(pInputStream)
+                                                       else
+                                                               __get_next_code_second_nbits_left_not_0(pInputStream)
+
+                                                       __get_next_code_second_while(pInputStream)
+                                               }               
+                                                       if (c == ending) {
+                                                               break;
+                                                       }
+
+                                                       if (c == clear) {
+                                                               curr_size = size + 1;
+                                                               slot = newcodes;
+                                                               top_slot = 1 << curr_size;
+
+                                                               do {
+                                                                       /* __get_next_code(pInputStream); */
+                                                                       if (navail_bytes < 2) {
+                                                                               if (nbits_left == 0)
+                                                                                       __get_next_code_first_nbits_left_0(pInputStream)
+                                                                               else
+                                                                                       __get_next_code_first_nbits_left_not_0(pInputStream)
+                                                                               __get_next_code_first_while(pInputStream)
+                                                                       } else {
+                                                                               if (nbits_left == 0) 
+                                                                                       __get_next_code_second_nbits_left_0(pInputStream)
+                                                                               else
+                                                                                       __get_next_code_second_nbits_left_not_0(pInputStream)
+
+                                                                               __get_next_code_second_while(pInputStream)
+                                                                       }               
+                                                               } while (c == clear);
+
+                                                               if (c == ending) {
+                                                                       break;
+                                                               }
+
+                                                               if (c >= slot) {
+                                                                       c = 0;
+                                                               }
+
+                                                               oc = fc = c;
+
+                                                               *sp++ = (unsigned char)c;
+                                                       } else {
+                                                               code = c;
+
+                                                               if (code >= slot) {
+                                                                       code = oc;
+                                                                       *sp++ = (unsigned char)fc;
+                                                               }
+
+                                                               while (code >= newcodes) {
+                                                                       *sp++ = suffix[code];
+                                                                       code = prefix[code];
+                                                               }
+
+                                                               *sp++ = (unsigned char)code;
+                                                               spCount++;
+                                                               if (slot < top_slot) {
+                                                                       fc = code;
+                                                                       suffix[slot] = (unsigned char)fc;
+                                                                       prefix[slot++] = oc;
+                                                                       oc = c;
+                                                               }
+                                                               if (slot >= top_slot) {
+                                                                       if (curr_size < 12) {
+                                                                               top_slot <<= 1;
+                                                                               ++curr_size;
+                                                                       }
+                                                               }
+                                                       }
+                                       }
+
+                                       break;
+                       }
+
+                       if (interLaced) {
+                               startloc = orghgt+image_top_pos;
+                               pImage32 = (unsigned int *)(pDecBuf) + startloc * decwdt;
+                               if (!flag) {
+                                       out_x = 0, out_y = startloc * dechgt;
+                                       a_x = logi_wdt >> 2;
+                                       b_x = ((logi_wdt*3) >> 2);
+                                       c_x = logi_wdt >> 2;
+                                       d_x = ((logi_wdt*3) >> 2);
+                                       if (out_y <= (logi_hgt >> 2)) {
+                                               a_y = logi_hgt >> 2;
+                                               b_y = logi_hgt >> 2;
+                                               c_y = ((logi_hgt*3) >> 2);
+                                               d_y = ((logi_hgt*3) >> 2);
+                                       } else {
+                                               if (((out_y%logi_hgt) - (logi_hgt >> 2)) > 0) {
+                                                       a_y = ((out_y/logi_hgt)+1) * logi_hgt + (logi_hgt >> 2);
+                                               } else if (((out_y%logi_hgt) - (logi_hgt >> 2)) < 0 || !(out_y%logi_hgt)) {
+                                                       a_y = ((out_y/logi_hgt)) * logi_hgt + (logi_hgt >> 2);
+                                               } else {
+                                                       a_y = out_y;
+                                               }
+
+                                               if (((out_y%logi_hgt) - ((logi_hgt*3) >> 2)) > 0) {
+                                                       c_y = ((out_y/logi_hgt+1) * logi_hgt + ((logi_hgt*3) >> 2));
+                                               } else if (((out_y%logi_hgt) - ((logi_hgt*3) >> 2)) < 0 || !(out_y%logi_hgt)) {
+                                                       c_y = ((out_y/logi_hgt)) * logi_hgt + ((logi_hgt*3) >> 2);
+                                               } else {
+                                                       c_y = out_y;
+                                               }
+                                               b_y = a_y, d_y = c_y;
+                                       }
+                               }
+                               out_y -= dechgt;
+                       }
+
+                               backGround = (unsigned int *)(pFrameData->pPrevImg + (((image_top_pos+orghgt) * logi_wdt) << 2));
+                               for (rowcount = image_top_pos+orghgt; rowcount < logi_hgt; rowcount++) {
+                                       if (flag) {
+                                               for (i = 0; i < logi_wdt; i++) {
+                                                       *pImage32++ = backGround[i] << 2;
+                                               }
+                                       } else {
+                                               out_x = 0, out_y += dechgt;
+                                               if (c_y < end) {
+                                                       d1 = a_y - out_y;
+                                                       d2 = c_y - out_y;
+                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
+                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
+                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
+                                                               for (i = 0; i < logi_wdt; i++) {
+                                                                       d1 = a_x - out_x;
+                                                                       d2 = b_x - out_x;
+                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                               a_x += logi_wdt, c_x += logi_wdt;
+                                                                       }
+                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                               b_x += logi_wdt, d_x += logi_wdt;
+                                                                       }
+                                                                       out_x += decwdt;
+                                                               }
+                                                               a_x = logi_wdt >> 2, a_y += logi_hgt;
+                                                               b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
+                                                               c_x = logi_wdt >> 2, c_y += logi_hgt;
+                                                               d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
+                                                       } else if (0 <= d1 && d1 < dechgt) {
+                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
+                                                               for (i = 0; i < logi_wdt; i++) {
+                                                                       d1 = a_x - out_x;
+                                                                       d2 = b_x - out_x;
+                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
+                                                                               a_x += logi_wdt;
+                                                                       }
+                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
+                                                                               b_x += logi_wdt;
+                                                                       }
+                                                                       out_x += decwdt;
+                                                               }
+                                                               a_x = logi_wdt >> 2, a_y += logi_hgt;
+                                                               b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
+                                                       } else if (0 <= d2 && d2 < dechgt) {
+                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
+                                                               for (i = 0; i < logi_wdt; i++) {
+                                                                       d1 = c_x - out_x;
+                                                                       d2 = d_x - out_x;
+                                                                       if (0 <= d1 && d1 < decwdt) {
+                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
+                                                                               c_x += logi_wdt;
+                                                                       }
+                                                                       if (0 <= d2  && d2 < decwdt) {
+                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
+                                                                               d_x += logi_wdt;
+                                                                       }
+                                                                       out_x += decwdt;
+                                                               }
+                                                               c_x = logi_wdt >> 2, c_y += logi_hgt;
+                                                               d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
+                                                       }
+                                               }
+                                       }
+                                       backGround += logi_wdt;
+                               }
+                               
+
+                               if (bCenterAlign) {
+                                       margin_wdt1_2 = (expected_width - resized_width) >> 1;
+                                       margin_hgt1_2 = (expected_height - resized_height) >> 1;
+                               } else {
+                                       margin_wdt1_2 = 0;
+                                       margin_hgt1_2 = 0;
+                               }
+
+
+                               /* 565 Conversion  */
+                               pImage32 = (unsigned int *)(pDecBuf);
+       
+                               for (i = 0, k = margin_hgt1_2; i < dechgt; i++) {
+                                       pImage16 = (unsigned short *)((unsigned char *)pOutBits + ((margin_wdt1_2 + (expected_width) * k) << 1));
+                                       for (j = 0; j < decwdt; j++) {
+                                               if ((*pImage32>>24) == 0) {
+                                                       *(pImage16++) = ((*pImage32 & 0xf80000) >> 8) | ((*pImage32 & 0xfc00) >> 5) | ((*pImage32 & 0xf8) >> 3);
+                                               } else if ((*pImage32 >> 24) == 1) {
+                                                       *(pImage16++) = (((*pImage32 & 0xf80000) >> 6) / 3)  | (((*pImage32 & 0xfc00) >> 3)/3) | (((*pImage32 & 0xf8) >> 1)/3);
+                                               } else if ((*pImage32 >> 24) == 2) {
+                                                       *(pImage16++) = ((*pImage32 & 0xf80000) >> 7) | ((*pImage32 & 0xfc00) >> 4) | ((*pImage32 & 0xf8) >> 2);
+                                               } else {
+                                                       *(pImage16++) = ui_backcolor565;
+                                               }
+                                               pImage32++;
+                                       }
+                                       k++;
+                               }
+
+                               if (decoderline) {
+                                       IfegMemFree(decoderline);
+                                       decoderline = 0;
+                               }
+                               if (pDecBuf) {
+                                       IfegMemFree(pDecBuf);
+                                       pDecBuf = 0;
+                               }
+
+                               pFrameData->offset = inputPos;
+                               pFrameData->imgCount++;
+
+                               return 1;
+
+                               break;
+
+                               default:
+                                       break;
+
+               }
+       }
+}
diff --git a/src/visual/media-img-codec-osal.c b/src/visual/media-img-codec-osal.c
new file mode 100644 (file)
index 0000000..35dd9d0
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include "media-img-codec-osal.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <drm-service.h>
+
+void *IfegMemAlloc(unsigned int size)
+{
+       void *pmem;
+       pmem = malloc(size);
+       return pmem;
+}
+
+void IfegMemFree(void *pMem)
+{
+       free(pMem);
+       pMem = 0;
+}
+
+void *IfegMemcpy(void *dest, const void *src, unsigned int count)
+{
+       return memcpy(dest, src, count);
+}
+
+void *IfegMemset(void *dest, int c, unsigned int count)
+{
+       return memset(dest, c, count);
+}
+
+ULONG IfegGetAvailableMemSize(void)
+{
+       return 1;
+}
+
+int IfegMemcmp(const void *pMem1, const void *pMem2, size_t length)
+{
+       return memcmp(pMem1, pMem2, length);
+}
+
+DRM_FILE_HANDLE hDrmFile = NULL;
+static BOOL _is_real_drm = FALSE;
+
+HFile DrmOpenFile(const char *szPathName)
+{
+       if (drm_svc_is_drm_file(szPathName) == DRM_TRUE) {
+               _is_real_drm = TRUE;
+       } else {
+               _is_real_drm = FALSE;
+       }
+
+       if (!_is_real_drm) {
+               FILE *fp = fopen(szPathName, "rb");
+
+               if (fp == NULL) {
+                       return (HFile) INVALID_HOBJ;
+               }
+
+               return fp;
+
+       } else {
+               int ret =
+                   drm_svc_open_file(szPathName, DRM_PERMISSION_DISPLAY,
+                                     &hDrmFile);
+
+               if (ret != DRM_RESULT_SUCCESS) {
+                       return (HFile) INVALID_HOBJ;
+               }
+               return hDrmFile;
+       }
+}
+
+BOOL DrmReadFile(HFile hFile, void *pBuffer, ULONG bufLen, ULONG * pReadLen)
+{
+       size_t readCnt = -1;
+
+       if (!_is_real_drm) {
+               readCnt = fread(pBuffer, sizeof(char), bufLen, hFile);
+               *pReadLen = (ULONG) readCnt;
+       } else {
+               drm_svc_read_file((DRM_FILE_HANDLE) hFile, pBuffer, bufLen,
+                                 &readCnt);
+               *pReadLen = (ULONG) readCnt;
+       }
+       return TRUE;
+}
+
+long DrmTellFile(HFile hFile)
+{
+       if (!_is_real_drm) {
+               return ftell(hFile);
+       } else {
+               return drm_svc_tell_file((DRM_FILE_HANDLE) hFile);
+       }
+}
+
+BOOL DrmSeekFile(HFile hFile, long position, long offset)
+{
+
+       if (position < 0) {
+               return FALSE;
+       }
+       if (!_is_real_drm) {
+               fseek(hFile, offset, position);
+       } else {
+               drm_svc_seek_file((DRM_FILE_HANDLE) hFile, offset, position);
+       }
+
+       return TRUE;
+}
+
+BOOL DrmGetFileAttributes(const char *szPathName, FmFileAttribute * pFileAttr)
+{
+       FILE *f = NULL;
+
+       f = fopen(szPathName, "r");
+
+       if (f == NULL) {
+               return FALSE;
+       }
+
+       fseek(f, 0, SEEK_END);
+       pFileAttr->fileSize = ftell(f);
+       fclose(f);
+
+       return TRUE;
+}
+
+BOOL DrmCloseFile(HFile hFile)
+{
+       if (!_is_real_drm) {
+               fclose(hFile);
+       } else {
+               drm_svc_close_file((DRM_FILE_HANDLE) hFile);
+       }
+
+       return TRUE;
+}
diff --git a/src/visual/media-img-codec-parser.c b/src/visual/media-img-codec-parser.c
new file mode 100644 (file)
index 0000000..e019b59
--- /dev/null
@@ -0,0 +1,884 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(_PERFORMANCE_CHECK_) && defined(_USE_LOG_FILE_)
+#include "media-info-debug.h"
+#include <time.h>
+#include <sys/time.h>
+#endif
+
+#include "media-svc-debug.h"
+#include "media-img-codec-common.h"
+#include "media-img-codec-parser.h"
+
+#define                FILE_READ_SIZE          4096
+typedef struct _stream {
+       HFile fd;
+       unsigned int buffpos;
+       unsigned int filepos;
+       unsigned int filesize;
+       unsigned int buffend;
+       unsigned int debugpos;
+       unsigned char *buffer;
+} IFEGSTREAMCTRL;
+
+ImgCodecType _ImgGetInfoStreaming(HFile hFile, unsigned long fileSize,
+                                 ImgImageInfo *imgInfo);
+BOOL process_EXIF(unsigned char *ExifSection, unsigned int length,
+                 unsigned int *pOrientataion);
+
+ImgCodecType ImgGetInfoHFile(HFile hFile, unsigned long fileSize,
+                            ImgImageInfo *imgInfo)
+{
+       ImgCodecType result = 0;
+       SysAssert(hFile);
+       SysAssert(fileSize);
+
+       if (imgInfo == NULL) {
+               result = _ImgGetInfoStreaming(hFile, fileSize, NULL);
+       } else {
+               result = _ImgGetInfoStreaming(hFile, fileSize, imgInfo);
+       }
+
+       DrmSeekFile(hFile, SEEK_SET, 0);
+
+       return result;
+
+}
+
+ImgCodecType ImgGetInfoFile(const char *filePath, ImgImageInfo * imgInfo)
+{
+       HFile hFile;
+       FmFileAttribute fileAttrib;
+       ImgCodecType result;
+       SysAssert(filePath);
+       hFile = DrmOpenFile(filePath);
+
+       if (hFile == (HFile) INVALID_HOBJ) {
+               return IMG_CODEC_NONE;
+       }
+       DrmGetFileAttributes(filePath, &fileAttrib);
+
+       if ((fileAttrib.fileSize == 0)) {
+               DrmCloseFile(hFile);
+               return IMG_CODEC_NONE;
+       }
+
+       mb_svc_debug("file size : %d", fileAttrib.fileSize);
+
+       result = ImgGetInfoHFile(hFile, fileAttrib.fileSize, imgInfo);
+
+       DrmCloseFile(hFile);
+
+       return result;
+
+}
+
+static unsigned char gIfegPNGHeader[] = { 
+       0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a };
+static unsigned char gIfegJPEGHeader[] = { 0xFF, 0xD8 };
+static unsigned char gIfegGIFHeader[] = { "GIF" };
+static unsigned char gIfegBMPHeader[] = { 0x42, 0x4D };
+
+static int _CheckBuffer(IFEGSTREAMCTRL *pIfegstreamctrl, unsigned int size)
+{
+       unsigned long fileread;
+
+       if ((size + pIfegstreamctrl->buffpos) > pIfegstreamctrl->buffend) {
+               if (pIfegstreamctrl->filepos == pIfegstreamctrl->filesize) {
+                       return 0;
+               }
+
+               if (pIfegstreamctrl->buffpos == 0) {
+                       if (DrmReadFile
+                           (pIfegstreamctrl->fd, pIfegstreamctrl->buffer,
+                            FILE_READ_SIZE, &fileread) == FALSE) {
+                               return 0;
+                       }
+                       if (fileread == 0) {
+                               return 0;
+                       }
+                       pIfegstreamctrl->buffend = fileread;
+                       pIfegstreamctrl->filepos += fileread;
+                       pIfegstreamctrl->buffpos = 0;
+               } else {
+
+                       if (size >= 2048
+                           || pIfegstreamctrl->buffend -
+                           pIfegstreamctrl->buffpos > FILE_READ_SIZE) {
+                               return 0;
+                       }
+                       AcMemcpy(pIfegstreamctrl->buffer,
+                                &pIfegstreamctrl->buffer[pIfegstreamctrl->
+                                                         buffpos],
+                                pIfegstreamctrl->buffend -
+                                pIfegstreamctrl->buffpos);
+                       if (DrmReadFile
+                           (pIfegstreamctrl->fd,
+                            &pIfegstreamctrl->buffer[pIfegstreamctrl->buffend -
+                                                     pIfegstreamctrl->buffpos],
+                            pIfegstreamctrl->buffpos, &fileread) == FALSE) {
+                               return 0;
+                       }
+                       if (fileread == 0) {
+                               return 0;
+                       }
+                       pIfegstreamctrl->buffend =
+                           pIfegstreamctrl->buffend -
+                           pIfegstreamctrl->buffpos + fileread;
+                       pIfegstreamctrl->buffpos = 0;
+                       pIfegstreamctrl->filepos += fileread;
+               }
+               return 1;
+       }
+       return 2;
+}
+
+static unsigned int _IfegReadUINT(unsigned char *pBuffer)
+{
+       return (((*pBuffer) << 24) | ((*(pBuffer + 1)) << 16) |
+               ((*(pBuffer + 2)) << 8) | (*(pBuffer + 3)));
+}
+
+ImgCodecType ImgGetInfo(unsigned char *pEncodedData, unsigned long fileSize,
+                       ImgImageInfo *imgInfo)
+{
+       unsigned int width = 0, height = 0;
+
+       /* Initialize values */
+       if (imgInfo) {
+               imgInfo->width = 0;
+               imgInfo->height = 0;
+               imgInfo->numberOfFrame = 1;
+               imgInfo->bOrientation = 0;
+       }
+
+       SysAssert(pEncodedData);
+       SysAssert(fileSize);
+
+       /***********************  PNG  *************************/
+       if (AcMemcmp(pEncodedData, gIfegPNGHeader, PNG_HEADER_LENGTH) == 0) {
+               unsigned char tmp;
+
+               if (fileSize < 40) {
+                       mb_svc_debug("IMG_CODEC_UNKNOWN_TYPE in PNG");
+                       return IMG_CODEC_UNKNOWN_TYPE;
+               }
+               /* Get Image Width */
+               width = _IfegReadUINT((pEncodedData + 16));
+
+               /* Get Image Height */
+               height = _IfegReadUINT((pEncodedData + 20));
+
+               /* Read Interlace byte */
+               tmp = *(pEncodedData + 28);
+               /* If image is interlaced then multiple should be 2 */
+               if (tmp) {
+                       mb_svc_debug("Interlaced PNG Image.");
+               }
+
+               mb_svc_debug("type: IMG_CODEC_PNG");
+
+               if (imgInfo) {
+                       imgInfo->width = width;
+                       imgInfo->height = height;
+               }
+               return IMG_CODEC_PNG;
+       }
+       /***********************  BMP  *************************/
+       else if (AcMemcmp(pEncodedData, gIfegBMPHeader, BMP_HEADER_LENGTH) == 0) {
+               /* Parse BMP File and get image width and image height */
+               if (fileSize < 26) {
+                       mb_svc_debug("IMG_CODEC_UNKNOWN_TYPE in BMP");
+                       return IMG_CODEC_UNKNOWN_TYPE;
+               }
+               if (imgInfo) {
+                       imgInfo->width =
+                           pEncodedData[18] | (pEncodedData[19] << 8) |
+                           (pEncodedData[20] << 16) | (pEncodedData[21] << 24);
+                       imgInfo->height =
+                           pEncodedData[22] | (pEncodedData[23] << 8) |
+                           (pEncodedData[24] << 16) | (pEncodedData[25] << 24);
+               }
+
+               mb_svc_debug("type : IMG_CODEC_BMP");
+               return IMG_CODEC_BMP;
+
+       }
+       /***********************  GIF  *************************/
+       else if (AcMemcmp(pEncodedData, gIfegGIFHeader, GIF_HEADER_LENGTH) == 0) {
+               int length;
+               int inputPos = 0;
+               int temp;
+               int finished;
+               int imagecount = 0;
+
+               if ((unsigned int)inputPos + 13 > fileSize) {
+                       mb_svc_debug("IMG_CODEC_UNKNOWN_TYPE in GIF");
+                       return IMG_CODEC_UNKNOWN_TYPE;
+               }
+
+               if (pEncodedData[0] != 'G' || pEncodedData[1] != 'I'
+                   || pEncodedData[2] != 'F' || pEncodedData[3] < '0'
+                   || pEncodedData[3] > '9' || pEncodedData[4] < '0'
+                   || pEncodedData[4] > '9' || pEncodedData[5] < 'A'
+                   || pEncodedData[5] > 'z') {
+                       mb_svc_debug("IMG_CODEC_UNKNOWN_TYPE in GIF");
+                       return IMG_CODEC_UNKNOWN_TYPE;
+               }
+               /* get Logical width, height */
+               if (imgInfo) {
+                       imgInfo->width =
+                           pEncodedData[6] | (pEncodedData[7] << 8);
+                       imgInfo->height =
+                           pEncodedData[8] | (pEncodedData[9] << 8);
+               }
+
+               if ((pEncodedData[10] & 0x80) != 0)     /* Global color table */ {
+                       temp = (pEncodedData[10] & 0x7) + 1;
+                       length = (1 << temp) * 3;
+                       inputPos += length;
+                       if ((unsigned int)inputPos > fileSize) {
+                               mb_svc_debug("IMG_CODEC_UNKNOWN_TYPE in GIF");
+                               return IMG_CODEC_UNKNOWN_TYPE;
+                       }
+               }
+
+               inputPos += 13;
+               finished = 0;
+
+               /* still gif image (image_cnt = 1) */
+               while (!finished) {
+                       if ((unsigned int)inputPos > fileSize)
+                               break;
+
+                       switch (pEncodedData[inputPos++]) {
+                       case 0x3b:      /* End of the GIF dataset */
+                               finished = 1;
+                               break;
+
+                       case 0x21:      /* Extension Block */
+                               switch (pEncodedData[inputPos++]) {
+                               case 0xf9:      /* Graphic control extension block */
+                                       if (4 != pEncodedData[inputPos++]) {    /* data length : fixed 4 bytes */ 
+                                               mb_svc_debug
+                                                   ("IMG_CODEC_UNKNOWN_TYPE in GIF");
+                                               return IMG_CODEC_UNKNOWN_TYPE;
+                                       }
+                                       inputPos += 4;
+                                       inputPos++;     /* block end */
+                                       break;
+
+                               case 0x01:      /* Plain Text block */
+                               case 0xfe:      /* Comment Extension block */
+                               case 0xff:      /* Appliation Extension block */
+                                       while ((length = pEncodedData[inputPos++]) > 0) {       /* get the data length */
+                                               inputPos += (length);
+                                               if ((unsigned int)inputPos >
+                                                   fileSize) {
+                                                       mb_svc_debug
+                                                           ("IMG_CODEC_UNKNOWN_TYPE in GIF");
+                                                       return
+                                                           IMG_CODEC_UNKNOWN_TYPE;
+                                               }
+                                       }
+                                       break;
+
+                               default:
+                                       break;
+                               }
+
+                               break;
+
+                       case 0x2c:      /* Start of an image object. Read the image description. */
+
+                               if ((unsigned int)inputPos + 9 > fileSize) {
+                                       mb_svc_debug
+                                           ("IMG_CODEC_UNKNOWN_TYPE in GIF");
+                                       return IMG_CODEC_UNKNOWN_TYPE;
+                               }
+                               /* Color Resolution */
+                               if ((pEncodedData[inputPos + 8] & 0x80) != 0) { /* Logical color table */
+                                       temp =
+                                           (pEncodedData[inputPos + 8] & 0x7) +
+                                           1;
+                                       length = (1 << temp) * 3;
+                                       inputPos += length;
+                                       if ((unsigned int)inputPos > fileSize) {
+                                               mb_svc_debug
+                                                   ("IMG_CODEC_UNKNOWN_TYPE in GIF");
+                                               return IMG_CODEC_UNKNOWN_TYPE;
+                                       }
+                               }
+
+                               inputPos += 9;
+
+                               temp = pEncodedData[inputPos++];
+                               if (temp < 2 || 9 < temp) {
+                                       mb_svc_debug
+                                           ("IMG_CODEC_UNKNOWN_TYPE in GIF");
+                                       return IMG_CODEC_UNKNOWN_TYPE;
+                               }
+
+                               do {
+                                       length = pEncodedData[inputPos++];
+                                       inputPos += length;
+                                       if ((unsigned int)inputPos > fileSize) {
+                                               mb_svc_debug
+                                                   ("IMG_CODEC_UNKNOWN_TYPE in GIF");
+                                               return IMG_CODEC_UNKNOWN_TYPE;
+                                       }
+                               } while (length);
+
+                               if (!imagecount)
+                                       imagecount++;
+                               else {
+                                       if (imgInfo)
+                                               imgInfo->numberOfFrame = 2;
+                                       return IMG_CODEC_AGIF;
+                               }
+                               break;
+
+                       default:
+                               finished = 0;
+                               break;
+
+                       }       /* end of  switch (pEncodedData[inputPos++]) */
+               }       /* end of  while (pImage->bitmapCount > image_cnt && !finished) */
+
+               return IMG_CODEC_GIF;
+       }
+
+       mb_svc_debug("IMG_CODEC_UNKNOWN_TYPE");
+       return IMG_CODEC_UNKNOWN_TYPE;
+}
+
+ImgCodecType _ImgGetInfoStreaming(HFile hFile, unsigned long fileSize,
+                                 ImgImageInfo *imgInfo)
+{
+       unsigned int fileleft;
+       unsigned long fileread;
+       unsigned char EncodedDataBuffer[4096];
+
+       unsigned int *pNumberOfFrames = NULL;
+       unsigned int *pWidth = NULL;
+       unsigned int *pHeight = NULL;
+       unsigned int *pOrientation = NULL;
+
+       if (imgInfo == NULL) {
+               pNumberOfFrames = NULL;
+               pWidth = NULL;
+               pHeight = NULL;
+               pOrientation = NULL;
+       } else {
+               pWidth = &(imgInfo->width);
+               pHeight = &(imgInfo->height);
+               pOrientation = &(imgInfo->bOrientation);
+               pNumberOfFrames = &(imgInfo->numberOfFrame);
+
+               *pWidth = 0;
+               *pHeight = 0;
+               *pOrientation = 0;
+       }
+
+       AcMemset(EncodedDataBuffer, 0, 4096);
+
+       /* Initialize values */
+       if (pNumberOfFrames) {
+               *pNumberOfFrames = 1;
+       }
+
+       SysAssert((const char *)&fileSize);
+
+       if (DrmReadFile(hFile, EncodedDataBuffer, 8, &fileread) == FALSE) {
+               mb_svc_debug("DrmReadFile was failed");
+               return IMG_CODEC_NONE;
+       }
+
+       if (fileread < MINIMUM_HEADER_BYTES) {
+               mb_svc_debug("IMG_CODEC_UNKNOWN_TYPE");
+               return IMG_CODEC_UNKNOWN_TYPE;
+       }
+       /***********************  PNG  *************************/
+       if (AcMemcmp(EncodedDataBuffer, gIfegPNGHeader, PNG_HEADER_LENGTH) == 0) {
+               unsigned char tmp;
+
+               if (DrmReadFile(hFile, EncodedDataBuffer, 32, &fileread) ==
+                   FALSE) {
+                       mb_svc_debug("DrmReadFile was failed");
+                       return IMG_CODEC_NONE;
+               }
+               if (fileread < 32) {
+                       mb_svc_debug("IMG_CODEC_UNKNOWN_TYPE in PNG");
+                       return IMG_CODEC_UNKNOWN_TYPE;
+               }
+               /* Get Image Width */
+               if (pWidth) {
+                       *pWidth = _IfegReadUINT((EncodedDataBuffer + 8));
+               }
+
+               /* Get Image Height */
+               if (pHeight) {
+                       *pHeight = _IfegReadUINT((EncodedDataBuffer + 12));
+               }
+
+               /* Read Interlace byte */
+               tmp = *(EncodedDataBuffer + 20);
+               /* If image is interlaced then multiple should be 2 */
+               if (tmp) {
+                       mb_svc_debug("Interlaced PNG Image.\n");
+               }
+               mb_svc_debug("IMG_CODEC_PNG\n");
+               return IMG_CODEC_PNG;
+       }
+       /***********************  BMP  *************************/
+       else if (AcMemcmp(EncodedDataBuffer, gIfegBMPHeader, BMP_HEADER_LENGTH)
+                == 0) {
+               /* Parse BMP File and get image width and image height */
+               if (DrmReadFile(hFile, &EncodedDataBuffer[8], 18, &fileread) ==
+                   FALSE) {
+                       mb_svc_debug("DrmReadFile was failed");
+                       return IMG_CODEC_NONE;
+               }
+               if (fileread < 18) {
+                       mb_svc_debug("IMG_CODEC_UNKNOWN_TYPE in BMP");
+                       return IMG_CODEC_UNKNOWN_TYPE;
+               }
+               if (pWidth == NULL || pHeight == NULL
+                   || pNumberOfFrames == NULL) {
+                       return IMG_CODEC_BMP;
+               }
+               if (pWidth) {
+                       *pWidth =
+                           EncodedDataBuffer[18] | (EncodedDataBuffer[19] << 8)
+                           | (EncodedDataBuffer[20] << 16) |
+                           (EncodedDataBuffer[21] << 24);
+               }
+               if (pHeight) {
+                       *pHeight =
+                           EncodedDataBuffer[22] | (EncodedDataBuffer[23] << 8)
+                           | (EncodedDataBuffer[24] << 16) |
+                           (EncodedDataBuffer[25] << 24);
+               }
+
+               mb_svc_debug("IMG_CODEC_BMP");
+               return IMG_CODEC_BMP;
+       }
+       /***********************  GIF  *************************/
+       else if (AcMemcmp(EncodedDataBuffer, gIfegGIFHeader, GIF_HEADER_LENGTH)
+                == 0) {
+               unsigned int tablelength = 0;
+               unsigned int imagecount = 0;
+               int finished = 0;
+               unsigned char temp;
+               unsigned int length;
+               IFEGSTREAMCTRL ifegstreamctrl;
+
+               if (13 > fileSize) {
+                       mb_svc_debug("IMG_CODEC_UNKNOWN_TYPE in GIF");
+                       return IMG_CODEC_UNKNOWN_TYPE;
+               }
+
+               if (DrmReadFile(hFile, &EncodedDataBuffer[8], 5, &fileread) ==
+                   FALSE) {
+                       mb_svc_debug("DrmReadFile was failed");
+
+                       return IMG_CODEC_NONE;
+               }
+               if (fileread < 5) {
+                       mb_svc_debug("IMG_CODEC_UNKNOWN_TYPE in GIF");
+                       return IMG_CODEC_UNKNOWN_TYPE;
+               }
+
+               if (EncodedDataBuffer[0] != 'G' || EncodedDataBuffer[1] != 'I'
+                   || EncodedDataBuffer[2] != 'F' || EncodedDataBuffer[3] < '0'
+                   || EncodedDataBuffer[3] > '9' || EncodedDataBuffer[4] < '0'
+                   || EncodedDataBuffer[4] > '9' || EncodedDataBuffer[5] < 'A'
+                   || EncodedDataBuffer[5] > 'z') {
+                       mb_svc_debug("IMG_CODEC_UNKNOWN_TYPE in GIF");
+                       return IMG_CODEC_UNKNOWN_TYPE;
+               }
+
+               if (!(pWidth && pHeight)) {
+                       return IMG_CODEC_UNKNOWN_TYPE;
+               } else {
+                       *pWidth =
+                           EncodedDataBuffer[6] | (EncodedDataBuffer[7] << 8);
+                       *pHeight =
+                           EncodedDataBuffer[8] | (EncodedDataBuffer[9] << 8);
+               }
+
+               mb_svc_debug("Logical width : %d, Height : %d", *pWidth,
+                            *pHeight);
+
+               if ((EncodedDataBuffer[10] & 0x80) != 0) {      /* Global color table */
+                       temp = (EncodedDataBuffer[10] & 0x7) + 1;
+                       tablelength = (1 << temp) * 3;
+
+                       if ((tablelength * sizeof(char)) >
+                           sizeof(EncodedDataBuffer)) {
+                               mb_svc_debug
+                                   ("_ImgGetInfoStreaming :table length is more than buffer length");
+                               return IMG_CODEC_UNKNOWN_TYPE;
+                       }
+
+                       if (13 + tablelength > fileSize) {
+                               mb_svc_debug("IMG_CODEC_UNKNOWN_TYPE in GIF");
+                               return IMG_CODEC_UNKNOWN_TYPE;
+                       }
+                       /* coverity[ -tainted_data_argument : EncodedDataBuffer ] */
+                       if (DrmReadFile
+                           (hFile, EncodedDataBuffer, tablelength,
+                            &fileread) == FALSE) {
+                               mb_svc_debug("DrmReadFile was failed");
+
+                               return IMG_CODEC_NONE;
+                       }
+                       if (fileread < tablelength) {
+                               mb_svc_debug("IMG_CODEC_UNKNOWN_TYPE in GIF");
+                               return IMG_CODEC_UNKNOWN_TYPE;
+                       }
+               }
+
+               fileleft = fileSize - 13 - tablelength;
+
+               ifegstreamctrl.fd = hFile;
+               ifegstreamctrl.filesize = fileleft;
+               ifegstreamctrl.filepos = 0;
+               ifegstreamctrl.buffpos = 0;
+               ifegstreamctrl.buffend = 0;
+               ifegstreamctrl.buffer = EncodedDataBuffer;
+
+               while (!finished) {
+                       if (ifegstreamctrl.buffpos > ifegstreamctrl.buffend)
+                               break;
+                       if (_CheckBuffer(&ifegstreamctrl, 1) == 0) {
+                               mb_svc_debug("_CheckBuffer was failed");
+                               return IMG_CODEC_UNKNOWN_TYPE;
+                       }
+
+                       switch (EncodedDataBuffer[ifegstreamctrl.buffpos++]) {
+
+                       case 0x3b:      /* End of the GIF dataset */
+                               finished = 1;
+                               break;
+
+                       case 0x21:      /* Extension Block */
+                               if (_CheckBuffer(&ifegstreamctrl, 1) == 0) {
+                                       mb_svc_debug("_CheckBuffer was failed");
+                                       return IMG_CODEC_UNKNOWN_TYPE;
+                               }
+
+                               switch (EncodedDataBuffer
+                                       [ifegstreamctrl.buffpos++]) {
+
+                               case 0xf9:      /* Graphic control extension block */
+                                       if (_CheckBuffer(&ifegstreamctrl, 6) ==
+                                           0) {
+                                               mb_svc_debug
+                                                   ("_CheckBuffer was failed");
+                                               return IMG_CODEC_UNKNOWN_TYPE;
+                                       }
+
+                                       if (4 != EncodedDataBuffer[ifegstreamctrl.buffpos++]) { /* data length : fixed 4 bytes */
+                                               return 0;
+                                       }
+                                       ifegstreamctrl.buffpos += 4;
+                                       ifegstreamctrl.buffpos++;       /* block end */
+                                       break;
+
+                               case 0x01:      /* Plain Text block */
+                               case 0xfe:      /* Comment Extension block */
+                               case 0xff:      /* Appliation Extension block */
+                                       if (_CheckBuffer(&ifegstreamctrl, 1) ==
+                                           0) {
+                                               mb_svc_debug
+                                                   ("_CheckBuffer was failed");
+                                               return IMG_CODEC_UNKNOWN_TYPE;
+                                       }
+
+                                       if (ifegstreamctrl.buffpos >
+                                           sizeof(EncodedDataBuffer)) {
+                                               mb_svc_debug
+                                                   ("buffer position exceeds buffer max length ");
+                                               return IMG_CODEC_UNKNOWN_TYPE;
+                                       }
+
+                                       while ((length = EncodedDataBuffer[ifegstreamctrl.buffpos++]) > 0) {    /* get the data length */
+                                               if (_CheckBuffer
+                                                   (&ifegstreamctrl,
+                                                    length) == 0) {
+                                                       mb_svc_debug
+                                                           ("_CheckBuffer was failed");
+                                                       return
+                                                           IMG_CODEC_UNKNOWN_TYPE;
+                                               }
+
+                                               ifegstreamctrl.buffpos +=
+                                                   (length);
+                                               /* File End Check */
+                                       }
+                                       break;
+
+                               default:
+                                       break;
+                               }
+
+                               break;
+
+                       case 0x2c:      /* Start of an image object. Read the image description. */
+
+                               if (_CheckBuffer(&ifegstreamctrl, 9) == 0) {
+                                       mb_svc_debug("_CheckBuffer was failed");
+                                       return IMG_CODEC_UNKNOWN_TYPE;
+                               }
+#if 1
+                               if (imagecount == 0) {
+                                       /* Regard the width/height of the first image block as the size of thumbnails. */
+                                       int img_block_w, img_block_h,
+                                           img_block_left, img_block_top;
+                                       img_block_left =
+                                           EncodedDataBuffer[ifegstreamctrl.
+                                                             buffpos] |
+                                           (EncodedDataBuffer
+                                            [ifegstreamctrl.buffpos + 1] << 8);
+                                       img_block_top =
+                                           EncodedDataBuffer[ifegstreamctrl.
+                                                             buffpos +
+                                                             2] |
+                                           (EncodedDataBuffer
+                                            [ifegstreamctrl.buffpos + 3] << 8);
+
+                                       img_block_w =
+                                           EncodedDataBuffer[ifegstreamctrl.
+                                                             buffpos +
+                                                             4] |
+                                           (EncodedDataBuffer
+                                            [ifegstreamctrl.buffpos + 5] << 8);
+                                       img_block_h =
+                                           EncodedDataBuffer[ifegstreamctrl.
+                                                             buffpos +
+                                                             6] |
+                                           (EncodedDataBuffer
+                                            [ifegstreamctrl.buffpos + 7] << 8);
+                                       mb_svc_debug
+                                           ("Image block width : %d, Height : %d, left:%d, top:%d\n",
+                                            img_block_w, img_block_h,
+                                            img_block_left, img_block_top);
+
+                                       *pWidth = img_block_w;
+                                       *pHeight = img_block_h;
+                               }
+#endif
+                               /* Color Resolution */
+                               if ((EncodedDataBuffer[ifegstreamctrl.buffpos + 8] & 0x80) != 0) {      /* Logical color table */
+                                       temp =
+                                           (EncodedDataBuffer
+                                            [ifegstreamctrl.buffpos +
+                                             8] & 0x7) + 1;
+                                       length = (1 << temp) * 3;
+                                       if (_CheckBuffer
+                                           (&ifegstreamctrl,
+                                            length + 9) == 0) {
+                                               mb_svc_debug
+                                                   ("_CheckBuffer was failed");
+                                               return IMG_CODEC_UNKNOWN_TYPE;
+                                       }
+
+                                       ifegstreamctrl.buffpos += length;
+                                       /* File End Check */
+                               }
+
+                               ifegstreamctrl.buffpos += 9;
+
+                               if (_CheckBuffer(&ifegstreamctrl, 1) == 0) {
+                                       mb_svc_debug("_CheckBuffer was failed");
+                                       return IMG_CODEC_UNKNOWN_TYPE;
+                               }
+
+                               temp =
+                                   EncodedDataBuffer[ifegstreamctrl.buffpos++];
+                               if (temp < 2 || 9 < temp) {
+                                       return IMG_CODEC_UNKNOWN_TYPE;
+                               }
+
+                               do {
+                                       if (_CheckBuffer(&ifegstreamctrl, 1) ==
+                                           0) {
+                                               mb_svc_debug
+                                                   ("_CheckBuffer was failed");
+                                               return IMG_CODEC_UNKNOWN_TYPE;
+                                       }
+
+                                       length =
+                                           EncodedDataBuffer[ifegstreamctrl.
+                                                             buffpos++];
+                                       if ((length + ifegstreamctrl.buffpos) > ifegstreamctrl.buffend) {
+                                               length =
+                                                   length +
+                                                   ifegstreamctrl.buffpos -
+                                                   ifegstreamctrl.buffend;
+                                               if (DrmSeekFile
+                                                   (ifegstreamctrl.fd,
+                                                    SEEK_CUR,
+                                                    length) == FALSE) {
+                                                       if (imagecount) {
+                                                               if (pNumberOfFrames)
+                                                                       *pNumberOfFrames
+                                                                           = 2;
+                                                               mb_svc_debug
+                                                                   ("IMG_CODEC_AGIF");
+                                                               return
+                                                                   IMG_CODEC_AGIF;
+                                                       }
+                                                       return
+                                                           IMG_CODEC_UNKNOWN_TYPE;
+                                               }
+                                               ifegstreamctrl.filepos +=
+                                                   length;
+                                               ifegstreamctrl.buffpos = 0;
+                                               ifegstreamctrl.buffend = 0;
+                                       } else {
+                                               ifegstreamctrl.buffpos +=
+                                                   length;
+                                       }
+
+                                       /* File End Check */
+                               } while (length);
+                               if (!imagecount)
+                                       imagecount++;
+                               else {
+                                       if (pNumberOfFrames)
+                                               *pNumberOfFrames = 2;
+                                       mb_svc_debug("IMG_CODEC_AGIF");
+                                       return IMG_CODEC_AGIF;
+                               }
+                               break;
+
+                       default:
+                               finished = 0;
+                               break;
+
+                       }
+               }
+               if (pNumberOfFrames) {
+                       *pNumberOfFrames = 1;
+               }
+               mb_svc_debug("IMG_CODEC_GIF");
+               return IMG_CODEC_GIF;
+       }
+
+       /***********************  Jpeg  *************************/
+       else if (AcMemcmp(EncodedDataBuffer, gIfegJPEGHeader, JPG_HEADER_LENGTH)
+                == 0) {
+#if 1
+               /*
+                  IFEGSTREAMCTRL ifegstreamctrl;
+                  if( DrmReadFile(hFile, &EncodedDataBuffer[8], FILE_READ_SIZE-8, &fileread) == FALSE )
+                  {
+                  mb_svc_debug( "DrmReadFile was failed");
+
+                  return IMG_CODEC_NONE;
+                  }
+
+                  ifegstreamctrl.fd = hFile;
+                  ifegstreamctrl.filesize = fileSize;
+                  ifegstreamctrl.filepos = fileread+8;
+                  ifegstreamctrl.buffpos = 2;
+                  ifegstreamctrl.buffend = 8+fileread;
+                  ifegstreamctrl.buffer = EncodedDataBuffer;
+                */
+
+#else  /* Get w / h from jpeg header */
+
+#ifdef _PERFORMANCE_CHECK_
+               long start = 0L, end = 0L;
+               start = mediainfo_get_debug_time();
+#endif
+               unsigned char *img_buf = NULL;
+               img_buf = (unsigned char *)malloc(fileSize);
+
+               rewind(hFile);
+               if (DrmReadFile(hFile, img_buf, fileSize, &fileread) == FALSE) {
+                       mb_svc_debug("DrmReadFile was failed");
+
+                       return IMG_CODEC_NONE;
+               }
+
+               unsigned short block_length = img_buf[4] * 256 + img_buf[5];
+               mb_svc_debug("block length : %d", block_length);
+               int i = 4;
+
+               while (i < fileSize) {
+                       i += block_length;
+                       if (i >= fileSize) {
+                               mb_svc_debug
+                                   ("Failed to get w / h from jpeg at index [%d]",
+                                    i);
+                               break;
+                       }
+
+                       if (img_buf[i] != 0xFF) {
+                               mb_svc_debug
+                                   ("Failed to get w / h from jpeg at index [%d]",
+                                    i);
+                               break;
+                       }
+
+                       if (img_buf[i + 1] == 0xC0) {
+                               *pWidth = img_buf[i + 5] * 256 + img_buf[i + 6];
+                               *pHeight =
+                                   img_buf[i + 7] * 256 + img_buf[i + 8];
+                               break;
+                       } else {
+                               i += 2;
+                               block_length =
+                                   img_buf[i] * 256 + img_buf[i + 1];
+                               mb_svc_debug("new block length : %d",
+                                            block_length);
+                       }
+               }
+               mb_svc_debug("Jpeg w: %d, h: %d", *pWidth, *pHeight);
+
+               if (img_buf)
+                       free(img_buf);
+
+#if defined(_PERFORMANCE_CHECK_) && defined(_USE_LOG_FILE_)
+               end = mediainfo_get_debug_time();
+               double get_size =
+                   ((double)(end - start) / (double)CLOCKS_PER_SEC);
+               mb_svc_debug("get_size from jpeg header : %f", get_size);
+               mediainfo_init_file_debug();
+               mediainfo_file_dbg("get_size from jpeg header : %f", get_size);
+               mediainfo_close_file_debug();
+#endif
+
+#endif                         /* End of Get w / h from jpeg header */
+
+               mb_svc_debug("IMG_CODEC_JPEG");
+               return IMG_CODEC_JPEG;
+       }
+       return IMG_CODEC_UNKNOWN_TYPE;
+}
diff --git a/src/visual/media-img-codec.c b/src/visual/media-img-codec.c
new file mode 100755 (executable)
index 0000000..831b214
--- /dev/null
@@ -0,0 +1,252 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "media-svc-debug.h"
+#include "media-img-codec.h"
+#include <string.h>
+
+unsigned int *ImgGetFirstFrameAGIFAtSize(const char *szFileName,
+                                        ImgImageInfo *image_info)
+{
+       AGifFrameInfo *pFrameInfo = 0;
+       void *pDecodedRGB888Buf = 0;
+       unsigned char *raw_data = NULL;
+
+       if (szFileName == NULL) {
+               mb_svc_debug
+                   ("ImgGetFirstFrameAGIFAtSize: Input File Name is NULL");
+               return NULL;
+       }
+
+       if (image_info == NULL) {
+               mb_svc_debug
+                   ("ImgGetFirstFrameAGIFAtSize: Input ImgImageInfo is NULL");
+               return NULL;
+       }
+
+       pFrameInfo =
+           ImgCreateAGIFFrame(szFileName, image_info->width,
+                              image_info->height, 0, FALSE);
+
+       if (pFrameInfo && pFrameInfo->pOutBits) {
+               ImgGetNextAGIFFrame(pFrameInfo, TRUE);
+
+               if (ImgConvertRGB565ToRGB888
+                   (pFrameInfo->pOutBits, &pDecodedRGB888Buf,
+                    pFrameInfo->width, pFrameInfo->height)) {
+                       if (pDecodedRGB888Buf) {
+                               free(pFrameInfo->pOutBits);
+                               pFrameInfo->pOutBits = pDecodedRGB888Buf;
+                               unsigned char *src =
+                                   ((unsigned char *)(pFrameInfo->pOutBits));
+                               int i =
+                                   image_info->width * image_info->height * 3;
+                               raw_data = (unsigned char *)malloc(i);
+                               memset(raw_data, 0, i);
+                               unsigned char *dest = raw_data;
+                               while (i--) {
+                                       if (dest != NULL) {
+                                               *dest =
+                                                   *((unsigned char *)(src));
+                                               dest++;
+                                               src++;
+                                       }
+                               }
+                       }
+               }
+       } else {
+               mb_svc_debug("ImgDecodeAGIFToPixbufFromFile :: Error");
+       }
+
+       if (pFrameInfo) {
+               ImgDestroyAGIFFrame(pFrameInfo);
+       }
+
+       return (unsigned int *)raw_data;
+}
+
+int ImgConvertRGB565ToRGB888(void *pBuf_rgb565, void **pBuf_rgb888, int width,
+                            int height)
+{
+       unsigned short *rgb565buf = 0;
+       unsigned char *rgb888Buf = 0;
+       unsigned char red, green, blue;
+       int i;
+
+       rgb565buf = (unsigned short *)pBuf_rgb565;
+       if (rgb565buf == NULL) {
+               mb_svc_debug("rgb565buf is NULL: Error !!!");
+               return FALSE;
+       }
+
+       rgb888Buf = (unsigned char *)malloc(width * height * 3);
+
+       if (rgb888Buf == NULL) {
+               mb_svc_debug("rgb888Buf is NULL: Error !!!");
+               return FALSE;
+       }
+
+       memset(rgb888Buf, 0, (width * height * 3));
+
+       for (i = 0; i < width * height; i++) {
+               red = ((rgb565buf[i] >> 11) & 0x1F) << 3;
+               green = ((rgb565buf[i] >> 5) & 0x3F) << 2;
+               blue = (rgb565buf[i] & 0x1F) << 3;
+               rgb888Buf[3 * i] = red;
+               rgb888Buf[3 * i + 1] = green;
+               rgb888Buf[3 * i + 2] = blue;
+       }
+
+       *pBuf_rgb888 = (void *)rgb888Buf;
+
+       return TRUE;
+}
+
+/**
+ * This function is wrapper function for "ImgFastCreateAGIFFrameData".
+ *
+ * @param      szFileName[in] Specifies the read image data.
+ * @param              width[in] Specifies a width of the image to be created.
+ * @param      height[in] Specifies a height of the image to be created.
+ * @param      bgColor[in] Specifies background color of output buffer.
+ * @param      bLoop[in] Specifies looping condition whether infinte or once play.
+ * @return     This fucntion returns AGifFrameInfo Structure's pointer.
+ * @see                ImgFastCreateAGIFFrameData.
+ */
+
+AGifFrameInfo *ImgCreateAGIFFrame(const char *szFileName, unsigned int width,
+                                 unsigned int height, unsigned int bgColor,
+                                 BOOL bLoop)
+{
+       HFile hFile;
+       FmFileAttribute fileAttrib;
+       unsigned long size;
+       unsigned char *pEncodedData = NULL;
+       int cFileSize;
+       int mem_alloc_size;
+
+       if (szFileName == NULL) {
+               mb_svc_debug("Input File Name is NULL");
+               return FALSE;
+       }
+
+       SysRequireEx(szFileName != NULL, FALSE);
+
+       hFile = DrmOpenFile(szFileName);
+       if (hFile == (HFile) INVALID_HOBJ) {
+               mb_svc_debug("ImgCreateAGIFFrame: Cannot open file");
+               return NULL;
+       }
+
+       DrmGetFileAttributes(szFileName, &fileAttrib);
+
+       if (fileAttrib.fileSize == 0) {
+               mb_svc_debug("Zero File Size");
+               DrmCloseFile(hFile);
+               return NULL;
+       }
+
+       cFileSize = fileAttrib.fileSize;
+       /* A size of allocated memory - w * h *2 means RGB565 and 4096 means the max of header length */
+       mem_alloc_size = width * height * 2 + MAX_GIF_HEADER_SIZE;
+
+       if ((pEncodedData = (unsigned char *)malloc(mem_alloc_size)) == NULL) {
+               mb_svc_debug("Memory Allocation to pEncodedData failed");
+               DrmCloseFile(hFile);
+               return NULL;
+       }
+       /* coverity[ -tainted_data_argument : pEncodedData ] */
+       if (DrmReadFile(hFile, pEncodedData, mem_alloc_size, &size) == FALSE) {
+               mb_svc_debug("DrmReadFile was failed");
+               DrmCloseFile(hFile);
+
+               if (pEncodedData) {
+                       free(pEncodedData);
+                       pEncodedData = NULL;
+               }
+
+               return NULL;
+       }
+
+       mb_svc_debug("ImgCreateAGIFFrame: file (%s) read...", szFileName);
+
+       DrmCloseFile(hFile);
+
+       return FastImgCreateAGIFFrameData(width, height, pEncodedData,
+                                         cFileSize, bgColor, bLoop);
+}
+
+/**
+ * This function is wrapper function for "ImgFastDestroyAGIFFrameData".
+ *
+ * @param      pFrameData[in]
+ * @return     void
+ * @see                ImgFastDestroyAGIFFrameData.
+ * @see                ImgFastDestroyAGIFFrameData.
+ *
+ * @note               ImgFastDestroyAGIFFrameData function set free all memory in AGifFrameInfo structure
+ *                     even pEncodedData
+ *
+ * @author     Hyunjun Ko <zzoon.ko@samsung.com>
+ */
+
+void ImgDestroyAGIFFrame(AGifFrameInfo *pFrameData)
+{
+       SysAssert(pFrameData);
+
+       FastImgDestroyAGIFFrameData(pFrameData);
+}
+
+/**
+ * This function is wrapper function for "ImgFastGetNextFrameAGIF".
+ *
+ * @param      pFrameData[in]
+ * @param              bCenterAlign Specifies true if you want center align in output buffer, else left top align
+ * @return     This fucntion returns True or False as decoding result.
+ * @see                ImgFastGetNextFrameAGIF.
+ *
+ * @note               This function returns one frame data it decoded.
+ *                     next time, returns next decoded frame data... and so on.
+ *
+ * @author     rubric(sinjae4b.lee@samsung.com)
+ */
+
+ImgFastCodecInfo ImgGetNextAGIFFrame(AGifFrameInfo *gFrameData,
+                                    BOOL bCenterAlign)
+{
+       int iResult;
+
+       if (gFrameData == NULL) {
+               mb_svc_debug("Input gFrameData is NULL");
+               return IMG_INFO_DECODING_FAIL;
+       }
+
+       iResult = FastImgGetNextFrameAGIF(gFrameData, bCenterAlign);
+
+       if (iResult == 1) {
+               return IMG_INFO_DECODING_SUCCESS;
+       } else if (iResult == 2) {
+               return IMG_INFO_AGIF_LAST_FRAME;
+       } else {
+               return IMG_INFO_DECODING_FAIL;
+       }
+
+}
diff --git a/src/visual/media-svc-api.c b/src/visual/media-svc-api.c
new file mode 100755 (executable)
index 0000000..e234149
--- /dev/null
@@ -0,0 +1,5117 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include "media-info-debug.h"
+#include "media-svc-api.h"
+#include "media-svc-thumb.h"
+#include "media-svc-db-util.h"
+#include "media-svc-debug.h"
+#include "media-svc-util.h"
+#include "media-svc-db.h"
+#include "media-info-util.h"
+#include "minfo-types.h"
+#include "media-svc-error.h"
+#include <glib.h>
+#include <glib-object.h>
+#include <drm-service.h>
+#include <dirent.h>
+#include <sys/types.h>
+
+#ifdef _PERFORMANCE_CHECK_
+double g_insertdb = 0;
+double g_thumb = 0;
+double g_meta = 0;
+long start = 0L, end = 0L;
+#endif
+
+static __thread GList *g_insert_sql_list = NULL;
+
+const char *mb_svc_media_order[5] = {
+       "uuid ASC",
+       "display_name COLLATE NOCASE DESC",
+       "display_name COLLATE NOCASE ASC",
+       "modified_date DESC",
+       "modified_date ASC",
+};
+
+const char *mb_svc_folder_order[5] = {
+       "uuid ASC",
+       "folder_name COLLATE NOCASE DESC",
+       "folder_name COLLATE NOCASE ASC",
+       "modified_date DESC",
+       "modified_date ASC",
+};
+
+typedef struct {
+       DIR* dp;
+       struct dirent* entry;
+       char dir_full_path[MB_SVC_DIR_PATH_LEN_MAX+1];
+} mb_svc_sync_param_s;
+
+#define MB_SVC_DB_DEFAULT_GET_ALL_RECORDS -1   /* get all records, not limit on start position */
+#define MB_SVC_DB_GET_UNTIL_LAST_RECORD -1     /* get all records until last item */
+
+static int __mb_svc_folder_by_path_iter_start(char *parent_path, mb_svc_iterator_s *mb_svc_iterator);
+static int __mb_svc_get_folder_record_by_path_info(const char *uri, char *display_name, minfo_store_type storage_type, mb_svc_folder_record_s *record);
+static int __mb_svc_get_folder_record_by_full_path(const char *folder_full_path, mb_svc_folder_record_s *folder_record);
+static int __mb_svc_get_media_id_by_fid_name(const char *folder_id, char *display_name, char *media_id);
+static int __mb_svc_get_media_list_by_folder_id(const char *folder_id, GList **p_record_list, int valid);
+static int __mb_svc_delete_media_records_list(GList *p_record_list);
+static int __mb_svc_delete_tag_by_id(const int tag_id);
+static int __mb_svc_update_tag(int tag_id, const char *tag_name);
+static int __mb_svc_update_tagmap(int src_tag_id, int dst_tag_id);
+static int __mb_svc_update_tagmap_by_media_id(const char *media_id, int src_tag_id, int dst_tag_id);
+static int __mb_svc_get_media_cnt_by_tagid(int tag_id);
+
+int mb_svc_insert_items()
+{
+       mb_svc_debug("");
+       int i = 0;
+       int length = g_list_length(g_insert_sql_list);
+
+       for (i = 0; i < length; i++) {
+               char *sql = (char*)g_list_nth_data(g_insert_sql_list, i);
+               mb_svc_query_sql(sql);
+       }
+
+       mb_svc_sql_list_release(&g_insert_sql_list);
+
+       return 0;
+}
+
+
+int
+mb_svc_insert_file_batch(const char *file_full_path, minfo_file_type content_type)
+{
+       char dir_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       char dir_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       char file_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       mb_svc_folder_record_s folder_record = {"",};
+       mb_svc_media_record_s media_record = {"",};
+       mb_svc_image_meta_record_s image_record = {0,};
+       mb_svc_video_meta_record_s video_record = {0,};
+       int folder_modified_date = 0;
+       int ret = 0;
+       int store_type = 0;
+       bool is_drm = false;
+       
+       char *folder_sql = NULL;
+       char *insert_sql = NULL;
+       char *meta_sql = NULL;
+
+       if (file_full_path == NULL ) {
+               mb_svc_debug("file_full_path == NULL || thumb_path == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("file_full_path is %s\n", file_full_path);
+       /* 1. get file detail */
+       _mb_svc_get_file_parent_path(file_full_path, dir_path);
+       mb_svc_debug("dir_path is %s\n", dir_path);
+
+       folder_modified_date = _mb_svc_get_file_dir_modified_date(dir_path);
+       mb_svc_debug("folder_modified_date is %d\n", folder_modified_date);
+
+       /* 2. insert or update folder table */
+       ret = __mb_svc_get_folder_record_by_full_path(dir_path, &folder_record);
+       if (ret < 0) {
+               mb_svc_debug("no any record in %s", dir_path);
+               store_type = _mb_svc_get_store_type_by_full(file_full_path);
+
+               if (store_type == MB_SVC_ERROR_INTERNAL) {
+                       mb_svc_debug("Failed to get storage type : %s",
+                                    file_full_path);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+               mb_svc_debug("store_type is %d\n", store_type);
+
+               _mb_svc_get_dir_display_name(dir_path, dir_display_name);
+               mb_svc_debug("dir_display_name is %s\n", dir_display_name);
+
+               folder_record.modified_date = folder_modified_date;
+               folder_record.storage_type = store_type;
+               strncpy(folder_record.uri, dir_path, MB_SVC_DIR_PATH_LEN_MAX + 1);
+               strncpy(folder_record.display_name, dir_display_name,
+                       MB_SVC_FILE_NAME_LEN_MAX + 1);
+               strncpy(folder_record.web_account_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
+               strncpy(folder_record.web_album_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
+               folder_record.lock_status = 0;
+
+               mb_svc_debug
+                   ("no record in %s, ready insert the folder record into db\n",
+                    dir_path);
+
+               ret = mb_svc_insert_record_folder(&folder_record);
+               if (ret < 0) {
+                       mb_svc_debug
+                               ("mb_svc_insert_record_folder failed (%d)\n", ret);
+                       return ret;
+               }
+       } else {
+               /* there is already matched folder record in folder table, update it if the file is modified */
+               mb_svc_debug
+                   ("folder_record info: uuid is %s,uri is %s,display_name is %s,modified_date is %d,web_account_id is %s,store_type is %d\n",
+                    folder_record.uuid, folder_record.uri,
+                    folder_record.display_name, folder_record.modified_date,
+                    folder_record.web_account_id, folder_record.storage_type);
+               mb_svc_debug
+                   ("existing file date in folder record is %d, new file date is %d",
+                    folder_record.modified_date, folder_modified_date);
+
+               store_type = folder_record.storage_type;
+               if (folder_record.modified_date < folder_modified_date) { /* the file is updated */
+                       mb_svc_debug("directory %s is modified", dir_path);
+                       folder_record.modified_date = folder_modified_date;
+                       ret = mb_svc_update_record_folder_sql(&folder_record, &folder_sql);
+                       if (ret < 0) {
+                               mb_svc_debug
+                                   ("mb_svc_update_record_folder_sql fails(%d)",
+                                    ret);
+                       }
+
+                       mb_svc_sql_list_add(&g_insert_sql_list, &folder_sql);
+               }
+       }
+
+       /* 3. insert media table, before insert a record, check whether the same record has existed.     */
+       mb_svc_debug("ready insert file info into media table\n");
+       mb_svc_debug("file_full_path is %s\n", file_full_path);
+
+       strncpy(media_record.path, file_full_path, sizeof(media_record.path));
+       _mb_svc_get_file_display_name(file_full_path, file_display_name);
+       mb_svc_debug("file_display_name is %s\n", file_display_name);
+       strncpy(media_record.display_name, file_display_name,
+               MB_SVC_FILE_NAME_LEN_MAX + 1);
+
+       media_record.content_type = content_type;
+       media_record.rate = 0;
+       mb_svc_debug
+           ("ready get file date for insert file info into media table\n");
+       media_record.modified_date =
+           _mb_svc_get_file_dir_modified_date(file_full_path);
+       is_drm = (drm_svc_is_drm_file(file_full_path) == DRM_TRUE);
+
+       ret =
+               _mb_svc_thumb_generate_hash_name(file_full_path,
+                                                               media_record.thumbnail_path,
+                                                               MB_SVC_FILE_PATH_LEN_MAX + 1);
+       
+       if (ret < 0) {
+               mb_svc_debug("_mb_svc_thumb_generate_hash_name failed : %d", ret);
+               return ret;
+       }
+
+       /* 4. if it's image file, insert into image_meta table */
+       if (media_record.content_type == MINFO_ITEM_IMAGE)      { /* it's image file, insert into image_meta table */
+               mb_svc_debug
+                   ("ready insert file info into media table,file date is %d\n",
+                    media_record.modified_date);
+               
+               bool thumb_done = FALSE;
+               ret = mb_svc_get_image_meta(file_full_path, &image_record, &thumb_done);
+
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_get_image_meta failed\n");
+                       return ret;
+               }
+
+               strncpy(media_record.folder_uuid, folder_record.uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+               ret = mb_svc_insert_record_media_sql(&media_record, store_type, &insert_sql);
+
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_insert_record_media_sql fails(%d)",
+                                    ret);
+                       return ret;
+               }
+               
+               mb_svc_sql_list_add(&g_insert_sql_list, &insert_sql);
+
+               strncpy(image_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+               ret =
+                   mb_svc_insert_record_image_meta_sql(&image_record, store_type, &meta_sql);
+
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_insert_record_image_meta_sql failed(%d)\n", ret);
+                       return ret;
+               }
+
+               mb_svc_sql_list_add(&g_insert_sql_list, &meta_sql);
+       }
+       /* 5       if video, insert video_meta and bookmark table */
+       else if (media_record.content_type == MINFO_ITEM_VIDEO) {       /* it's video file, insert into vidoe table */
+               mb_svc_debug
+                   ("ready insert file info into media table,file date is %d\n",
+                    media_record.modified_date);
+
+               video_record.last_played_time = 0;
+               video_record.latitude = 0.0;
+               video_record.longitude = 0.0;
+
+               ret = mb_svc_get_video_meta(file_full_path, &video_record);
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_get_video_meta failed\n");
+                       return ret;
+               }
+
+               strncpy(media_record.folder_uuid, folder_record.uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+               ret = mb_svc_insert_record_media_sql(&media_record, store_type, &insert_sql);
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_insert_record_media_sql fails(%d)",
+                                    ret);
+                       return ret;
+               }
+               mb_svc_sql_list_add(&g_insert_sql_list, &insert_sql);
+
+               strncpy(video_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+               ret =
+                   mb_svc_insert_record_video_meta_sql(&video_record, store_type, &meta_sql);
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("mb_svc_insert_record_video_meta_sql failed(%d)\n", ret);
+                       return ret;
+               }
+               mb_svc_sql_list_add(&g_insert_sql_list, &meta_sql);
+       }
+
+       return 0;
+}
+
+int
+mb_svc_insert_file(const char *file_full_path, minfo_file_type content_type)
+{
+       char dir_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       char dir_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       char file_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       mb_svc_folder_record_s folder_record = {"",};
+       mb_svc_media_record_s media_record = {"",};
+       mb_svc_image_meta_record_s image_record = {0,};
+       mb_svc_video_meta_record_s video_record = {0,};
+       int folder_modified_date = 0;
+       int ret = 0;
+       int store_type = 0;
+       bool is_drm = false;
+       GList *insert_sql_list = NULL;
+       char *folder_sql = NULL;
+       char *insert_sql = NULL;
+       char *meta_sql = NULL;
+       int insert_new_folder = 0;
+
+       if (file_full_path == NULL ) {
+               mb_svc_debug("file_full_path == NULL || thumb_path == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("file_full_path is %s\n", file_full_path);
+       /* 1. get file detail */
+       _mb_svc_get_file_parent_path(file_full_path, dir_path);
+       mb_svc_debug("dir_path is %s\n", dir_path);
+
+       folder_modified_date = _mb_svc_get_file_dir_modified_date(dir_path);
+       mb_svc_debug("folder_modified_date is %d\n", folder_modified_date);
+
+       /* 2. insert or update folder table */
+       ret = __mb_svc_get_folder_record_by_full_path(dir_path, &folder_record);
+       if (ret < 0) {
+               mb_svc_debug("no any record in %s", dir_path);
+               store_type = _mb_svc_get_store_type_by_full(file_full_path);
+
+               if (store_type == MB_SVC_ERROR_INTERNAL) {
+                       mb_svc_debug("Failed to get storage type : %s",
+                                    file_full_path);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+               mb_svc_debug("store_type is %d\n", store_type);
+
+               _mb_svc_get_dir_display_name(dir_path, dir_display_name);
+               mb_svc_debug("dir_display_name is %s\n", dir_display_name);
+
+               folder_record.modified_date = folder_modified_date;
+               folder_record.storage_type = store_type;
+               strncpy(folder_record.uri, dir_path, MB_SVC_DIR_PATH_LEN_MAX + 1);
+               strncpy(folder_record.display_name, dir_display_name,
+                       MB_SVC_FILE_NAME_LEN_MAX + 1);
+               strncpy(folder_record.web_account_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
+               strncpy(folder_record.web_album_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
+               folder_record.lock_status = 0;
+
+               mb_svc_debug
+                   ("no record in %s, ready insert the folder record into db\n",
+                    dir_path);
+
+               insert_new_folder = 1;
+       } else {
+               /* there is already matched folder record in folder table, update it if the file is modified */
+               mb_svc_debug
+                   ("folder_record info: uuid is %s,uri is %s,display_name is %s,modified_date is %d,web_account_id is %s,store_type is %d\n",
+                    folder_record.uuid, folder_record.uri,
+                    folder_record.display_name, folder_record.modified_date,
+                    folder_record.web_account_id, folder_record.storage_type);
+               mb_svc_debug
+                   ("existing file date in folder record is %d, new file date is %d",
+                    folder_record.modified_date, folder_modified_date);
+
+               store_type = folder_record.storage_type;
+               if (folder_record.modified_date < folder_modified_date) { /* the file is updated */
+                       mb_svc_debug("directory %s is modified", dir_path);
+                       folder_record.modified_date = folder_modified_date;
+                       ret = mb_svc_update_record_folder_sql(&folder_record, &folder_sql);
+                       if (ret < 0) {
+                               mb_svc_debug
+                                   ("mb_svc_update_record_folder_sql fails(%d)",
+                                    ret);
+                       }
+
+                       mb_svc_sql_list_add(&insert_sql_list, &folder_sql);
+               }
+       }
+
+       /* 3. insert media table, before insert a record, check whether the same record has existed.     */
+       mb_svc_debug("ready insert file info into media table\n");
+       mb_svc_debug("file_full_path is %s\n", file_full_path);
+
+       strncpy(media_record.path, file_full_path, sizeof(media_record.path));
+       _mb_svc_get_file_display_name(file_full_path, file_display_name);
+       mb_svc_debug("file_display_name is %s\n", file_display_name);
+       strncpy(media_record.display_name, file_display_name,
+               MB_SVC_FILE_NAME_LEN_MAX + 1);
+
+       media_record.content_type = content_type;
+       media_record.rate = 0;
+       mb_svc_debug
+           ("ready get file date for insert file info into media table\n");
+       media_record.modified_date =
+           _mb_svc_get_file_dir_modified_date(file_full_path);
+       is_drm = (drm_svc_is_drm_file(file_full_path) == DRM_TRUE);
+
+       /* 4. if it's image file, insert into image_meta table */
+       if (media_record.content_type == MINFO_ITEM_IMAGE)      { /* it's image file, insert into image_meta table */
+               mb_svc_debug
+                   ("ready insert file info into media table,file date is %d\n",
+                    media_record.modified_date);
+
+#ifdef _PERFORMANCE_CHECK_
+               start = mediainfo_get_debug_time();
+#endif
+               
+               bool thumb_done = FALSE;
+               ret = mb_svc_get_image_meta(file_full_path, &image_record, &thumb_done);
+
+#ifdef _PERFORMANCE_CHECK_
+               end = mediainfo_get_debug_time();
+
+               g_meta += ((double)(end - start) / (double)CLOCKS_PER_SEC);
+               mb_svc_debug("Meta : %f", g_meta);
+#endif
+
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_get_image_meta failed\n");
+                       mb_svc_sql_list_release(&insert_sql_list);
+                       return ret;
+               }
+
+               ret = mb_svc_sqlite3_begin_trans();
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+                       mb_svc_sql_list_release(&insert_sql_list);
+                       return ret;
+               }
+
+               if (insert_new_folder == 1) {
+                       
+                       ret = mb_svc_insert_record_folder_sql(&folder_record, &folder_sql);
+                       if (ret < 0) {
+                               mb_svc_debug
+                                       ("mb_svc_insert_record_folder_sql failed (%d)\n", ret);
+                               return ret;
+                       }
+
+                       mb_svc_sql_list_add(&insert_sql_list, &folder_sql);
+               }
+
+               strncpy(media_record.folder_uuid, folder_record.uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+               ret = mb_svc_insert_record_media_sql(&media_record, store_type, &insert_sql);
+
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_insert_record_media_sql fails(%d)",
+                                    ret);
+                       mb_svc_sql_list_release(&insert_sql_list);
+                       return ret;
+               }
+               
+               mb_svc_sql_list_add(&insert_sql_list, &insert_sql);
+
+               strncpy(image_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+               ret =
+                   mb_svc_insert_record_image_meta_sql(&image_record, store_type, &meta_sql);
+
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_insert_record_image_meta_sql failed(%d)\n", ret);
+                       mb_svc_sql_list_release(&insert_sql_list);
+                       return ret;
+               }
+
+               mb_svc_sql_list_add(&insert_sql_list, &meta_sql);
+       }
+
+       /* 5       if video, insert video_meta and bookmark table */
+       else if (media_record.content_type == MINFO_ITEM_VIDEO) {       /* it's video file, insert into vidoe table */
+
+               mb_svc_debug
+                   ("ready insert file info into media table,file date is %d\n",
+                    media_record.modified_date);
+
+               video_record.last_played_time = 0;
+               video_record.latitude = 0.0;
+               video_record.longitude = 0.0;
+
+               ret = mb_svc_get_video_meta(file_full_path, &video_record);
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_get_video_meta failed\n");
+                       mb_svc_sql_list_release(&insert_sql_list);
+                       return ret;
+               }
+
+               ret = mb_svc_sqlite3_begin_trans();
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+                       mb_svc_sql_list_release(&insert_sql_list);
+                       return ret;
+               }
+
+               if (insert_new_folder == 1) {
+                       
+                       ret = mb_svc_insert_record_folder_sql(&folder_record, &folder_sql);
+                       if (ret < 0) {
+                               mb_svc_debug
+                                       ("mb_svc_insert_record_folder_sql failed (%d)\n", ret);
+                               return ret;
+                       }
+
+                       mb_svc_sql_list_add(&insert_sql_list, &folder_sql);
+               }
+
+               strncpy(media_record.folder_uuid, folder_record.uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+               ret = mb_svc_insert_record_media_sql(&media_record, store_type, &insert_sql);
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_insert_record_media_sql fails(%d)",
+                                    ret);
+                       mb_svc_sql_list_release(&insert_sql_list);
+                       return ret;
+               }
+               mb_svc_sql_list_add(&insert_sql_list, &insert_sql);
+
+               strncpy(video_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+               ret =
+                   mb_svc_insert_record_video_meta_sql(&video_record, store_type, &meta_sql);
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("mb_svc_insert_record_video_meta_sql failed(%d)\n", ret);
+                       mb_svc_sql_list_release(&insert_sql_list);
+                       return ret;
+               }
+               mb_svc_sql_list_add(&insert_sql_list, &meta_sql);
+       }
+
+       /* Start transaction */
+       int i = 0;
+       int length = g_list_length(insert_sql_list);
+
+#ifdef _PERFORMANCE_CHECK_
+       start = mediainfo_get_debug_time();
+#endif
+
+       for (i = 0; i < length; i++) {
+               char *sql = (char *)g_list_nth_data(insert_sql_list, i);
+               ret = mb_svc_query_sql(sql);
+
+               if (ret < 0) {
+                       mb_svc_debug
+                               ("mb_svc_query_sql failed.. Now start to rollback\n");
+                       mb_svc_sqlite3_rollback_trans();
+                       mb_svc_sql_list_release(&insert_sql_list);
+                       return ret;
+               }
+       }
+
+       ret = mb_svc_sqlite3_commit_trans();
+       if (ret < 0) {
+               mb_svc_debug
+                       ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+               mb_svc_sql_list_release(&insert_sql_list);
+               return ret;
+       }
+
+#ifdef _PERFORMANCE_CHECK_
+       end = mediainfo_get_debug_time();
+
+       g_insertdb += ((double)(end - start) / (double)CLOCKS_PER_SEC);
+       mb_svc_debug("Insert : %f", g_insertdb);
+       mb_svc_debug
+       ("========== End of Performance check of one item ==============\n\n");
+#endif
+
+       /* Release sql list */  
+       mb_svc_sql_list_release(&insert_sql_list);
+
+       return 0;
+}
+
+
+int mb_svc_delete_file(const char *file_full_path)
+{
+       char dir_full_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       char file_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       mb_svc_folder_record_s folder_record = {"",};
+       mb_svc_media_record_s media_record = {"",};
+       int ret = -1;
+       int media_id = -1;
+       int media_record_cnt = 0;
+       int folder_modified_date = 0;
+
+       if (file_full_path == NULL) {
+               mb_svc_debug("file_full_path == NULL \n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("Delete start : %s", file_full_path);
+
+       _mb_svc_get_file_parent_path(file_full_path, dir_full_path);
+       ret = __mb_svc_get_folder_record_by_full_path(dir_full_path, &folder_record);
+       if (ret < 0) {
+               mb_svc_debug(" file directory %s doesn't exist ",
+                            dir_full_path);
+               return MB_SVC_ERROR_DIR_NOT_EXSITED;
+       }
+
+       _mb_svc_get_file_display_name(file_full_path, file_display_name);
+       /* if the folder has at least one file */
+       ret =
+           mb_svc_get_media_record_by_full_path(file_full_path, &media_record);
+
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_get_media_record_by_full_path fail:file_full_path is %s ",
+                    file_full_path);
+               return ret;
+       }
+
+       /* delete the matched file info in media table */
+       ret = mb_svc_delete_record_media_by_id(media_record.media_uuid);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_delete_record_media fail:folder id is %s,file name is %s ",
+                    media_record.folder_uuid, file_display_name);
+               return ret;
+       }
+       mb_svc_debug
+           ("mb_svc_delete_record_media sccceed,media_id is %s,file type is %d, path is %s\n",
+            media_record.media_uuid, media_record.content_type, media_record.path);
+
+#ifdef DELETE_FOLDER_RECORD_IF_NO_FILE_IN      /* the media file is deleted succeed, then verify if the folder has no left files */
+       media_record_cnt = mb_svc_get_folder_content_count_by_folder_id(media_record.folder_uuid);      /* after delete the media file,get the left media file count in the specified folder */
+       mb_svc_debug("media_record_cnt after delete the media file is %d\n",
+                    media_record_cnt);
+       if (media_record_cnt == 0)      { /* the folder has no left files, so delete the folder record */
+               ret = mb_svc_delete_record_folder_by_id(folder_record.uuid);
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_delete_record_older fail:%s\n",
+                                    folder_record.uuid);
+                       return ret;
+               }
+       } else {                /* update old folder modified date */
+               folder_modified_date =
+                   _mb_svc_get_file_dir_modified_date(dir_full_path);
+               mb_svc_debug("folder_modified_date is %d\n",
+                            folder_modified_date);
+               if (folder_record.modified_date < folder_modified_date) {
+                       mb_svc_debug("directory %s is modified", dir_full_path);
+                       folder_record.modified_date = folder_modified_date;
+                       mb_svc_update_record_folder(&folder_record);
+               }
+       }
+
+#endif
+       /* delete thumbnail file */
+       _mb_svc_thumb_delete(file_full_path);
+
+       /* delete file info in image_meta table & (video_meta table and bookmark table if it's video file) */
+       ret =
+           mb_svc_delete_bookmark_meta_by_media_id(media_record.media_uuid,
+                                                   media_record.content_type);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_delete_record_video_or_image_by_media_id fail:media id is %d\n",
+                    media_id);
+       }
+
+       return ret;
+}
+
+int
+mb_svc_rename_file(const char *old_file_full_path,
+                  const char *new_file_full_path, minfo_file_type content_type,
+                  char *thumb_path)
+{
+       mb_svc_debug("");
+
+       char old_file_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       char new_file_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       char old_dir_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       mb_svc_media_record_s media_record = {"",};
+       mb_svc_folder_record_s folder_record = {"",};
+       int ret = 0;
+       int folder_modified_date = 0;
+       char old_media_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+
+       if (old_file_full_path == NULL || new_file_full_path == NULL) {
+               mb_svc_debug
+                   ("old_file_full_path==NULL || new_file_full_path==NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("old file_full_path is %s, new file full path is %s\n",
+                    old_file_full_path, new_file_full_path);
+
+       _mb_svc_get_file_display_name(old_file_full_path,
+                                     old_file_display_name);
+       _mb_svc_get_file_parent_path(old_file_full_path, old_dir_path);
+
+       ret = __mb_svc_get_folder_record_by_full_path(old_dir_path, &folder_record);
+       if (ret < 0) {
+               mb_svc_debug(" file directory %s doesn't exist ", old_dir_path);
+               return MB_SVC_ERROR_DIR_NOT_EXSITED;
+       }
+
+       ret =
+           mb_svc_get_media_record_by_fid_name(folder_record.uuid,
+                                               old_file_display_name,
+                                               &media_record);
+       if (ret >= 0) {
+               strncpy(old_media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+               _mb_svc_get_file_display_name(new_file_full_path,
+                                             new_file_display_name);
+               mb_svc_debug("new file_display_name is %s\n",
+                            new_file_display_name);
+
+               snprintf(media_record.path, sizeof(media_record.path), "%s/%s",
+                        folder_record.uri, new_file_display_name);
+               strncpy(media_record.display_name, new_file_display_name,
+                       MB_SVC_FILE_NAME_LEN_MAX + 1);
+               
+               media_record.modified_date =
+                   _mb_svc_get_file_dir_modified_date(new_file_full_path);
+
+               /*  thumb file rename */
+               _mb_svc_thumb_rename(old_file_full_path, new_file_full_path,
+                                    thumb_path);
+               strncpy(media_record.thumbnail_path, thumb_path,
+                       MB_SVC_FILE_PATH_LEN_MAX + 1);
+
+               mb_svc_update_record_media(&media_record);
+       }
+
+       folder_modified_date = _mb_svc_get_file_dir_modified_date(old_dir_path);
+       mb_svc_debug("folder_modified_date is %d\n", folder_modified_date);
+       if (folder_record.modified_date < folder_modified_date) {
+               mb_svc_debug("directory %s is modified", old_dir_path);
+               folder_record.modified_date = folder_modified_date;
+               mb_svc_update_record_folder(&folder_record);
+       }
+
+       return 0;
+}
+
+int
+mb_svc_move_file(const char *old_file_full_path, const char *new_file_full_path,
+                minfo_file_type content_type, char *thumb_path)
+{
+       mb_svc_debug("");
+
+       int ret = 0;
+
+       if (old_file_full_path == NULL || new_file_full_path == NULL
+           || thumb_path == NULL) {
+               mb_svc_debug
+                   ("old_file_full_path==NULL || new_file_full_path==NULL || thumb_path == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+       mb_svc_debug("old file_full_path is %s, new file full path is %s\n",
+                    old_file_full_path, new_file_full_path);
+       
+       char old_file_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       char new_file_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       char old_dir_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       char new_dir_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+
+       mb_svc_folder_record_s src_folder_record = {"",};
+       mb_svc_folder_record_s dst_folder_record = {"",};
+       mb_svc_media_record_s media_record = {"",};
+       int src_clus_cont_cnt = 0;
+       int src_clus_modified_date = 0;
+       int dst_clus_modified_date = 0;
+       char src_cluster_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+
+       GList *move_sql_list = NULL;
+       char *insert_new_folder_sql = NULL;
+       char *update_old_folder_sql = NULL;
+       char *update_new_folder_sql = NULL;
+       char *delete_folder_sql = NULL;
+       char *media_sql = NULL;
+       int insert_new_folder = 0;
+       
+       _mb_svc_get_file_display_name(old_file_full_path,
+                                     old_file_display_name);
+       _mb_svc_get_file_parent_path(old_file_full_path, old_dir_path);
+
+       _mb_svc_get_file_display_name(new_file_full_path,
+                                     new_file_display_name);
+       _mb_svc_get_file_parent_path(new_file_full_path, new_dir_path);
+
+       ret = __mb_svc_get_folder_record_by_full_path(new_dir_path, &dst_folder_record);
+       if (ret < 0) {
+               mb_svc_debug("Directory %s is NOT in DB", new_dir_path);
+               mb_svc_debug("Now making new dir %s", new_dir_path);
+
+               int store_type = 0;
+               char new_dir_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+               int folder_modified_date = 0;
+
+               store_type = _mb_svc_get_store_type_by_full(new_file_full_path);
+               
+               if (store_type == MB_SVC_ERROR_INTERNAL) {
+                       mb_svc_debug("Failed to get storage type : %s",
+                                    new_file_full_path);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+
+               _mb_svc_get_dir_display_name(new_dir_path, new_dir_display_name);
+               mb_svc_debug("dir_display_name is %s\n", new_dir_display_name);
+
+               folder_modified_date = _mb_svc_get_file_dir_modified_date(new_dir_path);
+
+               dst_folder_record.modified_date = folder_modified_date;
+               dst_folder_record.storage_type = store_type;
+               strncpy(dst_folder_record.uri, new_dir_path, MB_SVC_DIR_PATH_LEN_MAX + 1);
+               strncpy(dst_folder_record.display_name, new_dir_display_name,
+                       MB_SVC_FILE_NAME_LEN_MAX + 1);
+               strncpy(dst_folder_record.web_account_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
+               strncpy(dst_folder_record.web_album_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
+               dst_folder_record.lock_status = 0;
+
+               insert_new_folder = 1;
+       }
+
+       ret = mb_svc_get_media_record_by_full_path(old_file_full_path, &media_record);
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_get_media_record_by_full_path fails : %d", ret);
+               return ret;
+       }
+       
+       strncpy(src_cluster_uuid, media_record.folder_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+       strncpy(media_record.folder_uuid, dst_folder_record.uuid, MB_SVC_UUID_LEN_MAX + 1);
+       strncpy(media_record.path, new_file_full_path, sizeof(media_record.path));
+       strncpy(media_record.display_name, new_file_display_name, sizeof(media_record.display_name));
+       media_record.modified_date = _mb_svc_get_file_dir_modified_date(new_file_full_path);
+
+       _mb_svc_thumb_move(old_file_full_path, new_file_full_path, thumb_path);
+
+       strncpy(media_record.thumbnail_path, thumb_path, sizeof(media_record.thumbnail_path));
+
+       /*  verify if the old folder has no  files left */
+       src_clus_cont_cnt =
+           mb_svc_get_folder_content_count_by_folder_id(src_cluster_uuid);
+
+       if (src_clus_cont_cnt == 1) {
+
+               ret = mb_svc_delete_record_folder_sql(src_cluster_uuid, &delete_folder_sql);
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_delete_record_folder_sql fail:%d\n",
+                                    ret);
+                       return ret;
+               }
+               mb_svc_sql_list_add(&move_sql_list, &delete_folder_sql);
+       } else  {       /* update  modified date */
+               src_clus_modified_date =
+                   _mb_svc_get_file_dir_modified_date(old_dir_path);
+               mb_svc_get_folder_record_by_id(src_cluster_uuid, &src_folder_record);
+               mb_svc_debug("src cluster modified_date is %d\n",
+                            src_clus_modified_date);
+               if (src_folder_record.modified_date < src_clus_modified_date) {
+                       src_folder_record.modified_date = src_clus_modified_date;
+
+                       ret = mb_svc_update_record_folder_sql(&src_folder_record, &update_old_folder_sql);
+                       if (ret < 0) {
+                               mb_svc_debug("mb_svc_delete_record_folder_sql fail:%d\n",
+                                               ret);
+                               return ret;
+                       }
+                       
+                       mb_svc_sql_list_add(&move_sql_list, &update_old_folder_sql);
+               }
+       }
+
+       ret = mb_svc_sqlite3_begin_trans();
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+               return ret;
+       }
+
+       if (insert_new_folder == 1) {
+               ret = mb_svc_insert_record_folder_sql(&dst_folder_record, &insert_new_folder_sql);
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_insert_record_folder_sql fails : %d", ret);
+                       return ret;
+               }
+
+               mb_svc_sql_list_add(&move_sql_list, &insert_new_folder_sql);
+
+               strncpy(media_record.folder_uuid, dst_folder_record.uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+       } else {
+               dst_clus_modified_date =
+                       _mb_svc_get_file_dir_modified_date(new_dir_path);
+       
+               mb_svc_debug("dst cluster modified_date is %d\n",
+                               dst_clus_modified_date);
+               if (dst_folder_record.modified_date < dst_clus_modified_date) {
+                       dst_folder_record.modified_date = dst_clus_modified_date;
+
+                       ret = mb_svc_update_record_folder_sql(&dst_folder_record, &update_new_folder_sql);
+                       if (ret < 0) {
+                               mb_svc_debug("mb_svc_delete_record_folder_sql fail:%d\n",
+                                               ret);
+                               return ret;
+                       }
+                       
+                       mb_svc_sql_list_add(&move_sql_list, &update_new_folder_sql);
+               }
+       }
+
+       ret = mb_svc_update_record_media_sql(&media_record, &media_sql);
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_update_record_media fails : %d", ret);
+               return ret;
+       }
+
+       mb_svc_sql_list_add(&move_sql_list, &media_sql);
+
+       /* Start transaction */
+       int i = 0;
+       int length = g_list_length(move_sql_list);
+
+       for (i = 0; i < length; i++) {
+               char *sql = (char *)g_list_nth_data(move_sql_list, i);
+               ret = mb_svc_query_sql(sql);
+
+               if (ret < 0) {
+                       mb_svc_debug
+                               ("mb_svc_query_sql failed.. Now start to rollback\n");
+                       mb_svc_sqlite3_rollback_trans();
+                       mb_svc_sql_list_release(&move_sql_list);
+                       return ret;
+               }
+       }
+
+       ret = mb_svc_sqlite3_commit_trans();
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+               return ret;
+       }
+
+       return ret;
+}
+
+int mb_svc_move_file_by_id(const char *src_media_id, const char *dst_cluster_id)
+{
+       mb_svc_debug("");
+
+       int ret = 0;
+       mb_svc_media_record_s media_record = {"",};
+       int src_clus_cont_cnt = 0;
+       int src_clus_modified_date = 0;
+       char src_clus_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+       int dst_clus_modified_date = 0;
+       char dst_clus_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+       mb_svc_folder_record_s folder_record = {"",};
+       char thumb_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+       char dst_file_full_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+       char src_cluster_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+
+       mb_svc_debug("minfo_mv_media#src_media_id: %s", src_media_id);
+       mb_svc_debug("minfo_mv_media#dst_cluster_id: %s", dst_cluster_id);
+
+       ret = mb_svc_get_media_record_by_id(src_media_id, &media_record);
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_get_media_record_by_id failed\n");
+               return ret;
+       }
+
+       strncpy(src_cluster_uuid, media_record.folder_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+       mb_svc_get_folder_fullpath_by_folder_id(dst_cluster_id, dst_clus_path,
+                                               sizeof(dst_clus_path));
+       snprintf(dst_file_full_path, MB_SVC_FILE_PATH_LEN_MAX + 1, "%s/%s",
+                dst_clus_path, media_record.display_name);
+
+       strncpy(media_record.path, dst_file_full_path, MB_SVC_FILE_PATH_LEN_MAX + 1);
+
+       _mb_svc_thumb_move(media_record.path, dst_file_full_path, thumb_path);
+
+       media_record.modified_date =
+           _mb_svc_get_file_dir_modified_date(dst_file_full_path);
+       strncpy(media_record.thumbnail_path, thumb_path,
+               MB_SVC_FILE_PATH_LEN_MAX + 1);
+       //media_record.folder_id = dst_cluster_id;
+       strncpy(media_record.folder_uuid, dst_cluster_id, MB_SVC_UUID_LEN_MAX + 1);
+
+       mb_svc_update_record_media(&media_record);
+
+       /*  verify if the old folder has no  files left */
+       src_clus_cont_cnt =
+           mb_svc_get_folder_content_count_by_folder_id(src_cluster_uuid);
+       if (src_clus_cont_cnt == 0) {
+               ret = mb_svc_delete_record_folder_by_id(src_cluster_uuid);
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_delete_record_older fail:%d\n",
+                                    src_clus_cont_cnt);
+                       return ret;
+               }
+       } else  {       /* update  modified date */
+               mb_svc_get_folder_fullpath_by_folder_id(src_cluster_uuid,
+                                                       src_clus_path,
+                                                       sizeof(src_clus_path));
+               src_clus_modified_date =
+                   _mb_svc_get_file_dir_modified_date(src_clus_path);
+               mb_svc_get_folder_record_by_id(src_cluster_uuid, &folder_record);
+               mb_svc_debug("src cluster modified_date is %d\n",
+                            src_clus_modified_date);
+               if (folder_record.modified_date < src_clus_modified_date) {
+                       mb_svc_debug("src cluster directory %s is modified",
+                                    src_clus_path);
+                       folder_record.modified_date = src_clus_modified_date;
+                       mb_svc_update_record_folder(&folder_record);
+               }
+       }
+
+       mb_svc_get_folder_fullpath_by_folder_id(dst_cluster_id, dst_clus_path,
+                                               sizeof(dst_clus_path));
+       dst_clus_modified_date =
+           _mb_svc_get_file_dir_modified_date(dst_clus_path);
+       mb_svc_get_folder_record_by_id(dst_cluster_id, &folder_record);
+       mb_svc_debug("src cluster modified_date is %d\n",
+                    dst_clus_modified_date);
+       if (folder_record.modified_date < dst_clus_modified_date) {
+               mb_svc_debug("src cluster directory %s is modified",
+                            dst_clus_path);
+               folder_record.modified_date = dst_clus_modified_date;
+               mb_svc_update_record_folder(&folder_record);
+       }
+
+       return 0;
+}
+
+int
+mb_svc_copy_file(const char *old_file_full_path, const char *new_file_full_path,
+                minfo_file_type content_type, char *thumb_path)
+{
+       char new_file_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       char new_dir_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       char dir_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       mb_svc_media_record_s media_record = {"",};
+       mb_svc_folder_record_s folder_record = {"",};
+       mb_svc_image_meta_record_s image_record = {0,};
+       mb_svc_video_meta_record_s video_record = {0,};
+       int folder_modified_date = 0;
+       int ret = 0;
+       int store_type = 0;
+       char old_media_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+       bool is_new_folder = FALSE;
+
+       if (old_file_full_path == NULL || new_file_full_path == NULL
+           || thumb_path == NULL) {
+               mb_svc_debug
+                   ("old_file_full_path==NULL || new_file_full_path==NULL || thumb_path == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+       mb_svc_debug("old file_full_path is %s, new file full path is %s\n",
+                    old_file_full_path, new_file_full_path);
+
+       /* 1. copy to dest dir */
+
+       /* 1.1. get old media record info */
+       ret =
+           mb_svc_get_media_record_by_full_path(old_file_full_path,
+                                                &media_record);
+
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_get_media_record_by_fid_name fail: %d\n", ret);
+               return ret;
+       }
+
+       /* 1.2. check new dir  */
+       _mb_svc_get_file_parent_path(new_file_full_path, new_dir_path);
+       folder_modified_date = _mb_svc_get_file_dir_modified_date(new_dir_path);
+       mb_svc_debug("folder_modified_date is %d\n", folder_modified_date);
+
+       ret = __mb_svc_get_folder_record_by_full_path(new_dir_path, &folder_record);
+
+       if (ret < 0 && ret == MB_SVC_ERROR_DB_INTERNAL) {
+
+               is_new_folder = TRUE;
+               mb_svc_debug("no any record in %s", new_dir_path);
+
+               store_type = _mb_svc_get_store_type_by_full(new_file_full_path);
+               if (store_type == MB_SVC_ERROR_INTERNAL) {
+                       mb_svc_debug("Failed to get storage type : %s",
+                                    new_file_full_path);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+               mb_svc_debug("store_type is %d\n", store_type);
+
+               _mb_svc_get_dir_display_name(new_dir_path, dir_display_name);
+               mb_svc_debug("dir_display_name is %s\n", dir_display_name);
+
+               /* _mb_svc_get_rel_path_by_full(new_dir_path, rel_path);
+               mb_svc_debug("rel path is %s\n", rel_path);
+               _mb_svc_get_dir_parent_path(rel_path, uri); 
+               mb_svc_debug("uri is %s\n", uri); */
+
+               folder_record.modified_date = folder_modified_date;
+               folder_record.storage_type = store_type;
+               strncpy(folder_record.uri, new_dir_path,
+                       MB_SVC_DIR_PATH_LEN_MAX + 1);
+               strncpy(folder_record.display_name, dir_display_name,
+                       MB_SVC_FILE_NAME_LEN_MAX + 1);
+               strncpy(folder_record.web_account_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
+               strncpy(folder_record.web_album_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
+               folder_record.lock_status = 0;
+
+               mb_svc_debug
+                   ("no record in %s, ready insert the folder record into db\n",
+                    new_dir_path);
+
+               ret = mb_svc_insert_record_folder(&folder_record);
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("insert file info into folder table failed. Trying to get folder record again.\n");
+                       memset(&folder_record, 0x00,
+                              sizeof(mb_svc_folder_record_s));
+                       ret = __mb_svc_get_folder_record_by_full_path(new_dir_path,
+                                                                 &folder_record);
+                       if (ret < 0) {
+                               mb_svc_debug("__mb_svc_get_folder_record_by_full_path failed again.");
+                               return ret;
+                       }
+                       is_new_folder = FALSE;
+               }
+               mb_svc_debug("folder record id of new inserted is %s\n",
+                            folder_record.uuid);
+       } else {
+               mb_svc_debug
+                   ("folder_record info: uuid is %s,uri is %s,display_name is %s,modified_date is %d,web_account_id is %s,store_type is %d\n",
+                    folder_record.uuid, folder_record.uri,
+                    folder_record.display_name, folder_record.modified_date,
+                    folder_record.web_account_id, folder_record.storage_type);
+
+               if (folder_record.modified_date < folder_modified_date) {
+                       mb_svc_debug("directory %s is modified", new_dir_path);
+                       folder_record.modified_date = folder_modified_date;
+                       mb_svc_update_record_folder(&folder_record);
+               }
+       }
+
+       strncpy(old_media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+       /* 2.3. set new values, take care of  file rename  */
+       _mb_svc_get_file_display_name(new_file_full_path,
+                                     new_file_display_name);
+       mb_svc_debug("new file_display_name is %s\n", new_file_display_name);
+       strncpy(media_record.display_name, new_file_display_name,
+               MB_SVC_FILE_NAME_LEN_MAX + 1);
+       strncpy(media_record.path, new_file_full_path,
+               MB_SVC_FILE_PATH_LEN_MAX + 1);
+
+       strncpy(media_record.folder_uuid, folder_record.uuid, MB_SVC_UUID_LEN_MAX + 1);
+       media_record.modified_date =
+           _mb_svc_get_file_dir_modified_date(new_file_full_path);
+
+       _mb_svc_thumb_generate_hash_name(new_file_full_path, thumb_path,
+                                        MB_SVC_FILE_PATH_LEN_MAX + 1);
+       strncpy(media_record.thumbnail_path, thumb_path,
+               MB_SVC_FILE_PATH_LEN_MAX + 1);
+
+       ret = mb_svc_insert_record_media(&media_record, store_type);
+       if (ret < 0) {
+               if (is_new_folder == TRUE) {
+                       ret =
+                           mb_svc_delete_record_folder_by_id(folder_record.uuid);
+                       if (ret < 0) {
+                               mb_svc_debug
+                                   ("mb_svc_delete_record_older fail:%s\n",
+                                    folder_record.uuid);
+                       }
+               }
+               return ret;
+       }
+
+       /* 2.4. copy  image_meta record or video_meta record */
+       if (content_type == MINFO_ITEM_IMAGE) {
+               mb_svc_debug("update image record\n");
+               ret =
+                   mb_svc_get_image_record_by_media_id(old_media_uuid,
+                                                       &image_record);
+               if (ret < 0) {
+                       mb_svc_debug("get image record by media id failed\n");
+                       return ret;
+               }
+
+               strncpy(image_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+               ret =
+                   mb_svc_insert_record_image_meta(&image_record, store_type);
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("mb_svc_insert_record_image_meta failed\n");
+                       return ret;
+               }
+
+       } else if (content_type == MINFO_ITEM_VIDEO) {
+               mb_svc_debug("update video record\n");
+               ret =
+                   mb_svc_get_video_record_by_media_id(old_media_uuid,
+                                                       &video_record);
+               if (ret < 0) {
+                       mb_svc_debug("get video record by media id failed\n");
+                       return ret;
+               }
+
+               strncpy(video_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+               ret =
+                   mb_svc_insert_record_video_meta(&video_record, store_type);
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("mb_svc_insert_record_video_meta failed\n");
+                       return ret;
+               }
+
+               /* Get bookmark list and update them */
+               mb_svc_bookmark_record_s bookmark_record = { 0 };
+               mb_svc_iterator_s mb_svc_bm_iterator = { 0 };
+               int record_cnt = 0;
+
+               ret =
+                   mb_svc_bookmark_iter_start(old_media_uuid,
+                                              &mb_svc_bm_iterator);
+               if (ret < 0) {
+                       mb_svc_debug("mb-svc iterator start failed");
+                       return MB_SVC_ERROR_DB_INTERNAL;
+               }
+
+               while (1) {
+                       ret =
+                           mb_svc_bookmark_iter_next(&mb_svc_bm_iterator,
+                                                     &bookmark_record);
+
+                       if (ret == MB_SVC_NO_RECORD_ANY_MORE)
+                               break;
+
+                       if (ret < 0) {
+                               mb_svc_debug
+                                   ("mb-svc iterator get next recrod failed");
+                               mb_svc_iter_finish(&mb_svc_bm_iterator);
+                               return ret;
+                       }
+
+                       record_cnt++;
+
+                       strncpy(bookmark_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+                       ret = mb_svc_insert_record_bookmark(&bookmark_record);
+                       if (ret < 0) {
+                               mb_svc_debug
+                                   ("mb_svc_insert_record_bookmark failed\n");
+                               return ret;
+                       }
+               }
+
+               mb_svc_iter_finish(&mb_svc_bm_iterator);
+       }
+
+       /* 2.5 copy thumnail file */
+       ret =
+           _mb_svc_thumb_copy(old_file_full_path, new_file_full_path,
+                              thumb_path);
+       if (ret < 0) {
+               mb_svc_debug("thumb copy fails [%d]", ret);
+               /* return ret; */
+       }
+
+       return 0;
+}
+
+int mb_svc_copy_file_by_id(const char *src_media_id, const char *dst_cluster_id)
+{
+       int ret = 0;
+       mb_svc_media_record_s media_record = {"",};
+       mb_svc_image_meta_record_s image_record = {0,};
+       mb_svc_video_meta_record_s video_record = {0,};
+       mb_svc_folder_record_s folder_record = {"",};
+       char dst_clus_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       char dst_file_full_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+       int dst_clus_modified_date = 0;
+       char thumb_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+       minfo_store_type store_type = MINFO_SYSTEM;
+
+       ret = mb_svc_get_media_record_by_id(src_media_id, &media_record);
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_get_media_record_by_id failed\n");
+               return ret;
+       }
+
+       mb_svc_get_folder_fullpath_by_folder_id(dst_cluster_id, dst_clus_path,
+                                               sizeof(dst_clus_path));
+       snprintf(dst_file_full_path, MB_SVC_FILE_PATH_LEN_MAX + 1, "%s/%s",
+                dst_clus_path, media_record.display_name);
+
+       store_type = _mb_svc_get_store_type_by_full(dst_file_full_path);
+       if (store_type == MB_SVC_ERROR_INTERNAL) {
+               mb_svc_debug("Failed to get storage type : %s",
+                            dst_file_full_path);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       _mb_svc_thumb_generate_hash_name(dst_file_full_path, thumb_path,
+                                        MB_SVC_FILE_PATH_LEN_MAX + 1);
+
+       media_record.modified_date =
+           _mb_svc_get_file_dir_modified_date(dst_file_full_path);
+       strncpy(media_record.path, dst_file_full_path,
+               MB_SVC_FILE_PATH_LEN_MAX + 1);
+       strncpy(media_record.thumbnail_path, thumb_path,
+               MB_SVC_FILE_PATH_LEN_MAX + 1);
+       //media_record.folder_id = dst_cluster_id;
+       strncpy(media_record.folder_uuid, dst_cluster_id, MB_SVC_UUID_LEN_MAX + 1);
+
+       mb_svc_insert_record_media(&media_record, store_type);
+
+       if (media_record.content_type == MINFO_ITEM_IMAGE) {
+               mb_svc_debug("update image record\n");
+               ret =
+                   mb_svc_get_image_record_by_media_id(src_media_id,
+                                                       &image_record);
+               if (ret < 0) {
+                       mb_svc_debug("get image record by media id failed\n");
+                       return ret;
+               }
+
+               strncpy(image_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+               ret =
+                   mb_svc_insert_record_image_meta(&image_record, store_type);
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("mb_svc_insert_record_image_meta failed\n");
+                       return ret;
+               }
+       } else if (media_record.content_type == MINFO_ITEM_VIDEO) {
+               mb_svc_debug("update video record\n");
+               ret =
+                   mb_svc_get_video_record_by_media_id(src_media_id,
+                                                       &video_record);
+               if (ret < 0) {
+                       mb_svc_debug("get video record by media id failed\n");
+                       return ret;
+               }
+
+               strncpy(video_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+               mb_svc_insert_record_video_meta(&video_record, store_type);
+       }
+
+       mb_svc_get_folder_fullpath_by_folder_id(dst_cluster_id, dst_clus_path,
+                                               sizeof(dst_clus_path));
+       dst_clus_modified_date =
+           _mb_svc_get_file_dir_modified_date(dst_clus_path);
+       mb_svc_get_folder_record_by_id(dst_cluster_id, &folder_record);
+       mb_svc_debug("src cluster modified_date is %d\n",
+                    dst_clus_modified_date);
+       if (folder_record.modified_date < dst_clus_modified_date) {
+               mb_svc_debug("src cluster directory %s is modified",
+                            dst_clus_path);
+               folder_record.modified_date = dst_clus_modified_date;
+               mb_svc_update_record_folder(&folder_record);
+       }
+
+       ret =
+           _mb_svc_thumb_copy(media_record.path, dst_file_full_path,
+                              thumb_path);
+       if (ret < 0) {
+               mb_svc_debug("thumb copy fails [%d]", ret);
+               /* return ret; */
+       }
+
+       return 0;
+}
+
+int mb_svc_update_cluster_name(const char *cluster_id, const char *new_name)
+{
+       int ret = -1;
+       int len = 0;
+       mb_svc_folder_record_s folder_record = {"",};
+       char old_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       char dir_full_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       char src_parent_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       char src_full_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       char dst_full_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       time_t date;
+
+       if (new_name == NULL) {
+               mb_svc_debug(" new name is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_update_cluster_name#cluster_id: %s", cluster_id);
+       mb_svc_debug("minfo_update_cluster_name#new_name: %s", new_name);
+
+       ret = mb_svc_get_folder_record_by_id(cluster_id, &folder_record);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("minfo_update_cluster_name: no folder record matched with the folder id\n");
+               return ret;
+       }
+
+       strncpy(old_name, folder_record.display_name, sizeof(old_name));
+       strncpy(folder_record.display_name, new_name,
+               sizeof(folder_record.display_name));
+       _mb_svc_get_file_parent_path(folder_record.uri, dir_full_path);
+       snprintf(src_parent_path, sizeof(src_parent_path), "%s/",
+                folder_record.uri);
+
+       len = g_strlcat(dir_full_path, "/", sizeof(dir_full_path));
+       if (len >= sizeof(dir_full_path)) {
+               mb_svc_debug("strlcat returns failure ( %d )", len);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       len = g_strlcat(dir_full_path, new_name, sizeof(dir_full_path));
+       if (len >= sizeof(dir_full_path)) {
+               mb_svc_debug("strlcat returns failure ( %d )", len);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       strncpy(folder_record.uri, dir_full_path, sizeof(folder_record.uri));
+       mb_svc_debug("uri: %s", folder_record.uri);
+
+       len = g_strlcat(dir_full_path, "/", sizeof(dir_full_path));
+       if (len >= sizeof(dir_full_path)) {
+               mb_svc_debug("strlcat returns failure ( %d )", len);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       /* Update all folder record's path, which are matched by old parent path */
+       ret = mb_svc_update_record_folder_path(src_parent_path, dir_full_path);
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_update_record_folder_path failed\n");
+               return ret;
+       }
+
+       time(&date);
+       folder_record.modified_date = date;
+
+       /* Update all folder record's modified date, which are changed above */
+       ret =
+           mb_svc_update_folder_modified_date(dir_full_path,
+                                              folder_record.modified_date);
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_update_folder_modified_date failed\n");
+               return ret;
+       }
+
+       ret = mb_svc_update_record_folder(&folder_record);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("minfo_update_cluster_name: update cluster name failed\n");
+               return ret;
+       }
+
+       mb_svc_folder_record_s matched_folder_record = {"",};
+       mb_svc_media_record_s media_record = {"",};
+       mb_svc_iterator_s mb_svc_folder_iterator = { 0 };
+       mb_svc_iterator_s mb_svc_media_iterator = { 0 };
+       minfo_item_filter filter = { 0 };
+       filter.favorite = MINFO_MEDIA_FAV_ALL;
+       filter.start_pos = -1;
+       filter.sort_type = MINFO_MEDIA_SORT_BY_NONE;
+       filter.file_type = MINFO_ITEM_ALL;
+       char old_media_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+
+       ret = __mb_svc_folder_by_path_iter_start(folder_record.uri, &mb_svc_folder_iterator);
+
+       if (ret < 0) {
+               mb_svc_debug("mb-svc iterator start failed");
+               return ret;
+       }
+
+       while (1) {
+               ret =
+                   mb_svc_folder_iter_next(&mb_svc_folder_iterator,
+                                           &matched_folder_record);
+
+               if (ret == MB_SVC_NO_RECORD_ANY_MORE) {
+                       break;
+               }
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("mb_svc_folder_iterator get next recrod failed");
+                       mb_svc_iter_finish(&mb_svc_folder_iterator);
+                       return ret;
+               }
+
+               ret =
+                   mb_svc_media_iter_start_new(matched_folder_record.uuid,
+                                               &filter, MINFO_CLUSTER_TYPE_ALL,
+                                               1, NULL,
+                                               &mb_svc_media_iterator);
+
+               if (ret < 0) {
+                       mb_svc_debug("mb-svc iterator start failed");
+                       mb_svc_iter_finish(&mb_svc_folder_iterator);
+                       return ret;
+               }
+
+               while (1) {
+                       ret =
+                           mb_svc_media_iter_next(&mb_svc_media_iterator,
+                                                  &media_record);
+
+                       if (ret == MB_SVC_NO_RECORD_ANY_MORE) {
+                               break;
+                       }
+
+                       if (ret < 0) {
+                               mb_svc_debug
+                                   ("mb-svc iterator get next recrod failed");
+                               mb_svc_iter_finish(&mb_svc_folder_iterator);
+                               mb_svc_iter_finish(&mb_svc_media_iterator);
+                               return ret;
+                       }
+
+                       strncpy(old_media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+                       snprintf(src_full_path, sizeof(src_full_path), "%s",
+                                media_record.path);
+
+                       memset(media_record.path, 0x00,
+                              sizeof(media_record.path));
+                       snprintf(media_record.path, sizeof(media_record.path),
+                                "%s/%s", matched_folder_record.uri,
+                                media_record.display_name);
+
+                       snprintf(dst_full_path, sizeof(dst_full_path), "%s",
+                                media_record.path);
+
+                       mb_svc_debug
+                           ("_mb_svc_thumb_move : src[ %s ], dst[ %s ]",
+                            src_full_path, dst_full_path);
+                       ret =
+                           _mb_svc_thumb_move(src_full_path, dst_full_path,
+                                              media_record.thumbnail_path);
+                       if (ret < 0) {
+                               mb_svc_debug
+                                   ("_mb_svc_thumb_move fails.. so use default thumbnail");
+                               snprintf(media_record.thumbnail_path,
+                                        sizeof(media_record.thumbnail_path),
+                                        "%s", DEFAULT_IMAGE_THUMB);
+                       }
+
+                       ret = mb_svc_update_record_media(&media_record);
+                       if (ret < 0) {
+                               mb_svc_debug
+                                   ("Error : mb_svc_update_record_media path : %s",
+                                    media_record.path);
+                               mb_svc_iter_finish(&mb_svc_folder_iterator);
+                               mb_svc_iter_finish(&mb_svc_media_iterator);
+                               return ret;
+                       }
+               }
+
+               mb_svc_iter_finish(&mb_svc_media_iterator);
+       }
+
+       mb_svc_iter_finish(&mb_svc_folder_iterator);
+
+       return 0;
+}
+
+EXPORT_API int mb_svc_initialize()
+{
+       int err = -1;
+       int tid = -1;
+       mb_svc_debug("mb_svc_initialize-----------enter\n");
+
+       g_type_init();
+
+       err = _media_info_init_handle_tbl();
+       if (err < 0) {
+               mb_svc_debug("Error:_media_info_init_handle_tbl\n");
+               return MB_SVC_ERROR_DB_CONNECT;
+       }
+
+       tid = _media_info_get_thread_id();
+       mb_svc_debug("Current thread id : %d", tid);
+
+       HandleTable *handle_table = NULL;
+       handle_table = _media_info_search_handle(tid);
+
+       if (handle_table == NULL) {
+               mb_svc_debug
+                   ("A handle in thread [%d] does not exist. So now trying to make connection");
+               int *key_tid = NULL;
+
+               err = _media_info_insert_handle(&key_tid, tid, &handle_table);
+               if (err < 0) {
+                       mb_svc_debug("A handle in thread [%d] exists. ", tid);
+                       if (key_tid)
+                               g_free(key_tid);
+                       if (handle_table)
+                               g_free(handle_table);
+                       return 0;
+               }
+
+               sqlite3 *handle = NULL;
+               err = mb_svc_connect_db(&handle);
+               if (err < 0 || handle == NULL) {
+                       mb_svc_debug("Error:failed to initialize DB\n");
+                       if (key_tid)
+                               g_free(key_tid);
+                       if (handle_table)
+                               g_free(handle_table);
+                       return MB_SVC_ERROR_DB_CONNECT;
+               }
+
+               handle_table->handle = handle;
+       } else {
+               mb_svc_debug("A handle in thread [%d] exists. ", tid);
+               _media_info_atomic_add_counting(handle_table);
+       }
+
+       mb_svc_debug("mb_svc_initialize-----------leave\n");
+       return 0;
+}
+
+EXPORT_API int mb_svc_finalize()
+{
+       int ret = 0;
+       int err = -1;
+       int tid = -1;
+       mb_svc_debug("mb_svc_finalize-----------enter\n");
+
+       tid = _media_info_get_thread_id();
+       mb_svc_debug("Current thread id : %d", tid);
+
+       HandleTable *handle_table = NULL;
+       handle_table = _media_info_search_handle(tid);
+
+       if (handle_table == NULL) {
+               mb_svc_debug("handle_table is NULL");
+               return MB_SVC_ERROR_DB_DISCONNECT;
+       } else {
+               mb_svc_debug("ref count in thread[%d] is %d", tid,
+                            handle_table->ref_cnt);
+
+               if (handle_table->ref_cnt > 1) {
+                       _media_info_atomic_sub_counting(handle_table);
+               } else {
+
+                       err = mb_svc_disconnect_db(handle_table->handle);
+                       if (err < 0) {
+                               mb_svc_debug("Error:mb_svc_disconnect_db\n");
+                               ret = MB_SVC_ERROR_DB_DISCONNECT;
+                       }
+
+                       err = _media_info_remove_handle(tid);
+                       if (err < 0) {
+                               mb_svc_debug
+                                   ("Error:_media_info_remove_handle\n");
+                               return MB_SVC_ERROR_DB_DISCONNECT;
+                       }
+
+                       _media_info_finalize_handle_tbl();
+
+               }
+       }
+
+       return ret;
+}
+
+/* clock_t */
+long mb_svc_get_clock(void)
+{
+       struct timeval tv;
+       long curtime;
+
+       gettimeofday(&tv, NULL);
+       curtime = tv.tv_sec * USEC_PER_SEC + tv.tv_usec;
+
+       /* int curtime = time((time_t*)NULL); */
+       return curtime;
+}
+
+int mb_svc_table_member_count(char *table_name)
+{
+       char q_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       int rc = 0;
+       sqlite3_stmt *stmt = NULL;
+       int count = 0;
+       int err = -1;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (table_name == NULL) {
+               mb_svc_debug("Error:table_name == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       snprintf(q_string, sizeof(q_string), MB_SVC_TABLE_COUNT_QUERY_STRING,
+                table_name);
+
+       err =
+           sqlite3_prepare_v2(handle, q_string, strlen(q_string), &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", q_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       rc = sqlite3_step(stmt);
+       while (rc == SQLITE_ROW) {
+               count = sqlite3_column_int(stmt, 0);
+               rc = sqlite3_step(stmt);
+       }
+       sqlite3_finalize(stmt);
+
+       stmt = NULL;
+       mb_svc_debug("record count of table %s is %d\n", table_name, count);
+       return count;
+}
+
+int
+mb_svc_geo_media_iter_start(const char *folder_id,
+                           minfo_folder_type store_filter,
+                           minfo_item_filter *filter,
+                           mb_svc_iterator_s *mb_svc_iterator,
+                           double min_longitude,
+                           double max_longitude,
+                           double min_latitude, double max_latitude)
+{
+       mb_svc_debug("");
+
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_MEDIA;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       char query_complete_string[MB_SVC_DEFAULT_QUERY_SIZE * 3 + 1] = { 0 };
+       char query_where[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       char tmp_str[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       /* mb_svc_debug ("mb_svc_media_iter_start--enter\n"); */
+
+       if (mb_svc_iterator == NULL || filter == NULL) {
+               mb_svc_debug("Error:mb_svc_iterator == NULL || filter == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+       if (filter->start_pos >= 0 && filter->start_pos > filter->end_pos) {
+               mb_svc_debug(" filter->start_pos (%d) > filter->end_pos (%d) = %d\n",
+                            filter->start_pos, filter->end_pos);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+       strncpy(query_where, "", MB_SVC_DEFAULT_QUERY_SIZE);
+
+       if (store_filter != MINFO_CLUSTER_TYPE_ALL) {
+               switch (store_filter) {
+               case MINFO_CLUSTER_TYPE_LOCAL_ALL:
+                       snprintf(tmp_str, sizeof(tmp_str),
+                                " and (storage_type = %d or storage_type = %d)",
+                                MINFO_PHONE, MINFO_MMC);
+                       break;
+               case MINFO_CLUSTER_TYPE_LOCAL_PHONE:
+                       snprintf(tmp_str, sizeof(tmp_str),
+                                " and storage_type = %d ", MINFO_PHONE);
+                       break;
+               case MINFO_CLUSTER_TYPE_LOCAL_MMC:
+                       snprintf(tmp_str, sizeof(tmp_str),
+                                " and storage_type = %d ", MINFO_MMC);
+                       break;
+               case MINFO_CLUSTER_TYPE_WEB:
+                       snprintf(tmp_str, sizeof(tmp_str),
+                                " and storage_type = %d ", MINFO_WEB);
+                       break;
+               case MINFO_CLUSTER_TYPE_STREAMING:
+                       snprintf(tmp_str, sizeof(tmp_str),
+                                " and storage_type = %d ",
+                                MINFO_WEB_STREAMING);
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       snprintf(query_string, MB_SVC_DEFAULT_QUERY_SIZE + 1,
+                MB_SVC_TABLE_SELECT_GEO_LIST, table_name, min_longitude,
+                max_longitude, min_latitude, max_latitude, min_longitude,
+                max_longitude, min_latitude, max_latitude, tmp_str);
+
+       memset(tmp_str, 0x00, sizeof(tmp_str));
+
+       mb_svc_debug("Query string: %s", query_string);
+
+       if (filter->favorite == MINFO_MEDIA_FAV_ONLY) {
+               strncat(query_where, " and a.rating = 1",
+                       MB_SVC_DEFAULT_QUERY_SIZE + 1);
+       } else if (filter->favorite == MINFO_MEDIA_UNFAV_ONLY) {
+               strncat(query_where, " and a.rating = 0",
+                       MB_SVC_DEFAULT_QUERY_SIZE + 1);
+       }
+
+       /* set to get only unlocked items */
+       strncat(query_where, " and b.lock_status = 0",
+               MB_SVC_DEFAULT_QUERY_SIZE + 1);
+
+       if (folder_id != NULL) {
+               snprintf(tmp_str, MB_SVC_DEFAULT_QUERY_SIZE + 1,
+                        " and a.folder_uuid = '%s'", folder_id);
+               strncat(query_where, tmp_str, MB_SVC_DEFAULT_QUERY_SIZE + 1);
+       }
+
+       snprintf(tmp_str, MB_SVC_DEFAULT_QUERY_SIZE + 1,
+                " and (a.content_type = 0");
+       strncat(query_where, tmp_str, MB_SVC_DEFAULT_QUERY_SIZE + 1);
+
+       if (filter->file_type & MINFO_ITEM_ALL) {
+               filter->file_type = MINFO_ITEM_IMAGE | MINFO_ITEM_VIDEO;
+       }
+
+       if (filter->file_type & MINFO_ITEM_IMAGE) {
+               snprintf(tmp_str, sizeof(tmp_str), " or a.content_type = %d",
+                        MINFO_ITEM_IMAGE);
+               strncat(query_where, tmp_str, MB_SVC_DEFAULT_QUERY_SIZE + 1);
+       }
+
+       if (filter->file_type & MINFO_ITEM_VIDEO) {
+               snprintf(tmp_str, sizeof(tmp_str), " or a.content_type = %d",
+                        MINFO_ITEM_VIDEO);
+               strncat(query_where, tmp_str, MB_SVC_DEFAULT_QUERY_SIZE + 1);
+       }
+
+       strncat(query_where, ")", MB_SVC_DEFAULT_QUERY_SIZE + 1);
+
+       if (filter->sort_type == MINFO_MEDIA_SORT_BY_NONE)
+               filter->sort_type = MINFO_MEDIA_SORT_BY_NAME_ASC;
+
+       snprintf(query_complete_string, MB_SVC_DEFAULT_QUERY_SIZE * 3 + 1,
+                "%s %s ORDER BY a.%s", query_string, query_where,
+                mb_svc_media_order[filter->sort_type]);
+
+       if (filter->start_pos != MB_SVC_DB_DEFAULT_GET_ALL_RECORDS) {   /* -1 get all record */
+               int length = filter->end_pos - filter->start_pos + 1;
+               if (length <= 0) {
+                       mb_svc_debug
+                           ("start position and end position is invalid ( start:%d, end:%d )",
+                            filter->start_pos, filter->end_pos);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+
+               snprintf(tmp_str, sizeof(tmp_str), " LIMIT %d,%d",
+                        filter->start_pos, length);
+               strncat(query_complete_string, tmp_str,
+                       sizeof(query_complete_string));
+       }
+
+       mb_svc_debug("############### SQL: %s\n", query_complete_string);
+
+       mb_svc_iterator->current_position = 0;
+
+       err =
+           sqlite3_prepare_v2(handle, query_complete_string,
+                              strlen(query_complete_string),
+                              &mb_svc_iterator->stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_complete_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int
+mb_svc_media_iter_start_new(const char *folder_id, minfo_item_filter *filter,
+                           minfo_folder_type folder_type, int valid,
+                           GList *p_folder_id_list,
+                           mb_svc_iterator_s *mb_svc_iterator)
+{
+       int err = -1;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       char query_complete_string[MB_SVC_DEFAULT_QUERY_SIZE * 3 + 1] = { 0 };
+       char query_where[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       char condition_str[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       int len = 0;
+
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+       snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
+                MB_SVC_TBL_NAME_MEDIA);
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (mb_svc_iterator == NULL || filter == NULL) {
+               mb_svc_debug("Error:mb_svc_iterator == NULL || filter == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+       if (filter->start_pos >= 0 && filter->start_pos > filter->end_pos) {
+               mb_svc_debug(" filter->start_pos (%d) > filter->end_pos (%d)",
+                            filter->start_pos, filter->end_pos);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       snprintf(query_string, sizeof(query_string), MB_SVC_SELECT_ALL_MEDIA,
+                table_name);
+
+       if (valid) {
+               strncpy(query_where,
+                       " f.uuid = m.folder_uuid and m.valid=1 and f.valid=1 ",
+                       sizeof(query_where));
+       } else {
+               strncpy(query_where,
+                       " f.uuid = m.folder_uuid and m.valid=0 and f.valid=0 ",
+                       sizeof(query_where));
+       }
+
+       if (filter->favorite == MINFO_MEDIA_FAV_ONLY) {
+               len =
+                   g_strlcat(query_where, " and m.rating = 1 ",
+                             sizeof(query_where));
+               if (len >= sizeof(query_where)) {
+                       mb_svc_debug("strlcat returns failure ( %d )", len);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       } else if (filter->favorite == MINFO_MEDIA_UNFAV_ONLY) {
+               len =
+                   g_strlcat(query_where, " and m.rating = 0 ",
+                             sizeof(query_where));
+               if (len >= sizeof(query_where)) {
+                       mb_svc_debug("strlcat returns failure ( %d )", len);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       memset(condition_str, 0x00, sizeof(condition_str));
+
+       if (folder_id != NULL) {
+               int len =
+                   snprintf(condition_str, sizeof(condition_str),
+                            " and folder_uuid = '%s' ", folder_id);
+               if (len < 0) {
+                       mb_svc_debug("snprintf returns failure ( %d )", len);
+                       condition_str[0] = '\0';
+               } else {
+                       condition_str[len] = '\0';
+               }
+
+               len =
+                   g_strlcat(query_where, condition_str, sizeof(query_where));
+               if (len >= sizeof(query_where)) {
+                       mb_svc_debug("strlcat returns failure ( %d )", len);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       } else {
+               int len =
+                   snprintf(condition_str, sizeof(condition_str),
+                            " and lock_status = 0 ");
+               if (len < 0) {
+                       mb_svc_debug("snprintf returns failure ( %d )", len);
+                       condition_str[0] = '\0';
+               } else {
+                       condition_str[len] = '\0';
+               }
+
+               len =
+                   g_strlcat(query_where, condition_str, sizeof(query_where));
+               if (len >= sizeof(query_where)) {
+                       mb_svc_debug("strlcat returns failure ( %d )", len);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       memset(condition_str, 0x00, sizeof(condition_str));
+
+       if (folder_type != MINFO_CLUSTER_TYPE_ALL) {
+               switch (folder_type) {
+               case MINFO_CLUSTER_TYPE_LOCAL_ALL:
+                       snprintf(condition_str, sizeof(condition_str),
+                                " and (storage_type = %d or storage_type = %d)",
+                                MINFO_PHONE, MINFO_MMC);
+                       break;
+               case MINFO_CLUSTER_TYPE_LOCAL_PHONE:
+                       snprintf(condition_str, sizeof(condition_str),
+                                " and storage_type = %d ", MINFO_PHONE);
+                       break;
+               case MINFO_CLUSTER_TYPE_LOCAL_MMC:
+                       snprintf(condition_str, sizeof(condition_str),
+                                " and storage_type = %d ", MINFO_MMC);
+                       break;
+               case MINFO_CLUSTER_TYPE_WEB:
+                       snprintf(condition_str, sizeof(condition_str),
+                                " and storage_type = %d ", MINFO_WEB);
+                       break;
+               case MINFO_CLUSTER_TYPE_STREAMING:
+                       snprintf(condition_str, sizeof(condition_str),
+                                " and storage_type = %d ",
+                                MINFO_WEB_STREAMING);
+                       break;
+               default:
+                       break;
+               }
+
+               len =
+                   g_strlcat(query_where, condition_str, sizeof(query_where));
+               if (len >= sizeof(query_where)) {
+                       mb_svc_debug("strlcat returns failure ( %d )", len);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       memset(condition_str, 0x00, sizeof(condition_str));
+       len =
+           snprintf(condition_str, sizeof(condition_str),
+                    " and (content_type = 0");
+       if (len < 0) {
+               mb_svc_debug("snprintf returns failure ( %d )", len);
+               condition_str[0] = '\0';
+       } else {
+               condition_str[len] = '\0';
+       }
+
+       len = g_strlcat(query_where, condition_str, sizeof(query_where));
+       if (len >= sizeof(query_where)) {
+               mb_svc_debug("strlcat returns failure ( %d )", len);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       memset(condition_str, 0x00, sizeof(condition_str));
+       if (filter->file_type & MINFO_ITEM_ALL) {
+               filter->file_type = MINFO_ITEM_IMAGE | MINFO_ITEM_VIDEO;
+       }
+
+       if (filter->file_type & MINFO_ITEM_IMAGE) {
+               len =
+                   snprintf(condition_str, sizeof(condition_str),
+                            " or content_type = %d", MINFO_ITEM_IMAGE);
+               if (len < 0) {
+                       mb_svc_debug("snprintf returns failure ( %d )", len);
+                       condition_str[0] = '\0';
+               } else {
+                       condition_str[len] = '\0';
+               }
+       }
+
+       len = g_strlcat(query_where, condition_str, sizeof(query_where));
+       if (len >= sizeof(query_where)) {
+               mb_svc_debug("strlcat returns failure ( %d )", len);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       memset(condition_str, 0x00, sizeof(condition_str));
+       if (filter->file_type & MINFO_ITEM_VIDEO) {
+               len =
+                   snprintf(condition_str, sizeof(condition_str),
+                            " or content_type = %d", MINFO_ITEM_VIDEO);
+               if (len < 0) {
+                       mb_svc_debug("snprintf returns failure ( %d )", len);
+                       condition_str[0] = '\0';
+               } else {
+                       condition_str[len] = '\0';
+               }
+       }
+
+       len = g_strlcat(condition_str, ")", sizeof(condition_str));
+       if (len >= sizeof(condition_str)) {
+               mb_svc_debug("strlcat returns failure ( %d )", len);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       len = g_strlcat(query_where, condition_str, sizeof(query_where));
+       if (len >= sizeof(query_where)) {
+               mb_svc_debug("strlcat returns failure ( %d )", len);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       len =
+           snprintf(query_complete_string, sizeof(query_complete_string),
+                    "%s %s ORDER BY m.%s", query_string, query_where,
+                    mb_svc_media_order[filter->sort_type]);
+       if (len < 0) {
+               mb_svc_debug("snprintf returns failure ( %d )", len);
+               query_complete_string[0] = '\0';
+       } else {
+               query_complete_string[len] = '\0';
+       }
+
+       memset(condition_str, 0x00, sizeof(condition_str));
+
+       if (filter->start_pos != MB_SVC_DB_DEFAULT_GET_ALL_RECORDS)     {/* -1 get all record */
+               int length = filter->end_pos - filter->start_pos + 1;
+               if (length <= 0) {
+                       mb_svc_debug
+                           ("start position and end position is invalid ( start:%d, end:%d )",
+                            filter->start_pos, filter->end_pos);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+
+               len =
+                   snprintf(condition_str, sizeof(condition_str),
+                            " LIMIT %d,%d", filter->start_pos, length);
+               if (len < 0) {
+                       mb_svc_debug("snprintf returns failure ( %d )", len);
+                       condition_str[0] = '\0';
+               } else {
+                       condition_str[len] = '\0';
+               }
+               len =
+                   g_strlcat(query_complete_string, condition_str,
+                             sizeof(query_complete_string));
+               if (len >= sizeof(query_complete_string)) {
+                       mb_svc_debug("strlcat returns failure ( %d )", len);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       mb_svc_debug("############### SQL: %s\n", query_complete_string);
+
+       mb_svc_iterator->current_position = 0;
+
+       err =
+           sqlite3_prepare_v2(handle, query_complete_string,
+                              strlen(query_complete_string),
+                              &mb_svc_iterator->stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_complete_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int 
+mb_svc_media_search_iter_start(minfo_search_field_t search_field, 
+                                                               const char *search_str, 
+                                                               minfo_folder_type folder_type,
+                                                               minfo_item_filter filter, 
+                                                               mb_svc_iterator_s *mb_svc_iterator)
+{
+       int err = -1;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       char query_complete_string[MB_SVC_DEFAULT_QUERY_SIZE * 3 + 1] = { 0 };
+       char query_where[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       char condition_str[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       int len = 0;
+       char *like_str = NULL;
+
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+       snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
+                MB_SVC_TBL_NAME_MEDIA);
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (mb_svc_iterator == NULL) {
+               mb_svc_debug("Error:mb_svc_iterator == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (filter.start_pos >= 0 && filter.start_pos > filter.end_pos) {
+               mb_svc_debug(" filter.start_pos (%d) > filter.end_pos (%d) = %d\n",
+                            filter.start_pos, filter.end_pos);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       snprintf(query_string, sizeof(query_string), MB_SVC_SELECT_ALL_MEDIA,
+                table_name);
+
+       strncpy(query_where,
+               " f.uuid = m.folder_uuid and m.valid=1 and f.valid=1 ",
+               sizeof(query_where));
+
+       if (filter.favorite == MINFO_MEDIA_FAV_ONLY) {
+               len =
+                   g_strlcat(query_where, " and m.rating = 1 ",
+                             sizeof(query_where));
+               if (len >= sizeof(query_where)) {
+                       mb_svc_debug("strlcat returns failure ( %d )", len);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       } else if (filter.favorite == MINFO_MEDIA_UNFAV_ONLY) {
+               len =
+                   g_strlcat(query_where, " and m.rating = 0 ",
+                             sizeof(query_where));
+               if (len >= sizeof(query_where)) {
+                       mb_svc_debug("strlcat returns failure ( %d )", len);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       memset(condition_str, 0x00, sizeof(condition_str));
+
+       if (folder_type != MINFO_CLUSTER_TYPE_ALL) {
+               switch (folder_type) {
+               case MINFO_CLUSTER_TYPE_LOCAL_ALL:
+                       snprintf(condition_str, sizeof(condition_str),
+                                " and (storage_type = %d or storage_type = %d)",
+                                MINFO_PHONE, MINFO_MMC);
+                       break;
+               case MINFO_CLUSTER_TYPE_LOCAL_PHONE:
+                       snprintf(condition_str, sizeof(condition_str),
+                                " and storage_type = %d ", MINFO_PHONE);
+                       break;
+               case MINFO_CLUSTER_TYPE_LOCAL_MMC:
+                       snprintf(condition_str, sizeof(condition_str),
+                                " and storage_type = %d ", MINFO_MMC);
+                       break;
+               case MINFO_CLUSTER_TYPE_WEB:
+                       snprintf(condition_str, sizeof(condition_str),
+                                " and storage_type = %d ", MINFO_WEB);
+                       break;
+               case MINFO_CLUSTER_TYPE_STREAMING:
+                       snprintf(condition_str, sizeof(condition_str),
+                                " and storage_type = %d ",
+                                MINFO_WEB_STREAMING);
+                       break;
+               default:
+                       break;
+               }
+
+               len =
+                   g_strlcat(query_where, condition_str, sizeof(query_where));
+               if (len >= sizeof(query_where)) {
+                       mb_svc_debug("strlcat returns failure ( %d )", len);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       memset(condition_str, 0x00, sizeof(condition_str));
+       len =
+           snprintf(condition_str, sizeof(condition_str),
+                    " and (content_type = 0");
+       if (len < 0) {
+               mb_svc_debug("snprintf returns failure ( %d )", len);
+               condition_str[0] = '\0';
+       } else {
+               condition_str[len] = '\0';
+       }
+
+       len = g_strlcat(query_where, condition_str, sizeof(query_where));
+       if (len >= sizeof(query_where)) {
+               mb_svc_debug("strlcat returns failure ( %d )", len);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       memset(condition_str, 0x00, sizeof(condition_str));
+       if (filter.file_type & MINFO_ITEM_ALL) {
+               filter.file_type = MINFO_ITEM_IMAGE | MINFO_ITEM_VIDEO;
+       }
+
+       if (filter.file_type & MINFO_ITEM_IMAGE) {
+               len =
+                   snprintf(condition_str, sizeof(condition_str),
+                            " or content_type = %d", MINFO_ITEM_IMAGE);
+               if (len < 0) {
+                       mb_svc_debug("snprintf returns failure ( %d )", len);
+                       condition_str[0] = '\0';
+               } else {
+                       condition_str[len] = '\0';
+               }
+       }
+
+       len = g_strlcat(query_where, condition_str, sizeof(query_where));
+       if (len >= sizeof(query_where)) {
+               mb_svc_debug("strlcat returns failure ( %d )", len);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       memset(condition_str, 0x00, sizeof(condition_str));
+       if (filter.file_type & MINFO_ITEM_VIDEO) {
+               len =
+                   snprintf(condition_str, sizeof(condition_str),
+                            " or content_type = %d", MINFO_ITEM_VIDEO);
+               if (len < 0) {
+                       mb_svc_debug("snprintf returns failure ( %d )", len);
+                       condition_str[0] = '\0';
+               } else {
+                       condition_str[len] = '\0';
+               }
+       }
+
+       len = g_strlcat(condition_str, ") ", sizeof(condition_str));
+       if (len >= sizeof(condition_str)) {
+               mb_svc_debug("strlcat returns failure ( %d )", len);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       len = g_strlcat(query_where, condition_str, sizeof(query_where));
+       if (len >= sizeof(query_where)) {
+               mb_svc_debug("strlcat returns failure ( %d )", len);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+/*
+       switch (search_field) {
+               case MINFO_SEARCH_BY_NAME:
+                       like_str = sqlite3_mprintf("and display_name like '%%%s%%' ", search_str);
+                       break;
+               case MINFO_SEARCH_BY_PATH:
+                       like_str = sqlite3_mprintf("and path like '%%%s%%' ", search_str);
+                       break;
+               case MINFO_SEARCH_BY_HTTP_URL:
+                       like_str = sqlite3_mprintf("and http_url like '%%%s%%' ", search_str);
+                       break;
+               default:
+                       break;
+       }
+*/
+       if (search_field & MINFO_SEARCH_BY_NAME) {
+               like_str = sqlite3_mprintf("and (display_name like '%%%q%%' ", search_str);
+
+               len = g_strlcat(query_where, like_str, sizeof(query_where));
+               sqlite3_free(like_str);
+
+               if (len >= sizeof(query_where)) {
+                       mb_svc_debug("strlcat returns failure ( %d )", len);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       if (search_field & MINFO_SEARCH_BY_PATH) {
+               if (search_field & MINFO_SEARCH_BY_NAME) {
+                       like_str = sqlite3_mprintf("or m.path like '%%%q%%' ", search_str);
+               } else {
+                       like_str = sqlite3_mprintf("and (m.path like '%%%q%%' ", search_str);
+               }
+
+               len = g_strlcat(query_where, like_str, sizeof(query_where));
+               sqlite3_free(like_str);
+
+               if (len >= sizeof(query_where)) {
+                       mb_svc_debug("strlcat returns failure ( %d )", len);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       if (search_field & MINFO_SEARCH_BY_HTTP_URL) {
+               if ((search_field & MINFO_SEARCH_BY_NAME) || (search_field & MINFO_SEARCH_BY_PATH)) {
+                       like_str = sqlite3_mprintf("or http_url like '%%%q%%' ", search_str);
+               } else {
+                       like_str = sqlite3_mprintf("and (http_url like '%%%q%%' ", search_str);
+               }
+
+               len = g_strlcat(query_where, like_str, sizeof(query_where));
+               sqlite3_free(like_str);
+
+               if (len >= sizeof(query_where)) {
+                       mb_svc_debug("strlcat returns failure ( %d )", len);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       len = g_strlcat(query_where, ") ", sizeof(query_where));
+
+       if (len >= sizeof(query_where)) {
+               mb_svc_debug("strlcat returns failure ( %d )", len);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+       
+       len =
+           snprintf(query_complete_string, sizeof(query_complete_string),
+                    "%s %s ORDER BY m.%s", query_string, query_where,
+                    mb_svc_media_order[filter.sort_type]);
+       if (len < 0) {
+               mb_svc_debug("snprintf returns failure ( %d )", len);
+               query_complete_string[0] = '\0';
+       } else {
+               query_complete_string[len] = '\0';
+       }
+
+       memset(condition_str, 0x00, sizeof(condition_str));
+
+       if (filter.start_pos != MB_SVC_DB_DEFAULT_GET_ALL_RECORDS)      {/* -1 get all record */
+               int length = filter.end_pos - filter.start_pos + 1;
+               if (length <= 0) {
+                       mb_svc_debug
+                           ("start position and end position is invalid ( start:%d, end:%d )",
+                            filter.start_pos, filter.end_pos);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+
+               len =
+                   snprintf(condition_str, sizeof(condition_str),
+                            " LIMIT %d,%d", filter.start_pos, length);
+               if (len < 0) {
+                       mb_svc_debug("snprintf returns failure ( %d )", len);
+                       condition_str[0] = '\0';
+               } else {
+                       condition_str[len] = '\0';
+               }
+               len =
+                   g_strlcat(query_complete_string, condition_str,
+                             sizeof(query_complete_string));
+               if (len >= sizeof(query_complete_string)) {
+                       mb_svc_debug("strlcat returns failure ( %d )", len);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       mb_svc_debug("############### SQL: %s\n", query_complete_string);
+
+       mb_svc_iterator->current_position = 0;
+
+       err =
+           sqlite3_prepare_v2(handle, query_complete_string,
+                              strlen(query_complete_string),
+                              &mb_svc_iterator->stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_complete_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int
+mb_svc_media_iter_next(mb_svc_iterator_s *mb_svc_iterator,
+                      mb_svc_media_record_s *record)
+{
+       int err = -1;
+
+       /* mb_svc_debug ("mb_svc_media_iter_next--enter\n"); */
+
+       if (mb_svc_iterator == NULL) {
+               mb_svc_debug("mb_svc_iterator == NULL || record == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       err = sqlite3_step(mb_svc_iterator->stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of iteration : count = %d\n",
+                            mb_svc_iterator->current_position);
+               return MB_SVC_NO_RECORD_ANY_MORE;
+       }
+
+       if (record) {
+               err = mb_svc_load_record_media(mb_svc_iterator->stmt, record);
+               if (err < 0) {
+                       mb_svc_debug("failed to load item\n");
+                       sqlite3_finalize(mb_svc_iterator->stmt);
+                       mb_svc_iterator->current_position = -1;
+                       return MB_SVC_ERROR_DB_INTERNAL;
+               }
+       }
+       mb_svc_iterator->current_position++;
+
+       return 0;
+}
+
+int mb_svc_iter_finish(mb_svc_iterator_s *mb_svc_iterator)
+{
+       int err = -1;
+
+       /* mb_svc_debug ("mb_svc_iter_finish---enter\n"); */
+
+       if (mb_svc_iterator == NULL) {
+               mb_svc_debug("Error:mb_svc_iterator == NULL \n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       err = sqlite3_finalize(mb_svc_iterator->stmt);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("failed to clear row\n");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       mb_svc_iterator->current_position = -1;
+       mb_svc_iterator->total_count = -1;
+       mb_svc_iterator->stmt = NULL;
+
+       /* mb_svc_debug ("mb_svc_iter_finish---leave\n"); */
+       return 0;
+}
+
+int
+mb_svc_get_video_record_by_media_id(const char *media_id,
+                                   mb_svc_video_meta_record_s *
+                                   video_meta_record)
+{
+
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_VIDEO_META;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       sqlite3_stmt *p_Stmt_mb = NULL;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (video_meta_record == NULL) {
+               mb_svc_debug("folder path is null \n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       snprintf(query_string, sizeof(query_string),
+                MB_SVC_TABLE_SELECT_VIDEO_BY_MUUID, table_name,
+                media_id);
+
+       mb_svc_debug("Query: %s", query_string);
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &p_Stmt_mb, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = sqlite3_step(p_Stmt_mb);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               sqlite3_finalize(p_Stmt_mb);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       mb_svc_load_record_video_meta(p_Stmt_mb, video_meta_record);
+
+       sqlite3_finalize(p_Stmt_mb);
+
+       return 0;
+
+}
+
+/*
+*
+*   get video by media_id from "video_meta" table, 
+*   condition: each video_meta record mapped to  media_id one by one
+*/
+int
+mb_svc_get_image_record_by_media_id(const char *media_id,
+                                   mb_svc_image_meta_record_s *
+                                   image_meta_record)
+{
+
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_IMAGE_META;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       sqlite3_stmt *stmt = NULL;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (image_meta_record == NULL) {
+               mb_svc_debug("folder path is null \n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       snprintf(query_string, sizeof(query_string),
+                MB_SVC_TABLE_SELECT_IMAGE_BY_MUUID, table_name,
+                media_id);
+
+       mb_svc_debug("Query: %s", query_string);
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = sqlite3_step(stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       mb_svc_load_record_image_meta(stmt, image_meta_record);
+
+       sqlite3_finalize(stmt);
+
+       return 0;
+
+}
+
+int
+mb_svc_get_folder_fullpath_by_folder_id(const char *folder_id, char *folder_fullpath,
+                                       int max_length)
+{
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_FOLDER;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       sqlite3_stmt *stmt = NULL;
+       char uri[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       int ret_len = 0;
+       char *tmp = NULL;
+
+       /* mb_svc_debug ("mb_svc_get_folder_fullpath_by_folder_id--enter\n"); */
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (folder_fullpath == NULL) {
+               mb_svc_debug("folder path is null \n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret_len =
+           snprintf(query_string, sizeof(query_string),
+                    MB_SVC_TABLE_SELECT_FOLDER_URI_BY_FUUID,
+                    table_name, folder_id);
+
+       if (ret_len >= sizeof(query_string)) {
+               mb_svc_debug("the query string's length is violation!\n");
+               return MB_SVC_ERROR_INTERNAL;
+       } else if (ret_len < 0) {
+               mb_svc_debug("snprintf failed!\n");
+               return MB_SVC_ERROR_INTERNAL;
+       }
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = sqlite3_step(stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       /* only one field(uri) selected, so the second para of *_text is int 0, means the first one of the selected result. */
+       tmp = (char *)sqlite3_column_text(stmt, 0);
+       if (strlen(tmp) >= sizeof(uri)) {
+               mb_svc_debug("real uri's length is violation!\n");
+               return MB_SVC_ERROR_INTERNAL;
+       }
+
+       strncpy(uri, (const char *)tmp, sizeof(uri));   /* get path of folder */
+       strncpy(folder_fullpath, uri, max_length);
+       mb_svc_debug("Full path : %s", folder_fullpath);
+
+       sqlite3_finalize(stmt);
+
+       return 0;
+}
+
+int
+mb_svc_get_media_fullpath(const char *folder_id, char *media_display_name,
+                         char *media_fullpath)
+{
+       int err = -1;
+       char folder_fullpath[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+
+       if (media_display_name == NULL || media_fullpath == NULL) {
+               mb_svc_debug("Error: NULL pointer  \n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+       err =
+           mb_svc_get_folder_fullpath_by_folder_id(folder_id, folder_fullpath,
+                                                   sizeof(folder_fullpath));
+       if (err < 0) {
+               mb_svc_debug("get folder fullpath error\n");
+               return err;
+       }
+
+       strncat(folder_fullpath, "/",
+               MB_SVC_FILE_PATH_LEN_MAX - strlen(folder_fullpath));
+       strncat(folder_fullpath, media_display_name,
+               MB_SVC_FILE_PATH_LEN_MAX - strlen(folder_fullpath));
+       strncpy(media_fullpath, folder_fullpath, MB_SVC_FILE_PATH_LEN_MAX);
+
+       return 0;
+}
+
+int
+mb_svc_folder_iter_start(minfo_cluster_filter *cluster_filter,
+                        mb_svc_iterator_s *mb_svc_iterator)
+{
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_FOLDER;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       char query_where[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       char tmp_str[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+
+       mb_svc_debug("mb_svc_folder_iter_start--enter\n");
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (cluster_filter == NULL || mb_svc_iterator == NULL) {
+               mb_svc_debug
+                   ("cluster_filter == NULL || mb_svc_iterator == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (cluster_filter->start_pos >= 0
+           && cluster_filter->start_pos > cluster_filter->end_pos) {
+               mb_svc_debug(" cluster_filter->start_pos (%d) > cluster_filter->end_pos (%d) = %d\n",
+                            cluster_filter->start_pos, cluster_filter->end_pos);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+       strncpy(query_where, " WHERE valid = 1 ", MB_SVC_DEFAULT_QUERY_SIZE);
+
+       snprintf(query_string, MB_SVC_DEFAULT_QUERY_SIZE,
+                MB_SVC_TABLE_SELECT_FOLDER_ALL_QUERY_STRING, table_name);
+
+       if (cluster_filter->cluster_type != MINFO_CLUSTER_TYPE_ALL) {
+               switch (cluster_filter->cluster_type) {
+               case MINFO_CLUSTER_TYPE_LOCAL_ALL:
+                       snprintf(tmp_str, sizeof(tmp_str),
+                                " and (storage_type = %d or storage_type = %d)",
+                                MINFO_PHONE, MINFO_MMC);
+                       break;
+               case MINFO_CLUSTER_TYPE_LOCAL_PHONE:
+                       snprintf(tmp_str, sizeof(tmp_str),
+                                " and storage_type = %d ", MINFO_PHONE);
+                       break;
+               case MINFO_CLUSTER_TYPE_LOCAL_MMC:
+                       snprintf(tmp_str, sizeof(tmp_str),
+                                " and storage_type = %d ", MINFO_MMC);
+                       break;
+               case MINFO_CLUSTER_TYPE_WEB:
+                       snprintf(tmp_str, sizeof(tmp_str),
+                                " and storage_type = %d ", MINFO_WEB);
+                       break;
+               case MINFO_CLUSTER_TYPE_STREAMING:
+                       snprintf(tmp_str, sizeof(tmp_str),
+                                " and storage_type = %d ",
+                                MINFO_WEB_STREAMING);
+                       break;
+               default:
+                       break;
+               }
+               strncat(query_where, tmp_str,
+                       MB_SVC_DEFAULT_QUERY_SIZE - strlen(tmp_str));
+       }
+       strncat(query_string, query_where,
+               MB_SVC_DEFAULT_QUERY_SIZE - strlen(query_string));
+       strncat(query_string, " ORDER BY ",
+               MB_SVC_DEFAULT_QUERY_SIZE - strlen(query_string));
+       strncat(query_string, mb_svc_folder_order[cluster_filter->sort_type],
+               MB_SVC_DEFAULT_QUERY_SIZE - strlen(query_string));
+
+       if (cluster_filter->start_pos != MB_SVC_DB_DEFAULT_GET_ALL_RECORDS)     {/* -1 get all record */
+               int length =
+                   cluster_filter->end_pos - cluster_filter->start_pos + 1;
+               if (length <= 0) {
+                       mb_svc_debug
+                           ("start position and end position is invalid ( start:%d, end:%d )",
+                            cluster_filter->start_pos,
+                            cluster_filter->end_pos);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+
+               snprintf(tmp_str, sizeof(tmp_str), " LIMIT %d,%d",
+                        cluster_filter->start_pos, length);
+               strcat(query_string, tmp_str);
+       }
+
+       mb_svc_debug("############### SQL: %s\n", query_string);
+
+       mb_svc_iterator->current_position = 0;
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &mb_svc_iterator->stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+static int __mb_svc_folder_by_path_iter_start(char *parent_path, mb_svc_iterator_s *mb_svc_iterator)
+{
+       mb_svc_debug("");
+
+       if (parent_path == NULL || mb_svc_iterator == NULL) {
+               mb_svc_debug("parent_path == NULL || mb_svc_iterator == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = -1;
+       char *query_string = NULL;
+       char path_like[MB_SVC_FILE_PATH_LEN_MAX + 1];
+
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+       snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
+                MB_SVC_TBL_NAME_FOLDER);
+       snprintf(path_like, sizeof(path_like), "%s/%%", parent_path);
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_SELECT_FOLDER_BY_PATH, table_name,
+                           parent_path, path_like);
+       mb_svc_debug("############### SQL: %s\n", query_string);
+
+       mb_svc_iterator->current_position = 0;
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &mb_svc_iterator->stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int
+mb_svc_folder_iter_next(mb_svc_iterator_s *mb_svc_iterator,
+                       mb_svc_folder_record_s *record)
+{
+       int err = -1;
+
+       if (mb_svc_iterator == NULL) {
+               mb_svc_debug("pointer mb_svc_iterator is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       err = sqlite3_step(mb_svc_iterator->stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of iteration : count = %d\n",
+                            mb_svc_iterator->current_position);
+               return MB_SVC_NO_RECORD_ANY_MORE;
+       }
+
+       if (record) {
+               err = mb_svc_load_record_folder(mb_svc_iterator->stmt, record);
+               if (err < 0) {
+                       mb_svc_debug("failed to load item\n");
+                       sqlite3_finalize(mb_svc_iterator->stmt);
+                       mb_svc_iterator->current_position = -1;
+                       return MB_SVC_ERROR_DB_INTERNAL;
+               }
+       }
+
+       mb_svc_iterator->current_position++;
+
+       return 0;
+}
+
+/*
+*
+* get folder content count from media table according to specified folder ID
+*/
+int mb_svc_get_folder_content_count_by_folder_id(const char *folder_id)
+{
+       char q_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       int rc = 0;
+       sqlite3_stmt *stmt = NULL;
+       int count = 0;
+       int err = -1;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+
+
+       snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
+                MB_SVC_TBL_NAME_MEDIA);
+
+       snprintf(q_string, sizeof(q_string),
+                MB_SVC_FOLDER_CONTENT_COUNT_BY_FUUID, table_name,
+                folder_id);
+
+       mb_svc_debug("Query : %s", q_string);
+
+       err =
+           sqlite3_prepare_v2(handle, q_string, strlen(q_string), &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", q_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       rc = sqlite3_step(stmt);
+       while (rc == SQLITE_ROW) {
+               count = sqlite3_column_int(stmt, 0);
+               rc = sqlite3_step(stmt);
+       }
+       sqlite3_finalize(stmt);
+
+       stmt = NULL;
+       mb_svc_debug("record count of table %s is %d\n", table_name, count);
+       return count;
+}
+
+/**
+*   caller need to provide memory space for storing bookmark_record
+*/
+int
+mb_svc_get_bookmark_record_by_id(int record_id,
+                                mb_svc_bookmark_record_s *record)
+{
+       sqlite3_stmt *stmt = NULL;
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_BOOKMARK;
+       char q_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (record == NULL) {
+               mb_svc_debug(" record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int len =
+           snprintf(q_string, sizeof(q_string),
+                    MB_SVC_TABLE_SELECT_BOOKMARK_BY_BID_QUERY_STRING,
+                    table_name, record_id);
+       if (len < 0) {
+               mb_svc_debug("snprintf returns failure ( %d )", len);
+               q_string[0] = '\0';
+       } else {
+               q_string[len] = '\0';
+       }
+
+       mb_svc_debug("Query: %s", q_string);
+
+       err =
+           sqlite3_prepare_v2(handle, q_string, strlen(q_string), &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", q_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = sqlite3_step(stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", q_string);
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       mb_svc_load_record_bookmark(stmt, record);
+       mb_svc_debug(" bookmark record thumbnail path = %s\n",
+                    record->thumbnail_path);
+
+       sqlite3_finalize(stmt);
+       stmt = NULL;
+
+       return 0;
+}
+
+/**
+*   caller need to provide memory space for storing bookmark_record
+*/
+int mb_svc_get_media_tag_by_id(int _id, mb_svc_tag_record_s *mtag_record)
+{
+       sqlite3_stmt *stmt = NULL;
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_TAG;
+       char q_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+
+       if (mtag_record == NULL) {
+               mb_svc_debug(" record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       snprintf(q_string, sizeof(q_string),
+                MB_SVC_TABLE_SELECT_TAG_BY_TID_QUERY_STRING, table_name, _id);
+       mb_svc_debug("Query: %s", q_string);
+
+       err =
+           sqlite3_prepare_v2(handle, q_string, strlen(q_string), &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", q_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = sqlite3_step(stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", q_string);
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       mb_svc_load_record_tag(stmt, mtag_record);
+       mb_svc_debug(" tag record tag name = %s and media_id is %s!\n",
+                    mtag_record->tag_name, mtag_record->media_uuid);
+
+       sqlite3_finalize(stmt);
+       stmt = NULL;
+
+       return 0;
+}
+
+int
+mb_svc_get_web_album_cluster_record(int sns_type, const char *name, const char *account_id, const char *album_id, mb_svc_folder_record_s *folder_record)
+{
+       int err = -1;
+       sqlite3_stmt *stmt = NULL;
+       char *table_name = MB_SVC_TBL_NAME_FOLDER;
+       char *query_string = NULL;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if(album_id == NULL) {
+               query_string = sqlite3_mprintf(MB_SVC_TABLE_SELECT_WEB_CLUSTER_RECORD_QUERY_STRING,
+                                                                               table_name, sns_type, name, account_id);
+       }else {
+               query_string = sqlite3_mprintf(MB_SVC_TABLE_SELECT_WEB_ALBUM_CLUSTER_RECORD_QUERY_STRING,
+                                                                               table_name, sns_type, name, account_id, album_id);
+       }
+       
+       err = sqlite3_prepare_v2(handle, query_string, strlen(query_string), &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_free(query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = sqlite3_step(stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_free(query_string);
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = mb_svc_load_record_folder(stmt, folder_record);
+       if (err < 0) {
+               mb_svc_debug("mb-svc load data failed");
+               sqlite3_free(query_string);
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       sqlite3_free(query_string);
+       sqlite3_finalize(stmt);
+
+       return 0;
+}
+
+int
+mb_svc_get_folder_list_by_web_account_id(char *web_account,
+                                        GList **p_record_list)
+{
+       int record_cnt = 0;
+       mb_svc_folder_record_s *fd_record;
+       int err = -1;
+       GList *l_record_list = NULL;
+       mb_svc_iterator_s mb_svc_iterator;
+       minfo_cluster_filter cluster_filter = { 0 };
+
+       if (web_account == NULL || p_record_list == NULL) {
+               mb_svc_debug
+                   ("Error: web_account == NULL || p_record_list == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       cluster_filter.cluster_type = MINFO_CLUSTER_TYPE_WEB;
+       cluster_filter.sort_type = MINFO_CLUSTER_SORT_BY_NONE;
+       cluster_filter.start_pos = MB_SVC_DB_DEFAULT_GET_ALL_RECORDS;
+
+       err = mb_svc_folder_iter_start(&cluster_filter, &mb_svc_iterator);
+
+       if (err == MB_SVC_ERROR_DB_NO_RECORD) {
+               return err;
+       } else if (err < 0) {
+               mb_svc_debug("mb-svc iterator start failed\n");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (1) {
+               fd_record =
+                   (mb_svc_folder_record_s *)
+                   malloc(sizeof(mb_svc_folder_record_s));
+               if (fd_record == NULL) {
+                       mb_svc_debug("allocate memory failed\n");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       return MB_SVC_ERROR_OUT_OF_MEMORY;
+               }
+               memset(fd_record, 0x00, sizeof(mb_svc_folder_record_s));
+
+               err = mb_svc_folder_iter_next(&mb_svc_iterator, fd_record);
+               if (err == MB_SVC_NO_RECORD_ANY_MORE) {
+                       free(fd_record);
+                       fd_record = NULL;
+                       break;
+               }
+
+               if (err < 0) {
+                       mb_svc_debug
+                           ("mb-svc iterator get next recrod failed\n");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       free(fd_record);
+                       return err;
+               }
+
+               if (strcmp(fd_record->web_account_id, web_account)) {
+                       free(fd_record);
+                       mb_svc_debug
+                           ("mb-svc iterator -------different get next\n ");
+                       continue;
+               }
+
+               record_cnt++;
+               l_record_list = g_list_append(l_record_list, fd_record);
+       }
+
+       mb_svc_iter_finish(&mb_svc_iterator);
+       *p_record_list = l_record_list;
+
+       if (record_cnt == 0)
+               return MB_SVC_ERROR_DB_NO_RECORD;
+       else
+               return 0;
+}
+
+static int __mb_svc_get_folder_record_by_path_info(const char *uri, char *display_name,
+                                                                               minfo_store_type storage_type, mb_svc_folder_record_s *record)
+{
+       int err = -1;
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+       char *query_string = NULL;
+
+       sqlite3_stmt *stmt = NULL;
+       if (record == NULL || uri == NULL || display_name == NULL) {
+               mb_svc_debug("pointer image_meta_record is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
+                MB_SVC_TBL_NAME_FOLDER);
+
+       query_string = sqlite3_mprintf(MB_SVC_TABLE_SELECT_FOLDER_BY_PATH_INFO,
+                                                                       table_name, uri, display_name, storage_type);
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_free(query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = sqlite3_step(stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_free(query_string);
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = mb_svc_load_record_folder(stmt, record);
+       if (err < 0) {
+               mb_svc_debug("mb-svc load data failed");
+               sqlite3_free(query_string);
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       sqlite3_free(query_string);
+       sqlite3_finalize(stmt);
+
+       return 0;
+}
+
+static int __mb_svc_get_folder_record_by_full_path(const char *folder_full_path,
+                                     mb_svc_folder_record_s *folder_record)
+{
+       minfo_store_type store_type = MINFO_SYSTEM;
+       int err = -1;
+       char display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+
+       if (folder_full_path == NULL || folder_record == NULL) {
+               mb_svc_debug
+                   ("Error:folder_full_path == NULL || folder_record == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       store_type = _mb_svc_get_store_type_by_full(folder_full_path);
+       if (store_type == MB_SVC_ERROR_INTERNAL) {
+               mb_svc_debug("Failed to get storage type : %s",
+                            folder_full_path);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       _mb_svc_get_dir_display_name(folder_full_path, display_name);
+
+       err = __mb_svc_get_folder_record_by_path_info(folder_full_path, display_name, store_type, folder_record);
+       if (err < 0) {
+               mb_svc_debug
+                   ("Error:get folder record via uri and display name failed\n");
+               return err;
+       }
+
+       return 0;
+}
+
+int
+mb_svc_get_folder_id_by_full_path(const char *folder_full_path, char *folder_id, int max_length)
+{
+       minfo_store_type store_type = MINFO_SYSTEM;
+       int err = -1;
+       char display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       char rel_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+       char *table_name = MB_SVC_TBL_NAME_FOLDER;
+       char *query_string = NULL;
+       sqlite3_stmt *stmt = NULL;
+
+       if (folder_full_path == NULL || folder_id == NULL) {
+               mb_svc_debug
+                   ("Error:folder_full_path == NULL || folder_id == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       store_type = _mb_svc_get_store_type_by_full(folder_full_path);
+       if (store_type == MB_SVC_ERROR_INTERNAL) {
+               mb_svc_debug("Failed to get storage type : %s",
+                            folder_full_path);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       _mb_svc_get_rel_path_by_full(folder_full_path, rel_path);
+       _mb_svc_get_dir_display_name(rel_path, display_name);
+
+       query_string = sqlite3_mprintf(MB_SVC_TABLE_SELECT_FOLDER_UUID_BY_PATH_INFO,
+                                                                       table_name, folder_full_path, display_name, store_type);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_free(query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = sqlite3_step(stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_free(query_string);
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       strncpy(folder_id, (const char *)sqlite3_column_text(stmt, 0), max_length);
+
+       sqlite3_free(query_string);
+       sqlite3_finalize(stmt);
+
+       return 0;
+}
+
+int
+mb_svc_get_folder_id_by_web_album_id(const char *web_album_id, char *folder_id)
+{
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_FOLDER;
+       char *query_string = NULL;
+       sqlite3_stmt *stmt = NULL;
+
+       if (web_album_id == NULL || folder_id == NULL) {
+               mb_svc_debug
+                   ("Error:web_album_id == NULL || folder_id == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       query_string = sqlite3_mprintf(MB_SVC_TABLE_SELECT_FOLDER_UUID_BY_WEB_ALBUM_ID_QUERY_STRING,
+                                                                       table_name, web_album_id);
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_free(query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = sqlite3_step(stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_free(query_string);
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       strncpy(folder_id, (const char *)sqlite3_column_text(stmt, 0), MB_SVC_UUID_LEN_MAX + 1);
+
+       sqlite3_free(query_string);
+       sqlite3_finalize(stmt);
+       return 0;
+}
+
+static int __mb_svc_get_media_id_by_fid_name(const char *folder_id, char *display_name, char *media_id)
+{
+       int err = -1;
+       char *query_string = NULL;
+       sqlite3_stmt *stmt = NULL;
+       char *table_name = MB_SVC_TBL_NAME_MEDIA;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       query_string = sqlite3_mprintf(MB_SVC_SELECT_MEDIA_ID_BY_FOLDER_UUID_AND_DISPLAY_NAME,
+                                                               table_name, folder_id, display_name);
+
+       mb_svc_debug("Query: %s", query_string);
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_free(query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       err = sqlite3_step(stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_free(query_string);
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       strncpy(media_id, (const char *)sqlite3_column_text(stmt, 0), MB_SVC_UUID_LEN_MAX + 1);
+
+       sqlite3_free(query_string);
+       sqlite3_finalize(stmt);
+
+       return 0;
+}
+
+int
+mb_svc_get_media_record_by_fid_name(const char *folder_id, const char *display_name,
+                                   mb_svc_media_record_s *m_record)
+{
+       int err = -1;
+       char *query_string = NULL;
+       sqlite3_stmt *stmt = NULL;
+       char *table_name = MB_SVC_TBL_NAME_MEDIA;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       query_string = sqlite3_mprintf(MB_SVC_SELECT_MEDIA_RECORD_BY_FOLDER_ID_AND_DISPLAY_NAME,
+                                                                       table_name, folder_id, display_name);
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_free(query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = sqlite3_step(stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_free(query_string);
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       mb_svc_load_record_media(stmt, m_record);
+
+       sqlite3_free(query_string);
+       sqlite3_finalize(stmt);
+
+       return 0;
+}
+
+int mb_svc_update_favorite_by_media_id(const char *media_id, int favorite)
+{
+       int err = mb_svc_update_favorite_by_id(media_id, favorite);
+
+       return err;
+}
+
+int
+mb_svc_get_media_record_by_id(const char *media_id,
+                             mb_svc_media_record_s *media_record)
+{
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_MEDIA;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       sqlite3_stmt *p_Stmt_mb = NULL;
+
+       if (media_id == NULL || media_record == NULL) {
+               mb_svc_debug("media_id == NULL || media_record == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       snprintf(query_string, sizeof(query_string),
+                MB_SVC_TABLE_SELECT_MEDIA_BY_MEDIA_UUID, table_name, media_id);
+
+       mb_svc_debug("Query: %s", query_string);
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &p_Stmt_mb, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = sqlite3_step(p_Stmt_mb);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               sqlite3_finalize(p_Stmt_mb);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       mb_svc_load_record_media(p_Stmt_mb, media_record);
+
+       mb_svc_debug("Path : %s", media_record->path);
+       mb_svc_debug("Thumb : %s", media_record->thumbnail_path);
+       sqlite3_finalize(p_Stmt_mb);
+       return 0;
+}
+
+int
+mb_svc_get_folder_name_by_id(const char *folder_id, char *folder_name, int max_length)
+{
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_FOLDER;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+
+       sqlite3_stmt *stmt = NULL;
+
+       if (folder_id == NULL) {
+               mb_svc_debug("folder_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (folder_name == NULL) {
+               mb_svc_debug("pointer folder_name is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       snprintf(query_string, sizeof(query_string),
+                MB_SVC_TABLE_SELECT_FOLDER_NAME_BY_UUID, table_name, folder_id);
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = sqlite3_step(stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       err = mb_svc_load_record_folder_name(stmt, folder_name, max_length);
+
+       if (err < 0) {
+               mb_svc_debug("mb-svc load data failed");
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       sqlite3_finalize(stmt);
+
+       return 0;
+
+}
+
+int
+mb_svc_get_folder_record_by_id(const char *folder_id,
+                              mb_svc_folder_record_s *folder_record)
+{
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_FOLDER;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       sqlite3_stmt *stmt = NULL;
+
+       if (folder_record == NULL) {
+               mb_svc_debug("pointer folder_record is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       snprintf(query_string, sizeof(query_string),
+                MB_SVC_TABLE_SELECT_FOLDER_RECORD_BY_UUID, table_name,
+                folder_id);
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = sqlite3_step(stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = mb_svc_load_record_folder(stmt, folder_record);
+       if (err < 0) {
+               mb_svc_debug("mb-svc load data failed");
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       sqlite3_finalize(stmt);
+
+       return 0;
+
+}
+
+int
+mb_svc_get_web_streaming_record_by_id(int webstreaming_id,
+                                     mb_svc_web_streaming_record_s *
+                                     webstreaming_record)
+{
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_WEB_STREAMING;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+
+       sqlite3_stmt *stmt = NULL;
+       if (webstreaming_record == NULL) {
+               mb_svc_debug("pointer webstreaming_record is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       snprintf(query_string, sizeof(query_string),
+                MB_SVC_TABLE_SELECT_WEBSTREAMING_RECORD_BY_ID, table_name,
+                webstreaming_id);
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = sqlite3_step(stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = mb_svc_load_record_web_streaming(stmt, webstreaming_record);
+       if (err < 0) {
+               mb_svc_debug("mb-svc load data failed");
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       sqlite3_finalize(stmt);
+
+       return 0;
+
+}
+
+int mb_svc_webstreaming_iter_start(mb_svc_iterator_s *mb_svc_iterator)
+{
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_FOLDER;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+
+       if (mb_svc_iterator == NULL) {
+               mb_svc_debug("mb_svc_iterator == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       snprintf(query_string, sizeof(query_string),
+                MB_SVC_TABLE_SELECT_FOLDER_ALL_QUERY_STRING, table_name);
+
+       mb_svc_iterator->current_position = 0;
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &mb_svc_iterator->stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int
+mb_svc_webstreaming_iter_next(mb_svc_iterator_s *mb_svc_iterator,
+                             mb_svc_web_streaming_record_s *
+                             webstreaming_record)
+{
+       int err = -1;
+
+       if (webstreaming_record == NULL || mb_svc_iterator == NULL) {
+               mb_svc_debug
+                   ("webstreaming_record == NULL || mb_svc_iterator == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+/*
+       if (mb_svc_iterator->current_position < -1 || mb_svc_iterator->current_position >= mb_svc_iterator->total_count - 1) {
+               mb_svc_debug ("iteration is not started: %d\n", mb_svc_iterator->current_position);
+               return MB_SVC_ERROR_DB_OUT_OF_RANGE;
+       }
+*/
+       err = sqlite3_step(mb_svc_iterator->stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of iteration : count = %d\n",
+                            mb_svc_iterator->current_position);
+               return MB_SVC_NO_RECORD_ANY_MORE;
+       }
+
+       memset(webstreaming_record, 0, sizeof(mb_svc_web_streaming_record_s));
+       err =
+           mb_svc_load_record_web_streaming(mb_svc_iterator->stmt,
+                                            webstreaming_record);
+       if (err < 0) {
+               mb_svc_debug("failed to load item\n");
+               sqlite3_finalize(mb_svc_iterator->stmt);
+               mb_svc_iterator->current_position = -1;
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       mb_svc_iterator->current_position++;
+
+       return 0;
+}
+
+static int __mb_svc_get_media_list_by_folder_id(const char *folder_id, GList **p_record_list, int valid)
+{
+       int record_cnt = 0;
+       mb_svc_media_record_s *md_record;
+       int err = -1;
+       GList *l_record_list = NULL;
+       mb_svc_iterator_s mb_svc_iterator = { 0 };
+
+       if (p_record_list == NULL) {
+               mb_svc_debug("p_record_list is null \n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       minfo_item_filter filter = { 0 };
+       filter.favorite = MINFO_MEDIA_FAV_ALL;
+       filter.start_pos = MB_SVC_DB_DEFAULT_GET_ALL_RECORDS;
+       filter.sort_type = MINFO_MEDIA_SORT_BY_NONE;
+       filter.file_type = MINFO_ITEM_IMAGE | MINFO_ITEM_VIDEO;
+
+       err =
+           mb_svc_media_iter_start_new(folder_id, &filter,
+                                       MINFO_CLUSTER_TYPE_ALL, valid, NULL,
+                                       &mb_svc_iterator);
+
+       if (err < 0) {
+               mb_svc_debug("mb-svc iterator start failed");
+               return err;
+       }
+
+       while (1) {
+               md_record =
+                   (mb_svc_media_record_s *)
+                   malloc(sizeof(mb_svc_media_record_s));
+               if (md_record == NULL) {
+                       mb_svc_debug("Error: memory allocation failed\n");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       _mb_svc_glist_free(&l_record_list, true);
+                       return MB_SVC_ERROR_OUT_OF_MEMORY;
+               }
+               memset(md_record, 0x00, sizeof(mb_svc_media_record_s));
+
+               err = mb_svc_media_iter_next(&mb_svc_iterator, md_record);
+
+               if (err == MB_SVC_NO_RECORD_ANY_MORE) {
+                       if (md_record)
+                               free(md_record);
+                       md_record = NULL;
+                       break;
+               }
+
+               if (err < 0) {
+                       mb_svc_debug("mb-svc iterator get next recrod failed");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       if (md_record)
+                               free(md_record);
+                       md_record = NULL;
+                       _mb_svc_glist_free(&l_record_list, true);
+                       return err;
+               }
+
+               record_cnt++;
+
+               l_record_list = g_list_append(l_record_list, md_record);
+       }
+
+       mb_svc_iter_finish(&mb_svc_iterator);
+       *p_record_list = l_record_list;
+
+       if (record_cnt == 0)
+               return MB_SVC_ERROR_DB_NO_RECORD;
+       else
+               return 0;
+}
+
+static int __mb_svc_get_invalid_media_list(const minfo_store_type storage_type, GList **p_record_list)
+{
+       int record_cnt = 0;
+       char *sql = NULL;
+       mb_svc_media_record_s *md_record;
+       int err = -1;
+       GList *l_record_list = NULL;
+       mb_svc_iterator_s mb_svc_iterator = { 0 };
+
+       if (p_record_list == NULL) {
+               mb_svc_debug("p_record_list is null \n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       sql = sqlite3_mprintf(MB_SVC_SELECT_INVALID_MEDIA_LIST, storage_type);
+       err =
+           sqlite3_prepare_v2(handle, sql, strlen(sql), &mb_svc_iterator.stmt, NULL);
+
+       sqlite3_free(sql);
+
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]", sqlite3_errmsg(handle));
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (1) {
+               md_record =
+                   (mb_svc_media_record_s *)
+                   malloc(sizeof(mb_svc_media_record_s));
+               if (md_record == NULL) {
+                       mb_svc_debug("Error: memory allocation failed\n");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       _mb_svc_glist_free(&l_record_list, true);
+                       return MB_SVC_ERROR_OUT_OF_MEMORY;
+               }
+               memset(md_record, 0x00, sizeof(mb_svc_media_record_s));
+
+               err = mb_svc_media_iter_next(&mb_svc_iterator, md_record);
+
+               if (err == MB_SVC_NO_RECORD_ANY_MORE) {
+                       if (md_record)
+                               free(md_record);
+                       md_record = NULL;
+                       break;
+               }
+
+               if (err < 0) {
+                       mb_svc_debug("mb-svc iterator get next recrod failed");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       if (md_record)
+                               free(md_record);
+                       md_record = NULL;
+                       _mb_svc_glist_free(&l_record_list, true);
+                       return err;
+               }
+
+               record_cnt++;
+
+               l_record_list = g_list_append(l_record_list, md_record);
+       }
+
+       mb_svc_iter_finish(&mb_svc_iterator);
+       *p_record_list = l_record_list;
+
+       if (record_cnt == 0)
+               return MB_SVC_ERROR_DB_NO_RECORD;
+       else
+               return 0;
+}
+
+static int __mb_svc_delete_media_records_list(GList *p_record_list)
+{
+       int ret = -1;
+       mb_svc_media_record_s *m_data = NULL;
+       int i = 0;
+
+       if (p_record_list != NULL) {
+               char *sql = NULL;
+               GList *delete_sql_list = NULL;
+               int trans_count = 30;
+               int cur_trans_count = 0;
+               int length = g_list_length(p_record_list);
+
+               for (i = 0; i < length; i++) {
+                       
+                       m_data =
+                           (mb_svc_media_record_s *)
+                           g_list_nth_data(p_record_list, i);
+
+                       ret = mb_svc_delete_record_media_sql(m_data->media_uuid, &sql);
+                       if (ret < 0) {
+                               mb_svc_debug
+                                   ("mb_svc_delete_record_media_sql failed\n");
+                       }
+
+                       mb_svc_sql_list_add(&delete_sql_list, &sql);
+
+                       if (m_data->content_type == MINFO_ITEM_IMAGE) {
+                               ret = mb_svc_delete_record_image_meta_sql(m_data->media_uuid, &sql);
+                               if (ret < 0) {
+                                       mb_svc_debug
+                                               ("mb_svc_delete_record_image_meta_sql failed\n");
+                               }
+
+                               mb_svc_sql_list_add(&delete_sql_list, &sql);
+
+                       } else if (m_data->content_type == MINFO_ITEM_VIDEO) {
+                               ret = mb_svc_delete_record_video_meta_sql(m_data->media_uuid, &sql);
+                               if (ret < 0) {
+                                       mb_svc_debug
+                                               ("mb_svc_delete_record_video_meta_sql failed\n");
+                               }
+
+                               mb_svc_sql_list_add(&delete_sql_list, &sql);
+
+                               ret =
+                                       mb_svc_delete_bookmark_meta_by_media_id_sql(m_data->media_uuid, &sql);
+                               if (ret < 0) {
+                                       mb_svc_debug
+                                               ("mb_svc_delete_bookmark_meta_by_media_id_sql failed\n");
+                               }
+
+                               mb_svc_sql_list_add(&delete_sql_list, &sql);
+                       }
+
+                       ret =
+                           mb_svc_delete_tagmap_by_media_id_sql(m_data->media_uuid, &sql);
+                       if (ret < 0) {
+                               mb_svc_debug
+                                   ("mb_svc_delete_tagmap_by_media_id_sql failed (%d)\n", ret);
+                       }
+
+                       mb_svc_sql_list_add(&delete_sql_list, &sql);
+
+                       /* delete thumbnail file directly */
+                       if (strlen(m_data->http_url) == 0) {
+                               ret = _mb_svc_thumb_rm(m_data->thumbnail_path);
+                       }
+                       if (ret < 0) {
+                               mb_svc_debug
+                                   ("_mb_svc_thumb_delete fail:file is %s\n",
+                                    m_data->thumbnail_path);
+                       }
+
+                       cur_trans_count++;
+
+                       if (cur_trans_count >= trans_count) {
+                               cur_trans_count = 0;
+                               
+                               /* Start transaction */
+                               int i = 0;
+                               int length = g_list_length(delete_sql_list);
+                       
+                               ret = mb_svc_sqlite3_begin_trans();
+                               if (ret < 0) {
+                                       mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+                                       mb_svc_sql_list_release(&delete_sql_list);
+                                       return ret;
+                               }
+                       
+                               for (i = 0; i < length; i++) {
+                                       char *sql = (char *)g_list_nth_data(delete_sql_list, i);
+                                       ret = mb_svc_query_sql(sql);
+                       
+                                       if (ret < 0) {
+                                               mb_svc_debug
+                                                       ("mb_svc_query_sql failed.. Now start to rollback\n");
+                                               mb_svc_sqlite3_rollback_trans();
+                                               mb_svc_sql_list_release(&delete_sql_list);
+                                               return ret;
+                                       }
+                               }
+                       
+                               ret = mb_svc_sqlite3_commit_trans();
+                               if (ret < 0) {
+                                       mb_svc_debug
+                                               ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+                                       mb_svc_sqlite3_rollback_trans();
+                                       mb_svc_sql_list_release(&delete_sql_list);
+                                       return ret;
+                               }
+                       }
+               }
+
+               if (cur_trans_count > 0) {
+                       cur_trans_count = 0;
+                       
+                       /* Start transaction */
+                       int i = 0;
+                       int length = g_list_length(delete_sql_list);
+               
+                       ret = mb_svc_sqlite3_begin_trans();
+                       if (ret < 0) {
+                               mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+                               mb_svc_sql_list_release(&delete_sql_list);
+                               return ret;
+                       }
+               
+                       for (i = 0; i < length; i++) {
+                               char *sql = (char *)g_list_nth_data(delete_sql_list, i);
+                               ret = mb_svc_query_sql(sql);
+               
+                               if (ret < 0) {
+                                       mb_svc_debug
+                                               ("mb_svc_query_sql failed.. Now start to rollback\n");
+                                       mb_svc_sqlite3_rollback_trans();
+                                       mb_svc_sql_list_release(&delete_sql_list);
+                                       return ret;
+                               }
+                       }
+               
+                       ret = mb_svc_sqlite3_commit_trans();
+                       if (ret < 0) {
+                               mb_svc_debug
+                                       ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+                               mb_svc_sqlite3_rollback_trans();
+                               mb_svc_sql_list_release(&delete_sql_list);
+                               return ret;
+                       }
+               }
+               
+               mb_svc_sql_list_release(&delete_sql_list);
+       }
+
+       return 0;
+}
+
+int mb_svc_delete_folder(const char *folder_id, minfo_store_type storage_type)
+{
+       int ret = 0;
+       GList *p_record_list = NULL;
+
+       if (folder_id == NULL) {
+               mb_svc_debug("folder_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = __mb_svc_get_media_list_by_folder_id(folder_id, &p_record_list, TRUE);
+
+       if (ret == MB_SVC_ERROR_DB_NO_RECORD) {
+               mb_svc_debug("There's no item in the folder %s", folder_id);
+               goto DELETE_FOLDER;
+       } else if (ret < 0) {
+               mb_svc_debug("minfo_delete_cluster, __mb_svc_get_media_list_by_folder_id failed\n");
+               return ret;
+       }
+
+       ret = __mb_svc_delete_media_records_list(p_record_list);
+       _mb_svc_glist_free(&p_record_list, true);
+
+       if (ret < 0) {
+               mb_svc_debug
+                   ("minfo_delete_cluster, delete media related records by folder_id failed\n");
+               return ret;
+       }
+
+ DELETE_FOLDER:
+       ret = mb_svc_delete_record_folder_by_id(folder_id);
+
+       if (ret < 0) {
+               mb_svc_debug
+                   ("minfo_delete_cluster, delete matched folder record failed\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+/*
+*
+* caller need to provide the local statement--stmt
+*/
+int
+mb_svc_bookmark_iter_start(const char *media_id, mb_svc_iterator_s *mb_svc_iterator)
+{
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_BOOKMARK;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+
+       if (mb_svc_iterator == NULL) {
+               mb_svc_debug("mb_svc_iterator == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       snprintf(query_string, sizeof(query_string),
+                MB_SVC_TABLE_SELECT_BOOKMARK_ALL_BY_MUUID, table_name,
+                media_id);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       mb_svc_iterator->current_position = 0;
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &mb_svc_iterator->stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return 0;
+}
+
+int
+mb_svc_bookmark_iter_next(mb_svc_iterator_s *mb_svc_iterator,
+                         mb_svc_bookmark_record_s *record)
+{
+       int err = -1;
+
+       if (record == NULL || mb_svc_iterator == NULL) {
+               mb_svc_debug("pointer record is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       err = sqlite3_step(mb_svc_iterator->stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of iteration : count = %d\n",
+                            mb_svc_iterator->current_position);
+               return MB_SVC_NO_RECORD_ANY_MORE;
+       }
+
+       err = mb_svc_load_record_bookmark(mb_svc_iterator->stmt, record);
+       if (err < 0) {
+               mb_svc_debug("failed to load item\n");
+               sqlite3_finalize(mb_svc_iterator->stmt);
+               mb_svc_iterator->current_position = -1;
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       mb_svc_iterator->current_position++;
+
+       return 0;
+}
+
+/*
+*
+* caller need to provide the local statement--stmt
+*/
+int
+mb_svc_tag_iter_start(const char *tag_name, const char *media_id,
+                     mb_svc_iterator_s *mb_svc_iterator)
+{
+       int err = -1;
+       char query_string_with_lock_status[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       int len = 0;
+
+       if (mb_svc_iterator == NULL) {
+               mb_svc_debug("mb_svc_iterator == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (tag_name != NULL) {
+               /* set to get only unlocked items */
+               len =
+                   snprintf(query_string_with_lock_status,
+                            sizeof(query_string_with_lock_status),
+                            MB_SVC_TABLE_SELECT_TAG_ALL_QUERY_STRING_BY_TAG_NAME_WITH_LOCK_STATUS,
+                            tag_name, 0);
+       } else if (media_id == NULL) {
+               /* set to get only unlocked items */
+               len =
+                   snprintf(query_string_with_lock_status,
+                            sizeof(query_string_with_lock_status),
+                            MB_SVC_TABLE_SELECT_TAG_ALL_QUERY_STRING_WITH_LOCK_STATUS,
+                            0);
+       } else {
+               /* set to get only unlocked items */
+               len =
+                   snprintf(query_string_with_lock_status,
+                            sizeof(query_string_with_lock_status),
+                            MB_SVC_TABLE_SELECT_TAG_ALL_QUERY_STRING_BY_MEDIA_ID_WITH_LOCK_STATUS,
+                            media_id, 0);
+       }
+
+       if (len < 0) {
+               mb_svc_debug("snprintf returns failure ( %d )", len);
+               query_string_with_lock_status[0] = '\0';
+       } else {
+               query_string_with_lock_status[len] = '\0';
+       }
+
+       mb_svc_debug("Query : %s", query_string_with_lock_status);
+
+       mb_svc_iterator->current_position = 0;
+
+       err =
+           sqlite3_prepare_v2(handle, query_string_with_lock_status,
+                              strlen(query_string_with_lock_status),
+                              &mb_svc_iterator->stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n",
+                            query_string_with_lock_status);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return 0;
+}
+
+int
+mb_svc_tag_iter_with_filter_start(const char *tag_name, minfo_tag_filter filter,
+                                 mb_svc_iterator_s *mb_svc_iterator)
+{
+       int err = -1;
+       char query_string_with_lock_status[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       char condition_str[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       int len = 0;
+
+       if (mb_svc_iterator == NULL) {
+               mb_svc_debug("mb_svc_iterator == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       memset(condition_str, 0x00, sizeof(condition_str));
+       if (!(filter.file_type & MINFO_ITEM_ALL)) {
+               char content_str[MB_SVC_DEFAULT_QUERY_SIZE] = { 0 };
+
+               len =
+                   snprintf(content_str, sizeof(content_str),
+                            " and ( m.content_type=%d ", 0);
+               if (len < 0) {
+                       mb_svc_debug("snprintf returns failure ( %d )", len);
+                       content_str[0] = '\0';
+               } else {
+                       content_str[len] = '\0';
+               }
+
+               len =
+                   g_strlcat(condition_str, content_str,
+                             sizeof(condition_str));
+               if (len >= sizeof(condition_str)) {
+                       mb_svc_debug("strlcat returns failure ( %d )", len);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+
+               if (filter.file_type & MINFO_ITEM_IMAGE) {
+                       len =
+                           snprintf(content_str, sizeof(content_str),
+                                    " or m.content_type=%d ",
+                                    MINFO_ITEM_IMAGE);
+                       if (len < 0) {
+                               mb_svc_debug("snprintf returns failure ( %d )",
+                                            len);
+                               content_str[0] = '\0';
+                       } else {
+                               content_str[len] = '\0';
+                       }
+
+                       len =
+                           g_strlcat(condition_str, content_str,
+                                     sizeof(condition_str));
+                       if (len >= sizeof(condition_str)) {
+                               mb_svc_debug("strlcat returns failure ( %d )",
+                                            len);
+                               return MB_SVC_ERROR_INVALID_PARAMETER;
+                       }
+               }
+
+               if (filter.file_type & MINFO_ITEM_VIDEO) {
+                       len =
+                           snprintf(content_str, sizeof(content_str),
+                                    " or m.content_type=%d ",
+                                    MINFO_ITEM_VIDEO);
+                       if (len < 0) {
+                               mb_svc_debug("snprintf returns failure ( %d )",
+                                            len);
+                               content_str[0] = '\0';
+                       } else {
+                               content_str[len] = '\0';
+                       }
+
+                       len =
+                           g_strlcat(condition_str, content_str,
+                                     sizeof(condition_str));
+                       if (len >= sizeof(condition_str)) {
+                               mb_svc_debug("strlcat returns failure ( %d )",
+                                            len);
+                               return MB_SVC_ERROR_INVALID_PARAMETER;
+                       }
+               }
+
+               len = g_strlcat(condition_str, ") ", sizeof(condition_str));
+               if (len >= sizeof(condition_str)) {
+                       mb_svc_debug("strlcat returns failure ( %d )", len);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       if (filter.start_pos != MB_SVC_DB_DEFAULT_GET_ALL_RECORDS) {    /* -1 get all record */
+               int length = filter.end_pos - filter.start_pos + 1;
+               if (length <= 0) {
+                       mb_svc_debug
+                           ("start position and end position is invalid ( start:%d, end:%d )",
+                            filter.start_pos, filter.end_pos);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+
+               char limit_str[MB_SVC_DEFAULT_QUERY_SIZE] = { 0 };
+               len =
+                   snprintf(limit_str, sizeof(limit_str), " LIMIT %d,%d",
+                            filter.start_pos, length);
+               if (len < 0) {
+                       mb_svc_debug("snprintf returns failure ( %d )", len);
+                       limit_str[0] = '\0';
+               } else {
+                       limit_str[len] = '\0';
+               }
+
+               len =
+                   g_strlcat(condition_str, limit_str, sizeof(condition_str));
+               if (len >= sizeof(condition_str)) {
+                       mb_svc_debug("strlcat returns failure ( %d )", len);
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       /* set to get only unlocked items */
+       len =
+           snprintf(query_string_with_lock_status,
+                    sizeof(query_string_with_lock_status),
+                    MB_SVC_TABLE_SELECT_TAG_ALL_QUERY_STRING_BY_TAG_NAME_WITH_LOCK_STATUS_AND_FILTER,
+                    tag_name, 0, condition_str);
+
+       if (len < 0) {
+               mb_svc_debug("snprintf returns failure ( %d )", len);
+               query_string_with_lock_status[0] = '\0';
+       } else {
+               query_string_with_lock_status[len] = '\0';
+       }
+
+       mb_svc_debug("Query : %s", query_string_with_lock_status);
+
+       mb_svc_iterator->current_position = 0;
+
+       err =
+           sqlite3_prepare_v2(handle, query_string_with_lock_status,
+                              strlen(query_string_with_lock_status),
+                              &mb_svc_iterator->stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n",
+                            query_string_with_lock_status);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return 0;
+}
+
+static int __mb_svc_delete_tag_by_id(const int tag_id)
+{
+       int err = -1;
+       char *query_string = NULL;
+       char *table_name = MB_SVC_TBL_NAME_TAG;
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_TABLE_DELETE_TAG_BY_TAGID, table_name,
+                           tag_id);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("failed to delete tagmap\n");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int mb_svc_delete_tagmap_by_media_id(const char *media_id)
+{
+       int err = -1;
+       char *query_string = NULL;
+       char *table_name = MB_SVC_TBL_NAME_TAG_MAP;
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_TABLE_DELETE_TAG_MAP_BY_MEDIA_UUID, table_name,
+                           media_id);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("failed to delete tagmap\n");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int mb_svc_delete_record_tag(const char *tag_name, const char *media_id)
+{
+       int err = -1;
+       int tag_id = 0;
+       int count = 0;
+       char *query_string = NULL;
+       char *table_name = MB_SVC_TBL_NAME_TAG_MAP;
+
+       if (tag_name == NULL) {
+               mb_svc_debug("tag_name pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       tag_id = mb_svc_get_tagid_by_tagname(tag_name);
+       if (tag_id <= 0) {
+               mb_svc_debug("There's no tag %s in the table");
+
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (media_id == NULL) {
+               query_string =
+                   sqlite3_mprintf(MB_SVC_TABLE_DELETE_TAG_MAP_BY_TAGNAME,
+                                   table_name, tag_id);
+       } else {
+               query_string =
+                   sqlite3_mprintf
+                   (MB_SVC_TABLE_DELETE_TAG_MAP_BY_TAGNAME_MEDIA_UUID,
+                    table_name, media_id, tag_id);
+       }
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("failed to delete tagmap\n");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       count = __mb_svc_get_media_cnt_by_tagid(tag_id);
+
+       if (count <= 0) {
+               err = __mb_svc_delete_tag_by_id(tag_id);
+               if (err < 0) {
+                       mb_svc_debug("__mb_svc_delete_tag_by_id : %d", tag_id);
+                       return err;
+               }
+       }
+
+       return err;
+}
+
+int
+mb_svc_media_id_list_by_tag_iter_next(mb_svc_iterator_s *mb_svc_iterator,
+                                     mb_svc_tag_record_s *record)
+{
+       int err = -1;
+
+       if (record == NULL || mb_svc_iterator == NULL) {
+               mb_svc_debug("pointer record is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       err = sqlite3_step(mb_svc_iterator->stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of iteration : count = %d\n",
+                            mb_svc_iterator->current_position);
+               return MB_SVC_NO_RECORD_ANY_MORE;
+       }
+
+       record->_id = sqlite3_column_int(mb_svc_iterator->stmt, 0);
+       //record->media_id = sqlite3_column_int(mb_svc_iterator->stmt, 1);
+       strncpy(record->media_uuid, (const char *)sqlite3_column_text(mb_svc_iterator->stmt, 1), MB_SVC_UUID_LEN_MAX + 1);
+       strncpy(record->tag_name, "", MB_SVC_ARRAY_LEN_MAX + 1);
+
+       mb_svc_iterator->current_position++;
+       return 0;
+}
+
+int
+mb_svc_tag_iter_next(mb_svc_iterator_s *mb_svc_iterator,
+                    mb_svc_tag_record_s *record)
+{
+       int err = -1;
+
+       if (record == NULL || mb_svc_iterator == NULL) {
+               mb_svc_debug("pointer record is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       err = sqlite3_step(mb_svc_iterator->stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of iteration : count = %d\n",
+                            mb_svc_iterator->current_position);
+               return MB_SVC_NO_RECORD_ANY_MORE;
+       }
+
+       err = mb_svc_load_record_tag(mb_svc_iterator->stmt, record);
+       if (err < 0) {
+               mb_svc_debug("failed to load item\n");
+               sqlite3_finalize(mb_svc_iterator->stmt);
+               mb_svc_iterator->current_position = -1;
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       mb_svc_iterator->current_position++;
+       return 0;
+}
+
+int mb_svc_rename_record_tag(const char *src_tagname, const char *dst_tag_name)
+{
+       int err = 0;
+
+       int src_tag_id = mb_svc_get_tagid_by_tagname(src_tagname);
+
+       if (src_tag_id <= 0) {
+               mb_svc_debug("there's no tag %s ", src_tagname);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int dst_tag_id = mb_svc_get_tagid_by_tagname(dst_tag_name);
+
+       if (dst_tag_id > 0) {
+               err = __mb_svc_update_tagmap(src_tag_id, dst_tag_id);
+       } else {
+               err = __mb_svc_update_tag(src_tag_id, dst_tag_name);
+       }
+
+       return err;
+}
+
+int
+mb_svc_rename_record_tag_by_id(const char *media_id, const char *src_tagname,
+                              const char *dst_tag_name)
+{
+       int err = 0;
+       mb_svc_tag_record_s tag_record = { 0 };
+
+       int src_tag_id = mb_svc_get_tagid_by_tagname(src_tagname);
+
+       if (src_tag_id <= 0) {
+               mb_svc_debug("there's no tag %s ", src_tagname);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int dst_tag_id = mb_svc_get_tagid_by_tagname(dst_tag_name);
+
+       if (dst_tag_id > 0) {
+               err = __mb_svc_update_tagmap_by_media_id(media_id, src_tag_id, dst_tag_id);
+       } else {
+
+               strncpy(tag_record.tag_name, dst_tag_name,
+                       MB_SVC_ARRAY_LEN_MAX + 1);
+
+               err = mb_svc_insert_record_tag(&tag_record);
+               if (err < 0) {
+                       mb_svc_debug("mb_svc_insert_record_tag fail\n");
+                       return err;
+               }
+
+               err = __mb_svc_update_tagmap_by_media_id(media_id, src_tag_id, tag_record._id);
+       }
+
+       return err;
+}
+
+static int __mb_svc_update_tag(int tag_id, const char *tag_name)
+{
+       mb_svc_debug("");
+
+       int err = -1;
+       char *query_string = NULL;
+       char *table_name = MB_SVC_TBL_NAME_TAG;
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_TABLE_UPDATE_TAG_NAME_QUERY_STRING_BY_TAG_ID,
+                           table_name, tag_name, tag_id);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("__mb_svc_update_tag failed\n");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+static int __mb_svc_update_tagmap(int src_tag_id, int dst_tag_id)
+{
+       mb_svc_debug("");
+
+       int err = -1;
+       char *query_string = NULL;
+       char *table_name = MB_SVC_TBL_NAME_TAG_MAP;
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_TABLE_UPDATE_TAG_MAP_QUERY_STRING_BY_TAG_ID,
+                           table_name, dst_tag_id, src_tag_id);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("mb_svc_update_tag failed\n");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+static int __mb_svc_update_tagmap_by_media_id(const char *media_id, int src_tag_id, int dst_tag_id)
+{
+       mb_svc_debug("");
+
+       int err = -1;
+       char *query_string = NULL;
+       char *table_name = MB_SVC_TBL_NAME_TAG_MAP;
+
+       query_string =
+           sqlite3_mprintf
+           (MB_SVC_TABLE_UPDATE_TAG_MAP_QUERY_STRING_BY_TAG_ID_AND_MEDIA_ID,
+            table_name, dst_tag_id, media_id, src_tag_id);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("mb_svc_update_tag failed\n");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int mb_svc_get_tagid_by_tagname(const char *tag_name)
+{
+       mb_svc_debug("");
+       char *table_name = MB_SVC_TBL_NAME_TAG;
+       char *query_string = NULL;
+
+       int rc = 0;
+       sqlite3_stmt *stmt = NULL;
+       int return_id = 0;
+       int err = -1;
+
+       if (tag_name == NULL) {
+               mb_svc_debug("Error:tag_name == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_TABLE_SELECT_TAG_COUNT_QUERY_STRING,
+                           table_name, tag_name);
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &stmt, NULL);
+       sqlite3_free(query_string);
+
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       rc = sqlite3_step(stmt);
+       while (rc == SQLITE_ROW) {
+               return_id = sqlite3_column_int(stmt, 0);
+               rc = sqlite3_step(stmt);
+       }
+       sqlite3_finalize(stmt);
+
+       stmt = NULL;
+
+       return return_id;
+}
+
+static int __mb_svc_get_media_cnt_by_tagid(int tag_id)
+{
+       int rc = 0;
+       sqlite3_stmt *stmt = NULL;
+       int count = 0;
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_TAG_MAP;
+       char *query_string = NULL;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_TABLE_SELECT_MEDIA_CNT_BY_TAGID, table_name,
+                           tag_id);
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &stmt, NULL);
+       sqlite3_free(query_string);
+
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       rc = sqlite3_step(stmt);
+       while (rc == SQLITE_ROW) {
+               count = sqlite3_column_int(stmt, 0);
+               rc = sqlite3_step(stmt);
+       }
+       sqlite3_finalize(stmt);
+
+       stmt = NULL;
+       mb_svc_debug("record count is %d\n", count);
+       return count;
+}
+
+int mb_svc_add_web_streaming_folder(char *folder_id)
+{
+       mb_svc_folder_record_s folder_record = {"",};
+       int ret = 0;
+
+       folder_record.modified_date = 0;
+       folder_record.sns_type = 0;
+       folder_record.storage_type = MINFO_WEB_STREAMING;
+       strncpy(folder_record.uri, "", MB_SVC_DIR_PATH_LEN_MAX + 1);
+       strncpy(folder_record.display_name, "", MB_SVC_FILE_NAME_LEN_MAX + 1);
+       strncpy(folder_record.web_account_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
+       strncpy(folder_record.web_album_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
+
+       ret = mb_svc_insert_record_folder(&folder_record);
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_insert_record_folder failed\n");
+               return ret;
+       }
+
+       strncpy(folder_id, folder_record.uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+       return 0;
+}
+
+int mb_svc_get_web_streaming_folder_uuid(char *folder_uuid, int max_length)
+{
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_FOLDER;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       sqlite3_stmt *stmt = NULL;
+       int folder_id = 0;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       snprintf(query_string, sizeof(query_string),
+                MB_SVC_TABLE_SELECT_FOLDER_UUID_BY_WEB_STREAMING, table_name,
+                MINFO_WEB_STREAMING);
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       err = sqlite3_step(stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_finalize(stmt);
+               folder_id = -1;
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       strncpy(folder_uuid, (const char *)sqlite3_column_text(stmt, 0), max_length);
+
+       sqlite3_finalize(stmt);
+
+       return 0;
+}
+
+int mb_svc_get_media_id_by_full_path(const char *file_full_path, char *media_id)
+{
+       int err = 0;
+       int folder_id = 0;
+       char folder_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+       char file_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       char dir_full_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+
+       _mb_svc_get_file_parent_path(file_full_path, dir_full_path);
+       _mb_svc_get_file_display_name(file_full_path, file_display_name);
+
+       err = mb_svc_get_folder_id_by_full_path(dir_full_path, folder_uuid, sizeof(folder_uuid));
+       if (err < 0) {
+               mb_svc_debug("mb_svc_get_folder_id_by_full_path fails:%s",
+                            dir_full_path);
+               return err;
+       }
+
+       _mb_svc_get_file_display_name(file_full_path, file_display_name);
+       err = __mb_svc_get_media_id_by_fid_name(folder_uuid, file_display_name, media_id);
+       if (err < 0) {
+               mb_svc_debug("__mb_svc_get_media_id_by_fid_name fails:%d,%s",
+                            folder_id, file_display_name);
+               return err;
+       }
+
+       return 0;
+}
+
+int mb_svc_get_media_id_by_http_url(const char *http_url, char *media_id)
+{
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_MEDIA;
+       char *query_string;
+       sqlite3_stmt *stmt = NULL;
+
+       if (http_url == NULL) {
+               mb_svc_debug("Error: http_url == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_TABLE_SELECT_MEDIA_ID_BY_HTTP_URL,
+                           table_name, http_url);
+       mb_svc_debug("Query : %s", query_string);
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &stmt, NULL);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_free(query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = sqlite3_step(stmt);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_free(query_string);
+               sqlite3_finalize(stmt);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       strncpy(media_id, (const char *)sqlite3_column_text(stmt,0),
+               MB_SVC_UUID_LEN_MAX + 1);
+
+       sqlite3_free(query_string);
+       sqlite3_finalize(stmt);
+
+       return 0;
+}
+
+int
+mb_svc_get_media_record_by_full_path(const char *file_full_path,
+                                    mb_svc_media_record_s *record)
+{
+       int err = -1;
+       char *table_name = MB_SVC_TBL_NAME_MEDIA;
+       char *query_string = NULL;
+       sqlite3_stmt *p_Stmt_mb = NULL;
+
+       if (record == NULL) {
+               mb_svc_debug("media_record is null \n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_TABLE_SELECT_MEDIA_BY_PATH, table_name,
+                           file_full_path);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &p_Stmt_mb, NULL);
+       sqlite3_free(query_string);
+
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       err = sqlite3_step(p_Stmt_mb);
+       if (err != SQLITE_ROW) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               sqlite3_finalize(p_Stmt_mb);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       mb_svc_load_record_media(p_Stmt_mb, record);
+
+       sqlite3_finalize(p_Stmt_mb);
+
+       return 0;
+}
+
+int mb_svc_delete_invalid_media_records(const minfo_store_type storage_type)
+{
+       mb_svc_debug("storage_type: %d", storage_type);
+
+       sqlite3_stmt *stmt = NULL;
+
+       int err = -1;
+       char folder_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+
+       char *sql = NULL;
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       GList *invalid_media_list = NULL;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       err = __mb_svc_get_invalid_media_list(storage_type, &invalid_media_list);
+       if (err == MB_SVC_ERROR_DB_NO_RECORD) {
+               mb_svc_debug("There is no invalid media");
+               return 0;
+       } else if (err < 0) {
+               mb_svc_debug("__mb_svc_get_invalid_media_list failed : %d", err);
+               mb_svc_debug("Keep going to remove invalid folder..");
+       } else {
+               err = __mb_svc_delete_media_records_list(invalid_media_list);
+               if (err < 0) {
+                       _mb_svc_glist_free(&invalid_media_list, true);
+                       mb_svc_debug
+                               ("__mb_svc_delete_media_records_list failed : %d", err);
+                       return err;
+               }
+       }
+
+       /* Get folder list to remove, which is invalid */
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+       snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
+                MB_SVC_TBL_NAME_FOLDER);
+
+       sql =
+           sqlite3_mprintf("select uuid from %s where storage_type = %d and valid=0;",
+                           table_name, storage_type);
+       err = sqlite3_prepare_v2(handle, sql, strlen(sql), &stmt, NULL);
+
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", sql);
+               sqlite3_free(sql);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       sqlite3_free(sql);
+
+       for (;;) {
+               err = sqlite3_step(stmt);
+               if (err != SQLITE_ROW) {
+                       break;
+               }
+
+               strncpy(folder_uuid, (const char *)sqlite3_column_text(stmt, 0), MB_SVC_UUID_LEN_MAX + 1);
+
+               err = mb_svc_delete_record_folder_by_id(folder_uuid);
+               if (err < 0) {
+                       mb_svc_debug("mb_svc_delete_record_folder_by_id fail:%d\n", err);
+                       return err;
+               }
+       }
+
+       err = sqlite3_finalize(stmt);
+       if (SQLITE_OK != err) {
+               mb_svc_debug("failed to clear row\n");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return 0;
+}
+
+int mb_svc_get_all_item_count(int *cnt)
+{
+       char q_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       int rc = 0;
+       sqlite3_stmt *stmt = NULL;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       int len =
+           snprintf(q_string, sizeof(q_string), MB_SVC_SELECT_ALL_ITEM_COUNT,
+                    MB_SVC_TBL_NAME_MEDIA);
+       if (len < 0) {
+               mb_svc_debug("snprintf returns failure ( %d )", len);
+               q_string[0] = '\0';
+       } else {
+               q_string[len] = '\0';
+       }
+
+       rc = sqlite3_prepare_v2(handle, q_string, strlen(q_string), &stmt,
+                               NULL);
+       if (SQLITE_OK != rc) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       rc = sqlite3_step(stmt);
+       while (rc == SQLITE_ROW) {
+               *cnt = sqlite3_column_int(stmt, 0);
+               rc = sqlite3_step(stmt);
+       }
+
+       sqlite3_finalize(stmt);
+       stmt = NULL;
+
+       return 0;
+}
+
+int mb_svc_get_media_count_by_tagname(const char *tagname, int *count)
+{
+       char q_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       int rc = 0;
+       sqlite3_stmt *stmt = NULL;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       char *tag_name_with_escape = NULL;
+       tag_name_with_escape = sqlite3_mprintf("%q", tagname);
+
+       int len =
+           snprintf(q_string, sizeof(q_string),
+                    MB_SVC_TABLE_SELECT_COUNT_BY_TAG_NAME_WITH_LOCK_STATUS,
+                    tag_name_with_escape, 0);
+       if (len < 0) {
+               mb_svc_debug("snprintf returns failure ( %d )", len);
+               q_string[0] = '\0';
+       } else {
+               q_string[len] = '\0';
+       }
+
+       sqlite3_free(tag_name_with_escape);
+
+       rc = sqlite3_prepare_v2(handle, q_string, strlen(q_string), &stmt,
+                               NULL);
+       if (SQLITE_OK != rc) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       rc = sqlite3_step(stmt);
+       while (rc == SQLITE_ROW) {
+               *count = sqlite3_column_int(stmt, 0);
+               rc = sqlite3_step(stmt);
+       }
+
+       sqlite3_finalize(stmt);
+       stmt = NULL;
+
+       return 0;
+}
+
diff --git a/src/visual/media-svc-db-util.c b/src/visual/media-svc-db-util.c
new file mode 100755 (executable)
index 0000000..257e528
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+*      common API
+*/
+
+#include "media-info-util.h"
+#include "media-svc-util.h"
+#include "media-svc-db-util.h"
+#include "media-svc-debug.h"
+#include "media-svc-error.h"
+
+int mb_svc_query_sql_gstring(GString *query_string)
+{
+       int err = -1;
+       char *err_msg;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       mb_svc_debug("SQL = %s\n", query_string->str);
+
+       err = sqlite3_exec(handle, query_string->str, NULL, NULL, &err_msg);
+       if (SQLITE_OK != err) {
+               if (err_msg) {
+                       mb_svc_debug("failed to query[%s]", err_msg);
+                       sqlite3_free(err_msg);
+               }
+               mb_svc_debug("Query fails : query_string[%s]",
+                            query_string->str);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (err_msg)
+               sqlite3_free(err_msg);
+       mb_svc_debug("query success\n");
+
+       return err;
+}
+
+int mb_svc_query_sql(char *query_str)
+{
+       int err = -1;
+       char *err_msg;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       mb_svc_debug("SQL = %s\n", query_str);
+
+       err = sqlite3_exec(handle, query_str, NULL, NULL, &err_msg);
+       if (SQLITE_OK != err) {
+               if (err_msg) {
+                       mb_svc_debug("failed to query[%s]", err_msg);
+                       sqlite3_free(err_msg);
+               }
+               mb_svc_debug("Query fails : query_string[%s]", query_str);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (err_msg)
+               sqlite3_free(err_msg);
+       mb_svc_debug("query success\n");
+
+       return err;
+}
+
+int mb_svc_sqlite3_begin_trans(void)
+{
+       char *err_msg = NULL;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       mb_svc_debug("mb_svc_sqlite3_begin_trans enter\n");
+       if (SQLITE_OK !=
+           sqlite3_exec(handle, "BEGIN IMMEDIATE;", NULL, NULL, &err_msg)) {
+               mb_svc_debug("Error:failed to begin transaction: error=%s\n",
+                            err_msg);
+               sqlite3_free(err_msg);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       sqlite3_free(err_msg);
+       mb_svc_debug("mb_svc_sqlite3_begin_trans leave\n");
+       return 0;
+}
+
+int mb_svc_sqlite3_commit_trans(void)
+{
+       char *err_msg = NULL;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       mb_svc_debug("mb_svc_sqlite3_commit_trans enter\n");
+       if (SQLITE_OK != sqlite3_exec(handle, "COMMIT;", NULL, NULL, &err_msg)) {
+               mb_svc_debug("Error:failed to end transaction: error=%s\n",
+                            err_msg);
+               sqlite3_free(err_msg);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       sqlite3_free(err_msg);
+       mb_svc_debug("mb_svc_sqlite3_commit_trans leave\n");
+       return 0;
+}
+
+int mb_svc_sqlite3_rollback_trans(void)
+{
+       char *err_msg = NULL;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       mb_svc_debug("mb_svc_sqlite3_rollback_trans enter\n");
+       if (SQLITE_OK !=
+           sqlite3_exec(handle, "ROLLBACK;", NULL, NULL, &err_msg)) {
+               mb_svc_debug("Error:failed to rollback transaction: error=%s\n",
+                            err_msg);
+               sqlite3_free(err_msg);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       sqlite3_free(err_msg);
+       mb_svc_debug("mb_svc_sqlite3_rollback_trans leave\n");
+       return 0;
+}
+
+void mb_svc_sql_list_add(GList **list, char **sql)
+{
+       *list = g_list_append( *list, *sql );
+}
+
+void mb_svc_sql_list_release(GList **sql_list)
+{
+       if (*sql_list) {
+               int i = 0;
+               char *sql = NULL;
+               for (i = 0; i < g_list_length(*sql_list); i++) {
+                       sql = (char*)g_list_nth_data(*sql_list, i);
+                       if (sql) sqlite3_free(sql);
+                       sql = NULL;
+               }
+
+               g_list_free(*sql_list);
+               *sql_list = NULL;
+       }
+}
diff --git a/src/visual/media-svc-db.c b/src/visual/media-svc-db.c
new file mode 100755 (executable)
index 0000000..e9a3902
--- /dev/null
@@ -0,0 +1,2604 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "media-info-env.h"
+#include "media-info-util.h"
+#include "media-svc-db.h"
+#include "media-svc-debug.h"
+#include "media-svc-db-util.h"
+#include "media-svc-util.h"
+#include "media-svc-api.h"
+#include "media-svc-error.h"
+#include "minfo-types.h"
+#include "media-svc-structures.h"
+#include <util-func.h>
+#include <sys/stat.h>
+
+
+/**
+ * Enumerations for table name.
+ */
+typedef enum {
+       MB_SVC_TABLE_NONE = -1,
+       MB_SVC_TABLE_BOOKMARK,
+       MB_SVC_TABLE_FOLDER,
+       MB_SVC_TABLE_WEB_STREAMING,
+       MB_SVC_TABLE_MEDIA,
+       MB_SVC_TABLE_VIDEO_META,
+       MB_SVC_TABLE_IMAGE_META,
+       MB_SVC_TABLE_TAG_MAP,
+       MB_SVC_TABLE_TAG,
+       MB_SVC_TABLE_NUM,
+} mb_svc_tbl_name_e;
+
+
+/**
+ * Enumerations for bookmark field name.
+ */
+typedef enum {
+       MB_SVC_BOOKMARK_NONE            = -1,
+       MB_SVC_BOOKMARK_ID,
+       MB_SVC_BOOKMARK_MEDIA_UUID,
+       MB_SVC_BOOKMARK_MARKED_TIME,
+       MB_SVC_BOOKMARK_THUMBNAIL_PATH,
+       MB_SVC_BOOKMARK_NUM,
+} mb_svc_bookmark_field_e;
+
+/**
+ * Enumerations for FOLDER field name.
+ */
+typedef enum {
+       MB_SVC_FOLDER_NONE              = -1,
+       MB_SVC_FOLDER_UUID,
+       MB_SVC_FOLDER_PATH,
+       MB_SVC_FOLDER_DISPLAY_NAME,
+       MB_SVC_FOLDER_MODIFIED_DATE,
+       MB_SVC_FOLDER_WEB_ACCOUNT_ID,
+       MB_SVC_FOLDER_STORAGE_TYPE,
+       MB_SVC_FOLDER_SNS_TYPE,
+       MB_SVC_FOLDER_ALBUM_LOCK_STATUS,
+       MB_SVC_FOLDER_WEB_ALBUM_ID,
+       MB_SVC_FOLDER_VALID,
+       MB_SVC_FOLDER_NUM,
+} mb_svc_folder_field_e;
+/**
+ * Enumerations for web_streaming field name.
+ */
+typedef enum {
+       MB_SVC_WEB_STREAMING_NONE               = -1,
+       MB_SVC_WEB_STREAMING_ID,
+       MB_SVC_WEB_STREAMING_FOLDER_UUID,
+       MB_SVC_WEB_STREAMING_TITLE,
+       MB_SVC_WEB_STREAMING_DURATION,
+       MB_SVC_WEB_STREAMING_URL,
+       MB_SVC_WEB_STREAMING_THNMB_PATH,
+       MB_SVC_WEB_STREAMING_NUM,
+} mb_svc_web_streaming_field_e;
+
+
+/**
+ * Enumerations for MEDIA field name.
+ */
+typedef enum {
+       MB_SVC_MEDIA_NONE               = -1,
+       MB_SVC_MEDIA_UUID,
+       MB_SVC_MEDIA_PATH,
+       MB_SVC_MEDIA_FOLDER_UUID,
+       MB_SVC_MEDIA_DISPLAY_NAME,
+       MB_SVC_MEDIA_CONTENT_TYPE,
+       MB_SVC_MEDIA_RATING,
+       MB_SVC_MEDIA_MODIFIED_DATE,
+       MB_SVC_MEDIA_THUMBNAIL_PATH,
+       MB_SVC_MEDIA_HTTP_URL,
+       MB_SVC_MEDIA_VALID,
+       MB_SVC_MEDIA_NUM,
+} mb_svc_media_field_e;
+
+/**
+ * Enumerations for videl_meta field name.
+ */
+typedef enum {
+       MB_SVC_VIDEO_META_NONE          = -1,
+       MB_SVC_VIDEO_META_ID,
+       MB_SVC_VIDEO_META_MEDIA_UUID,
+       MB_SVC_VIDEO_META_ALBUM,
+       MB_SVC_VIDEO_META_ARTIST,
+       MB_SVC_VIDEO_META_TITLE,
+       MB_SVC_VIDEO_META_DESCRIPTION,
+       MB_SVC_VIDEO_META_YOUTUBE_CATEGORY,
+       MB_SVC_VIDEO_META_BOOKMARK_LAST_PLAYED,
+       MB_SVC_VIDEO_META_DURATION,
+       MB_SVC_VIDEO_META_LONGISTUDE,
+       MB_SVC_VIDEO_META_LATITUDE,
+       MB_SVC_VIDEO_META_WIDTH,
+       MB_SVC_VIDEO_META_HEIGHT,
+       MB_SVC_VIDEO_META_DATETAKEN,
+       MB_SVC_VIDEO_META_NUM,
+} mb_svc_video_meta_field_e;
+
+
+/**
+ * Enumerations for IMAGE_META field name.
+ */
+typedef enum {
+       MB_SVC_IMAGE_META_NONE          = -1,
+       MB_SVC_IMAGE_META_ID,
+       MB_SVC_IMAGE_META_MEDIA_UUID,
+       MB_SVC_IMAGE_META_LONGISTUDE,
+       MB_SVC_IMAGE_META_LATITUDE,
+       MB_SVC_IMAGE_META_DESCRIPTION,
+       MB_SVC_IMAGE_META_WIDTH,
+       MB_SVC_IMAGE_META_HEIGHT,
+       MB_SVC_IMAGE_META_ORIENTATION,
+       MB_SVC_IMAGE_META_DATETAKEN,
+       MB_SVC_IMAGE_META_NUM,
+} mb_svc_image_meta_field_e;
+
+/**
+ * Enumerations for VISUAL_TAG_MAP field name.
+ */
+typedef enum {
+       MB_SVC_TAG_MAP_NONE             = -1,
+       MB_SVC_TAG_MAP_ID,
+       MB_SVC_TAG_MAP_MEDIA_UUID,
+       MB_SVC_TAG_MAP_TAG_ID,
+       MB_SVC_TAG_MAP_NUM,
+} mb_svc_tag_map_field_e;
+
+/**
+ * Enumerations for VISUAL_TAG field name.
+ */
+typedef enum {
+       MB_SVC_TAG_NONE         = -1,
+       MB_SVC_TAG_ID,
+       MB_SVC_TAG_NAME,
+       MB_SVC_TAG_NUM,
+} mb_svc_tag_field_e;
+
+/**
+ *     table fields information
+ */
+typedef struct {
+        char *field_name;
+        char *field_type;
+}mb_svc_tbl_field_s;
+
+/**
+ *     table information
+ */
+
+#define MB_SVC_FIELD_CNT_MAX 16
+#define MB_SVC_TABLE_CNT_MAX 8
+
+typedef struct {
+       char *table_name;
+       mb_svc_tbl_field_s mb_svc_field[MB_SVC_FIELD_CNT_MAX];
+       char *primary_key;
+} mb_svc_tbl_s;
+
+
+mb_svc_tbl_s mb_svc_tbl[MB_SVC_TABLE_CNT_MAX] = {
+       {"video_bookmark", {
+                           {"_id", "INTEGER"} ,        /* PK */
+                           {"media_uuid", "VARCHAR(256)"} ,
+                           {"marked_time", "INT"}
+                           ,
+                           {"thumbnail_path", "VARCHAR(256)"}
+                           ,
+                           {0}
+                           }
+        ,
+        ", primary key (_id)"}
+       ,
+
+       {"visual_folder", {
+                          {"uuid", "VARCHAR(256)"} ,   /* PK */
+                          {"path", "VARCHAR(256)"} ,   /* full path */
+                          {"folder_name", "VARCHAR(256)"}
+                          ,
+                          {"modified_date", "INT"}
+                          ,
+                          {"web_account_id", "VARCHAR(256)"}
+                          ,
+                          {"storage_type", "INT"}
+                          ,
+                          {"sns_type", "INT"}
+                          ,
+                          {"lock_status", "INT"}
+                          ,
+                          {"web_album_id", "VARCHAR(256)"}
+                          ,
+                          {"valid", "INT"}
+                          ,
+                          {0}
+                          }
+        ,
+        ", primary key (_id)"}
+       ,
+
+       {"web_streaming", {
+                          {"_id", "INTEGER"} /* PK */
+                          ,
+                          {"folder_uuid", "VARCHAR(256)"}      /* FK, folder table */
+                          ,
+                          {"title", "VARCHAR(256)"}
+                          ,
+                          {"duration", "INT"}
+                          ,
+                          {"url", "VARCHAR(256)"}
+                          ,
+                          {"thumb_path", "VARCHAR(256)"}
+                          ,
+                          {0}
+                          }
+        ,
+        ", primary key (_id)"}
+       ,
+
+       {"visual_media", {
+                         {"uuid", "VARCHAR(256)"}
+                         ,
+                         {"path", "VARCHAR(256)"}
+                         ,
+                         {"folder_uuid", "VARCHAR(256)"}
+                         ,
+                         {"display_name", "VARCHAR(256)"}
+                         ,
+                         {"content_type", "INT"}
+                         ,
+                         {"rating", "INT"}
+                         ,
+                         {"modified_date", "INT"}
+                         ,
+                         {"thumbnail_path", "VARCHAR(256)"}
+                         ,
+                         {"http_url", "VARCHAR(256)"}
+                         ,
+                         {"valid", "INT"}
+                         ,
+                         {0}
+                         }
+        ,
+        ", primary key (_id)"}
+       ,
+
+       {"video_meta", {
+                       {"_id", "INTEGER"}
+                       ,
+                       {"media_uuid", "VARCHAR(256)"}
+                       ,
+                       {"album", "VARCHAR(256)"}
+                       ,
+                       {"artist", "VARCHAR(256)"}
+                       ,
+                       {"title", "VARCHAR(256)"}
+                       ,
+                       {"description", "VARCHAR(256)"}
+                       ,
+                       {"youtube_category", "VARCHAR(256)"}
+                       ,
+                       {"last_played_time", "INT"}
+                       ,
+                       {"duration", "INT"}
+                       ,
+                       {"longitude", "DOUBLE"}
+                       ,
+                       {"latitude", "DOUBLE"}
+                       ,
+                       {"width", "INT"}
+                       ,
+                       {"height", "INT"}
+                       ,
+                       {"datetaken", "INT"}
+                       ,
+                       {0}
+                       }
+        ,
+        ", primary key (_id)"}
+       ,
+
+       {"image_meta", {
+                       {"_id", "INTEGER"}
+                       ,
+                       {"media_uuid", "VARCHAR(256)"}
+                       ,
+                       {"longitude", "DOUBLE"}
+                       ,
+                       {"latitude", "DOUBLE"}
+                       ,
+                       {"description", "VARCHAR(256)"}
+                       ,
+                       {"width", "INT"}
+                       ,
+                       {"height", "INT"}
+                       ,
+                       {"orientation", "INT"}
+                       ,
+                       {"datetaken", "INT"}
+                       ,
+                       {0}
+                       }
+        ,
+        ", primary key (_id)"}
+       ,
+
+       {"visual_tag_map", {
+                           {"_id", "INTEGER"} /* PK */
+                           ,
+                               {"media_uuid", "VARCHAR(256)"}
+                           ,
+                           {"tag_id", "INT"}
+                           ,
+                           {0}
+                           }
+        ,
+        ", primary key (_id)"}
+       ,
+
+       {"visual_tag", {
+                       {"_id", "INTEGER"} /* FK, media table */
+                       ,
+                       {"tag_name", "VARCHAR(256)"}
+                       ,
+                       {0}
+                       }
+        ,
+        ", primary key (_id)"}
+};
+
+int field_num_max[MB_SVC_TABLE_CNT_MAX] = { MB_SVC_BOOKMARK_NUM,
+       MB_SVC_FOLDER_NUM,
+       MB_SVC_WEB_STREAMING_NUM,
+       MB_SVC_MEDIA_NUM,
+       MB_SVC_VIDEO_META_NUM,
+       MB_SVC_IMAGE_META_NUM,
+       MB_SVC_TAG_MAP_NUM,
+       MB_SVC_TAG_NUM
+};
+
+static __thread GList *g_sql_list = NULL;
+static __thread char g_last_updated_folder_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+
+#if 0
+static int __mb_svc_create_tbl(bool external);
+static int __mb_svc_drop_tbl(void);
+#endif
+static int __mb_svc_delete_record(int id, mb_svc_tbl_name_e tbl_name);
+static int __mb_svc_delete_record_by_uuid(const char *id, mb_svc_tbl_name_e tbl_name);
+static int __mb_svc_db_get_next_id(int table_id);
+
+#if 0
+static int __mb_svc_create_tbl(bool external)
+{
+       int err = -1;
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       char *primary_key = NULL;
+       int i, j;
+       mb_svc_tbl_field_s *mb_svc_field = NULL;
+       int field_count = 0;
+       GString *query_string =
+           g_string_sized_new(MB_SVC_DEFAULT_QUERY_SIZE + 1);
+       mb_svc_debug("__mb_svc_create_tbl--enter\n");
+
+       for (i = 0; i < MB_SVC_TABLE_CNT_MAX; ++i) {
+               field_count = field_num_max[i];
+               memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+
+               snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
+                        mb_svc_tbl[i].table_name);
+
+               mb_svc_field = mb_svc_tbl[i].mb_svc_field;
+               primary_key = mb_svc_tbl[i].primary_key;
+
+               err = _mb_svc_table_exist(table_name);
+               if (err > 0) {
+                       continue;
+               }
+               g_string_printf(query_string, "CREATE TABLE %s(", table_name);
+
+               for (j = 0; j < field_count; ++j) {
+                       if (j != 0) {
+                               g_string_append(query_string, ", ");
+                       }
+                       g_string_append_printf(query_string, "%s %s",
+                                              mb_svc_field[j].field_name,
+                                              mb_svc_field[j].field_type);
+               }
+
+               g_string_append(query_string, primary_key);
+               g_string_append(query_string, " );");
+
+               err = mb_svc_query_sql_gstring(query_string);
+               if (err < 0) {
+                       mb_svc_debug("failed to create table\n");
+                       mb_svc_debug("query string is %s\n", query_string->str);
+
+                       g_string_free(query_string, TRUE);
+                       return MB_SVC_ERROR_DB_INTERNAL;
+               }
+       }
+
+       g_string_free(query_string, TRUE);
+
+       mb_svc_debug("__mb_svc_create_tbl--leave\n");
+       return 0;
+}
+
+static int __mb_svc_drop_tbl(void)
+{
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       int i, err;
+       char *table_name;
+       mb_svc_debug("__mb_svc_drop_tbl--enter\n");
+
+       for (i = 0; i < MB_SVC_TABLE_CNT_MAX; ++i) {
+               table_name = mb_svc_tbl[i].table_name;
+               if (table_name == NULL) {
+                       mb_svc_debug("table_name is null\n");
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+               err = _mb_svc_table_exist(table_name);
+               if (err > 0) {
+                       snprintf(query_string, sizeof(query_string),
+                                MB_SVC_TABLE_DROP_QUERY_STRING, table_name);
+                       err = mb_svc_query_sql(query_string);
+                       if (err < 0) {
+                               mb_svc_debug("drop failed\n");
+                               mb_svc_debug("query string is %s\n",
+                                            query_string);
+                               return MB_SVC_ERROR_DB_INTERNAL;
+                       }
+               }
+       }
+       mb_svc_debug("__mb_svc_drop_tbl--leave\n");
+       return 0;
+}
+#endif
+
+int mb_svc_set_folder_as_valid_sql_add(const char *folder_id, int valid)
+{
+       mb_svc_debug("Folder ID:%s, valid:%d", folder_id, valid);
+       char *sql = NULL;
+
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_FOLDER;
+
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+
+       snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
+                mb_svc_tbl[field_seq].table_name);
+
+       sql = sqlite3_mprintf(MB_SVC_UPDATE_VALID_BY_UUID, 
+                                                                               table_name, 
+                                                                               valid,
+                                                                               folder_id);
+
+       mb_svc_sql_list_add(&g_sql_list, &sql);
+
+       return 0;
+}
+
+int mb_svc_set_item_as_valid_sql_add(const char *full_path, int valid)
+{
+       mb_svc_debug("full path: %s, valid:%d", full_path, valid);
+
+       mb_svc_media_record_s media_record = {"",};
+       int ret = -1;
+
+       if (full_path == NULL) {
+               mb_svc_debug("full_path == NULL \n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = mb_svc_get_media_record_by_full_path(full_path, &media_record);
+       if (ret < 0) {
+               mb_svc_debug(" mb_svc_get_media_record_by_full_path fails (%d)", ret);
+               return ret;
+       }
+       mb_svc_debug("Media ID : %s", media_record.media_uuid);
+
+       /* Set the record as valid/invalid in 'media' table */
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_MEDIA;
+
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+
+       snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
+                mb_svc_tbl[field_seq].table_name);
+
+       char *sql =
+           sqlite3_mprintf(MB_SVC_UPDATE_VALID_BY_UUID, table_name, valid,
+                           media_record.media_uuid);
+
+       mb_svc_sql_list_add(&g_sql_list, &sql);
+
+       if ((valid == 1) && (strcmp(g_last_updated_folder_uuid, media_record.folder_uuid) != 0)) {
+               strncpy(g_last_updated_folder_uuid, media_record.folder_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+               ret =
+                   mb_svc_set_folder_as_valid_sql_add(media_record.folder_uuid, valid);
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("mb_svc_update_folder_valid_sql_add fail:%d\n", ret);
+                       return ret;
+               }
+       }
+
+       return 0;
+}
+
+int mb_svc_set_item_as_valid()
+{
+       mb_svc_debug("");
+       int i = 0;
+       int length = g_list_length(g_sql_list);
+
+       for (i = 0; i < length; i++) {
+               char *sql = (char*)g_list_nth_data(g_sql_list, i);
+               mb_svc_query_sql(sql);
+       }
+
+       mb_svc_sql_list_release(&g_sql_list);
+
+       return 0;
+}
+
+static int mb_svc_busy_handler(void *pData, int count)
+{
+       usleep(50000);
+       printf("mb_svc_busy_handler called : %d\n", count);
+       mb_svc_debug("mb_svc_busy_handler called : %d\n", count);
+
+       return 100 - count;
+}
+
+/* connect to database-server */
+int mb_svc_connect_db(sqlite3 **handle)
+{
+       mb_svc_debug("mb_svc_connect_db\n");
+       int ret = 0;
+
+       ret =
+           db_util_open(MEDIA_INFO_DATABASE_NAME, handle,
+                        DB_UTIL_REGISTER_HOOK_METHOD);
+       if (SQLITE_OK != ret) {
+               mb_svc_debug("can not connect to db-server\n");
+               if (*handle) mb_svc_debug("[sqlite] %s\n", sqlite3_errmsg(*handle));
+
+               *handle = NULL;
+
+               return MB_SVC_ERROR_DB_CONNECT;
+       }
+
+       /* Register Busy handler */
+       ret = sqlite3_busy_handler(*handle, mb_svc_busy_handler, NULL);
+       if (SQLITE_OK != ret) {
+               mb_svc_debug("Fail to register busy handler\n");        
+               if (*handle) mb_svc_debug("[sqlite] %s\n", sqlite3_errmsg(*handle));
+
+               db_util_close(*handle);
+               *handle = NULL;
+
+               return MB_SVC_ERROR_DB_CONNECT;
+       }
+
+       mb_svc_debug("connected to db-server\n");
+
+       return 0;
+}
+
+/* disconnect from database-server */
+int mb_svc_disconnect_db(sqlite3 *handle)
+{
+       /* disconnect from database-server */
+       int ret = 0;
+
+       ret = db_util_close(handle);
+
+       if (SQLITE_OK != ret) {
+               mb_svc_debug("can not disconnect database\n");
+               mb_svc_debug("[sqlite] %s\n", sqlite3_errmsg(handle));
+
+               return MB_SVC_ERROR_DB_DISCONNECT;
+       }
+       handle = NULL;
+
+       mb_svc_debug("Disconnected successfully\n");
+       return 0;
+}
+
+mb_svc_tbl_s *mb_svc_search_matched_svc_tbl(mb_svc_tbl_name_e tbl_name)
+{
+       int i;
+
+       if (tbl_name <= MB_SVC_TABLE_NONE || tbl_name >= MB_SVC_TABLE_NUM) {
+               mb_svc_debug("table name is invalid\n");
+               return NULL;
+       }
+
+       char *table_name = mb_svc_tbl[tbl_name].table_name;
+
+       if (table_name == NULL) {
+               mb_svc_debug("table_name pointer is null\n");
+               return NULL;
+       }
+
+       for (i = 0; i < MB_SVC_TABLE_CNT_MAX; ++i) { /* search the matched table */
+               if (!strncmp
+                   (table_name, mb_svc_tbl[i].table_name,
+                    MB_SVC_ARRAY_LEN_MAX)) {
+                       return &mb_svc_tbl[i];
+               }
+       }
+       mb_svc_debug("error, no matched mb svc table found. %s", table_name);
+       return NULL;
+}
+
+int _mb_svc_table_exist(char *table_name)
+{
+       char szQuery[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       int ret = -1;;
+       char szTableName[64] = { 0 };
+       char *pszTempName = NULL;
+       sqlite3_stmt *pstStmt_pb = NULL;
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       if (table_name == NULL) {
+               mb_svc_debug("table_name pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+       snprintf(szQuery, sizeof(szQuery), MB_SVC_TABLE_EXIST_QUERY_STRING,
+                table_name);
+
+       ret =
+           sqlite3_prepare_v2(handle, szQuery, strlen(szQuery), &pstStmt_pb,
+                              NULL);
+       if (SQLITE_OK != ret) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", szQuery);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       ret = sqlite3_step(pstStmt_pb);
+       if (SQLITE_ROW != ret) {
+               mb_svc_debug("end of row [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", szQuery);
+               sqlite3_finalize(pstStmt_pb);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       pszTempName = (char *)sqlite3_column_text(pstStmt_pb, 0);
+       if (NULL != pszTempName) {
+               strncpy(szTableName, pszTempName, strlen(pszTempName));
+       }
+       sqlite3_finalize(pstStmt_pb);
+
+       mb_svc_debug("if [%s]=[%s], table exist!!!\n", table_name, szTableName);
+       ret = !(strcmp(table_name, szTableName));
+
+       return ret;
+}
+
+int _mb_svc_truncate_tbl()
+{
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       int i, err;
+       char *table_name;
+       mb_svc_debug("_mb_svc_truncate_tbl--enter\n");
+
+       for (i = 0; i < MB_SVC_TABLE_CNT_MAX; ++i) {
+               table_name = mb_svc_tbl[i].table_name;
+               if (table_name == NULL) {
+                       mb_svc_debug("table_name is null\n");
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+               err = _mb_svc_table_exist(table_name);
+               if (err > 0) {
+                       snprintf(query_string, sizeof(query_string),
+                                MB_SVC_TABLE_DELETE_QUERY_STRING, table_name);
+                       err = mb_svc_query_sql(query_string);
+                       if (err < 0) {
+                               mb_svc_debug("truncate table failed\n");
+                               mb_svc_debug("query string is %s\n",
+                                            query_string);
+                               return MB_SVC_ERROR_DB_INTERNAL;
+                       }
+               }
+       }
+       mb_svc_debug("_mb_svc_truncate_tbl--leave\n");
+       return 0;
+}
+
+static int __mb_svc_db_get_next_id(int table_id)
+{
+       int ret = 0;
+       sqlite3_stmt *stmt = NULL;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       snprintf(query_string, sizeof(query_string), "select max(_id) from %s;",
+                (char *)mb_svc_tbl[table_id].table_name);
+
+       mb_svc_debug("Query : %s", query_string);
+       ret =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &stmt, NULL);
+
+       if (ret != SQLITE_OK) {
+               mb_svc_debug("Make Sequence error for prepare %s",
+                            sqlite3_errmsg(handle));
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       ret = sqlite3_step(stmt);
+       if (ret != SQLITE_ROW) {
+               mb_svc_debug("There's no record %s", sqlite3_errmsg(handle));
+
+               sqlite3_finalize(stmt);
+               stmt = NULL;
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       ret = sqlite3_column_int(stmt, 0);
+
+       sqlite3_finalize(stmt);
+       stmt = NULL;
+
+       mb_svc_debug("Next ID : %d", ret + 1);
+
+       return ret + 1;
+}
+
+static int __mb_svc_delete_record(int id, mb_svc_tbl_name_e tbl_name)
+{
+       int err = -1;
+       mb_svc_tbl_s *matched_tbl = NULL;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+
+       if (id <= 0) {
+               mb_svc_debug("id is wrong");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (tbl_name <= MB_SVC_TABLE_NONE || tbl_name >= MB_SVC_TABLE_NUM) {
+               mb_svc_debug("table name is invalid\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       matched_tbl = mb_svc_search_matched_svc_tbl(tbl_name);
+       if (matched_tbl != NULL) {
+               snprintf(table_name, sizeof(table_name), "%s",
+                        mb_svc_tbl[tbl_name].table_name);
+               snprintf(query_string, sizeof(query_string),
+                        MB_SVC_RECORD_DELETE_QUERY_STRING, table_name, id);
+
+               mb_svc_debug("Query: %s", query_string);
+
+               err = mb_svc_query_sql(query_string);
+               if (err < 0) {
+                       mb_svc_debug("failed to delete record\n");
+                       mb_svc_debug("query string is %s\n", query_string);
+                       return MB_SVC_ERROR_DB_INTERNAL;
+               } else {
+                       mb_svc_debug("Succeed to delete record\n");
+                       mb_svc_debug("query string is %s\n", query_string);
+               }
+       } else {
+               mb_svc_debug("failed to delete record\n");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return 0;
+}
+
+static int __mb_svc_delete_record_by_uuid(const char *id, mb_svc_tbl_name_e tbl_name)
+{
+       int err = -1;
+       mb_svc_tbl_s *matched_tbl = NULL;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+
+       if (id == NULL) {
+               mb_svc_debug("id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (tbl_name <= MB_SVC_TABLE_NONE || tbl_name >= MB_SVC_TABLE_NUM) {
+               mb_svc_debug("table name is invalid\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       matched_tbl = mb_svc_search_matched_svc_tbl(tbl_name);
+       if (matched_tbl != NULL) {
+               snprintf(table_name, sizeof(table_name), "%s",
+                        mb_svc_tbl[tbl_name].table_name);
+               snprintf(query_string, sizeof(query_string),
+                        MB_SVC_RECORD_DELETE_BY_UUID, table_name, id);
+
+               mb_svc_debug("Query: %s", query_string);
+
+               err = mb_svc_query_sql(query_string);
+               if (err < 0) {
+                       mb_svc_debug("failed to delete record\n");
+                       mb_svc_debug("query string is %s\n", query_string);
+                       return MB_SVC_ERROR_DB_INTERNAL;
+               } else {
+                       mb_svc_debug("Succeed to delete record\n");
+                       mb_svc_debug("query string is %s\n", query_string);
+               }
+       } else {
+               mb_svc_debug("failed to delete record\n");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return 0;
+}
+
+int mb_svc_delete_record_bookmark_by_id(int id)
+{
+       return __mb_svc_delete_record(id, MB_SVC_TABLE_BOOKMARK);
+}
+
+int mb_svc_delete_record_folder_by_id(const char *id)
+{
+       return __mb_svc_delete_record_by_uuid(id, MB_SVC_TABLE_FOLDER);
+}
+
+int mb_svc_delete_record_web_streaming_by_id(int id)
+{
+       return __mb_svc_delete_record(id, MB_SVC_TABLE_WEB_STREAMING);
+}
+
+int mb_svc_delete_record_media_by_id(const char *id)
+{
+       return __mb_svc_delete_record_by_uuid(id, MB_SVC_TABLE_MEDIA);
+}
+
+int mb_svc_delete_record_video_meta_by_id(int id)
+{
+       return __mb_svc_delete_record(id, MB_SVC_TABLE_VIDEO_META);
+}
+
+int mb_svc_delete_record_image_meta_by_id(int id)
+{
+       return __mb_svc_delete_record(id, MB_SVC_TABLE_IMAGE_META);
+}
+
+int mb_svc_insert_record_bookmark(mb_svc_bookmark_record_s *record)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = -1;
+       mb_svc_tbl_field_s *mb_svc_field;
+       char *query_string = NULL;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_BOOKMARK;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+/*
+       record->_id = __mb_svc_db_get_next_id(MB_SVC_TABLE_BOOKMARK);
+
+       if (record->_id < 0) {
+               mb_svc_debug("__mb_svc_db_get_next_id failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+*/
+       query_string =
+           sqlite3_mprintf(MB_SVC_INSERT_BOOKMARK_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+//                         mb_svc_field[MB_SVC_BOOKMARK_ID].field_name,
+                           mb_svc_field[MB_SVC_BOOKMARK_MEDIA_UUID].field_name,
+                           mb_svc_field[MB_SVC_BOOKMARK_MARKED_TIME].field_name,
+                           mb_svc_field[MB_SVC_BOOKMARK_THUMBNAIL_PATH].
+                           field_name, /* record->_id, */record->media_uuid,
+                           record->marked_time, record->thumbnail_path);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("Inserting bookmark table failed\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int mb_svc_insert_record_folder(mb_svc_folder_record_s *record)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = -1;
+       mb_svc_tbl_field_s *mb_svc_field;
+       char *query_string = NULL;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_FOLDER;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       strncpy(record->uuid, _media_info_generate_uuid(), MB_SVC_UUID_LEN_MAX + 1);
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_INSERT_FOLDER_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+                           mb_svc_field[MB_SVC_FOLDER_UUID].field_name,
+                           mb_svc_field[MB_SVC_FOLDER_PATH].field_name,
+                           mb_svc_field[MB_SVC_FOLDER_DISPLAY_NAME].field_name,
+                           mb_svc_field[MB_SVC_FOLDER_MODIFIED_DATE].
+                           field_name,
+                           mb_svc_field[MB_SVC_FOLDER_WEB_ACCOUNT_ID].
+                           field_name,
+                           mb_svc_field[MB_SVC_FOLDER_STORAGE_TYPE].field_name,
+                           mb_svc_field[MB_SVC_FOLDER_SNS_TYPE].field_name,
+                           mb_svc_field[MB_SVC_FOLDER_ALBUM_LOCK_STATUS].
+                           field_name,
+                           mb_svc_field[MB_SVC_FOLDER_WEB_ALBUM_ID].field_name,
+                           mb_svc_field[MB_SVC_FOLDER_VALID].field_name,
+                           record->uuid, record->uri, record->display_name,
+                           record->modified_date, record->web_account_id,
+                           record->storage_type, record->sns_type,
+                           record->lock_status, record->web_album_id, 1);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("Inserting folder table failed\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int mb_svc_insert_record_folder_sql(mb_svc_folder_record_s *record, char **sql)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = 0;
+       mb_svc_tbl_field_s *mb_svc_field;
+
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_FOLDER;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       strncpy(record->uuid, _media_info_generate_uuid(), MB_SVC_UUID_LEN_MAX + 1);
+
+       *sql =
+           sqlite3_mprintf(MB_SVC_INSERT_FOLDER_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+                           mb_svc_field[MB_SVC_FOLDER_UUID].field_name,
+                           mb_svc_field[MB_SVC_FOLDER_PATH].field_name,
+                           mb_svc_field[MB_SVC_FOLDER_DISPLAY_NAME].field_name,
+                           mb_svc_field[MB_SVC_FOLDER_MODIFIED_DATE].
+                           field_name,
+                           mb_svc_field[MB_SVC_FOLDER_WEB_ACCOUNT_ID].
+                           field_name,
+                           mb_svc_field[MB_SVC_FOLDER_STORAGE_TYPE].field_name,
+                           mb_svc_field[MB_SVC_FOLDER_SNS_TYPE].field_name,
+                           mb_svc_field[MB_SVC_FOLDER_ALBUM_LOCK_STATUS].
+                           field_name,
+                           mb_svc_field[MB_SVC_FOLDER_WEB_ALBUM_ID].field_name,
+                           mb_svc_field[MB_SVC_FOLDER_VALID].field_name,
+                           record->uuid, record->uri, record->display_name,
+                           record->modified_date, record->web_account_id,
+                           record->storage_type, record->sns_type,
+                           record->lock_status, record->web_album_id, 1);
+
+       mb_svc_debug("Query : %s", *sql);
+
+       return err;
+}
+
+int mb_svc_insert_record_web_streaming(mb_svc_web_streaming_record_s *record)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = -1;
+       mb_svc_tbl_field_s *mb_svc_field;
+       char *query_string = NULL;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_WEB_STREAMING;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       record->_id = __mb_svc_db_get_next_id(MB_SVC_TABLE_WEB_STREAMING);
+
+       if (record->_id < 0) {
+               mb_svc_debug("__mb_svc_db_get_next_id failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_INSERT_WEB_STREAMING_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+                           mb_svc_field[MB_SVC_WEB_STREAMING_ID].field_name,
+                           mb_svc_field[MB_SVC_WEB_STREAMING_FOLDER_UUID].
+                           field_name,
+                           mb_svc_field[MB_SVC_WEB_STREAMING_TITLE].field_name,
+                           mb_svc_field[MB_SVC_WEB_STREAMING_DURATION].
+                           field_name,
+                           mb_svc_field[MB_SVC_WEB_STREAMING_URL].field_name,
+                           mb_svc_field[MB_SVC_WEB_STREAMING_THNMB_PATH].
+                           field_name, record->_id, record->folder_uuid,
+                           record->title, record->duration, record->url,
+                           record->thumb_path);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("Inserting web streaming table failed\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+/**
+ *     insert record into table--media 
+ */
+int mb_svc_insert_record_media(mb_svc_media_record_s *record,
+                              minfo_store_type storage_type)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = -1;
+       mb_svc_tbl_field_s *mb_svc_field;
+       char *query_string = NULL;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_MEDIA;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       strncpy(record->media_uuid, _media_info_generate_uuid(), MB_SVC_UUID_LEN_MAX + 1);
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_INSERT_MEDIA_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+                           mb_svc_field[MB_SVC_MEDIA_UUID].field_name,
+                           mb_svc_field[MB_SVC_MEDIA_PATH].field_name,
+                           mb_svc_field[MB_SVC_MEDIA_FOLDER_UUID].field_name,
+                           mb_svc_field[MB_SVC_MEDIA_DISPLAY_NAME].field_name,
+                           mb_svc_field[MB_SVC_MEDIA_CONTENT_TYPE].field_name,
+                           mb_svc_field[MB_SVC_MEDIA_RATING].field_name,
+                           mb_svc_field[MB_SVC_MEDIA_MODIFIED_DATE].field_name,
+                           mb_svc_field[MB_SVC_MEDIA_THUMBNAIL_PATH].
+                           field_name,
+                           mb_svc_field[MB_SVC_MEDIA_HTTP_URL].field_name,
+                           mb_svc_field[MB_SVC_MEDIA_VALID].field_name,
+                           record->media_uuid, record->path,
+                           record->folder_uuid, record->display_name, record->content_type,
+                           record->rate, record->modified_date,
+                           record->thumbnail_path, record->http_url, 1);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("Inserting media table failed\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int mb_svc_insert_record_media_sql(mb_svc_media_record_s *record,
+                                       minfo_store_type storage_type,
+                                       char **sql)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = 0;
+       mb_svc_tbl_field_s *mb_svc_field;
+
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_MEDIA;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       strncpy(record->media_uuid, _media_info_generate_uuid(), MB_SVC_UUID_LEN_MAX + 1);
+
+       *sql =
+           sqlite3_mprintf(MB_SVC_INSERT_MEDIA_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+                           mb_svc_field[MB_SVC_MEDIA_UUID].field_name,
+                           mb_svc_field[MB_SVC_MEDIA_PATH].field_name,
+                           mb_svc_field[MB_SVC_MEDIA_FOLDER_UUID].field_name,
+                           mb_svc_field[MB_SVC_MEDIA_DISPLAY_NAME].field_name,
+                           mb_svc_field[MB_SVC_MEDIA_CONTENT_TYPE].field_name,
+                           mb_svc_field[MB_SVC_MEDIA_RATING].field_name,
+                           mb_svc_field[MB_SVC_MEDIA_MODIFIED_DATE].field_name,
+                           mb_svc_field[MB_SVC_MEDIA_THUMBNAIL_PATH].
+                           field_name,
+                           mb_svc_field[MB_SVC_MEDIA_HTTP_URL].field_name,
+                           mb_svc_field[MB_SVC_MEDIA_VALID].field_name,
+                           record->media_uuid, record->path,
+                               record->folder_uuid,
+                           record->display_name, record->content_type,
+                           record->rate, record->modified_date,
+                           record->thumbnail_path, record->http_url, 1);
+
+       mb_svc_debug("Query : %s", *sql);
+
+       return err;
+}
+
+int
+mb_svc_insert_record_video_meta(mb_svc_video_meta_record_s *record,
+                               minfo_store_type storage_type)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = -1;
+       mb_svc_tbl_field_s *mb_svc_field;
+       char *query_string = NULL;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_VIDEO_META;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+/*
+       record->_id = __mb_svc_db_get_next_id(MB_SVC_TABLE_VIDEO_META);
+
+       if (record->_id < 0) {
+               mb_svc_debug("__mb_svc_db_get_next_id failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+*/
+       query_string =
+           sqlite3_mprintf(MB_SVC_INSERT_VIDEO_META_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+//                         mb_svc_field[MB_SVC_VIDEO_META_ID].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_MEDIA_UUID].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_ALBUM].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_ARTIST].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_TITLE].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_DESCRIPTION].
+                           field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_YOUTUBE_CATEGORY].
+                           field_name,
+                           mb_svc_field
+                           [MB_SVC_VIDEO_META_BOOKMARK_LAST_PLAYED].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_DURATION].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_LONGISTUDE].
+                           field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_LATITUDE].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_WIDTH].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_HEIGHT].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_DATETAKEN].
+                           field_name, /* record->_id, */record->media_uuid,
+                           record->album, record->artist, record->title,
+                           record->description, record->youtube_category,
+                           record->last_played_time, record->duration,
+                           record->longitude, record->latitude, record->width,
+                           record->height, record->datetaken);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("Inserting video meta table failed\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int
+mb_svc_insert_record_video_meta_sql(mb_svc_video_meta_record_s *record,
+                               minfo_store_type storage_type,
+                               char **sql)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = 0;
+       mb_svc_tbl_field_s *mb_svc_field;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_VIDEO_META;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+/*
+       record->_id = __mb_svc_db_get_next_id(MB_SVC_TABLE_VIDEO_META);
+
+       if (record->_id < 0) {
+               mb_svc_debug("__mb_svc_db_get_next_id failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+*/
+       *sql =
+           sqlite3_mprintf(MB_SVC_INSERT_VIDEO_META_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+//                         mb_svc_field[MB_SVC_VIDEO_META_ID].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_MEDIA_UUID].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_ALBUM].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_ARTIST].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_TITLE].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_DESCRIPTION].
+                           field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_YOUTUBE_CATEGORY].
+                           field_name,
+                           mb_svc_field
+                           [MB_SVC_VIDEO_META_BOOKMARK_LAST_PLAYED].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_DURATION].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_LONGISTUDE].
+                           field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_LATITUDE].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_WIDTH].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_HEIGHT].field_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_DATETAKEN].
+                           field_name, /* record->_id, */record->media_uuid,
+                           record->album, record->artist, record->title,
+                           record->description, record->youtube_category,
+                           record->last_played_time, record->duration,
+                           record->longitude, record->latitude, record->width,
+                           record->height, record->datetaken);
+
+       mb_svc_debug("Query : %s", *sql);
+
+       return err;
+}
+
+int
+mb_svc_insert_record_image_meta(mb_svc_image_meta_record_s *record,
+                               minfo_store_type storage_type)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = -1;
+       mb_svc_tbl_field_s *mb_svc_field;
+       char *query_string = NULL;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_IMAGE_META;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+/*
+       record->_id = __mb_svc_db_get_next_id(MB_SVC_TABLE_IMAGE_META);
+
+       if (record->_id < 0) {
+               mb_svc_debug("__mb_svc_db_get_next_id failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+*/
+       query_string =
+           sqlite3_mprintf(MB_SVC_INSERT_IMAGE_META_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+//                         mb_svc_field[MB_SVC_IMAGE_META_ID].field_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_MEDIA_UUID].field_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_LONGISTUDE].
+                           field_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_LATITUDE].field_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_DESCRIPTION].
+                           field_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_WIDTH].field_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_HEIGHT].field_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_ORIENTATION].
+                           field_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_DATETAKEN].
+                           field_name, /* record->_id, */record->media_uuid,
+                           record->longitude, record->latitude,
+                           record->description, record->width, record->height,
+                           record->orientation, record->datetaken);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("Inserting image meta table failed\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int
+mb_svc_insert_record_image_meta_sql(mb_svc_image_meta_record_s *record,
+                               minfo_store_type storage_type,
+                               char **sql)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = 0;
+       mb_svc_tbl_field_s *mb_svc_field;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_IMAGE_META;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+/*
+       record->_id = __mb_svc_db_get_next_id(MB_SVC_TABLE_IMAGE_META);
+
+       if (record->_id < 0) {
+               mb_svc_debug("__mb_svc_db_get_next_id failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+*/
+       *sql =
+           sqlite3_mprintf(MB_SVC_INSERT_IMAGE_META_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+//                         mb_svc_field[MB_SVC_IMAGE_META_ID].field_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_MEDIA_UUID].field_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_LONGISTUDE].
+                           field_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_LATITUDE].field_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_DESCRIPTION].
+                           field_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_WIDTH].field_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_HEIGHT].field_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_ORIENTATION].
+                           field_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_DATETAKEN].
+                           field_name, /* record->_id, */record->media_uuid,
+                           record->longitude, record->latitude,
+                           record->description, record->width, record->height,
+                           record->orientation, record->datetaken);
+
+       mb_svc_debug("Query : %s", *sql);
+
+       return err;
+}
+
+int mb_svc_update_record_folder(mb_svc_folder_record_s *record)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = -1;
+       mb_svc_tbl_field_s *mb_svc_field;
+       char *query_string = NULL;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_FOLDER;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_UPDATE_FOLDER_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+                           mb_svc_field[MB_SVC_FOLDER_PATH].field_name,
+                           record->uri,
+                           mb_svc_field[MB_SVC_FOLDER_DISPLAY_NAME].field_name,
+                           record->display_name,
+                           mb_svc_field[MB_SVC_FOLDER_MODIFIED_DATE].
+                           field_name, record->modified_date,
+                           mb_svc_field[MB_SVC_FOLDER_WEB_ACCOUNT_ID].
+                           field_name, record->web_account_id,
+                           mb_svc_field[MB_SVC_FOLDER_STORAGE_TYPE].field_name,
+                           record->storage_type,
+                           mb_svc_field[MB_SVC_FOLDER_SNS_TYPE].field_name,
+                           record->sns_type,
+                           mb_svc_field[MB_SVC_FOLDER_ALBUM_LOCK_STATUS].
+                           field_name, record->lock_status, record->uuid);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("Updating folder table failed\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int mb_svc_update_record_folder_sql(mb_svc_folder_record_s *record, char **sql)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = 0;
+       mb_svc_tbl_field_s *mb_svc_field;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_FOLDER;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       *sql =
+           sqlite3_mprintf(MB_SVC_UPDATE_FOLDER_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+                           mb_svc_field[MB_SVC_FOLDER_PATH].field_name,
+                           record->uri,
+                           mb_svc_field[MB_SVC_FOLDER_DISPLAY_NAME].field_name,
+                           record->display_name,
+                           mb_svc_field[MB_SVC_FOLDER_MODIFIED_DATE].
+                           field_name, record->modified_date,
+                           mb_svc_field[MB_SVC_FOLDER_WEB_ACCOUNT_ID].
+                           field_name, record->web_account_id,
+                           mb_svc_field[MB_SVC_FOLDER_STORAGE_TYPE].field_name,
+                           record->storage_type,
+                           mb_svc_field[MB_SVC_FOLDER_SNS_TYPE].field_name,
+                           record->sns_type,
+                           mb_svc_field[MB_SVC_FOLDER_ALBUM_LOCK_STATUS].
+                           field_name, record->lock_status, record->uuid);
+
+       mb_svc_debug("Query : %s", *sql);
+
+       return err;
+}
+
+int mb_svc_update_record_folder_path(char *old_path, char *new_path)
+{
+       mb_svc_debug("");
+
+       if (old_path == NULL || new_path == NULL) {
+               mb_svc_debug("old_path == NULL || new_path ");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = -1;
+       mb_svc_tbl_field_s *mb_svc_field;
+       char *query_string = NULL;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_FOLDER;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_UPDATE_FOLDER_PATH_TABLE,
+                           mb_svc_tbl[field_seq].table_name, old_path,
+                           new_path);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("Updating folder table failed\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int mb_svc_update_folder_modified_date(char *path, int date)
+{
+       mb_svc_debug("");
+
+       if (path == NULL) {
+               mb_svc_debug("old_path == NULL || new_path == NULL ");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = -1;
+       mb_svc_tbl_field_s *mb_svc_field;
+       char *query_string = NULL;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_FOLDER;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+       char path_like[MB_SVC_FILE_PATH_LEN_MAX + 1];
+
+       snprintf(path_like, sizeof(path_like), "%s%%", path);
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_UPDATE_FOLDER_MODIFIED_DATE_TABLE,
+                           mb_svc_tbl[field_seq].table_name, date, path_like);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("Updating folder table failed\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int mb_svc_update_record_media(mb_svc_media_record_s *record)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = -1;
+       mb_svc_tbl_field_s *mb_svc_field;
+       char *query_string = NULL;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_MEDIA;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_UPDATE_MEDIA_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+                           mb_svc_field[MB_SVC_MEDIA_FOLDER_UUID].field_name,
+                           record->folder_uuid,
+                           mb_svc_field[MB_SVC_MEDIA_PATH].field_name,
+                           record->path,
+                           mb_svc_field[MB_SVC_MEDIA_DISPLAY_NAME].field_name,
+                           record->display_name,
+                           mb_svc_field[MB_SVC_MEDIA_CONTENT_TYPE].field_name,
+                           record->content_type,
+                           mb_svc_field[MB_SVC_MEDIA_RATING].field_name,
+                           record->rate,
+                           mb_svc_field[MB_SVC_MEDIA_MODIFIED_DATE].field_name,
+                           record->modified_date,
+                           mb_svc_field[MB_SVC_MEDIA_THUMBNAIL_PATH].
+                           field_name, record->thumbnail_path,
+                           mb_svc_field[MB_SVC_MEDIA_HTTP_URL].field_name,
+                           record->http_url, record->media_uuid);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("Updating media table failed\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int mb_svc_update_record_media_sql(mb_svc_media_record_s *record, char **sql)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = 0;
+       mb_svc_tbl_field_s *mb_svc_field;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_MEDIA;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       *sql =
+           sqlite3_mprintf(MB_SVC_UPDATE_MEDIA_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+                           mb_svc_field[MB_SVC_MEDIA_FOLDER_UUID].field_name,
+                           record->folder_uuid,
+                           mb_svc_field[MB_SVC_MEDIA_PATH].field_name,
+                           record->path,
+                           mb_svc_field[MB_SVC_MEDIA_DISPLAY_NAME].field_name,
+                           record->display_name,
+                           mb_svc_field[MB_SVC_MEDIA_CONTENT_TYPE].field_name,
+                           record->content_type,
+                           mb_svc_field[MB_SVC_MEDIA_RATING].field_name,
+                           record->rate,
+                           mb_svc_field[MB_SVC_MEDIA_MODIFIED_DATE].field_name,
+                           record->modified_date,
+                           mb_svc_field[MB_SVC_MEDIA_THUMBNAIL_PATH].
+                           field_name, record->thumbnail_path,
+                           mb_svc_field[MB_SVC_MEDIA_HTTP_URL].field_name,
+                           record->http_url, record->media_uuid);
+
+       mb_svc_debug("Query : %s", *sql);
+
+       return err;
+}
+
+int mb_svc_update_record_video_meta(mb_svc_video_meta_record_s *record)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = -1;
+       mb_svc_tbl_field_s *mb_svc_field;
+       char *query_string = NULL;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_VIDEO_META;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_UPDATE_VIDEO_META_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+                           mb_svc_field[MB_SVC_VIDEO_META_MEDIA_UUID].field_name,
+                           record->media_uuid,
+                           mb_svc_field[MB_SVC_VIDEO_META_ALBUM].field_name,
+                           record->album,
+                           mb_svc_field[MB_SVC_VIDEO_META_ARTIST].field_name,
+                           record->artist,
+                           mb_svc_field[MB_SVC_VIDEO_META_TITLE].field_name,
+                           record->title,
+                           mb_svc_field[MB_SVC_VIDEO_META_DESCRIPTION].
+                           field_name, record->description,
+                           mb_svc_field[MB_SVC_VIDEO_META_YOUTUBE_CATEGORY].
+                           field_name, record->youtube_category,
+                           mb_svc_field
+                           [MB_SVC_VIDEO_META_BOOKMARK_LAST_PLAYED].field_name,
+                           record->last_played_time,
+                           mb_svc_field[MB_SVC_VIDEO_META_DURATION].field_name,
+                           record->duration,
+                           mb_svc_field[MB_SVC_VIDEO_META_LONGISTUDE].
+                           field_name, record->longitude,
+                           mb_svc_field[MB_SVC_VIDEO_META_LATITUDE].field_name,
+                           record->latitude,
+                           mb_svc_field[MB_SVC_VIDEO_META_WIDTH].field_name,
+                           record->width,
+                           mb_svc_field[MB_SVC_VIDEO_META_HEIGHT].field_name,
+                           record->height,
+                           mb_svc_field[MB_SVC_VIDEO_META_DATETAKEN].
+                           field_name, record->datetaken, record->_id);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("Updating video meta table failed\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int mb_svc_update_record_image_meta(mb_svc_image_meta_record_s *record)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = -1;
+       mb_svc_tbl_field_s *mb_svc_field;
+       char *query_string = NULL;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_IMAGE_META;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_UPDATE_IMAGE_META_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+                           mb_svc_field[MB_SVC_IMAGE_META_MEDIA_UUID].field_name,
+                           record->media_uuid,
+                           mb_svc_field[MB_SVC_IMAGE_META_LONGISTUDE].
+                           field_name, record->longitude,
+                           mb_svc_field[MB_SVC_IMAGE_META_LATITUDE].field_name,
+                           record->latitude,
+                           mb_svc_field[MB_SVC_IMAGE_META_DESCRIPTION].
+                           field_name, record->description,
+                           mb_svc_field[MB_SVC_IMAGE_META_WIDTH].field_name,
+                           record->width,
+                           mb_svc_field[MB_SVC_IMAGE_META_HEIGHT].field_name,
+                           record->height,
+                           mb_svc_field[MB_SVC_IMAGE_META_ORIENTATION].
+                           field_name, record->orientation,
+                           mb_svc_field[MB_SVC_IMAGE_META_DATETAKEN].
+                           field_name, record->datetaken, record->_id);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("Updating image meta table failed\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int
+mb_svc_update_width_and_height(const char *media_id, minfo_file_type content_type,
+                              int width, int height)
+{
+       mb_svc_debug("");
+
+       if (content_type <= MINFO_ITEM_NONE || content_type >= MINFO_ITEM_ALL) {
+               mb_svc_debug
+                   ("content_type <= MINFO_ITEM_NONE || content_type >= MINFO_ITEM_ALL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = -1;
+       mb_svc_tbl_field_s *mb_svc_field;
+       char *query_string = NULL;
+       mb_svc_tbl_name_e field_seq;
+
+       if (content_type == MINFO_ITEM_IMAGE)
+               field_seq = MB_SVC_TABLE_IMAGE_META;
+       else if (content_type == MINFO_ITEM_VIDEO)
+               field_seq = MB_SVC_TABLE_VIDEO_META;
+       else
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       if (content_type == MINFO_ITEM_IMAGE)
+               query_string =
+                   sqlite3_mprintf(MB_SVC_UPDATE_META_WIDTH_HEIGHT,
+                                   mb_svc_tbl[field_seq].table_name,
+                                   mb_svc_field[MB_SVC_IMAGE_META_WIDTH].
+                                   field_name, width,
+                                   mb_svc_field[MB_SVC_IMAGE_META_HEIGHT].
+                                   field_name, height, media_id);
+       else if (content_type == MINFO_ITEM_VIDEO)
+               query_string =
+                   sqlite3_mprintf(MB_SVC_UPDATE_META_WIDTH_HEIGHT,
+                                   mb_svc_tbl[field_seq].table_name,
+                                   mb_svc_field[MB_SVC_VIDEO_META_WIDTH].
+                                   field_name, width,
+                                   mb_svc_field[MB_SVC_VIDEO_META_HEIGHT].
+                                   field_name, height, media_id);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("Updating image meta width and height failed\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int
+mb_svc_update_width_and_height_sql(const char *media_id, minfo_file_type content_type,
+                              int width, int height, char **sql)
+{
+       mb_svc_debug("");
+
+       if (content_type <= MINFO_ITEM_NONE || content_type >= MINFO_ITEM_ALL) {
+               mb_svc_debug
+                   ("content_type <= MINFO_ITEM_NONE || content_type >= MINFO_ITEM_ALL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = 0;
+       mb_svc_tbl_field_s *mb_svc_field;
+       mb_svc_tbl_name_e field_seq;
+
+       if (content_type == MINFO_ITEM_IMAGE)
+               field_seq = MB_SVC_TABLE_IMAGE_META;
+       else if (content_type == MINFO_ITEM_VIDEO)
+               field_seq = MB_SVC_TABLE_VIDEO_META;
+       else
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       if (content_type == MINFO_ITEM_IMAGE)
+               *sql =
+                   sqlite3_mprintf(MB_SVC_UPDATE_META_WIDTH_HEIGHT,
+                                   mb_svc_tbl[field_seq].table_name,
+                                   mb_svc_field[MB_SVC_IMAGE_META_WIDTH].
+                                   field_name, width,
+                                   mb_svc_field[MB_SVC_IMAGE_META_HEIGHT].
+                                   field_name, height, media_id);
+       else if (content_type == MINFO_ITEM_VIDEO)
+               *sql =
+                   sqlite3_mprintf(MB_SVC_UPDATE_META_WIDTH_HEIGHT,
+                                   mb_svc_tbl[field_seq].table_name,
+                                   mb_svc_field[MB_SVC_VIDEO_META_WIDTH].
+                                   field_name, width,
+                                   mb_svc_field[MB_SVC_VIDEO_META_HEIGHT].
+                                   field_name, height, media_id);
+
+       mb_svc_debug("Query : %s", *sql);
+
+       return err;
+}
+
+int
+mb_svc_load_record_bookmark(sqlite3_stmt *stmt,
+                           mb_svc_bookmark_record_s *record)
+{
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+       record->_id = sqlite3_column_int(stmt, MB_SVC_BOOKMARK_ID);
+       strncpy(record->media_uuid,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_BOOKMARK_MEDIA_UUID),
+               MB_SVC_UUID_LEN_MAX + 1);
+       record->marked_time =
+           sqlite3_column_int(stmt, MB_SVC_BOOKMARK_MARKED_TIME);
+       strncpy(record->thumbnail_path,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_BOOKMARK_THUMBNAIL_PATH),
+               MB_SVC_FILE_PATH_LEN_MAX + 1);
+
+       return 0;
+}
+
+int
+mb_svc_load_record_folder(sqlite3_stmt *stmt, mb_svc_folder_record_s *record)
+{
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       strncpy(record->uuid,
+               (const char *)sqlite3_column_text(stmt, MB_SVC_FOLDER_UUID),
+               MB_SVC_UUID_LEN_MAX + 1);
+       strncpy(record->uri,
+               (const char *)sqlite3_column_text(stmt, MB_SVC_FOLDER_PATH),
+               MB_SVC_DIR_PATH_LEN_MAX + 1);
+       strncpy(record->display_name,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_FOLDER_DISPLAY_NAME),
+               MB_SVC_FILE_NAME_LEN_MAX + 1);
+       record->modified_date =
+           sqlite3_column_int(stmt, MB_SVC_FOLDER_MODIFIED_DATE);
+       strncpy(record->web_account_id,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_FOLDER_WEB_ACCOUNT_ID),
+               MB_SVC_ARRAY_LEN_MAX + 1);
+       record->storage_type =
+           sqlite3_column_int(stmt, MB_SVC_FOLDER_STORAGE_TYPE);
+       record->sns_type = sqlite3_column_int(stmt, MB_SVC_FOLDER_SNS_TYPE);
+       record->lock_status =
+           sqlite3_column_int(stmt, MB_SVC_FOLDER_ALBUM_LOCK_STATUS);
+       strncpy(record->web_album_id,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_FOLDER_WEB_ALBUM_ID),
+               MB_SVC_ARRAY_LEN_MAX + 1);
+
+       return 0;
+}
+
+int
+mb_svc_load_record_folder_name(sqlite3_stmt *stmt, char *folder_name,
+                              int max_length)
+{
+       if (folder_name == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       strncpy(folder_name, (const char *)sqlite3_column_text(stmt, 0),
+               max_length);
+
+       return 0;
+}
+
+int
+mb_svc_load_record_web_streaming(sqlite3_stmt *stmt,
+                                mb_svc_web_streaming_record_s *record)
+{
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       record->_id = sqlite3_column_int(stmt, MB_SVC_WEB_STREAMING_ID);
+       strncpy(record->folder_uuid,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_WEB_STREAMING_FOLDER_UUID),
+               sizeof(record->folder_uuid));
+       strncpy(record->title,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_WEB_STREAMING_TITLE),
+               sizeof(record->title));
+       record->title[sizeof(record->title) - 1] = '\0';
+       record->duration =
+           sqlite3_column_int(stmt, MB_SVC_WEB_STREAMING_DURATION);
+       strncpy(record->url,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_WEB_STREAMING_URL),
+               MB_SVC_FILE_PATH_LEN_MAX + 1);
+       strncpy(record->thumb_path,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_WEB_STREAMING_THNMB_PATH),
+               MB_SVC_FILE_PATH_LEN_MAX + 1);
+
+       return 0;
+}
+
+int
+mb_svc_load_record_media(sqlite3_stmt *stmt, mb_svc_media_record_s *record)
+{
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       strncpy(record->media_uuid,
+               (const char *)sqlite3_column_text(stmt, MB_SVC_MEDIA_UUID),
+               MB_SVC_UUID_LEN_MAX + 1);
+       strncpy(record->folder_uuid,
+               (const char *)sqlite3_column_text(stmt, MB_SVC_MEDIA_FOLDER_UUID),
+               MB_SVC_UUID_LEN_MAX + 1);
+       strncpy(record->path,
+               (const char *)sqlite3_column_text(stmt, MB_SVC_MEDIA_PATH),
+               MB_SVC_FILE_PATH_LEN_MAX + 1);
+       strncpy(record->display_name,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_MEDIA_DISPLAY_NAME),
+               MB_SVC_FILE_NAME_LEN_MAX + 1);
+       record->content_type =
+           sqlite3_column_int(stmt, MB_SVC_MEDIA_CONTENT_TYPE);
+       record->rate = sqlite3_column_int(stmt, MB_SVC_MEDIA_RATING);
+       record->modified_date =
+           sqlite3_column_int(stmt, MB_SVC_MEDIA_MODIFIED_DATE);
+       strncpy(record->thumbnail_path,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_MEDIA_THUMBNAIL_PATH),
+               MB_SVC_FILE_PATH_LEN_MAX + 1);
+       strncpy(record->http_url,
+               (const char *)sqlite3_column_text(stmt, MB_SVC_MEDIA_HTTP_URL),
+               MB_SVC_DIR_PATH_LEN_MAX + 1);
+
+       return 0;
+}
+
+int
+mb_svc_load_record_video_meta(sqlite3_stmt *stmt,
+                             mb_svc_video_meta_record_s *record)
+{
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+       record->_id = sqlite3_column_int(stmt, MB_SVC_VIDEO_META_ID);
+       strncpy(record->media_uuid,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_VIDEO_META_MEDIA_UUID),
+               MB_SVC_UUID_LEN_MAX + 1);
+       strncpy(record->album,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_VIDEO_META_ALBUM),
+               MB_SVC_FILE_NAME_LEN_MAX + 1);
+       strncpy(record->artist,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_VIDEO_META_ARTIST),
+               MB_SVC_ARRAY_LEN_MAX + 1);
+       strncpy(record->title,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_VIDEO_META_TITLE),
+               MB_SVC_FILE_NAME_LEN_MAX + 1);
+       strncpy(record->description,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_VIDEO_META_DESCRIPTION),
+               MB_SVC_ARRAY_LEN_MAX + 1);
+       strncpy(record->youtube_category,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_VIDEO_META_YOUTUBE_CATEGORY),
+               MB_SVC_ARRAY_LEN_MAX + 1);
+       record->last_played_time =
+           sqlite3_column_int(stmt, MB_SVC_VIDEO_META_BOOKMARK_LAST_PLAYED);
+       record->duration = sqlite3_column_int(stmt, MB_SVC_VIDEO_META_DURATION);
+       record->longitude =
+           sqlite3_column_double(stmt, MB_SVC_VIDEO_META_LONGISTUDE);
+       record->latitude =
+           sqlite3_column_double(stmt, MB_SVC_VIDEO_META_LATITUDE);
+       record->width = sqlite3_column_int(stmt, MB_SVC_VIDEO_META_LATITUDE);
+       record->height = sqlite3_column_int(stmt, MB_SVC_VIDEO_META_LATITUDE);
+       record->datetaken =
+           sqlite3_column_int(stmt, MB_SVC_VIDEO_META_LATITUDE);
+
+       return 0;
+}
+
+int
+mb_svc_load_record_image_meta(sqlite3_stmt *stmt,
+                             mb_svc_image_meta_record_s *record)
+{
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+       record->_id = sqlite3_column_int(stmt, MB_SVC_IMAGE_META_ID);
+       strncpy(record->media_uuid,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_IMAGE_META_MEDIA_UUID),
+               MB_SVC_UUID_LEN_MAX + 1);
+       record->longitude =
+           sqlite3_column_double(stmt, MB_SVC_IMAGE_META_LONGISTUDE);
+       record->latitude =
+           sqlite3_column_double(stmt, MB_SVC_IMAGE_META_LATITUDE);
+       strncpy(record->description,
+               (const char *)sqlite3_column_text(stmt,
+                                                 MB_SVC_IMAGE_META_DESCRIPTION),
+               MB_SVC_ARRAY_LEN_MAX + 1);
+       record->width = sqlite3_column_int(stmt, MB_SVC_IMAGE_META_WIDTH);
+       record->height = sqlite3_column_int(stmt, MB_SVC_IMAGE_META_HEIGHT);
+       record->orientation =
+           sqlite3_column_int(stmt, MB_SVC_IMAGE_META_ORIENTATION);
+       record->datetaken =
+           sqlite3_column_int(stmt, MB_SVC_IMAGE_META_DATETAKEN);
+
+       return 0;
+}
+
+int mb_svc_delete_record_media(const char *folder_id, char *display_name)
+{
+       int err = -1;
+       char *query_string = NULL;
+
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+
+       snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
+                mb_svc_tbl[MB_SVC_TABLE_MEDIA].table_name);
+
+       query_string = sqlite3_mprintf(MB_SVC_DELETE_MEDIA_BY_FOLDER_ID_AND_DISPLAY_NAME,
+                                                                       table_name, folder_id, display_name);
+
+       err = mb_svc_query_sql(query_string);
+       if (err < 0) {
+               mb_svc_debug("failed to delete record\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_free(query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return 0;
+}
+
+int mb_svc_delete_record_folder_sql(const char *folder_id, char **sql)
+{
+       *sql = sqlite3_mprintf(MB_SVC_RECORD_DELETE_BY_UUID,
+                                                       mb_svc_tbl[MB_SVC_TABLE_FOLDER].table_name,
+                                                       folder_id);
+
+       return 0;
+}
+
+int mb_svc_delete_record_media_sql(const char *media_id, char **sql)
+{
+       *sql = sqlite3_mprintf(MB_SVC_RECORD_DELETE_BY_UUID,
+                                                       mb_svc_tbl[MB_SVC_TABLE_MEDIA].table_name,
+                                                       media_id);
+
+       return 0;
+}
+
+int mb_svc_delete_record_image_meta_sql(const char *media_id, char **sql)
+{
+       *sql = sqlite3_mprintf(MB_SVC_DELETE_MEDIA_RELATED_INFO_BY_MEDIA_UUID,
+                                                       mb_svc_tbl[MB_SVC_TABLE_IMAGE_META].table_name,
+                                                       media_id);
+
+       return 0;
+}
+
+
+int mb_svc_delete_record_video_meta_sql(const char *media_id, char **sql)
+{
+       *sql = sqlite3_mprintf(MB_SVC_DELETE_MEDIA_RELATED_INFO_BY_MEDIA_UUID,
+                                                       mb_svc_tbl[MB_SVC_TABLE_VIDEO_META].table_name,
+                                                       media_id);
+
+       return 0;
+}
+
+int
+mb_svc_delete_tagmap_by_media_id_sql(const char *media_id, char **sql)
+{
+       *sql = sqlite3_mprintf(MB_SVC_DELETE_MEDIA_RELATED_INFO_BY_MEDIA_UUID,
+                                                       mb_svc_tbl[MB_SVC_TABLE_TAG_MAP].table_name,
+                                                       media_id);
+
+       return 0;
+}
+
+int mb_svc_insert_record_tag(mb_svc_tag_record_s *record)
+{
+       mb_svc_debug("");
+
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = -1;
+       mb_svc_tbl_field_s *mb_svc_field;
+       char *query_string = NULL;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_TAG;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       record->_id = __mb_svc_db_get_next_id(MB_SVC_TABLE_TAG);
+
+       if (record->_id < 0) {
+               mb_svc_debug("__mb_svc_db_get_next_id failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_INSERT_TAG_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+                           mb_svc_field[MB_SVC_TAG_ID].field_name,
+                           mb_svc_field[MB_SVC_TAG_NAME].field_name,
+                           record->_id, record->tag_name);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("Inserting tag table failed\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int mb_svc_insert_record_tag_map(const char *media_uuid, int tag_id)
+{
+       mb_svc_debug("");
+
+       int err = -1;
+       mb_svc_tbl_field_s *mb_svc_field;
+       char *query_string = NULL;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_TAG_MAP;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       int _id = __mb_svc_db_get_next_id(MB_SVC_TABLE_TAG_MAP);
+
+       if (_id < 0) {
+               mb_svc_debug("__mb_svc_db_get_next_id failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       query_string =
+           sqlite3_mprintf(MB_SVC_INSERT_TAG_MAP_TABLE,
+                           mb_svc_tbl[field_seq].table_name,
+                           mb_svc_field[MB_SVC_TAG_MAP_ID].field_name,
+                           mb_svc_field[MB_SVC_TAG_MAP_MEDIA_UUID].field_name,
+                           mb_svc_field[MB_SVC_TAG_MAP_TAG_ID].field_name, _id,
+                           media_uuid, tag_id);
+
+       mb_svc_debug("Query : %s", query_string);
+
+       err = mb_svc_query_sql(query_string);
+       sqlite3_free(query_string);
+
+       if (err < 0) {
+               mb_svc_debug("Inserting tag map table failed\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return err;
+}
+
+int mb_svc_load_record_tag(sqlite3_stmt *stmt, mb_svc_tag_record_s *record)
+{
+       mb_svc_debug("mb_svc_load_record_tag--enter\n");
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+       record->_id = sqlite3_column_int(stmt, MB_SVC_TAG_ID);
+       strncpy(record->tag_name,
+               (const char *)sqlite3_column_text(stmt, MB_SVC_TAG_NAME),
+               MB_SVC_ARRAY_LEN_MAX + 1);
+
+       mb_svc_debug("mb_svc_load_record_tag--leave\n");
+       return 0;
+}
+
+int mb_svc_load_record_tagmap(sqlite3_stmt *stmt, mb_svc_tag_record_s *record)
+{
+       mb_svc_debug("mb_svc_load_record_tag--enter\n");
+       if (record == NULL) {
+               mb_svc_debug("record pointer is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       record->_id = sqlite3_column_int(stmt, MB_SVC_TAG_MAP_ID);      
+       strncpy(record->media_uuid,
+               (const char *)sqlite3_column_text(stmt, MB_SVC_TAG_MAP_MEDIA_UUID),
+               MB_SVC_UUID_LEN_MAX + 1);
+
+       strncpy(record->tag_name, "", MB_SVC_ARRAY_LEN_MAX + 1);
+
+       mb_svc_debug("mb_svc_load_record_tag--leave\n");
+       return 0;
+}
+
+int
+mb_svc_delete_bookmark_meta_by_media_id(const char *media_id, minfo_file_type content_type)
+{
+       int err = -1;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+       char *tbl_name = NULL;
+
+       if (content_type == MINFO_ITEM_IMAGE) {
+               tbl_name = MB_SVC_TBL_NAME_IMAGE_META;
+       } else if (content_type == MINFO_ITEM_VIDEO) {
+               tbl_name = MB_SVC_TBL_NAME_VIDEO_META;
+       } else {
+               return MB_SVC_ERROR_INTERNAL;
+       }
+
+       /* delete video or image record */
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+
+       snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s", tbl_name);
+
+       snprintf(query_string, sizeof(query_string),
+                MB_SVC_DELETE_MEDIA_RELATED_INFO_BY_MEDIA_UUID, table_name,
+                media_id);
+       err = mb_svc_query_sql(query_string);
+       if (err < 0) {
+               mb_svc_debug("failed to delete record\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       /* if video record delete, then its related bookmark should be deleted too. */
+       if (content_type == MINFO_ITEM_VIDEO) {
+               tbl_name = MB_SVC_TBL_NAME_BOOKMARK;
+               snprintf(query_string, sizeof(query_string),
+                        MB_SVC_DELETE_MEDIA_RELATED_INFO_BY_MEDIA_UUID, tbl_name,
+                        media_id);
+               err = mb_svc_query_sql(query_string);
+               if (err < 0) {
+                       mb_svc_debug("failed to delete record\n");
+                       mb_svc_debug("query string is %s\n", query_string);
+                       return MB_SVC_ERROR_DB_INTERNAL;
+               }
+       }
+
+       /* still delete a tag record. */
+       tbl_name = MB_SVC_TBL_NAME_TAG_MAP;
+       snprintf(query_string, sizeof(query_string),
+                MB_SVC_DELETE_MEDIA_RELATED_INFO_BY_MEDIA_UUID, tbl_name,
+                media_id);
+
+       err = mb_svc_query_sql(query_string);
+       if (err < 0) {
+               mb_svc_debug("failed to delete record\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return 0;
+}
+
+int
+mb_svc_delete_bookmark_meta_by_media_id_sql(const char *media_id, char **sql)
+{
+       *sql = sqlite3_mprintf(MB_SVC_DELETE_MEDIA_RELATED_INFO_BY_MEDIA_UUID,
+                                                       mb_svc_tbl[MB_SVC_TABLE_BOOKMARK].table_name,
+                                                       media_id);
+
+       return 0;
+}
+
+int mb_svc_update_thumb_path_by_id(const char *media_id, const char *thumb_path)
+{
+       int err = -1;
+       char *query_string = NULL;
+
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+
+       snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
+                mb_svc_tbl[MB_SVC_TABLE_MEDIA].table_name);
+
+       query_string = sqlite3_mprintf(MB_SVC_UPDATE_MEDIA_THUMB_PATH, 
+                                                                               table_name, thumb_path, media_id);
+
+       err = mb_svc_query_sql(query_string);
+       if (err < 0) {
+               mb_svc_debug("failed to update record favorite\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               sqlite3_free(query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       sqlite3_free(query_string);
+
+       return 0;
+}
+
+int mb_svc_update_favorite_by_id(const char *media_id, int favorite)
+{
+       int err = -1;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+
+       snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
+                mb_svc_tbl[MB_SVC_TABLE_MEDIA].table_name);
+
+       snprintf(query_string, sizeof(query_string),
+                MB_SVC_UPDATE_MEDIA_FAVORITE_BY_ID, table_name, favorite,
+                media_id);
+       err = mb_svc_query_sql(query_string);
+       if (err < 0) {
+               mb_svc_debug("failed to update record favorite\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return 0;
+}
+
+int mb_svc_update_date_by_id(const char *media_id, int date)
+{
+       mb_svc_debug("");
+       int err = -1;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+
+       snprintf(table_name, sizeof(table_name), "%s",
+                mb_svc_tbl[MB_SVC_TABLE_MEDIA].table_name);
+
+       snprintf(query_string, sizeof(query_string),
+                MB_SVC_UPDATE_MEDIA_DATE_BY_ID, table_name, date, media_id);
+       err = mb_svc_query_sql(query_string);
+       if (err < 0) {
+               mb_svc_debug("failed to update record date\n");
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       return 0;
+}
+
+int mb_svc_update_thumb_path_sql(const char *media_id, const char *thumb_path, char **sql)
+{
+       mb_svc_debug("");
+
+       if (thumb_path == NULL) {
+               mb_svc_debug("thumb_path is null\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("thumb:%s, id:%d", thumb_path, media_id);
+
+       int err = 0;
+       mb_svc_tbl_field_s *mb_svc_field;
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_MEDIA;
+       mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
+
+       *sql =
+           sqlite3_mprintf(MB_SVC_UPDATE_MEDIA_THUMB_PATH, 
+                                               mb_svc_tbl[field_seq].table_name,
+                                               thumb_path,
+                                               media_id);
+       
+       mb_svc_debug("Query : %s", *sql);
+
+       return err;
+}
+
+int
+mb_svc_update_album_lock_status(const char *folder_id, int lock,
+                               minfo_store_type storage_type)
+{
+       int err = 0;
+       sqlite3_stmt *stmt = NULL;
+       char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+
+       if (lock != 0 && lock != 1) {
+               mb_svc_debug("lock status is invalid");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       mb_svc_debug
+           ("mb_svc_update_album_lock_status( folder id:%d, storage_type:%d, lock:%d",
+            folder_id, storage_type, lock);
+
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+
+       snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
+                MB_SVC_TBL_NAME_FOLDER);
+
+       snprintf(query_string, sizeof(query_string),
+                MB_SVC_UPDATE_FOLDER_ALBUM_STATUS, table_name);
+       mb_svc_debug("Query : %s", query_string);
+
+       err =
+           sqlite3_prepare_v2(handle, query_string, strlen(query_string),
+                              &stmt, NULL);
+
+       if (err != SQLITE_OK) {
+               mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", query_string);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       sqlite3_bind_int(stmt, 1, lock);
+       sqlite3_bind_text(stmt, 2, folder_id, strlen(folder_id), NULL);
+
+       err = sqlite3_step(stmt);
+
+       if (err != SQLITE_OK && err != SQLITE_DONE) {
+               mb_svc_debug("sqlite3_step fails : %s, db error info is : %s",
+                            query_string, sqlite3_errmsg(handle));
+
+               err = MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       sqlite3_finalize(stmt);
+
+       return err;
+}
+
+int
+mb_svc_set_media_records_as_valid(const minfo_store_type storage_type,
+                                 int valid)
+{
+       mb_svc_debug("storage_type: %d", storage_type);
+
+       /* 1. first set reords as valid/invalid in 'folder' table */
+       mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_FOLDER;
+       sqlite3_stmt *stmt = NULL;
+       int f_id = 0;
+       char folder_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+
+       char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+
+       sqlite3 *handle = _media_info_get_proper_handle();
+       if (handle == NULL) {
+               mb_svc_debug("handle is NULL");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
+                mb_svc_tbl[field_seq].table_name);
+
+       int err;
+       char *sql =
+           sqlite3_mprintf("update %s set valid = %d where storage_type = %d;",
+                           table_name, valid, storage_type);
+       err = mb_svc_query_sql(sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               mb_svc_debug
+                   ("To set all items as valid is failed in folder table(%d)",
+                    err);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+       /* 2. get all of related folder id. */
+       sql =
+           sqlite3_mprintf("select uuid from %s where storage_type = %d;",
+                           table_name, storage_type);
+       err = sqlite3_prepare_v2(handle, sql, strlen(sql), &stmt, NULL);
+
+       mb_svc_debug("SQL : %s", sql);
+
+       if (SQLITE_OK != err) {
+               mb_svc_debug("prepare error [%s]", sqlite3_errmsg(handle));
+               mb_svc_debug("query string is %s\n", sql);
+               sqlite3_free(sql);
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       sqlite3_free(sql);
+
+       field_seq = MB_SVC_TABLE_MEDIA;
+       memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+       snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
+                mb_svc_tbl[field_seq].table_name);
+
+       for (;;) {
+               err = sqlite3_step(stmt);
+               if (err != SQLITE_ROW) {
+                       break;
+               }
+
+               //f_id = sqlite3_column_int(stmt, 0);
+               strncpy(folder_uuid, (const char *)sqlite3_column_text(stmt, 0), MB_SVC_UUID_LEN_MAX + 1);
+
+               /* 3. then set every reords as valid/invalid in 'media' table */
+               sql =
+                   sqlite3_mprintf
+                   ("update %s set valid = %d where folder_uuid = '%s';",
+                    table_name, valid, folder_uuid);
+               err = mb_svc_query_sql(sql);
+               sqlite3_free(sql);
+               if (err != SQLITE_OK) {
+                       mb_svc_debug
+                           ("To set all items as valid is failed in folder[%d]",
+                            f_id);
+                       sqlite3_finalize(stmt);
+                       return MB_SVC_ERROR_DB_INTERNAL;
+               }
+       }
+
+       sqlite3_finalize(stmt);
+
+       return 0;
+}
diff --git a/src/visual/media-svc-thumb.c b/src/visual/media-svc-thumb.c
new file mode 100755 (executable)
index 0000000..2a0fb79
--- /dev/null
@@ -0,0 +1,3300 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+* This file includes API sets for syncronization with other module.
+*
+* @file          media-svc-thumb.c
+* @author      chaolong.lin(chaolong.lin@samsung.com)
+* @version     1.0
+* @brief       This file is the implementation of all APIs for thumbnail manager
+*/
+
+#define _GNU_SOURCE
+#include <time.h>
+
+#ifdef _PERFORMANCE_CHECK_
+#include "media-info-debug.h"
+#endif
+
+#include "media-svc-thumb.h"
+#include "media-svc-debug.h"
+#include "media-svc-error.h"
+#include "media-svc-util.h"
+#include "media-img-codec.h"
+#include "media-img-codec-parser.h"
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <mm_file.h>
+#include <mm_util_imgp.h>
+#include <mm_util_jpeg.h>
+#include <drm-service.h>
+#include <Evas.h>
+#include <Ecore_Evas.h>
+#include <string.h>
+#include <libexif/exif-data.h>
+
+
+#if defined(_PERFORMANCE_CHECK_) && defined(_USE_LOG_FILE_)
+static double g_video_save = 0;
+static double g_img_save = 0;
+static double g_agif_save = 0;
+
+static double g_video_thumb = 0;
+static double g_img_thumb = 0;
+static double g_agif_thumb = 0;
+#endif
+
+#define UNKNOWN_TAG                                    "Unknown"
+#define MB_SVC_THUMB_WIDTH                                     320
+#define MB_SVC_THUMB_HEIGHT                                    240
+#define MB_SVC_THUMB_LENGTH                                    256
+#define MB_SVC_THUMB_LENGTH_LIMIT                      10000
+#define MB_SVC_EXIF_BUFFER_LEN_MAX                     1023
+#define MB_SVC_THUMB_BUFFER_LEN_MAX                    4095
+
+/* The maximum of resolution to be able to get thumbnail is 3000 x 3000, except for only jpeg */
+#define MB_SVC_MAX_ALLOWED_MEM_FOR_THUMB       9000000
+/* The maximum of resolution of jpeg image which is NOT resized to make thumb */
+#define MB_SVC_MAX_ALLOWED_MEM_NOT_RESIZED_FOR_THUMB   105000
+
+typedef struct{
+       int size;
+       bool is_drm;
+       int width;
+       int height;
+       int orientation;
+       ImgCodecType image_type;
+       minfo_file_type content_type;
+       const char* file_full_path;
+       char* thumb_hash_path;
+}mb_svc_thumb_info_s;
+
+enum Exif_Orientation {
+    NOT_AVAILABLE=0,
+    NORMAL  =1,
+    HFLIP   =2,
+    ROT_180 =3,
+    VFLIP   =4,
+    TRANSPOSE   =5,
+    ROT_90  =6,
+    TRANSVERSE  =7,
+    ROT_270 =8
+};
+
+static int __mb_svc_thumb_cp(char *src_file_full_path, char *dest_file_full_path);
+static int __mb_svc_thumb_save(const void *image, mb_svc_thumb_info_s thumb_info, size_t max_thumb_length, mb_svc_image_meta_record_s *img_meta_record);
+static int __get_thumbfile_size(char *filepath);
+static int __mb_svc_get_exif_info(ExifData *ed, char *buf, int *value, int ifdtype, long tagtype);
+static int __mb_svc_get_time_val_from_str(char *buf);
+static void __mb_svc_split_to_double(char *input, double *arr, int *num);
+
+static void __mb_svc_split_to_double(char *input, double *arr, int *num)
+{
+       char tmp_arr[255] = { 0, };
+       int len = strlen(input);
+       int i = 0, idx = 0, tmp_idx = 0;
+       int is_prev_space = 0;
+
+       for (;;) {
+               if (input[len - 1] == ' ') {
+                       len--;
+               } else {
+                       break;
+               }
+       }
+
+       for (i = 0; i < len; i++) {
+               if (idx > 2) {
+                       break;
+               }
+
+               if (input[i] == ' ') {
+                       if (is_prev_space == 1) {
+                               continue;
+                       }
+                       if (idx <= 2) {
+                               arr[idx++] = atof(tmp_arr);
+                       }
+                       tmp_idx = 0;
+                       is_prev_space = 1;
+                       continue;
+               }
+
+               tmp_arr[tmp_idx] = input[i];
+               tmp_arr[++tmp_idx] = '\0';
+               is_prev_space = 0;
+       }
+
+       if (i == len) {
+               if (idx <= 2) {
+                       arr[idx++] = atof(tmp_arr);
+               }
+               *num = idx;
+               return;
+       } else {
+               *num = idx--;
+               return;
+       }
+}
+
+int _mb_svc_get_size_using_evas(const char *file_path, int *width, int *height)
+{
+       ecore_evas_init();
+
+       Ecore_Evas *ee = ecore_evas_buffer_new(0, 0);
+
+       if (!ee) {
+               mb_svc_debug("ecore_evas_new fails");
+               return -1;
+       }
+       Evas *evas = ecore_evas_get(ee);
+       if (!evas) {
+               mb_svc_debug("ecore_evas_get fails");
+               ecore_evas_free(ee);
+               return -1;
+       }
+
+       Evas_Object *image_object = evas_object_image_add(evas);
+       if (!image_object) {
+               mb_svc_debug("evas_object_image_add fails");
+               ecore_evas_free(ee);
+               return -1;
+       }
+
+       evas_object_image_file_set(image_object, file_path, NULL);
+       evas_object_image_size_get(image_object, width, height);
+
+       mb_svc_debug("Width : %d, Height : %d", width, height);
+       
+       ecore_evas_free(ee);
+       ecore_evas_shutdown();
+
+       return 0;
+}
+
+static int __mb_svc_get_time_val_from_str(char *buf)
+{
+       int year, month, day, hour, min, sec;
+       struct tm val;
+       time_t ret;
+
+       sscanf(buf, "%4d:%2d:%2d %2d:%2d:%2d", &year, &month, &day, &hour, &min,
+              &sec);
+       mb_svc_debug("%d / %d / %d  %d : %d : %d", year, month, day, hour, min,
+                    sec);
+       strptime(buf, "%Y:%m:%d %H:%M:%S", &val);
+
+       ret = mktime(&val);
+       mb_svc_debug("time_t : %ld\n", ret);
+       /* mb_svc_debug("time to char : %s\n", ctime(&ret) ); */
+
+       return ret;
+}
+
+static int __mb_svc_get_exif_info(ExifData *ed, char *buf, int *value, int ifdtype, long tagtype)
+{
+       ExifEntry *entry;
+       ExifIfd ifd;
+       ExifTag tag;
+
+       if (ed == NULL) {
+               return -1;
+       }
+
+       ifd = ifdtype;
+       tag = tagtype;
+
+       /* entry = exif_content_get_entry(ed->ifd[ifd], tag); */
+       entry = exif_data_get_entry(ed, tag);
+       if (entry) {
+               if (tag == EXIF_TAG_ORIENTATION ||
+                               tag == EXIF_TAG_PIXEL_X_DIMENSION || 
+                               tag == EXIF_TAG_PIXEL_Y_DIMENSION) {
+
+                       if (value == NULL) {
+                               mb_svc_debug("value is NULL");
+                               return -1;
+                       }
+
+                       ExifByteOrder mByteOrder = exif_data_get_byte_order(ed);
+                       short exif_value = exif_get_short(entry->data, mByteOrder);
+                       mb_svc_debug("%s : %d", exif_tag_get_name_in_ifd(tag,ifd), exif_value);
+                       *value = (int)exif_value;
+               } else {
+                       /* Get the contents of the tag in human-readable form */
+                       if (buf == NULL) {
+                               mb_svc_debug("buf is NULL");
+                               return -1;
+                       }
+                       exif_entry_get_value(entry, buf,
+                                            MB_SVC_EXIF_BUFFER_LEN_MAX);
+                       buf[strlen(buf)] = '\0';
+
+                       if (*buf) {
+                               mb_svc_debug("%s: %s\n",
+                                            exif_tag_get_name_in_ifd(tag, ifd),
+                                            buf);
+                       }
+               }
+       }
+
+       return 0;
+}
+
+int
+mb_svc_get_exif_gps_info(ExifData *ed, double *gps_value,
+                        int ifdtype, long tagtype)
+{
+       ExifEntry *entry;
+       ExifIfd ifd;
+       ExifTag tag;
+       char buf[MB_SVC_EXIF_BUFFER_LEN_MAX + 1] = { '\0' };
+
+       if (ed == NULL) {
+               return -1;
+       }
+
+       memset(buf, 0x00, MB_SVC_EXIF_BUFFER_LEN_MAX + 1);
+
+       if (gps_value == NULL) {
+               mb_svc_debug("gps_value==NULL ");
+               return -1;
+       }
+
+       *gps_value = MINFO_DEFAULT_GPS;
+
+       ifd = ifdtype;
+       tag = tagtype;
+
+       entry = exif_data_get_entry(ed, tag);
+
+       if (entry) {
+               if (tag == EXIF_TAG_GPS_LATITUDE
+                   || tag == EXIF_TAG_GPS_LONGITUDE) {
+                       /* Get the contents of the tag in human-readable form */
+                       exif_entry_get_value(entry, buf,
+                                            MB_SVC_EXIF_BUFFER_LEN_MAX);
+                       buf[strlen(buf)] = '\0';
+
+                       if (*buf) {
+                               mb_svc_debug("%s: %s\n",
+                                            exif_tag_get_name_in_ifd(tag, ifd),
+                                            buf);
+                       }
+
+                       double tmp_arr[3] = { 0.0, 0.0, 0.0 };
+                       int count = 0;
+
+                       __mb_svc_split_to_double(buf, tmp_arr, &count);
+                       if (count != 3) {
+                               mb_svc_debug("Value is invalid");
+                               return -1;
+                       }
+
+                       *gps_value =
+                           tmp_arr[0] + tmp_arr[1] / 60 + tmp_arr[2] / 3600;
+                       mb_svc_debug("GPS value is %f", *gps_value);
+
+               } else {
+                       mb_svc_debug
+                           ("tag is not EXIF_TAG_GPS_LATITUDE or EXIF_TAG_GPS_LONGITUDE");
+                       return -1;
+               }
+       }
+
+       return 0;
+}
+
+int
+mb_svc_drm_get_buffer(const char *file_full_path, unsigned char **buffer,
+                     int *size)
+{
+       DRM_RESULT res;
+       DRM_FILE_HANDLE hDrmFile = NULL;
+
+       mb_svc_debug("mb_svc_drm_get_buffer\n");
+
+       if (file_full_path == NULL || buffer == NULL || size == NULL) {
+               mb_svc_debug
+                   ("file_full_path==NULL || buffer==NULL || size==NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       res =
+           drm_svc_open_file(file_full_path, DRM_PERMISSION_DISPLAY,
+                             &hDrmFile);
+       if (res == DRM_RESULT_SUCCESS) {
+               drm_file_attribute_t drm_attr;
+               /* get attribute to get file size  */
+               drm_svc_get_fileattribute(file_full_path, &drm_attr);
+               /* read drm file  */
+               if (drm_attr.size < 2 * 1024 * 1024) {
+                       *buffer = (unsigned char *)malloc(drm_attr.size);
+                       if (*buffer) {
+                               drm_svc_read_file(hDrmFile, *buffer,
+                                                 drm_attr.size,
+                                                 (unsigned int *)size);
+                       }
+                       mb_svc_debug
+                           ("mb_svc_drm_get_buffer : buffer=%p, size=%d",
+                            *buffer, drm_attr.size);
+               }
+               drm_svc_close_file(hDrmFile);
+               return 1;
+       }
+       return 0;
+}
+
+static int __get_thumbfile_size(char *filepath)
+{
+       FILE *fp;
+       int file_size = 0;
+       fp = fopen(filepath, "r");
+       if (!fp) {
+               mb_svc_debug("file open failed!\n");
+               return -1;
+       }
+
+       fseek(fp, 0l, SEEK_END);
+
+       file_size = ftell(fp);
+       fclose(fp);
+
+       return file_size;
+}
+
+static void __mb_svc_image_rotate_180(Evas_Object *obj)
+{
+       unsigned int *data;
+       unsigned int *p1, *p2, tmp;
+       int x, hw, iw, ih;
+
+       evas_object_image_size_get(obj, &iw, &ih);
+       data = evas_object_image_data_get(obj, 1);
+
+       hw = iw * ih;
+       x = (hw / 2);
+       p1 = data;
+       p2 = data + hw - 1;
+       for (; --x > 0;) {
+               tmp = *p1;
+               *p1 = *p2;
+               *p2 = tmp;
+               p1++;
+               p2--;
+       }
+       evas_object_image_data_set(obj, data);
+       evas_object_image_data_update_add(obj, 0, 0, iw, ih);
+}
+
+static void __mb_svc_image_rotate_90(Evas_Object *obj)
+{
+       unsigned int *data, *data2, *to, *from;
+       int x, y, w, hw, iw, ih;
+       evas_object_image_size_get(obj, &iw, &ih);
+
+       data = evas_object_image_data_get(obj, EINA_FALSE);     /* for reading */
+       /* memcpy */
+       data2 = malloc(iw * ih * sizeof(unsigned int));
+       memcpy(data2, data, iw * ih * sizeof(unsigned int));
+
+       /* set width, height */
+       w = ih;
+       ih = iw;
+       iw = w;
+       hw = w * ih;
+
+       /* set width, height to image obj */
+       evas_object_image_size_set(obj, iw, ih);
+       data = evas_object_image_data_get(obj, EINA_TRUE);
+       to = data + w - 1;
+       hw = -hw - 1;
+       from = data2;
+
+       for (x = iw; --x >= 0;) {
+               for (y = ih; --y >= 0;) {
+                       *to = *from;
+                       from++;
+                       to += w;
+               }
+
+               to += hw;
+       }
+
+       if (data2) {
+               free(data2);
+       }
+
+       evas_object_image_data_set(obj, data);
+       evas_object_image_data_update_add(obj, 0, 0, iw, ih);
+}
+
+static void __mb_svc_image_rotate_270(Evas_Object *obj)
+{
+       unsigned int *data, *data2, *to, *from;
+       int x, y, w, hw, iw, ih;
+       evas_object_image_size_get(obj, &iw, &ih);
+
+       data = evas_object_image_data_get(obj, EINA_FALSE);     /* for reading */
+       /* memcpy */
+       data2 = malloc(iw * ih * sizeof(unsigned int));
+       memcpy(data2, data, iw * ih * sizeof(unsigned int));
+
+       /* set width, height */
+       w = ih;
+       ih = iw;
+       iw = w;
+       hw = w * ih;
+
+       /* set width, height to image obj */
+       evas_object_image_size_set(obj, iw, ih);
+       data = evas_object_image_data_get(obj, EINA_TRUE);
+
+       to = data + hw - w;
+       w = -w;
+       hw = hw + 1;
+       from = data2;
+
+       for (x = iw; --x >= 0;) {
+               for (y = ih; --y >= 0;) {
+                       *to = *from;
+                       from++;
+                       to += w;
+               }
+
+               to += hw;
+       }
+
+       if (data2) {
+               free(data2);
+       }
+
+       evas_object_image_data_set(obj, data);
+       evas_object_image_data_update_add(obj, 0, 0, iw, ih);
+}
+
+static int
+__mb_svc_thumb_save(const void *image, mb_svc_thumb_info_s thumb_info,
+                   size_t max_thumb_length,
+                   mb_svc_image_meta_record_s *img_meta_record)
+{
+       mb_svc_debug("");
+       char thumb_pathname[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+       int nwrite = -1;
+       int err = 0;
+       char *src = (char *)image;
+
+       gsize size = 0;
+       char *data = NULL;
+       unsigned char *buffer = NULL;
+       int b_size = 0;
+       bool use_default = FALSE;
+       int ret_len = -1;
+
+       int thumb_width = 0;
+       int thumb_height = 0;
+       double ratio_wh;
+
+#ifdef _PERFORMANCE_CHECK_
+       long start = 0L, end = 0L;
+       long entire_s = 0L, entire_e = 0L;
+#endif
+
+#ifdef _USE_LOG_FILE_
+       mediainfo_init_file_debug();
+       mediainfo_file_dbg("File : %s", thumb_info.file_full_path);
+#endif
+
+       mb_svc_debug("hash : %s(%d)", thumb_info.thumb_hash_path,
+                    strlen(thumb_info.thumb_hash_path));
+       strncpy(thumb_pathname, thumb_info.thumb_hash_path,
+               sizeof(thumb_pathname));
+       if (strlen(thumb_pathname) < strlen(thumb_info.thumb_hash_path)) {
+               mb_svc_debug("Error for the length of thumb path");
+               return MB_SVC_ERROR_INTERNAL;
+       }
+
+       ecore_evas_init();
+
+       if (thumb_info.content_type == MINFO_ITEM_VIDEO) {
+               {
+                       bool portrait = FALSE;
+                       if (thumb_info.width < thumb_info.height)
+                               portrait = TRUE;
+
+                       if (portrait) {
+                               ratio_wh =
+                                   (double)thumb_info.width /
+                                   (double)thumb_info.height;
+                               thumb_height = MB_SVC_THUMB_LENGTH;
+                               thumb_width = thumb_height * ratio_wh;
+                       } else {
+                               ratio_wh =
+                                   (double)thumb_info.height /
+                                   (double)thumb_info.width;
+                               thumb_width = MB_SVC_THUMB_LENGTH;
+                               thumb_height = thumb_width * ratio_wh;
+                       }
+
+                       mb_svc_debug("ratio : %f\n", ratio_wh);
+                       mb_svc_debug("Thumb width : %d, Thumb height : %d\n",
+                                    thumb_width, thumb_height);
+
+                       int i = thumb_info.width * thumb_info.height;
+                       if (!(size = i)) {
+                               mb_svc_debug("size != i\n");
+                               return MB_SVC_ERROR_CREATE_THUMBNAIL;
+                       }
+
+                       if (!src) {
+                               mb_svc_debug("src is null\n");
+                               ret_len =
+                                   snprintf(thumb_pathname,
+                                            sizeof(thumb_pathname), "%s",
+                                            DEFAULT_VIDEO_THUMB);
+                               if (ret_len < 0) {
+                                       mb_svc_debug("Error when snprintf");
+                                       return MB_SVC_ERROR_INTERNAL;
+                               }
+                               use_default = TRUE;
+                       } else {
+                               mb_svc_debug("evas Start : %s",
+                                            thumb_info.file_full_path);
+
+#ifdef _PERFORMANCE_CHECK_
+                               entire_s = mediainfo_get_debug_time();
+#endif
+
+                               unsigned int buf_size = 0;
+                               if (mm_util_get_image_size
+                                   (MM_UTIL_IMG_FMT_RGB888, thumb_width,
+                                    thumb_height, &buf_size) < 0) {
+                                       mb_svc_debug
+                                           ("Failed to get buffer size");
+                                       return MB_SVC_ERROR_INTERNAL;
+                               }
+                               mb_svc_debug("mm_util_get_image_size : %d",
+                                            buf_size);
+
+                               unsigned char *dst =
+                                   (unsigned char *)malloc(buf_size);
+
+                               if (mm_util_resize_image
+                                   ((unsigned char *)src, thumb_info.width,
+                                    thumb_info.height, MM_UTIL_IMG_FMT_RGB888,
+                                    dst, (unsigned int *)&thumb_width,
+                                    (unsigned int *)&thumb_height) < 0) {
+                                       mb_svc_debug
+                                           ("Failed to resize the thumbnails");
+                                       if (dst)
+                                               free(dst);
+                                       return MB_SVC_ERROR_INTERNAL;
+                               }
+
+                               Ecore_Evas *ee =
+                                       ecore_evas_buffer_new(thumb_width, thumb_height);
+                               Evas *evas = ecore_evas_get(ee);
+
+                               Evas_Object *img = NULL;
+                               img = evas_object_image_add(evas);
+
+                               if (img == NULL) {
+                                       mb_svc_debug("image object is NULL\n");
+                                       if (dst)
+                                               free(dst);
+                                       ecore_evas_free(ee);
+                                       ecore_evas_shutdown();
+                                       return -1;
+                               }
+
+                               evas_object_image_colorspace_set(img,
+                                                                EVAS_COLORSPACE_ARGB8888);
+                               evas_object_image_size_set(img, thumb_width,
+                                                          thumb_height);
+                               evas_object_image_fill_set(img, 0, 0,
+                                                          thumb_width,
+                                                          thumb_height);
+
+                               unsigned char *m = NULL;
+                               m = evas_object_image_data_get(img, 1);
+#if 1                          /* Use self-logic to convert from RGB888 to RGBA */
+
+#ifdef _PERFORMANCE_CHECK_
+                               start = mediainfo_get_debug_time();
+#endif
+                               int i = 0, j;
+                               for (j = 0; j < thumb_width * 3 * thumb_height;
+                                    j += 3) {
+                                       m[i++] = (dst[j + 2]);
+                                       m[i++] = (dst[j + 1]);
+                                       m[i++] = (dst[j]);
+                                       m[i++] = 0x0;
+                               }
+#ifdef _PERFORMANCE_CHECK_
+                               end = mediainfo_get_debug_time();
+                               double convert =
+                                   ((double)(end - start) /
+                                    (double)CLOCKS_PER_SEC);
+                               mb_svc_debug("Convert from RGB888 to RGBA : %f",
+                                            convert);
+#ifdef _USE_LOG_FILE_
+                               mediainfo_file_dbg
+                                   ("Convert from RGB888 to RGBA : %f, ( W:%d, H:%d)",
+                                    convert, thumb_width, thumb_height);
+#endif
+#endif
+
+#else                          /* Use mmf api to convert from RGB888 to RGBA */
+                               int mm_ret = 0;
+                               if ((mm_ret =
+                                    mm_util_convert_colorspace(dst,
+                                                               thumb_width,
+                                                               thumb_height,
+                                                               MM_UTIL_IMG_FMT_RGB888,
+                                                               m,
+                                                               MM_UTIL_IMG_FMT_ARGB8888))
+                                   < 0) {
+                                       mb_svc_debug
+                                           ("Failed to change from rgb888 to argb8888 %d",
+                                            mm_ret);
+                                       if (dst)
+                                               free(dst);
+                                       return MB_SVC_ERROR_INTERNAL;
+                               }
+#endif                         /* End of use mmf api to convert from RGB888 to RGBA */
+
+                               evas_object_image_data_set(img, m);
+                               evas_object_image_data_update_add(img, 0, 0,
+                                                                 thumb_width,
+                                                                 thumb_height);
+
+#ifdef _PERFORMANCE_CHECK_
+                               start = mediainfo_get_debug_time();
+#endif
+                               if (evas_object_image_save
+                                   (img, thumb_pathname, NULL,
+                                    "quality=100 compress=1")) {
+                                       mb_svc_debug
+                                           ("evas_object_image_save success\n");
+                                       data = NULL;
+                               } else {
+                                       /* Temporary code to avoid race condition */
+                                       if (g_file_test
+                                               (thumb_pathname, G_FILE_TEST_EXISTS)) {
+                                               mb_svc_debug("Thumbnail already exists");
+
+                                               ecore_evas_free(ee);
+                                               ecore_evas_shutdown();
+
+                                               return 0;
+                                       } else {
+                                               mb_svc_debug("Thumbnail doesn't exist");
+                                               mb_svc_debug("evas_object_image_save fail\n");
+                                               use_default = TRUE;
+                                               data = NULL;
+                                       }
+                               }
+
+#ifdef _PERFORMANCE_CHECK_
+                               end = mediainfo_get_debug_time();
+                               double save =
+                                   ((double)(end - start) /
+                                    (double)CLOCKS_PER_SEC);
+                               mb_svc_debug("Save : %f", save);
+#ifdef _USE_LOG_FILE_
+                               mediainfo_file_dbg("Save( %d / %d ) : %f",
+                                                  thumb_width, thumb_height,
+                                                  save);
+                               g_video_save += save;
+                               mediainfo_file_dbg("video save sum: %f",
+                                                  g_video_save);
+#endif
+#endif
+                               if (dst)
+                                       free(dst);
+                               ecore_evas_free(ee);
+
+#ifdef _PERFORMANCE_CHECK_
+                               entire_e = mediainfo_get_debug_time();
+                               double make_video_thumb =
+                                   ((double)(entire_e - entire_s) /
+                                    (double)CLOCKS_PER_SEC);
+                               mb_svc_debug("Making video : %f\n\n",
+                                            make_video_thumb);
+#ifdef _USE_LOG_FILE_
+                               mediainfo_file_dbg("Making video : %f",
+                                                  make_video_thumb);
+                               g_video_thumb += make_video_thumb;
+                               mediainfo_file_dbg("Making video sum: %f\n\n",
+                                                  g_video_thumb);
+#endif
+#endif
+                       }
+               }
+               mb_svc_debug("thumb_pathname is %s\n", thumb_pathname);
+       }
+
+       else if (thumb_info.content_type == MINFO_ITEM_IMAGE) {
+               mb_svc_debug
+                   ("item type is image, imgtype is %d,_is_real_drm is %d\n",
+                    thumb_info.image_type, thumb_info.is_drm);
+
+               int total_mem = 0;
+               bool portrait = FALSE;
+
+               if (thumb_info.image_type <= 0) {
+                       mb_svc_debug("Unknown image type");
+                       ret_len =
+                           snprintf(thumb_pathname, sizeof(thumb_pathname),
+                                    "%s", DEFAULT_IMAGE_THUMB);
+                       if (ret_len < 0) {
+                               mb_svc_debug("Error when snprintf");
+                               return MB_SVC_ERROR_INTERNAL;
+                       }
+                       use_default = TRUE;
+                       data = NULL;
+
+               } else if (thumb_info.is_drm) {
+
+                       mb_svc_debug("this image file is not real drm\n");
+                       mb_svc_drm_get_buffer(thumb_info.file_full_path,
+                                             &buffer, &b_size);
+                       if (b_size <= 0) {
+                               ret_len =
+                                   snprintf(thumb_pathname,
+                                            sizeof(thumb_pathname), "%s",
+                                            DEFAULT_IMAGE_THUMB);
+                               if (ret_len < 0) {
+                                       mb_svc_debug("Error when snprintf");
+                                       return MB_SVC_ERROR_INTERNAL;
+                               }
+                               use_default = TRUE;
+                       } else {
+                               data = (char *)buffer;
+                               size = b_size;
+                       }
+
+               } else if (src && (thumb_info.size > 0)) {
+                       data = src;
+                       size = thumb_info.size;
+                       mb_svc_debug("get thumbnail of exif %d: %d\n",
+                                    (int)data, size);
+
+               } else {
+#ifdef _PERFORMANCE_CHECK_
+                       entire_s = mediainfo_get_debug_time();
+#endif
+                       if (thumb_info.width <= 0 && thumb_info.height <= 0) {
+#ifdef _USE_LOG_FILE_
+                               mediainfo_file_dbg
+                                   ("Failed to get w and h before : %s",
+                                    thumb_info.file_full_path);
+                               start = mediainfo_get_debug_time();
+#endif
+
+                               /* using evas to get w/h */
+                               Ecore_Evas *ee =
+                                       ecore_evas_buffer_new(thumb_width, thumb_height);
+                               if (!ee) {
+                                       mb_svc_debug("ecore_evas_new fails");
+                                       return -1;
+                               }
+                               Evas *evas = ecore_evas_get(ee);
+                               if (!evas) {
+                                       mb_svc_debug("ecore_evas_get fails");
+                                       ecore_evas_free(ee);
+                                       return -1;
+                               }
+
+                               Evas_Object *image_object =
+                                   evas_object_image_add(evas);
+                               if (!image_object) {
+                                       mb_svc_debug
+                                           ("evas_object_image_add fails");
+                                       ecore_evas_free(ee);
+                                       return -1;
+                               }
+
+                               evas_object_image_file_set(image_object,
+                                                          thumb_info.
+                                                          file_full_path,
+                                                          NULL);
+                               evas_object_image_size_get(image_object,
+                                                          &(thumb_info.width),
+                                                          &(thumb_info.height));
+                               ecore_evas_free(ee);
+
+#ifdef _PERFORMANCE_CHECK_
+                               end = mediainfo_get_debug_time();
+                               double get_size =
+                                   ((double)(end - start) /
+                                    (double)CLOCKS_PER_SEC);
+                               mb_svc_debug("get_size : %f", get_size);
+#ifdef _USE_LOG_FILE_
+                               mediainfo_file_dbg("get_size : %f", get_size);
+#endif
+#endif
+                       }
+
+                       mb_svc_debug("image width : %d, height : %d",
+                                    thumb_info.width, thumb_info.height);
+
+                       if (img_meta_record) {
+                               img_meta_record->width = thumb_info.width;
+                               img_meta_record->height = thumb_info.height;
+                       }
+
+                       if (thumb_info.width <= 0 || thumb_info.height <= 0) {
+                               ret_len =
+                                   snprintf(thumb_pathname,
+                                            sizeof(thumb_pathname), "%s",
+                                            DEFAULT_IMAGE_THUMB);
+                               if (ret_len < 0) {
+                                       mb_svc_debug("Error when snprintf");
+                                       return MB_SVC_ERROR_INTERNAL;
+                               }
+                               use_default = TRUE;
+                       } else {
+
+                               total_mem = thumb_info.width * thumb_info.height;
+
+                               if (thumb_info.width < thumb_info.height)
+                                       portrait = TRUE;
+
+                               if (portrait) {
+                                       ratio_wh =
+                                           (double)thumb_info.width /
+                                           (double)thumb_info.height;
+                                       thumb_height = MB_SVC_THUMB_LENGTH;
+                                       thumb_width = thumb_height * ratio_wh;
+                               } else {
+                                       ratio_wh =
+                                           (double)thumb_info.height /
+                                           (double)thumb_info.width;
+                                       thumb_width = MB_SVC_THUMB_LENGTH;
+                                       thumb_height = thumb_width * ratio_wh;
+                               }
+                               mb_svc_debug("ratio : %f\n", ratio_wh);
+                               mb_svc_debug
+                                   ("Thumb width : %d, Thumb height : %d\n",
+                                    thumb_width, thumb_height);
+                       }
+
+                       if (thumb_info.image_type != IMG_CODEC_AGIF
+                           && !use_default) {
+                               mb_svc_debug
+                                   ("this is non-agif image file,is_real_drm is %d\n",
+                                    thumb_info.is_drm);
+
+                               if (thumb_info.image_type == IMG_CODEC_JPEG
+                                   && total_mem <= MB_SVC_MAX_ALLOWED_MEM_NOT_RESIZED_FOR_THUMB) {
+       
+                                       /* Using mm-util to make thumb of small original jepg */
+                                       mb_svc_debug("This is small jpeg. It's not resized");
+
+                                       int orientation = thumb_info.orientation;
+                                       mm_util_img_rotate_type rot_type = MM_UTIL_ROTATE_0;
+
+                                       mb_svc_debug("Orientation : %d", orientation);
+                                       if (orientation == ROT_90) {
+                                               rot_type = MM_UTIL_ROTATE_270;
+                                       } else if (orientation == ROT_180) {
+                                               rot_type = MM_UTIL_ROTATE_180;
+                                       } else if (orientation == ROT_270) {
+                                               rot_type = MM_UTIL_ROTATE_90;
+                                       }
+
+                                       if (orientation == ROT_90 || orientation == ROT_180 || orientation == ROT_270) {
+
+                                               mm_util_jpeg_yuv_data decoded = {0,};
+                                       
+                                               err = mm_util_decode_from_jpeg_file(&decoded, 
+                                                                                       (char *)thumb_info.file_full_path, 
+                                                                                       MM_UTIL_JPEG_FMT_YUV420);
+                                               if (err < 0) {
+                                                       mb_svc_debug("mm_util_decode_from_jpeg_turbo_memory failed : %d", err);
+                                                       return err;
+                                               }
+                                       
+                                               mb_svc_debug("decoded size:%d, w:%d, h:%d\n", decoded.size, decoded.width, decoded.height);
+       
+                                               unsigned char *rotated = NULL;
+                                               unsigned int rot_w = decoded.height;
+                                               unsigned int rot_h = decoded.width;
+                                               unsigned int rot_size = 0;
+
+                                               if (orientation == ROT_180) {
+                                                       rot_w = decoded.width;
+                                                       rot_h = decoded.height;
+                                               }
+                                       
+                                               err = mm_util_get_image_size(MM_UTIL_JPEG_FMT_YUV420, rot_w, rot_h, &rot_size);
+                                               if (err < 0) {
+                                                       mb_svc_debug("mm_util_get_image_size failed : %d", err);
+                                                       if (decoded.data != NULL) free(decoded.data);
+                                                       return err;
+                                               }
+                                       
+                                               mb_svc_debug("Size of Rotated : %d", rot_size);
+                                       
+                                               rotated = (unsigned char *)malloc(rot_size);
+                                               err = mm_util_rotate_image(decoded.data, decoded.width, decoded.height, 
+                                                                                                       MM_UTIL_JPEG_FMT_YUV420,
+                                                                                                       rotated, &rot_w, &rot_h, 
+                                                                                                       rot_type);
+
+                                               if (err < 0) {
+                                                       mb_svc_debug("mm_util_rotate_image failed : %d", err);
+                                                       if (decoded.data != NULL) free(decoded.data);
+                                                       if (rotated != NULL) free(rotated);
+                                                       return err;
+                                               } else {
+                                                       mb_svc_debug("mm_util_rotate_image succeed");
+                                               }
+
+                                               err = mm_util_jpeg_encode_to_file(thumb_pathname, rotated, rot_w, rot_h, MM_UTIL_JPEG_FMT_YUV420, 100);
+                               
+                                               if (err < 0) {
+                                                       mb_svc_debug("mm_util_jpeg_encode_to_file failed: %d", err);
+                                                       if (decoded.data != NULL) free(decoded.data);
+                                                       if (rotated != NULL) free(rotated);
+                                                       return err;
+                                               }
+
+                                               if (decoded.data != NULL) free(decoded.data);
+                                               if (rotated != NULL) free(rotated);
+                                               data = NULL;
+
+                                       } else {
+                                               err = __mb_svc_thumb_cp((char *)thumb_info.file_full_path, thumb_pathname);
+                                               if (err < 0) {
+                                                       mb_svc_debug("__mb_svc_thumb_cp failed: %d", err);
+                                                       return -1;
+                                               }
+                                       }
+                               } else if (thumb_info.image_type == IMG_CODEC_JPEG
+                                   || total_mem <= MB_SVC_MAX_ALLOWED_MEM_FOR_THUMB) {
+                                       /* using evas to make thumbnail of general images */
+                                       Ecore_Evas *ee =
+                                                ecore_evas_buffer_new(thumb_width,
+                                                                 thumb_height);
+                                       if (!ee) {
+                                               mb_svc_debug
+                                                   ("Failed to create a ecore evas\n");
+                                               ecore_evas_shutdown();
+                                               return -1;
+                                       }
+
+                                       Evas *evas = ecore_evas_get(ee);
+                                       if (!evas) {
+                                               mb_svc_debug
+                                                   ("Failed to ecore_evas_get\n");
+                                               ecore_evas_free(ee);
+                                               ecore_evas_shutdown();
+                                               return -1;
+                                       }
+
+                                       Ecore_Evas *resize_img_ee;
+                                       resize_img_ee =
+                                           ecore_evas_buffer_new(thumb_width,
+                                                                 thumb_height);
+
+                                       if (!resize_img_ee) {
+                                               mb_svc_debug
+                                                   ("Failed to create a new ecore evas buffer\n");
+                                               ecore_evas_free(ee);
+                                               ecore_evas_shutdown();
+                                               return -1;
+                                       }
+
+                                       Evas *resize_img_e =
+                                           ecore_evas_get(resize_img_ee);
+                                       if (!resize_img_e) {
+                                               mb_svc_debug
+                                                   ("Failed to ecore_evas_get\n");
+                                               ecore_evas_free(ee);
+                                               ecore_evas_free(resize_img_ee);
+                                               ecore_evas_shutdown();
+                                               return -1;
+                                       }
+
+                                       Evas_Object *source_img =
+                                           evas_object_image_add(resize_img_e);
+                                       if (!source_img) {
+                                               mb_svc_debug
+                                                   ("evas_object_image_add failed\n");
+                                               ecore_evas_free(ee);
+                                               ecore_evas_free(resize_img_ee);
+                                               ecore_evas_shutdown();
+                                               return -1;
+                                       }
+
+                                       evas_object_image_load_size_set
+                                           (source_img, thumb_width,
+                                            thumb_height);
+                                       evas_object_image_file_set(source_img,
+                                                                  thumb_info.
+                                                                  file_full_path,
+                                                                  NULL);
+
+                                       evas_object_image_fill_set(source_img,
+                                                                  0, 0,
+                                                                  thumb_width,
+                                                                  thumb_height);
+                                       evas_object_image_filled_set(source_img,
+                                                                    1);
+                                       evas_object_resize(source_img,
+                                                          thumb_width,
+                                                          thumb_height);
+                                       evas_object_show(source_img);
+
+#ifdef _PERFORMANCE_CHECK_
+                                       start = mediainfo_get_debug_time();
+#endif
+                                       Evas_Object *ret_image =
+                                           evas_object_image_add(evas);
+                                       /* evas_object_image_data_set(ret_image, NULL); */
+                                       evas_object_image_size_set(ret_image,
+                                                                  thumb_width,
+                                                                  thumb_height);
+                                       evas_object_image_fill_set(ret_image, 0,
+                                                                  0,
+                                                                  thumb_width,
+                                                                  thumb_height);
+
+                                       evas_object_image_filled_set(ret_image,
+                                                                    EINA_TRUE);
+                                       /* evas_object_image_data_copy_set(ret_image, (int *)ecore_evas_buffer_pixels_get(resize_img_ee)); */
+                                       evas_object_image_data_set(ret_image,
+                                                                  (int *)
+                                                                  ecore_evas_buffer_pixels_get
+                                                                  (resize_img_ee));
+                                       evas_object_image_data_update_add
+                                           (ret_image, 0, 0, thumb_width,
+                                            thumb_height);
+
+#ifdef _PERFORMANCE_CHECK_
+                                       end = mediainfo_get_debug_time();
+                                       double copy_set =
+                                           ((double)(end - start) /
+                                            (double)CLOCKS_PER_SEC);
+                                       mb_svc_debug("copy_set : %f", copy_set);
+#ifdef _USE_LOG_FILE_
+                                       mediainfo_file_dbg("copy_set : %f",
+                                                          copy_set);
+#endif
+#endif
+
+#ifdef _PERFORMANCE_CHECK_
+                                       start = mediainfo_get_debug_time();
+#endif
+                                       /* check it's orientation */
+                                       if (thumb_info.orientation == ROT_90) {
+                                               mb_svc_debug
+                                                   ("This needs to be rotated -90");
+                                               __mb_svc_image_rotate_90
+                                                   (ret_image);
+                                       } else if (thumb_info.orientation ==
+                                                  ROT_180) {
+                                               mb_svc_debug
+                                                   ("This needs to be rotated -180");
+                                               __mb_svc_image_rotate_180
+                                                   (ret_image);
+                                       } else if (thumb_info.orientation ==
+                                                  ROT_270) {
+                                               mb_svc_debug
+                                                   ("This needs to be rotated -270");
+                                               __mb_svc_image_rotate_270
+                                                   (ret_image);
+                                       }
+#ifdef _PERFORMANCE_CHECK_
+                                       end = mediainfo_get_debug_time();
+                                       double rotate =
+                                           ((double)(end - start) /
+                                            (double)CLOCKS_PER_SEC);
+                                       mb_svc_debug("rotate : %f", rotate);
+#ifdef _USE_LOG_FILE_
+                                       mediainfo_file_dbg("rotate : %f",
+                                                          rotate);
+#endif
+#endif
+
+#ifdef _PERFORMANCE_CHECK_
+                                       start = mediainfo_get_debug_time();
+#endif
+                                       mb_svc_debug("evas_object_image_save start(%s)", thumb_pathname);
+
+                                       if (evas_object_image_save
+                                           (ret_image, thumb_pathname, NULL,
+                                            "quality=100 compress=1")) {
+                                               mb_svc_debug
+                                                   ("evas_object_image_save success\n");
+                                       } else {
+                                               mb_svc_debug
+                                                   ("evas_object_image_save fails\n");
+                                               
+                                               /* Temporary code to avoid race condition */
+                                               if (g_file_test
+                                                       (thumb_pathname, G_FILE_TEST_EXISTS)) {
+                                                       mb_svc_debug("Thumbnail already exists");
+                                                       
+                                                       evas_object_del(source_img);
+                                                       ecore_evas_free(resize_img_ee);
+                                                       ecore_evas_free(ee);
+       
+                                                       ecore_evas_shutdown();
+       
+                                                       return 0;
+                                               } else {
+                                                       mb_svc_debug("Thumbnail doesn't exist");
+                                                       use_default = TRUE;
+                                               }
+                                       }
+
+#ifdef _PERFORMANCE_CHECK_
+                                       end = mediainfo_get_debug_time();
+                                       double save =
+                                           ((double)(end - start) /
+                                            (double)CLOCKS_PER_SEC);
+                                       mb_svc_debug("Save : %f", save);
+#ifdef _USE_LOG_FILE_
+                                       mediainfo_file_dbg
+                                           ("Save( %d / %d ) : %f",
+                                            thumb_width, thumb_height, save);
+                                       g_img_save += save;
+                                       mediainfo_file_dbg("image save sum: %f",
+                                                          g_img_save);
+#endif
+#endif
+                                       evas_object_del(source_img);
+                                       ecore_evas_free(resize_img_ee);
+                                       ecore_evas_free(ee);
+                                       data = NULL;
+                               } else {
+                                       mb_svc_debug
+                                           ("It's too big to make thumbnails for memory");
+                                       ret_len =
+                                           snprintf(thumb_pathname,
+                                                    sizeof(thumb_pathname),
+                                                    "%s", DEFAULT_IMAGE_THUMB);
+                                       if (ret_len < 0) {
+                                               mb_svc_debug
+                                                   ("Error when snprintf");
+                                               return MB_SVC_ERROR_INTERNAL;
+                                       }
+                                       use_default = TRUE;
+                                       data = NULL;
+                               }
+#ifdef _PERFORMANCE_CHECK_
+                               entire_e = mediainfo_get_debug_time();
+                               double make_img_thumb =
+                                   ((double)(entire_e - entire_s) /
+                                    (double)CLOCKS_PER_SEC);
+                               mb_svc_debug("Making img : %f\n\n",
+                                            make_img_thumb);
+#ifdef _USE_LOG_FILE_
+                               mediainfo_file_dbg("Making img : %f",
+                                                  make_img_thumb);
+                               g_img_thumb += make_img_thumb;
+                               mediainfo_file_dbg("Making image sum: %f\n\n",
+                                                  g_img_thumb);
+#endif
+#endif
+                       } else if (thumb_info.image_type == IMG_CODEC_AGIF && !use_default) {   /* For agif files */
+                               mb_svc_debug("this is agif file\n");
+#ifdef _PERFORMANCE_CHECK_
+                               entire_s = mediainfo_get_debug_time();
+#endif
+                               if (src == NULL) {
+                                       mb_svc_debug
+                                           ("There's no thumbnail from this agif file");
+
+                                       ret_len =
+                                           snprintf(thumb_pathname,
+                                                    sizeof(thumb_pathname),
+                                                    "%s", DEFAULT_IMAGE_THUMB);
+                                       if (ret_len < 0) {
+                                               mb_svc_debug
+                                                   ("Error when snprintf");
+                                               return MB_SVC_ERROR_INTERNAL;
+                                       }
+                                       use_default = TRUE;
+                               } else if (thumb_info.width <= 0
+                                          || thumb_info.height <= 0) {
+                                       ret_len =
+                                           snprintf(thumb_pathname,
+                                                    sizeof(thumb_pathname),
+                                                    "%s", DEFAULT_IMAGE_THUMB);
+                                       if (ret_len < 0) {
+                                               mb_svc_debug
+                                                   ("Error when snprintf");
+                                               return MB_SVC_ERROR_INTERNAL;
+                                       }
+                                       use_default = TRUE;
+                               } else {
+                                       /* Using evas to get agif thumbnails */
+                                       unsigned int buf_size = 0;
+                                       if (mm_util_get_image_size
+                                           (MM_UTIL_IMG_FMT_RGB888,
+                                            thumb_width, thumb_height,
+                                            &buf_size) < 0) {
+                                               mb_svc_debug
+                                                   ("Failed to get buffer size");
+                                               return MB_SVC_ERROR_INTERNAL;
+                                       }
+                                       mb_svc_debug
+                                           ("mm_util_get_image_size : %d",
+                                            buf_size);
+
+                                       unsigned char *dst =
+                                           (unsigned char *)malloc(buf_size);
+
+#ifdef _PERFORMANCE_CHECK_
+                                       start = mediainfo_get_debug_time();
+#endif
+                                       if (mm_util_resize_image
+                                           ((unsigned char *)src,
+                                            thumb_info.width,
+                                            thumb_info.height,
+                                            MM_UTIL_IMG_FMT_RGB888, dst,
+                                            (unsigned int *)&thumb_width,
+                                            (unsigned int *)&thumb_height) <
+                                           0) {
+                                               mb_svc_debug
+                                                   ("Failed to resize the thumbnails");
+                                               if (dst)
+                                                       free(dst);
+                                               return MB_SVC_ERROR_INTERNAL;
+                                       }
+#ifdef _PERFORMANCE_CHECK_
+                                       end = mediainfo_get_debug_time();
+                                       double resize =
+                                           ((double)(end - start) /
+                                            (double)CLOCKS_PER_SEC);
+                                       mb_svc_debug("Resize : %f", resize);
+#ifdef _USE_LOG_FILE_
+                                       mediainfo_file_dbg("Resize : %f",
+                                                          resize);
+#endif
+#endif
+                                       Ecore_Evas *ee =
+                                           ecore_evas_buffer_new(thumb_info.width,
+                                                                 thumb_info.height);
+                                       Evas *evas = ecore_evas_get(ee);
+
+                                       Evas_Object *img = NULL;
+                                       img = evas_object_image_add(evas);
+
+                                       if (img == NULL) {
+                                               printf("img object is NULL\n");
+                                               if (dst)
+                                                       free(dst);
+                                               ecore_evas_free(ee);
+                                               ecore_evas_shutdown();
+                                               return -1;
+                                       }
+
+                                       evas_object_image_colorspace_set(img,
+                                                                        EVAS_COLORSPACE_ARGB8888);;
+                                       evas_object_image_size_set(img,
+                                                                  thumb_width,
+                                                                  thumb_height);
+                                       evas_object_image_fill_set(img, 0, 0,
+                                                                  thumb_width,
+                                                                  thumb_height);
+                                       /* evas_object_image_size_set(img, thumb_info.width, thumb_info.height); */
+                                       /* evas_object_image_fill_set(img, 0, 0, thumb_info.width, thumb_info.height); */
+
+                                       unsigned char *m = NULL;
+                                       m = evas_object_image_data_get(img, 1);
+#if 1
+#ifdef _PERFORMANCE_CHECK_
+                                       start = mediainfo_get_debug_time();
+#endif
+                                       int i = 0, j;
+/*
+                                       for(j = 0; j < thumb_info.width *3 * thumb_info.height; j+=3 ) {
+                                               m[i++] = (src[j+2]);
+                                               m[i++] = (src[j+1]);
+                                               m[i++] = (src[j]);
+                                               m[i++] = 0x0;
+                                       }
+*/
+                                       for (j = 0;
+                                            j < thumb_width * 3 * thumb_height;
+                                            j += 3) {
+                                               m[i++] = (dst[j + 2]);
+                                               m[i++] = (dst[j + 1]);
+                                               m[i++] = (dst[j]);
+                                               m[i++] = 0x0;
+                                       }
+#ifdef _PERFORMANCE_CHECK_
+                                       end = mediainfo_get_debug_time();
+                                       double convert =
+                                           ((double)(end - start) /
+                                            (double)CLOCKS_PER_SEC);
+                                       mb_svc_debug
+                                           ("Convert from RGB888 to RGBA : %f",
+                                            convert);
+#ifdef _USE_LOG_FILE_
+                                       mediainfo_file_dbg
+                                           ("Convert from RGB888 to RGBA : %f",
+                                            convert);
+#endif
+#endif
+#else                          /* Using evas to get agif thumbnails */
+                                       int mm_ret = 0;
+                                       if ((mm_ret =
+                                            mm_util_convert_colorspace(dst,
+                                                                       thumb_width,
+                                                                       thumb_height,
+                                                                       MM_UTIL_IMG_FMT_RGB888,
+                                                                       m,
+                                                                       MM_UTIL_IMG_FMT_ARGB8888))
+                                           < 0) {
+                                               mb_svc_debug
+                                                   ("Failed to change from rgb888 to argb8888 : %d",
+                                                    mm_ret);
+                                               if (dst)
+                                                       free(dst);
+                                               return MB_SVC_ERROR_INTERNAL;
+                                       }
+#endif
+
+                                       evas_object_image_data_set(img, m);
+                                       evas_object_image_data_update_add(img,
+                                                                         0, 0,
+                                                                         thumb_width,
+                                                                         thumb_height);
+
+#ifdef _PERFORMANCE_CHECK_
+                                       start = mediainfo_get_debug_time();
+#endif
+                                       if (evas_object_image_save
+                                           (img, thumb_pathname, NULL,
+                                            "quality=100 compress=1")) {
+                                               mb_svc_debug
+                                                   ("evas_object_image_save success\n");
+                                       } else {
+                                               /* Temporary code to avoid race condition */
+                                               if (g_file_test
+                                                       (thumb_pathname, G_FILE_TEST_EXISTS)) {
+                                                       mb_svc_debug("Thumbnail already exists");
+                                                       
+                                                       ecore_evas_free(ee);
+       
+                                                       ecore_evas_shutdown();
+       
+                                                       return 0;
+                                               } else {
+                                                       mb_svc_debug("Thumbnail doesn't exist");
+                                                       mb_svc_debug("evas_object_image_save fail\n");
+                                                       use_default = TRUE;
+                                               }
+                                       }
+
+#ifdef _PERFORMANCE_CHECK_
+                                       end = mediainfo_get_debug_time();
+                                       double save =
+                                           ((double)(end - start) /
+                                            (double)CLOCKS_PER_SEC);
+                                       mb_svc_debug("Save : %f", save);
+#ifdef _USE_LOG_FILE_
+                                       mediainfo_file_dbg
+                                           ("Save( %d / %d ) : %f",
+                                            thumb_width, thumb_height, save);
+                                       g_agif_save += save;
+                                       mediainfo_file_dbg("agif save sum: %f",
+                                                          g_agif_save);
+#endif
+#endif
+                                       ecore_evas_free(ee);
+                                       if (src)
+                                               free(src);
+                                       if (dst)
+                                               free(dst);
+                                       data = NULL;
+                               }
+#ifdef _PERFORMANCE_CHECK_
+                               entire_e = mediainfo_get_debug_time();
+                               double make_agif_thumb =
+                                   ((double)(entire_e - entire_s) /
+                                    (double)CLOCKS_PER_SEC);
+                               mb_svc_debug("Making agif thumb : %f\n\n",
+                                            make_agif_thumb);
+#ifdef _USE_LOG_FILE_
+                               mediainfo_file_dbg("Making agif : %f",
+                                                  make_agif_thumb);
+                               g_agif_thumb += make_agif_thumb;
+                               mediainfo_file_dbg("Making agif sum: %f\n\n",
+                                                  g_agif_thumb);
+#endif
+#endif
+                       }
+               }
+       }
+
+       if (data != NULL) {
+               int fd;
+               /* fd = open(thumb_pathname, O_RDWR | O_CREAT | O_APPEND | O_SYNC, 600); */
+               fd = open(thumb_pathname, O_RDWR | O_CREAT, 600);
+               if (fd < 0) {
+                       mb_svc_debug("File open fails");
+                       return MB_SVC_ERROR_FILE_IO;
+               }
+
+               nwrite = write(fd, data, size);
+               close(fd);
+
+               g_free(data);
+       }
+
+       size = __get_thumbfile_size(thumb_pathname);
+       if (size == 0) {
+               mb_svc_debug("File size is ZERO : %s", thumb_pathname);
+               ret_len =
+                   snprintf(thumb_pathname, sizeof(thumb_pathname), "%s",
+                            DEFAULT_IMAGE_THUMB);
+               if (ret_len < 0) {
+                       mb_svc_debug("Error when snprintf");
+                       return MB_SVC_ERROR_INTERNAL;
+               }
+               use_default = TRUE;
+       }
+
+       mb_svc_debug("thumb_pathname is %s\n", thumb_pathname);
+
+       if (use_default) {
+               ret_len =
+                   snprintf(thumb_info.thumb_hash_path, max_thumb_length, "%s",
+                            DEFAULT_IMAGE_THUMB);
+               if (ret_len < 0) {
+                       mb_svc_debug("Error when snprintf");
+                       return MB_SVC_ERROR_INTERNAL;
+               }
+       }
+
+       mb_svc_debug("thumb file : %s\n", thumb_info.thumb_hash_path);
+
+       err = g_file_test(thumb_info.thumb_hash_path, G_FILE_TEST_EXISTS);
+       if (!err) {
+               mb_svc_debug("failed to create thumbnail!\n");
+               return MB_SVC_ERROR_CREATE_THUMBNAIL;
+       }
+
+       chmod(thumb_info.thumb_hash_path, 0775);
+
+       ecore_evas_shutdown();
+
+#ifdef _USE_LOG_FILE_
+       mediainfo_close_file_debug();
+#endif
+       return 0;
+}
+
+static int
+__mb_svc_thumb_save_new(const void *image, mb_svc_thumb_info_s thumb_info,
+                       size_t max_thumb_length)
+{
+       mb_svc_debug("");
+       char thumb_pathname[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+       int nwrite = -1;
+       int err = 0;
+       char *src = (char *)image;
+       gsize size = 0;
+       char *data = NULL;
+       unsigned char *buffer = NULL;
+       int b_size = 0;
+       bool use_default = FALSE;
+       int ret_len = -1;
+
+       int thumb_width = 0;
+       int thumb_height = 0;
+       double ratio_wh;
+
+#ifdef _PERFORMANCE_CHECK_
+       long start = 0L, end = 0L;
+       long entire_s = 0L, entire_e = 0L;
+#endif
+
+#ifdef _USE_LOG_FILE_
+       mediainfo_init_file_debug();
+       mediainfo_file_dbg("File : %s", thumb_info.file_full_path);
+#endif
+
+       mb_svc_debug("hash : %s(%d)", thumb_info.thumb_hash_path,
+                    strlen(thumb_info.thumb_hash_path));
+       strncpy(thumb_pathname, thumb_info.thumb_hash_path,
+               sizeof(thumb_pathname));
+       if (strlen(thumb_pathname) < strlen(thumb_info.thumb_hash_path)) {
+               mb_svc_debug("Error for the length of thumb path");
+               return MB_SVC_ERROR_INTERNAL;
+       }
+
+       ecore_evas_init();
+
+       if (thumb_info.content_type == MINFO_ITEM_VIDEO) {
+               {
+                       bool portrait = FALSE;
+                       if (thumb_info.width < thumb_info.height)
+                               portrait = TRUE;
+
+                       if (portrait) {
+                               ratio_wh =
+                                   (double)thumb_info.width /
+                                   (double)thumb_info.height;
+                               thumb_height = MB_SVC_THUMB_LENGTH;
+                               thumb_width = thumb_height * ratio_wh;
+                       } else {
+                               ratio_wh =
+                                   (double)thumb_info.height /
+                                   (double)thumb_info.width;
+                               thumb_width = MB_SVC_THUMB_LENGTH;
+                               thumb_height = thumb_width * ratio_wh;
+                       }
+
+                       mb_svc_debug("ratio : %f\n", ratio_wh);
+                       mb_svc_debug("Thumb width : %d, Thumb height : %d\n",
+                                    thumb_width, thumb_height);
+
+                       int i = thumb_info.width * thumb_info.height;
+                       if (!(size = i)) {
+                               mb_svc_debug("size != i\n");
+                               return MB_SVC_ERROR_CREATE_THUMBNAIL;
+                       }
+
+                       if (!src) {
+                               mb_svc_debug("src is null\n");
+                               ret_len =
+                                   snprintf(thumb_pathname,
+                                            sizeof(thumb_pathname), "%s",
+                                            DEFAULT_VIDEO_THUMB);
+                               if (ret_len < 0) {
+                                       mb_svc_debug("Error when snprintf");
+                                       return MB_SVC_ERROR_INTERNAL;
+                               }
+                               use_default = TRUE;
+                       } else {
+                               mb_svc_debug("evas Start : %s",
+                                            thumb_info.file_full_path);
+
+#ifdef _PERFORMANCE_CHECK_
+                               entire_s = mediainfo_get_debug_time();
+#endif
+
+                               unsigned int buf_size = 0;
+                               if (mm_util_get_image_size
+                                   (MM_UTIL_IMG_FMT_RGB888, thumb_width,
+                                    thumb_height, &buf_size) < 0) {
+                                       mb_svc_debug
+                                           ("Failed to get buffer size");
+                                       return MB_SVC_ERROR_INTERNAL;
+                               }
+                               mb_svc_debug("mm_util_get_image_size : %d",
+                                            buf_size);
+
+                               unsigned char *dst =
+                                   (unsigned char *)malloc(buf_size);
+
+                               if (mm_util_resize_image
+                                   ((unsigned char *)src, thumb_info.width,
+                                    thumb_info.height, MM_UTIL_IMG_FMT_RGB888,
+                                    dst, (unsigned int *)&thumb_width,
+                                    (unsigned int *)&thumb_height) < 0) {
+                                       mb_svc_debug
+                                           ("Failed to resize the thumbnails");
+                                       if (dst)
+                                               free(dst);
+                                       return MB_SVC_ERROR_INTERNAL;
+                               }
+
+                               Ecore_Evas *ee =
+/*
+                                   ecore_evas_new("software_x11", 0, 0,
+                                                  thumb_width, thumb_height,
+                                                  NULL);
+*/
+                                       ecore_evas_buffer_new(thumb_width,
+                                                                 thumb_height);
+                               Evas *evas = ecore_evas_get(ee);
+
+                               Evas_Object *img = NULL;
+                               img = evas_object_image_add(evas);
+
+                               if (img == NULL) {
+                                       mb_svc_debug("image object is NULL\n");
+                                       if (dst)
+                                               free(dst);
+                                       ecore_evas_free(ee);
+                                       ecore_evas_shutdown();
+                                       return -1;
+                               }
+
+                               evas_object_image_colorspace_set(img,
+                                                                EVAS_COLORSPACE_ARGB8888);
+                               evas_object_image_size_set(img, thumb_width,
+                                                          thumb_height);
+                               evas_object_image_fill_set(img, 0, 0,
+                                                          thumb_width,
+                                                          thumb_height);
+
+                               unsigned char *m = NULL;
+                               m = evas_object_image_data_get(img, 1);
+#if 1                          /* Use self-logic to convert from RGB888 to RGBA */
+
+#ifdef _PERFORMANCE_CHECK_
+                               start = mediainfo_get_debug_time();
+#endif
+                               int i = 0, j;
+                               for (j = 0; j < thumb_width * 3 * thumb_height;
+                                    j += 3) {
+                                       m[i++] = (dst[j + 2]);
+                                       m[i++] = (dst[j + 1]);
+                                       m[i++] = (dst[j]);
+                                       m[i++] = 0x0;
+                               }
+#ifdef _PERFORMANCE_CHECK_
+                               end = mediainfo_get_debug_time();
+                               double convert =
+                                   ((double)(end - start) /
+                                    (double)CLOCKS_PER_SEC);
+                               mb_svc_debug("Convert from RGB888 to RGBA : %f",
+                                            convert);
+#ifdef _USE_LOG_FILE_
+                               mediainfo_file_dbg
+                                   ("Convert from RGB888 to RGBA : %f, ( W:%d, H:%d)",
+                                    convert, thumb_width, thumb_height);
+#endif
+#endif
+
+#else                          /* Use mmf api to convert from RGB888 to RGBA */
+                               int mm_ret = 0;
+                               if ((mm_ret =
+                                    mm_util_convert_colorspace(dst,
+                                                               thumb_width,
+                                                               thumb_height,
+                                                               MM_UTIL_IMG_FMT_RGB888,
+                                                               m,
+                                                               MM_UTIL_IMG_FMT_ARGB8888))
+                                   < 0) {
+                                       mb_svc_debug
+                                           ("Failed to change from rgb888 to argb8888 %d",
+                                            mm_ret);
+                                       if (dst)
+                                               free(dst);
+                                       return MB_SVC_ERROR_INTERNAL;
+                               }
+#endif                         /* End of use mmf api to convert from RGB888 to RGBA */
+
+                               evas_object_image_data_set(img, m);
+                               evas_object_image_data_update_add(img, 0, 0,
+                                                                 thumb_width,
+                                                                 thumb_height);
+
+#ifdef _PERFORMANCE_CHECK_
+                               start = mediainfo_get_debug_time();
+#endif
+                               if (evas_object_image_save
+                                   (img, thumb_pathname, NULL,
+                                    "quality=100 compress=1")) {
+                                       mb_svc_debug
+                                           ("evas_object_image_save success\n");
+                                       data = NULL;
+                               } else {
+                                       mb_svc_debug
+                                           ("evas_object_image_save fail\n");
+                                       use_default = TRUE;
+                                       data = NULL;
+                               }
+
+#ifdef _PERFORMANCE_CHECK_
+                               end = mediainfo_get_debug_time();
+                               double save =
+                                   ((double)(end - start) /
+                                    (double)CLOCKS_PER_SEC);
+                               mb_svc_debug("Save : %f", save);
+#ifdef _USE_LOG_FILE_
+                               mediainfo_file_dbg("Save( %d / %d ) : %f",
+                                                  thumb_width, thumb_height,
+                                                  save);
+                               g_video_save += save;
+                               mediainfo_file_dbg("video save sum: %f",
+                                                  g_video_save);
+#endif
+#endif
+                               if (dst)
+                                       free(dst);
+                               ecore_evas_free(ee);
+
+#ifdef _PERFORMANCE_CHECK_
+                               entire_e = mediainfo_get_debug_time();
+                               double make_video_thumb =
+                                   ((double)(entire_e - entire_s) /
+                                    (double)CLOCKS_PER_SEC);
+                               mb_svc_debug("Making video : %f\n\n",
+                                            make_video_thumb);
+#ifdef _USE_LOG_FILE_
+                               mediainfo_file_dbg("Making video : %f",
+                                                  make_video_thumb);
+                               g_video_thumb += make_video_thumb;
+                               mediainfo_file_dbg("Making video sum: %f\n\n",
+                                                  g_video_thumb);
+#endif
+#endif
+
+                       }
+               }
+               mb_svc_debug("thumb_pathname is %s\n", thumb_pathname);
+       }
+
+       else if (thumb_info.content_type == MINFO_ITEM_IMAGE) {
+               mb_svc_debug
+                   ("item type is image, imgtype is %d,_is_real_drm is %d\n",
+                    thumb_info.image_type, thumb_info.is_drm);
+
+               int total_mem = 0;
+               bool portrait = FALSE;
+
+               if (thumb_info.image_type <= 0) {
+                       mb_svc_debug("Unknown image type");
+                       ret_len =
+                           snprintf(thumb_pathname, sizeof(thumb_pathname),
+                                    "%s", DEFAULT_IMAGE_THUMB);
+                       if (ret_len < 0) {
+                               mb_svc_debug("Error when snprintf");
+                               return MB_SVC_ERROR_INTERNAL;
+                       }
+                       use_default = TRUE;
+                       data = NULL;
+
+               } else if (thumb_info.is_drm) {
+
+                       mb_svc_debug("this image file is not real drm\n");
+                       mb_svc_drm_get_buffer(thumb_info.file_full_path,
+                                             &buffer, &b_size);
+                       if (b_size <= 0) {
+                               ret_len =
+                                   snprintf(thumb_pathname,
+                                            sizeof(thumb_pathname), "%s",
+                                            DEFAULT_IMAGE_THUMB);
+                               if (ret_len < 0) {
+                                       mb_svc_debug("Error when snprintf");
+                                       return MB_SVC_ERROR_INTERNAL;
+                               }
+                               use_default = TRUE;
+                       } else {
+                               data = (char *)buffer;
+                               size = b_size;
+                       }
+
+               } else if (src && (thumb_info.size > 0)) {
+                       data = src;
+                       size = thumb_info.size;
+                       mb_svc_debug("get thumbnail of exif %d: %d\n",
+                                    (int)data, size);
+
+               } else {
+#ifdef _PERFORMANCE_CHECK_
+                       entire_s = mediainfo_get_debug_time();
+#endif
+                       if (thumb_info.width <= 0 && thumb_info.height <= 0) {
+#ifdef _USE_LOG_FILE_
+                               mediainfo_file_dbg
+                                   ("Failed to get w and h before : %s",
+                                    thumb_info.file_full_path);
+                               start = mediainfo_get_debug_time();
+#endif
+
+                               Ecore_Evas *ee =
+/*
+                                   ecore_evas_new("software_x11", 0, 0,
+                                                  thumb_width, thumb_height,
+                                                  NULL);
+*/
+                                       ecore_evas_buffer_new(thumb_width,
+                                                                 thumb_height);
+                               if (!ee) {
+                                       mb_svc_debug("ecore_evas_new fails");
+                                       return -1;
+                               }
+                               Evas *evas = ecore_evas_get(ee);
+                               if (!evas) {
+                                       mb_svc_debug("ecore_evas_get fails");
+                                       ecore_evas_free(ee);
+                                       return -1;
+                               }
+
+                               Evas_Object *image_object =
+                                   evas_object_image_add(evas);
+                               if (!image_object) {
+                                       mb_svc_debug
+                                           ("evas_object_image_add fails");
+                                       ecore_evas_free(ee);
+                                       return -1;
+                               }
+
+                               evas_object_image_file_set(image_object,
+                                                          thumb_info.
+                                                          file_full_path,
+                                                          NULL);
+                               evas_object_image_size_get(image_object,
+                                                          &(thumb_info.width),
+                                                          &(thumb_info.
+                                                            height));
+                               ecore_evas_free(ee);
+
+#ifdef _PERFORMANCE_CHECK_
+                               end = mediainfo_get_debug_time();
+                               double get_size =
+                                   ((double)(end - start) /
+                                    (double)CLOCKS_PER_SEC);
+                               mb_svc_debug("get_size : %f", get_size);
+#ifdef _USE_LOG_FILE_
+                               mediainfo_file_dbg("get_size : %f", get_size);
+#endif
+#endif
+                       }
+
+                       mb_svc_debug("image width : %d, height : %d",
+                                    thumb_info.width, thumb_info.height);
+
+                       if (thumb_info.width <= 0 || thumb_info.height <= 0) {
+                               ret_len =
+                                   snprintf(thumb_pathname,
+                                            sizeof(thumb_pathname), "%s",
+                                            DEFAULT_IMAGE_THUMB);
+                               if (ret_len < 0) {
+                                       mb_svc_debug("Error when snprintf");
+                                       return MB_SVC_ERROR_INTERNAL;
+                               }
+                               use_default = TRUE;
+                       } else {
+
+                               total_mem = thumb_info.width * thumb_info.height;
+
+                               if (thumb_info.width < thumb_info.height)
+                                       portrait = TRUE;
+
+                               if (portrait) {
+                                       ratio_wh =
+                                           (double)thumb_info.width /
+                                           (double)thumb_info.height;
+                                       thumb_height = MB_SVC_THUMB_LENGTH;
+                                       thumb_width = thumb_height * ratio_wh;
+                               } else {
+                                       ratio_wh =
+                                           (double)thumb_info.height /
+                                           (double)thumb_info.width;
+                                       thumb_width = MB_SVC_THUMB_LENGTH;
+                                       thumb_height = thumb_width * ratio_wh;
+                               }
+                               mb_svc_debug("ratio : %f\n", ratio_wh);
+                               mb_svc_debug
+                                   ("Thumb width : %d, Thumb height : %d\n",
+                                    thumb_width, thumb_height);
+                       }
+
+                       if (thumb_info.image_type != IMG_CODEC_AGIF
+                           && !use_default) {
+                               mb_svc_debug
+                                   ("this is non-agif image file,is_real_drm is %d\n",
+                                    thumb_info.is_drm);
+
+                               if (thumb_info.image_type == IMG_CODEC_JPEG
+                                   || total_mem <= MB_SVC_MAX_ALLOWED_MEM_FOR_THUMB) {
+                                       Ecore_Evas *ee =
+/*
+                                           ecore_evas_new("software_x11", 0, 0,
+                                                          thumb_width,
+                                                          thumb_height, NULL);
+*/
+                                       ecore_evas_buffer_new(thumb_width,
+                                                                 thumb_height);
+                                       if (!ee) {
+                                               mb_svc_debug
+                                                   ("Failed to create a ecore evas\n");
+                                               ecore_evas_shutdown();
+                                               return -1;
+                                       }
+
+                                       Evas *evas = ecore_evas_get(ee);
+                                       if (!evas) {
+                                               mb_svc_debug
+                                                   ("Failed to ecore_evas_get\n");
+                                               ecore_evas_free(ee);
+                                               ecore_evas_shutdown();
+                                               return -1;
+                                       }
+
+                                       Ecore_Evas *resize_img_ee;
+                                       resize_img_ee =
+                                           ecore_evas_buffer_new(thumb_width,
+                                                                 thumb_height);
+
+                                       if (!resize_img_ee) {
+                                               mb_svc_debug
+                                                   ("Failed to create a new ecore evas buffer\n");
+                                               ecore_evas_free(ee);
+                                               ecore_evas_shutdown();
+                                               return -1;
+                                       }
+
+                                       Evas *resize_img_e =
+                                           ecore_evas_get(resize_img_ee);
+                                       if (!resize_img_e) {
+                                               mb_svc_debug
+                                                   ("Failed to ecore_evas_get\n");
+                                               ecore_evas_free(ee);
+                                               ecore_evas_free(resize_img_ee);
+                                               ecore_evas_shutdown();
+                                               return -1;
+                                       }
+
+                                       Evas_Object *source_img =
+                                           evas_object_image_add(resize_img_e);
+                                       if (!source_img) {
+                                               mb_svc_debug
+                                                   ("evas_object_image_add failed\n");
+                                               ecore_evas_free(ee);
+                                               ecore_evas_free(resize_img_ee);
+                                               ecore_evas_shutdown();
+                                               return -1;
+                                       }
+
+                                       evas_object_image_load_size_set
+                                           (source_img, thumb_width,
+                                            thumb_height);
+                                       evas_object_image_file_set(source_img,
+                                                                  thumb_info.
+                                                                  file_full_path,
+                                                                  NULL);
+
+                                       evas_object_image_fill_set(source_img,
+                                                                  0, 0,
+                                                                  thumb_width,
+                                                                  thumb_height);
+                                       evas_object_image_filled_set(source_img,
+                                                                    1);
+                                       evas_object_resize(source_img,
+                                                          thumb_width,
+                                                          thumb_height);
+                                       evas_object_show(source_img);
+
+#ifdef _PERFORMANCE_CHECK_
+                                       start = mediainfo_get_debug_time();
+#endif
+                                       Evas_Object *ret_image =
+                                           evas_object_image_add(evas);
+                                       /* evas_object_image_data_set(ret_image, NULL); */
+                                       evas_object_image_size_set(ret_image,
+                                                                  thumb_width,
+                                                                  thumb_height);
+                                       evas_object_image_fill_set(ret_image, 0,
+                                                                  0,
+                                                                  thumb_width,
+                                                                  thumb_height);
+
+                                       evas_object_image_filled_set(ret_image,
+                                                                    EINA_TRUE);
+                                       /* evas_object_image_data_copy_set(ret_image, (int *)ecore_evas_buffer_pixels_get(resize_img_ee)); */
+                                       evas_object_image_data_set(ret_image,
+                                                                  (int *)
+                                                                  ecore_evas_buffer_pixels_get
+                                                                  (resize_img_ee));
+                                       evas_object_image_data_update_add
+                                           (ret_image, 0, 0, thumb_width,
+                                            thumb_height);
+
+#ifdef _PERFORMANCE_CHECK_
+                                       end = mediainfo_get_debug_time();
+                                       double copy_set =
+                                           ((double)(end - start) /
+                                            (double)CLOCKS_PER_SEC);
+                                       mb_svc_debug("copy_set : %f", copy_set);
+#ifdef _USE_LOG_FILE_
+                                       mediainfo_file_dbg("copy_set : %f",
+                                                          copy_set);
+#endif
+#endif
+
+#ifdef _PERFORMANCE_CHECK_
+                                       start = mediainfo_get_debug_time();
+#endif
+                                       /* check it's orientation */
+                                       if (thumb_info.orientation == ROT_90) {
+                                               mb_svc_debug
+                                                   ("This needs to be rotated -90");
+                                               __mb_svc_image_rotate_90
+                                                   (ret_image);
+                                       } else if (thumb_info.orientation ==
+                                                  ROT_180) {
+                                               mb_svc_debug
+                                                   ("This needs to be rotated -180");
+                                               __mb_svc_image_rotate_180
+                                                   (ret_image);
+                                       } else if (thumb_info.orientation ==
+                                                  ROT_270) {
+                                               mb_svc_debug
+                                                   ("This needs to be rotated -270");
+                                               __mb_svc_image_rotate_270
+                                                   (ret_image);
+                                       }
+#ifdef _PERFORMANCE_CHECK_
+                                       end = mediainfo_get_debug_time();
+                                       double rotate =
+                                           ((double)(end - start) /
+                                            (double)CLOCKS_PER_SEC);
+                                       mb_svc_debug("rotate : %f", rotate);
+#ifdef _USE_LOG_FILE_
+                                       mediainfo_file_dbg("rotate : %f",
+                                                          rotate);
+#endif
+#endif
+
+#ifdef _PERFORMANCE_CHECK_
+                                       start = mediainfo_get_debug_time();
+#endif
+                                       if (evas_object_image_save
+                                           (ret_image, thumb_pathname, NULL,
+                                            "quality=100 compress=1")) {
+                                               mb_svc_debug
+                                                   ("evas_object_image_save success\n");
+                                       } else {
+                                               mb_svc_debug
+                                                   ("evas_object_image_save fails\n");
+                                               use_default = TRUE;
+                                       }
+
+#ifdef _PERFORMANCE_CHECK_
+                                       end = mediainfo_get_debug_time();
+                                       double save =
+                                           ((double)(end - start) /
+                                            (double)CLOCKS_PER_SEC);
+                                       mb_svc_debug("Save : %f", save);
+#ifdef _USE_LOG_FILE_
+                                       mediainfo_file_dbg
+                                           ("Save( %d / %d ) : %f",
+                                            thumb_width, thumb_height, save);
+                                       g_img_save += save;
+                                       mediainfo_file_dbg("image save sum: %f",
+                                                          g_img_save);
+#endif
+#endif
+                                       evas_object_del(source_img);
+                                       ecore_evas_free(resize_img_ee);
+                                       ecore_evas_free(ee);
+                                       data = NULL;
+                               } else {
+                                       mb_svc_debug
+                                           ("It's too big to make thumbnails for memory");
+                                       ret_len =
+                                           snprintf(thumb_pathname,
+                                                    sizeof(thumb_pathname),
+                                                    "%s", DEFAULT_IMAGE_THUMB);
+                                       if (ret_len < 0) {
+                                               mb_svc_debug
+                                                   ("Error when snprintf");
+                                               return MB_SVC_ERROR_INTERNAL;
+                                       }
+                                       use_default = TRUE;
+                                       data = NULL;
+                               }
+#ifdef _PERFORMANCE_CHECK_
+                               entire_e = mediainfo_get_debug_time();
+                               double make_img_thumb =
+                                   ((double)(entire_e - entire_s) /
+                                    (double)CLOCKS_PER_SEC);
+                               mb_svc_debug("Making img : %f\n\n",
+                                            make_img_thumb);
+#ifdef _USE_LOG_FILE_
+                               mediainfo_file_dbg("Making img : %f",
+                                                  make_img_thumb);
+                               g_img_thumb += make_img_thumb;
+                               mediainfo_file_dbg("Making image sum: %f\n\n",
+                                                  g_img_thumb);
+#endif
+#endif
+                       } else if (thumb_info.image_type == IMG_CODEC_AGIF && !use_default) {   /* For agif files */
+                               mb_svc_debug("this is agif file\n");
+#ifdef _PERFORMANCE_CHECK_
+                               entire_s = mediainfo_get_debug_time();
+#endif
+                               if (src == NULL) {
+                                       mb_svc_debug
+                                           ("There's no thumbnail from this agif file");
+
+                                       ret_len =
+                                           snprintf(thumb_pathname,
+                                                    sizeof(thumb_pathname),
+                                                    "%s", DEFAULT_IMAGE_THUMB);
+                                       if (ret_len < 0) {
+                                               mb_svc_debug
+                                                   ("Error when snprintf");
+                                               return MB_SVC_ERROR_INTERNAL;
+                                       }
+                                       use_default = TRUE;
+                               } else if (thumb_info.width <= 0
+                                          || thumb_info.height <= 0) {
+                                       ret_len =
+                                           snprintf(thumb_pathname,
+                                                    sizeof(thumb_pathname),
+                                                    "%s", DEFAULT_IMAGE_THUMB);
+                                       if (ret_len < 0) {
+                                               mb_svc_debug
+                                                   ("Error when snprintf");
+                                               return MB_SVC_ERROR_INTERNAL;
+                                       }
+                                       use_default = TRUE;
+                               } else {
+                                       unsigned int buf_size = 0;
+                                       if (mm_util_get_image_size
+                                           (MM_UTIL_IMG_FMT_RGB888,
+                                            thumb_width, thumb_height,
+                                            &buf_size) < 0) {
+                                               mb_svc_debug
+                                                   ("Failed to get buffer size");
+                                               return MB_SVC_ERROR_INTERNAL;
+                                       }
+                                       mb_svc_debug
+                                           ("mm_util_get_image_size : %d",
+                                            buf_size);
+
+                                       unsigned char *dst =
+                                           (unsigned char *)malloc(buf_size);
+
+#ifdef _PERFORMANCE_CHECK_
+                                       start = mediainfo_get_debug_time();
+#endif
+                                       if (mm_util_resize_image
+                                           ((unsigned char *)src,
+                                            thumb_info.width,
+                                            thumb_info.height,
+                                            MM_UTIL_IMG_FMT_RGB888, dst,
+                                            (unsigned int *)&thumb_width,
+                                            (unsigned int *)&thumb_height) <
+                                           0) {
+                                               mb_svc_debug
+                                                   ("Failed to resize the thumbnails");
+                                               if (dst)
+                                                       free(dst);
+                                               return MB_SVC_ERROR_INTERNAL;
+                                       }
+#ifdef _PERFORMANCE_CHECK_
+                                       end = mediainfo_get_debug_time();
+                                       double resize =
+                                           ((double)(end - start) /
+                                            (double)CLOCKS_PER_SEC);
+                                       mb_svc_debug("Resize : %f", resize);
+#ifdef _USE_LOG_FILE_
+                                       mediainfo_file_dbg("Resize : %f",
+                                                          resize);
+#endif
+#endif
+                                       Ecore_Evas *ee =
+/*
+                                           ecore_evas_new("software_x11", 0, 0,
+                                                          thumb_info.width,
+                                                          thumb_info.height,
+                                                          NULL);
+*/
+                                               ecore_evas_buffer_new(thumb_info.width,
+                                                                 thumb_info.height);
+                                       Evas *evas = ecore_evas_get(ee);
+
+                                       Evas_Object *img = NULL;
+                                       img = evas_object_image_add(evas);
+
+                                       if (img == NULL) {
+                                               printf("img object is NULL\n");
+                                               if (dst)
+                                                       free(dst);
+                                               ecore_evas_free(ee);
+                                               ecore_evas_shutdown();
+                                               return -1;
+                                       }
+
+                                       evas_object_image_colorspace_set(img,
+                                                                        EVAS_COLORSPACE_ARGB8888);;
+                                       evas_object_image_size_set(img,
+                                                                  thumb_width,
+                                                                  thumb_height);
+                                       evas_object_image_fill_set(img, 0, 0,
+                                                                  thumb_width,
+                                                                  thumb_height);
+                                       /* evas_object_image_size_set(img, thumb_info.width, thumb_info.height); */
+                                       /* evas_object_image_fill_set(img, 0, 0, thumb_info.width, thumb_info.height); */
+
+                                       unsigned char *m = NULL;
+                                       m = evas_object_image_data_get(img, 1);
+#if 1
+#ifdef _PERFORMANCE_CHECK_
+                                       start = mediainfo_get_debug_time();
+#endif
+                                       int i = 0, j;
+
+                                       for (j = 0;
+                                            j < thumb_width * 3 * thumb_height;
+                                            j += 3) {
+                                               m[i++] = (dst[j + 2]);
+                                               m[i++] = (dst[j + 1]);
+                                               m[i++] = (dst[j]);
+                                               m[i++] = 0x0;
+                                       }
+#ifdef _PERFORMANCE_CHECK_
+                                       end = mediainfo_get_debug_time();
+                                       double convert =
+                                           ((double)(end - start) /
+                                            (double)CLOCKS_PER_SEC);
+                                       mb_svc_debug
+                                           ("Convert from RGB888 to RGBA : %f",
+                                            convert);
+#ifdef _USE_LOG_FILE_
+                                       mediainfo_file_dbg
+                                           ("Convert from RGB888 to RGBA : %f",
+                                            convert);
+#endif
+#endif
+#else                          /* Using evas to get agif thumbnails */
+                                       int mm_ret = 0;
+                                       if ((mm_ret =
+                                            mm_util_convert_colorspace(dst,
+                                                                       thumb_width,
+                                                                       thumb_height,
+                                                                       MM_UTIL_IMG_FMT_RGB888,
+                                                                       m,
+                                                                       MM_UTIL_IMG_FMT_ARGB8888))
+                                           < 0) {
+                                               mb_svc_debug
+                                                   ("Failed to change from rgb888 to argb8888 : %d",
+                                                    mm_ret);
+                                               if (dst)
+                                                       free(dst);
+                                               return MB_SVC_ERROR_INTERNAL;
+                                       }
+#endif
+
+                                       evas_object_image_data_set(img, m);
+                                       evas_object_image_data_update_add(img,
+                                                                         0, 0,
+                                                                         thumb_width,
+                                                                         thumb_height);
+
+#ifdef _PERFORMANCE_CHECK_
+                                       start = mediainfo_get_debug_time();
+#endif
+                                       if (evas_object_image_save
+                                           (img, thumb_pathname, NULL,
+                                            "quality=100 compress=1")) {
+                                               mb_svc_debug
+                                                   ("evas_object_image_save success\n");
+                                       } else {
+                                               mb_svc_debug
+                                                   ("evas_object_image_save fails\n");
+                                               use_default = TRUE;
+                                       }
+
+#ifdef _PERFORMANCE_CHECK_
+                                       end = mediainfo_get_debug_time();
+                                       double save =
+                                           ((double)(end - start) /
+                                            (double)CLOCKS_PER_SEC);
+                                       mb_svc_debug("Save : %f", save);
+#ifdef _USE_LOG_FILE_
+                                       mediainfo_file_dbg
+                                           ("Save( %d / %d ) : %f",
+                                            thumb_width, thumb_height, save);
+                                       g_agif_save += save;
+                                       mediainfo_file_dbg("agif save sum: %f",
+                                                          g_agif_save);
+#endif
+#endif
+                                       if (src)
+                                               free(src);
+                                       if (dst)
+                                               free(dst);
+                                       ecore_evas_free(ee);
+                                       data = NULL;
+                               }
+#ifdef _PERFORMANCE_CHECK_
+                               entire_e = mediainfo_get_debug_time();
+                               double make_agif_thumb =
+                                   ((double)(entire_e - entire_s) /
+                                    (double)CLOCKS_PER_SEC);
+                               mb_svc_debug("Making agif thumb : %f\n\n",
+                                            make_agif_thumb);
+#ifdef _USE_LOG_FILE_
+                               mediainfo_file_dbg("Making agif : %f",
+                                                  make_agif_thumb);
+                               g_agif_thumb += make_agif_thumb;
+                               mediainfo_file_dbg("Making agif sum: %f\n\n",
+                                                  g_agif_thumb);
+#endif
+#endif
+                       }
+               }
+       }
+
+       if (data != NULL) {
+               int fd;
+               /* fd = open(thumb_pathname, O_RDWR | O_CREAT | O_APPEND | O_SYNC, 600); */
+               fd = open(thumb_pathname, O_RDWR | O_CREAT, 600);
+               if (fd < 0) {
+                       mb_svc_debug("File open fails");
+                       return MB_SVC_ERROR_FILE_IO;
+               }
+
+               nwrite = write(fd, data, size);
+               close(fd);
+
+               g_free(data);
+
+       }
+
+       size = __get_thumbfile_size(thumb_pathname);
+       if (size == 0) {
+               mb_svc_debug("File size is ZERO : %s", thumb_pathname);
+               ret_len =
+                   snprintf(thumb_pathname, sizeof(thumb_pathname), "%s",
+                            DEFAULT_IMAGE_THUMB);
+               if (ret_len < 0) {
+                       mb_svc_debug("Error when snprintf");
+                       return MB_SVC_ERROR_INTERNAL;
+               }
+               use_default = TRUE;
+       }
+
+       mb_svc_debug("thumb_pathname is %s\n", thumb_pathname);
+
+       if (use_default) {
+               ret_len =
+                   snprintf(thumb_info.thumb_hash_path, max_thumb_length, "%s",
+                            DEFAULT_IMAGE_THUMB);
+               if (ret_len < 0) {
+                       mb_svc_debug("Error when snprintf");
+                       return MB_SVC_ERROR_INTERNAL;
+               }
+       }
+
+       mb_svc_debug("thumb file : %s\n", thumb_info.thumb_hash_path);
+
+       err = g_file_test(thumb_info.thumb_hash_path, G_FILE_TEST_EXISTS);
+       if (!err) {
+               mb_svc_debug("failed to create thumbnail!\n");
+               return MB_SVC_ERROR_CREATE_THUMBNAIL;
+       }
+
+       chmod(thumb_info.thumb_hash_path, 0775);
+       ecore_evas_shutdown();
+
+#ifdef _USE_LOG_FILE_
+       mediainfo_close_file_debug();
+#endif
+       return 0;
+}
+
+int
+mb_svc_image_create_thumb(const char *file_full_path, char *thumb_hash_path,
+                         size_t max_thumb_length, bool force,
+                         mb_svc_image_meta_record_s *img_meta_record)
+{
+       unsigned int *thumb = NULL;
+       int err = 0;
+       ImgImageInfo image_info = { 0 };
+       mb_svc_thumb_info_s thumb_info = { 0 };
+       char file_ext[MB_SVC_FILE_EXT_LEN_MAX + 1] = { 0 };
+
+       mb_svc_debug("_mb_svc_image_create_thumb------------start\n");
+
+       if (file_full_path == NULL || thumb_hash_path == NULL) {
+               mb_svc_debug("file_full_path==NULL || thumb_hash_path==NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (img_meta_record == NULL) {
+               mb_svc_debug("img_meta_record == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (g_file_test
+           (thumb_hash_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
+               if (force) {
+                       if ((err = _mb_svc_thumb_rm(thumb_hash_path)) < 0) {
+                               mb_svc_debug
+                                   ("The existed thumbnail is removed");
+                       } else {
+                               mb_svc_debug("_mb_svc_thumb_rm failed : %d",
+                                            err);
+                       }
+               } else {
+                       mb_svc_debug("Thumbnail already exists");
+                       return 0;
+               }
+       }
+
+       thumb_info.image_type = ImgGetInfoFile(file_full_path, &image_info);
+       mb_svc_debug("image type is %d\n", thumb_info.image_type);
+       thumb_info.width = image_info.width;
+       thumb_info.height = image_info.height;
+       mb_svc_debug("image width:%d, height:%d \n", thumb_info.width,
+                    thumb_info.height);
+
+       if (thumb_info.width > MB_SVC_THUMB_LENGTH_LIMIT
+           || thumb_info.height > MB_SVC_THUMB_LENGTH_LIMIT) {
+               mb_svc_debug
+                   ("Widht or height is so big. Can't create thumbnail");
+               return MB_SVC_ERROR_CREATE_THUMBNAIL;
+       }
+
+       /* convert format and save */
+       thumb_info.size = -1;
+       if (!(_mb_svc_get_file_ext(file_full_path, file_ext))) {
+               return MB_SVC_ERROR_CREATE_THUMBNAIL;
+       }
+
+       mb_svc_debug("file ext  is %s\n", file_ext);
+       if (strcasecmp(file_ext, "wbmp") == 0) {
+               thumb_info.image_type = IMG_CODEC_WBMP;
+       } else if ((strcasecmp(file_ext, "dcf") == 0)
+                  || (strcasecmp(file_ext, "dm") == 0)) {
+               thumb_info.image_type = IMG_CODEC_DRM;
+       }
+
+       if (thumb_info.image_type == IMG_CODEC_AGIF) {
+               if (thumb_info.width * thumb_info.height > MB_SVC_MAX_ALLOWED_MEM_FOR_THUMB) {
+                       thumb = NULL;
+               } else {
+                       thumb = ImgGetFirstFrameAGIFAtSize(file_full_path, &image_info);
+               }
+       }
+
+       thumb_info.orientation = img_meta_record->orientation;
+       thumb_info.file_full_path = file_full_path;
+       thumb_info.thumb_hash_path = thumb_hash_path;
+       thumb_info.content_type = MINFO_ITEM_IMAGE;
+       thumb_info.is_drm = (drm_svc_is_drm_file(file_full_path) == DRM_TRUE);
+
+       err =
+           __mb_svc_thumb_save(thumb, thumb_info, max_thumb_length,
+                               img_meta_record);
+       if (err < 0) {
+               mb_svc_debug("failed to save thumbnail!\n");
+               
+               int ret_len =
+                   snprintf(thumb_info.thumb_hash_path, max_thumb_length, "%s",
+                            DEFAULT_IMAGE_THUMB);
+               if (ret_len < 0) {
+                       mb_svc_debug("Error when snprintf");
+                       return MB_SVC_ERROR_INTERNAL;
+               }
+
+               return err;
+       }
+
+       mb_svc_debug("_mb_svc_image_create_thumb------------leave\n");
+       return 0;
+}
+
+int
+mb_svc_image_create_thumb_new(const char *file_full_path, char *thumb_hash_path,
+                             size_t max_thumb_length,
+                             mb_svc_image_meta_record_s *img_meta_record)
+{
+       unsigned int *thumb = NULL;
+       int err = 0;
+       ImgImageInfo image_info = { 0 };
+       mb_svc_thumb_info_s thumb_info = { 0 };
+       char file_ext[MB_SVC_FILE_EXT_LEN_MAX + 1] = { 0 };
+
+       mb_svc_debug("_mb_svc_image_create_thumb------------start\n");
+
+       if (file_full_path == NULL || thumb_hash_path == NULL
+           || img_meta_record == NULL) {
+               mb_svc_debug
+                   ("file_full_path==NULL || thumb_hash_path==NULL || img_meta_record == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (g_file_test
+           (thumb_hash_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
+               mb_svc_debug("Thumbnail already exists");
+               return 0;
+       }
+
+       thumb_info.image_type = ImgGetInfoFile(file_full_path, &image_info);
+       thumb_info.width = image_info.width;
+       thumb_info.height = image_info.height;
+
+       if (thumb_info.width > MB_SVC_THUMB_LENGTH_LIMIT
+           || thumb_info.height > MB_SVC_THUMB_LENGTH_LIMIT) {
+               mb_svc_debug
+                   ("Widht or height is so big. Can't create thumbnail");
+               return MB_SVC_ERROR_CREATE_THUMBNAIL;
+       }
+
+       /* convert format and save */
+       thumb_info.size = -1;
+       if (!(_mb_svc_get_file_ext(file_full_path, file_ext))) {
+               return MB_SVC_ERROR_CREATE_THUMBNAIL;
+       }
+
+       mb_svc_debug("file ext  is %s\n", file_ext);
+       if (strcasecmp(file_ext, "wbmp") == 0) {
+               thumb_info.image_type = IMG_CODEC_WBMP;
+       } else if ((strcasecmp(file_ext, "dcf") == 0)
+                  || (strcasecmp(file_ext, "dm") == 0)) {
+               thumb_info.image_type = IMG_CODEC_DRM;
+       }
+
+       if (thumb_info.image_type == IMG_CODEC_AGIF) {
+               thumb = ImgGetFirstFrameAGIFAtSize(file_full_path, &image_info);
+       }
+
+       thumb_info.file_full_path = file_full_path;
+       thumb_info.thumb_hash_path = thumb_hash_path;
+       thumb_info.content_type = MINFO_ITEM_IMAGE;
+       thumb_info.is_drm = (drm_svc_is_drm_file(file_full_path) == DRM_TRUE);
+
+       err = __mb_svc_thumb_save_new(thumb, thumb_info, max_thumb_length);
+       if (err < 0) {
+               mb_svc_debug("failed to save thumbnail!\n");
+               return err;
+       }
+
+       img_meta_record->width = thumb_info.width;
+       img_meta_record->height = thumb_info.height;
+
+       mb_svc_debug("_mb_svc_image_create_thumb------------leave\n");
+       return 0;
+}
+
+int
+mb_svc_get_image_meta(const char *file_full_path,
+                                               mb_svc_image_meta_record_s *image_record,
+                                               bool *thumb_done)
+{
+       char buf[MB_SVC_EXIF_BUFFER_LEN_MAX + 1] = { '\0' };
+       memset(buf, 0x00, MB_SVC_EXIF_BUFFER_LEN_MAX + 1);
+
+       double value = 0.0;
+       int orient_value = 0;
+       int exif_width = 0;
+       int exif_height = 0;
+       ExifData *ed = NULL;
+
+       if (file_full_path == NULL || image_record == NULL) {
+               mb_svc_debug("file_full_path == NULL || image_record == NULL ");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       /* Load an ExifData object from an EXIF file */
+       ed = exif_data_new_from_file(file_full_path);
+
+       if (!ed) {
+               mb_svc_debug("File not readable or no EXIF data in file %s\n",
+                            file_full_path);
+       }
+
+       if (__mb_svc_get_exif_info
+           (ed, buf, NULL, EXIF_IFD_0,
+            EXIF_TAG_GPS_LATITUDE_REF) == 0) {
+               if (strlen(buf) != 0) {
+                       if (mb_svc_get_exif_gps_info
+                           (ed, &value, EXIF_IFD_GPS,
+                            EXIF_TAG_GPS_LATITUDE) == 0) {
+                               if (strcmp(buf, "S") == 0) {
+                                       value = -1 * value;
+                               }
+                               image_record->latitude = value;
+                       } else {
+                               image_record->latitude = MINFO_DEFAULT_GPS;
+                               mb_svc_debug
+                                   ("__mb_svc_get_exif_info:EXIF_TAG_GPS_LATITUDE  fails");
+                       }
+               } else {
+                       image_record->latitude = MINFO_DEFAULT_GPS;
+                       mb_svc_debug
+                           ("__mb_svc_get_exif_info:EXIF_TAG_GPS_LATITUDE is empty");
+               }
+       } else {
+               image_record->latitude = MINFO_DEFAULT_GPS;
+               mb_svc_debug
+                   ("__mb_svc_get_exif_info:EXIF_TAG_GPS_LATITUDE  fails");
+       }
+
+       memset(buf, 0x00, sizeof(buf));
+
+       if (__mb_svc_get_exif_info
+           (ed, buf, NULL, EXIF_IFD_0,
+            EXIF_TAG_GPS_LONGITUDE_REF) == 0) {
+               if (strlen(buf) != 0) {
+                       if (mb_svc_get_exif_gps_info
+                           (ed, &value, EXIF_IFD_GPS,
+                            EXIF_TAG_GPS_LONGITUDE) == 0) {
+                               if (strcmp(buf, "W") == 0) {
+                                       value = -1 * value;
+                               }
+                               image_record->longitude = value;
+                       } else {
+                               image_record->longitude = MINFO_DEFAULT_GPS;
+                               mb_svc_debug
+                                   ("__mb_svc_get_exif_info:EXIF_TAG_GPS_LONGITUDE  fails");
+                       }
+               } else {
+                       image_record->longitude = MINFO_DEFAULT_GPS;
+                       mb_svc_debug
+                           ("__mb_svc_get_exif_info:EXIF_TAG_GPS_LONGITUDE is empty");
+               }
+       } else {
+               image_record->longitude = MINFO_DEFAULT_GPS;
+               mb_svc_debug
+                   ("__mb_svc_get_exif_info:EXIF_TAG_GPS_LONGITUDE  fails");
+       }
+
+       memset(buf, 0x00, MB_SVC_EXIF_BUFFER_LEN_MAX + 1);
+
+       if (__mb_svc_get_exif_info
+           (ed, buf, NULL, EXIF_IFD_0,
+            EXIF_TAG_IMAGE_DESCRIPTION) == 0) {
+               if (strlen(buf) == 0) {
+                       strncpy(image_record->description, "No description",
+                               sizeof(image_record->description));
+               } else {
+                       strncpy(image_record->description, buf,
+                               sizeof(image_record->description));
+                       image_record->
+                           description[sizeof(image_record->description) - 1] =
+                           '\0';
+               }
+       } else {
+               mb_svc_debug
+                   ("__mb_svc_get_exif_info:EXIF_TAG_IMAGE_DESCRIPTION  fails");
+       }
+
+       memset(buf, 0x00, MB_SVC_EXIF_BUFFER_LEN_MAX + 1);
+
+       if (__mb_svc_get_exif_info
+           (ed, buf, NULL, EXIF_IFD_0, EXIF_TAG_DATE_TIME) == 0) {
+               if (strlen(buf) == 0) {
+                       mb_svc_debug("time  is NULL");
+               } else {
+                       mb_svc_debug("time  is %s", buf);
+                       image_record->datetaken =
+                           __mb_svc_get_time_val_from_str(buf);
+               }
+       } else {
+               mb_svc_debug("__mb_svc_get_exif_info:EXIF_TAG_DATE_TIME  fails");
+       }
+
+       /* Get orientation value from exif. */
+       if (__mb_svc_get_exif_info
+           (ed, NULL, &orient_value, EXIF_IFD_0,
+            EXIF_TAG_ORIENTATION) == 0) {
+               if (orient_value >= NOT_AVAILABLE && orient_value <= ROT_270) {
+                       image_record->orientation = orient_value;
+               } else {
+                       image_record->orientation = 0;
+               }
+       } else {
+               image_record->orientation = 0;
+               mb_svc_debug
+                   ("__mb_svc_get_exif_info:EXIF_TAG_ORIENTATION  fails");
+       }
+
+       /* Get width value from exif. */
+       if (__mb_svc_get_exif_info
+           (ed, NULL, &exif_width, EXIF_IFD_EXIF, EXIF_TAG_PIXEL_X_DIMENSION) == 0) {
+               if (exif_width > 0) {
+                       image_record->width = exif_width;
+               } else {
+                       image_record->width = 0;
+               }
+       } else {
+               image_record->width = 0;
+               mb_svc_debug
+                   ("__mb_svc_get_exif_info:EXIF_TAG_PIXEL_X_DIMENSION  fails");
+       }
+
+       /* Get height value from exif. */
+       if (__mb_svc_get_exif_info
+           (ed, NULL, &exif_height, EXIF_IFD_EXIF, EXIF_TAG_PIXEL_Y_DIMENSION) == 0) {
+               if (exif_width > 0) {
+                       image_record->height = exif_height;
+               } else {
+                       image_record->height = 0;
+               }
+       } else {
+               image_record->height = 0;
+               mb_svc_debug
+                   ("__mb_svc_get_exif_info:EXIF_TAG_PIXEL_Y_DIMENSION  fails");
+       }
+
+       //err = __mb_svc_get_thumb_and_save_from_exif(ed, file_full_path, image_record->orientation);
+       //if (err == 0) *thumb_done = TRUE;
+
+       if (ed != NULL) exif_data_unref(ed);
+
+       return 0;
+}
+
+int
+mb_svc_get_video_meta(const char *file_full_path,
+                     mb_svc_video_meta_record_s *video_record)
+{
+       MMHandleType content = (MMHandleType) NULL;
+       MMHandleType tag = (MMHandleType) NULL;
+       char *p = NULL;
+       int size = 0;
+       int duration = 0;
+       int width = 0;
+       int height = 0;
+       int err = -1;
+       char *err_msg = NULL;
+       double gps_value = 0.0;
+
+       err = mm_file_create_content_attrs(&content, file_full_path);
+       if (content != (MMHandleType) NULL) {
+               err =
+                   mm_file_get_attrs(content, &err_msg,
+                                     MM_FILE_CONTENT_DURATION, &duration,
+                                     NULL);
+               if (err != 0) {
+                       mb_svc_debug("mm_file_get_attrs fails : %s", err_msg);
+                       free(err_msg);
+                       err_msg = NULL;
+               }
+
+               video_record->duration = duration;
+
+               err =
+                   mm_file_get_attrs(content, &err_msg,
+                                     MM_FILE_CONTENT_VIDEO_WIDTH, &width,
+                                     NULL);
+               if (err != 0) {
+                       mb_svc_debug("mm_file_get_attrs fails : %s", err_msg);
+                       free(err_msg);
+                       err_msg = NULL;
+               }
+
+               video_record->width = width;
+
+               err =
+                   mm_file_get_attrs(content, &err_msg,
+                                     MM_FILE_CONTENT_VIDEO_HEIGHT, &height,
+                                     NULL);
+               if (err != 0) {
+                       mb_svc_debug("mm_file_get_attrs fails : %s", err_msg);
+                       free(err_msg);
+                       err_msg = NULL;
+               }
+
+               video_record->height = height;
+               mm_file_destroy_content_attrs(content);
+
+               mb_svc_debug("duration of video is %d!!\n", duration);
+               mb_svc_debug("width of video is %d!!\n", width);
+               mb_svc_debug("height of video is %d!!\n", height);
+       } else {
+               mb_svc_debug
+                   ("no tag information of video to invoke mm_file_create_content_attrs %s\n",
+                    file_full_path);
+               return MB_SVC_ERROR_INTERNAL;
+       }
+
+       err = mm_file_create_tag_attrs(&tag, file_full_path);
+       if (!tag) {
+               mb_svc_debug
+                   ("no tag information of video to invoke mm_file_create_tag_attrs %s\n",
+                    file_full_path);
+               return MB_SVC_ERROR_INTERNAL;
+       } else {
+               err =
+                   mm_file_get_attrs(tag, &err_msg, MM_FILE_TAG_TITLE, &p,
+                                     &size, NULL);
+               if (err == 0 && size > 0) {
+                       strncpy(video_record->title, p,
+                               sizeof(video_record->title) - 1);
+               } else {
+                       if (err_msg) {
+                               mb_svc_debug("mm_file_get_attrs fails : %s",
+                                            err_msg);
+                               free(err_msg);
+                               err_msg = NULL;
+                       }
+                       strncpy(video_record->title, UNKNOWN_TAG,
+                               sizeof(video_record->title) - 1);
+               }
+
+               err =
+                   mm_file_get_attrs(tag, &err_msg, MM_FILE_TAG_ARTIST, &p,
+                                     &size, NULL);
+               if (err == 0 && size > 0) {
+                       strncpy(video_record->artist, p,
+                               sizeof(video_record->artist) - 1);
+               } else {
+                       if (err_msg) {
+                               mb_svc_debug("mm_file_get_attrs fails : %s",
+                                            err_msg);
+                               free(err_msg);
+                               err_msg = NULL;
+                       }
+                       strncpy(video_record->artist, UNKNOWN_TAG,
+                               sizeof(video_record->artist) - 1);
+               }
+
+               err =
+                   mm_file_get_attrs(tag, &err_msg, MM_FILE_TAG_ALBUM, &p,
+                                     &size, NULL);
+               if (err == 0 && size > 0) {
+                       strncpy(video_record->album, p,
+                               sizeof(video_record->album) - 1);
+               } else {
+                       if (err_msg) {
+                               mb_svc_debug("mm_file_get_attrs fails : %s",
+                                            err_msg);
+                               free(err_msg);
+                               err_msg = NULL;
+                       }
+                       strncpy(video_record->album, UNKNOWN_TAG,
+                               sizeof(video_record->album) - 1);
+               }
+
+               err =
+                   mm_file_get_attrs(tag, &err_msg, MM_FILE_TAG_DESCRIPTION,
+                                     &p, &size, NULL);
+               if (err == 0 && size > 0) {
+                       strncpy(video_record->description, p,
+                               sizeof(video_record->description) - 1);
+               } else {
+                       if (err_msg) {
+                               mb_svc_debug("mm_file_get_attrs fails : %s",
+                                            err_msg);
+                               free(err_msg);
+                               err_msg = NULL;
+                       }
+                       strncpy(video_record->description, UNKNOWN_TAG,
+                               sizeof(video_record->description) - 1);
+               }
+
+               err =
+                   mm_file_get_attrs(tag, &err_msg, MM_FILE_TAG_LONGITUDE,
+                                     &gps_value, NULL);
+               if (err == 0) {
+                       mb_svc_debug("longitude: %f", gps_value);
+
+                       if (gps_value == 0.0)
+                               gps_value = MINFO_DEFAULT_GPS;
+                       video_record->longitude = gps_value;
+               } else {
+                       if (err_msg) {
+                               mb_svc_debug("mm_file_get_attrs fails : %s",
+                                            err_msg);
+                               free(err_msg);
+                               err_msg = NULL;
+                       }
+                       video_record->longitude = MINFO_DEFAULT_GPS;
+               }
+
+               err =
+                   mm_file_get_attrs(tag, &err_msg, MM_FILE_TAG_LATIDUE,
+                                     &gps_value, NULL);
+               if (err == 0) {
+                       mb_svc_debug("latitude: %f", gps_value);
+
+                       if (gps_value == 0.0)
+                               gps_value = MINFO_DEFAULT_GPS;
+                       video_record->latitude = gps_value;
+               } else {
+                       if (err_msg) {
+                               mb_svc_debug("mm_file_get_attrs fails : %s",
+                                            err_msg);
+                               free(err_msg);
+                               err_msg = NULL;
+                       }
+                       video_record->latitude = MINFO_DEFAULT_GPS;
+               }
+
+               err =
+                   mm_file_get_attrs(tag, &err_msg, MM_FILE_TAG_DATE, &p,
+                                     &size, NULL);
+               if (err == 0 && size > 0) {
+                       mb_svc_debug("Date: %s[%d]", p, size);
+                       video_record->datetaken =
+                           __mb_svc_get_time_val_from_str(p);
+               } else {
+                       if (size <= 0) {
+                               mb_svc_debug("Size: [%d]", size);
+                       }
+
+                       if (err_msg) {
+                               mb_svc_debug("mm_file_get_attrs fails : %s",
+                                            err_msg);
+                               free(err_msg);
+                               err_msg = NULL;
+                       }
+                       video_record->datetaken = 0;
+               }
+
+               mb_svc_debug("title of video is %s!!\n", video_record->title);
+               mb_svc_debug("artist of video is %s!!\n", video_record->artist);
+               mb_svc_debug("album of video is %s!!\n", video_record->album);
+               mb_svc_debug("description of video is %s!!\n",
+                            video_record->description);
+               mb_svc_debug("longitude of video is %f\n",
+                            video_record->longitude);
+               mb_svc_debug("latitude of video is %f\n",
+                            video_record->latitude);
+               mb_svc_debug("datetaken of video is %f\n",
+                            video_record->datetaken);
+
+               mm_file_destroy_tag_attrs(tag);
+       }
+
+       return 0;
+}
+
+int
+mb_svc_video_create_thumb(const char *file_full_path, char *thumb_hash_path,
+                         size_t max_thumb_length)
+{
+       MMHandleType content = (MMHandleType) NULL;
+       void *frame = NULL;
+       int err = -1;
+       mb_svc_thumb_info_s thumb_info = { 0 };
+       int video_track_num = 0;
+       char *err_msg = NULL;
+
+       mb_svc_debug("_mb_svc_video_generate_thumbnail------------start\n");
+       if (file_full_path == NULL) {
+               mb_svc_debug("file_full_path == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       thumb_info.is_drm = (drm_svc_is_drm_file(file_full_path) == DRM_TRUE);
+       err = mm_file_create_content_attrs(&content, file_full_path);
+
+       if (err < 0) {
+               mb_svc_debug("mm_file_create_content_attrs fails : %d", err);
+       }
+
+       err =
+           mm_file_get_attrs(content, &err_msg,
+                             MM_FILE_CONTENT_VIDEO_TRACK_COUNT,
+                             &video_track_num, NULL);
+
+       if (err != 0) {
+               mb_svc_debug("mm_file_get_attrs fails : %s", err_msg);
+               free(err_msg);
+               err_msg = NULL;
+       }
+
+       /* MMF api handle both normal and DRM video */
+       if (video_track_num > 0 || thumb_info.is_drm) {
+
+               err = mm_file_get_attrs(content, &err_msg,
+                                       MM_FILE_CONTENT_VIDEO_WIDTH,
+                                       &thumb_info.width,
+                                       MM_FILE_CONTENT_VIDEO_HEIGHT,
+                                       &thumb_info.height,
+                                       MM_FILE_CONTENT_VIDEO_THUMBNAIL, &frame, /* raw image is RGB888 format */
+                                       &thumb_info.size, NULL);
+
+               if (err != 0) {
+                       mb_svc_debug("mm_file_get_attrs fails : %s", err_msg);
+                       free(err_msg);
+                       err_msg = NULL;
+               }
+
+               thumb_info.size = thumb_info.width * 3 * thumb_info.height;
+               mb_svc_debug("video width: %d\n", thumb_info.width);
+               mb_svc_debug("video height: %d\n", thumb_info.height);
+               mb_svc_debug("thumbnail size=%d\n", thumb_info.size);
+               mb_svc_debug("video thumbnail: %p\n", frame);
+
+               thumb_info.content_type = MINFO_ITEM_VIDEO;
+               thumb_info.file_full_path = file_full_path;
+               thumb_info.image_type = IMG_CODEC_NONE;
+               thumb_info.thumb_hash_path = thumb_hash_path;
+       } else {
+               thumb_info.content_type = MINFO_ITEM_VIDEO;
+               thumb_info.file_full_path = file_full_path;
+               thumb_info.image_type = IMG_CODEC_NONE;
+               thumb_info.thumb_hash_path = thumb_hash_path;
+
+               mb_svc_debug("no contents information\n");
+       }
+
+       __mb_svc_thumb_save(frame, thumb_info, max_thumb_length, NULL);
+
+       mm_file_destroy_content_attrs(content);
+       mb_svc_debug("_mb_svc_video_generate_thumbnail------------leave\n");
+       return 0;
+}
+
+int
+_mb_svc_thumb_generate_hash_name(const char *file_full_path,
+                                char *thumb_hash_path, size_t max_thumb_path)
+{
+       char *thumb_dir = NULL;
+       char hash_name[255 + 1];
+       char file_ext[MB_SVC_FILE_EXT_LEN_MAX + 1] = { 0 };
+       int store_type = 0;
+
+       if (file_full_path == NULL || thumb_hash_path == NULL
+           || max_thumb_path <= 0) {
+               mb_svc_debug
+                   ("file_full_path==NULL || thumb_hash_path == NULL || max_thumb_path <= 0");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       _mb_svc_get_file_ext(file_full_path, file_ext);
+       store_type = _mb_svc_get_store_type_by_full(file_full_path);
+       if (store_type == MINFO_PHONE) {
+               thumb_dir = MB_SVC_THUMB_PHONE_PATH;
+       } else if (store_type == MINFO_MMC) {
+               thumb_dir = MB_SVC_THUMB_MMC_PATH;
+       } else {
+               thumb_dir = MB_SVC_THUMB_PHONE_PATH;
+       }
+
+       //hash_name = _mb_svc_generate_hash_name(file_full_path);
+       int err = -1;
+       err = mb_svc_generate_hash_code(file_full_path, hash_name, sizeof(hash_name));
+       if (err < 0) {
+               mb_svc_debug("mb_svc_generate_hash_code failed : %d", err);
+               return MB_SVC_ERROR_INTERNAL;
+       }
+
+       int ret_len;
+       ret_len =
+           snprintf(thumb_hash_path, max_thumb_path, "%s/.%s-%s.jpg",
+                    thumb_dir, file_ext, hash_name);
+       if (ret_len < 0) {
+               mb_svc_debug("Error when snprintf");
+               return MB_SVC_ERROR_INTERNAL;
+       } else if (ret_len > max_thumb_path) {
+               mb_svc_debug("Error for the length of thumb pathname");
+               return MB_SVC_ERROR_INTERNAL;
+       }
+
+       mb_svc_debug("thumb hash : %s", thumb_hash_path);
+
+       return 0;
+}
+
+/**
+* @brief  Delete thumbnail file of original file.
+* @param  file_full_path  original file.
+* @return 0 ok, -1 failed.
+*/
+int _mb_svc_thumb_delete(const char *file_full_path)
+{
+       char thumb_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+       int ret = -1;
+
+       mb_svc_debug("_mb_svc_thumb_delete--enter\n");
+
+       ret =
+           _mb_svc_thumb_generate_hash_name(file_full_path, thumb_path,
+                                            MB_SVC_FILE_PATH_LEN_MAX + 1);
+       if (ret < 0) {
+               return ret;
+       }
+
+       return _mb_svc_thumb_rm(thumb_path);
+}
+
+/**
+* @brief  Copy thumbnail of src to the one of dest.
+* @param[in]   src_file_full_path    src original file.
+* @param[in]   dest_file_full_path   dest original file.
+* @param[out]  dest_thumb_path       thumbnail file of dest orignal file.
+* @return  0 ok, -1 failed.
+*/
+int
+_mb_svc_thumb_copy(const char *src_file_full_path,
+                  const char *dest_file_full_path, char *dest_thumb_path)
+{
+       int result = 0;
+       char src_thumb_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+
+       if (!dest_thumb_path) {
+               mb_svc_debug("dest_thumb_path is NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("_mb_svc_thumb_copy--enter\n");
+
+       result =
+           _mb_svc_thumb_generate_hash_name(src_file_full_path, src_thumb_path,
+                                            MB_SVC_FILE_PATH_LEN_MAX + 1);
+       if (result < 0) {
+               return result;
+       }
+
+       result =
+           _mb_svc_thumb_generate_hash_name(dest_file_full_path,
+                                            dest_thumb_path,
+                                            MB_SVC_FILE_PATH_LEN_MAX + 1);
+       if (result < 0) {
+               return result;
+       }
+
+       if (__mb_svc_thumb_cp(src_thumb_path, dest_thumb_path) != 0) {
+               return MB_SVC_ERROR_COPY_THUMBNAIL;
+       }
+
+       return 0;
+}
+
+/**
+* @brief  Move thumbnail of src to the one of dest.
+* @param[in]   src_file_full_path    src original file.
+* @param[in]   dest_file_full_path   dest original file.
+* @param[out]  dest_thumb_path       thumbnail file of dest orignal file.
+* @return  0 ok, -1 failed.
+*/
+int
+_mb_svc_thumb_move(const char *src_file_full_path,
+                  const char *dest_file_full_path, char *dest_thumb_path)
+{
+       int result = 0;
+       char src_thumb_path[MB_SVC_FILE_PATH_LEN_MAX + 1];
+
+       if (!dest_thumb_path) {
+               mb_svc_debug("dest_thumb_path is NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("_mb_svc_thumb_move--enter\n");
+
+       result =
+           _mb_svc_thumb_generate_hash_name(src_file_full_path, src_thumb_path,
+                                            MB_SVC_FILE_PATH_LEN_MAX + 1);
+       if (result < 0) {
+               return result;
+       }
+
+       /* Get dest file thumbnail path    */
+       result =
+           _mb_svc_thumb_generate_hash_name(dest_file_full_path,
+                                            dest_thumb_path,
+                                            MB_SVC_FILE_PATH_LEN_MAX + 1);
+       if (result < 0) {
+               return result;
+       }
+
+       if (rename(src_thumb_path, dest_thumb_path) < 0) {
+               mb_svc_debug("thumb rename is failed");
+               return MB_SVC_ERROR_MOVE_THUMBNAIL;
+       }
+
+       return 0;
+/*
+       if ( ( result = __mb_svc_thumb_cp(src_thumb_path, dest_thumb_path) ) != 0) {
+               mb_svc_debug("__mb_svc_thumb_cp fails : %d", result);
+               return MB_SVC_ERROR_MOVE_THUMBNAIL;
+       }
+       else 
+       {
+               return _mb_svc_thumb_rm(src_thumb_path);
+       }
+*/
+}
+
+/**
+* @brief  Rename thumbnail of src to the one of dest.
+* @param[in]   src_file_full_path    src original file.
+* @param[in]   dest_file_full_path   dest original file.
+* @param[out]  dest_thumb_path       thumbnail file of dest orignal file.
+* @return  0 ok, -1 failed.
+*/
+int
+_mb_svc_thumb_rename(const char *src_file_full_path,
+                    const char *dest_file_full_path, char *dest_thumb_path)
+{
+       return _mb_svc_thumb_move(src_file_full_path, dest_file_full_path,
+                                 dest_thumb_path);
+}
+
+static int
+__mb_svc_thumb_cp(char *src_file_full_path, char *dest_file_full_path)
+{
+       FILE *src_fd, *dest_fd;
+       char buf[16384];
+       size_t num = 0;
+       int ret = 0;
+
+       if (src_file_full_path == NULL || dest_file_full_path == NULL ||
+           (strncmp
+            (src_file_full_path, dest_file_full_path,
+             MB_SVC_FILE_NAME_LEN_MAX) == 0)) {
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       src_fd = fopen(src_file_full_path, "rb");
+       if (!src_fd) {
+               mb_svc_debug("Src File open failed : %s", src_file_full_path);
+               return MB_SVC_ERROR_FILE_NOT_EXSITED;
+       }
+       dest_fd = fopen(dest_file_full_path, "wb");
+       if (!dest_fd) {
+               fclose(src_fd);
+               mb_svc_debug("Dst File open failed : %s", dest_file_full_path);
+               return MB_SVC_ERROR_FILE_NOT_EXSITED;
+       }
+       while ((num = fread(buf, 1, sizeof(buf), src_fd)) > 0) {
+               if (((int)num > sizeof(buf)) || ((int)num < 0)) {
+                       ret = MB_SVC_ERROR_FILE_IO;
+               } else if (fwrite(buf, 1, num, dest_fd) != num) {
+                       ret = MB_SVC_ERROR_FILE_IO;
+               }
+       }
+
+       fclose(src_fd);
+       fclose(dest_fd);
+
+       return ret;
+}
+
+int _mb_svc_thumb_rm(char *file_full_path)
+{
+       mb_svc_debug("_mb_svc_thumb_rm : %s", file_full_path);
+
+       if (strncmp
+           (DEFAULT_IMAGE_THUMB, file_full_path,
+            strlen(DEFAULT_IMAGE_THUMB)) == 0
+           || strncmp(DEFAULT_VIDEO_THUMB, file_full_path,
+                      strlen(DEFAULT_IMAGE_THUMB)) == 0) {
+               mb_svc_debug("this is default thumb. Cannot remove");
+               return 0;
+       }
+
+       if (unlink(file_full_path) == -1) {
+               if (errno == ENOENT) {
+                       return MB_SVC_ERROR_FILE_NOT_EXSITED;
+               } else {
+                       return MB_SVC_ERROR_INTERNAL;
+               }
+       }
+
+       return 0;
+}
diff --git a/src/visual/media-svc-util.c b/src/visual/media-svc-util.c
new file mode 100755 (executable)
index 0000000..6b0d123
--- /dev/null
@@ -0,0 +1,341 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "media-svc-util.h"
+#include "media-svc-debug.h"
+#include "media-svc-error.h"
+#include "minfo-types.h"
+#include "media-svc-structures.h"
+
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <drm-service.h>
+#include <string.h>
+#include <aul/aul.h>
+
+bool _mb_svc_get_file_display_name(const char *file_path, char *file_name)
+{
+       char *result = NULL;
+
+       if ((result = strrchr(file_path, '/'))) {
+               strncpy(file_name, (result + 1), MB_SVC_FILE_NAME_LEN_MAX + 1);
+               return TRUE;
+       }
+
+       strncpy(file_name, file_path, MB_SVC_FILE_NAME_LEN_MAX + 1);
+       file_name[MB_SVC_FILE_NAME_LEN_MAX] = '\0';
+
+       return TRUE;
+}
+
+bool _mb_svc_get_file_parent_path(const char *file_path, char *parent_path)
+{
+       char file_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+
+       _mb_svc_get_file_display_name(file_path, file_name);
+       strncpy(parent_path, file_path, MB_SVC_FILE_PATH_LEN_MAX + 1);
+       parent_path[strlen(file_path) - strlen(file_name) - 1] = '\0';
+
+       if (strlen(parent_path) == 0) {
+               strncpy(parent_path, "/", MB_SVC_FILE_PATH_LEN_MAX + 1);
+       }
+
+       return TRUE;
+}
+
+bool _mb_svc_get_dir_display_name(const char *dir_path, char *dir_name)
+{
+       char path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       char *result = NULL;
+
+       strncpy(path, dir_path, sizeof(path));
+
+       if ((result = strrchr(path, '/'))) {
+               if (*(result + 1) == '\0') {
+                       *result = '\0';
+               }
+       }
+
+       if (strncmp(dir_path, MB_SVC_PATH_MMC, strlen(dir_path)) == 0
+           || strncmp(dir_path, MB_SVC_PATH_PHONE, strlen(dir_path)) == 0) {
+               mb_svc_debug("dir path is empty because path is root");
+               strncpy(dir_name, "", MB_SVC_FILE_NAME_LEN_MAX + 1);
+               return true;
+       }
+
+       if ((result = strrchr(path, '/'))) {
+               strncpy(dir_name, (result + 1), MB_SVC_FILE_NAME_LEN_MAX + 1);
+               return TRUE;
+       }
+
+       strncpy(dir_name, path, MB_SVC_FILE_NAME_LEN_MAX + 1);
+       dir_name[MB_SVC_FILE_NAME_LEN_MAX] = '\0';
+
+       return TRUE;
+}
+
+/*
+** in this funtion, if dir_path equals "/01/02/03", parent path is "/01/02/", not "01/02"
+** if dir_path equals "/01", its parent path is "/"
+*/
+bool _mb_svc_get_dir_parent_path(const char *dir_path, char *parent_path)
+{
+       char dir_name[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+
+       _mb_svc_get_dir_display_name(dir_path, dir_name);
+       strncpy(parent_path, dir_path, MB_SVC_DIR_PATH_LEN_MAX + 1);
+       parent_path[strlen(parent_path) - strlen(dir_name)] = '\0';
+       mb_svc_debug("parent_path is %s", parent_path);
+       return TRUE;
+}
+
+int _mb_svc_get_file_dir_modified_date(const char *full_path)
+{
+       struct stat statbuf = { 0 };
+       int fd = 0;
+       int err = 0;
+
+       fd = stat(full_path, &statbuf);
+       if (fd == -1) {
+               err = errno;
+               mb_svc_debug("stat(%s) fails. err[%d]", full_path, err);
+               return MB_SVC_ERROR_INTERNAL;
+       }
+
+       return statbuf.st_mtime;
+}
+
+bool
+_mb_svc_get_full_path(const char *path, minfo_store_type storage_type,
+                     char *full_path)
+{
+       if (path == NULL || full_path == NULL) {
+               mb_svc_debug("path == NULL || full_path == NULL ");
+               return false;
+       }
+
+       switch (storage_type) {
+       case MINFO_MMC:
+               strncpy(full_path, MB_SVC_PATH_MMC, MB_SVC_FILE_PATH_LEN_MAX + 1);
+               break;
+       case MINFO_PHONE:
+       default:
+               strncpy(full_path, MB_SVC_PATH_PHONE, MB_SVC_FILE_PATH_LEN_MAX + 1);
+               break;
+       }
+       if (strncmp(path, "/", MB_SVC_FILE_PATH_LEN_MAX + 1) != 0) {
+               strcat(full_path, path);
+       }
+
+       return true;
+}
+
+bool _mb_svc_is_valid_path(const char *full_path)
+{
+       char phone_root_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       char mmc_root_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+
+       if (strlen(full_path) == 0) {
+               return FALSE;
+       }
+
+       _mb_svc_get_full_path("/", MINFO_PHONE, phone_root_path);
+       _mb_svc_get_full_path("/", MINFO_MMC, mmc_root_path);
+
+       if (strncmp(full_path, phone_root_path, strlen(phone_root_path)) == 0) {
+               /* like "/mnt/ums/.message" isn't valid mesage, shoud filter */
+               if (strlen(full_path) > strlen(phone_root_path) + 1 && full_path[strlen(phone_root_path) + 1] == '.') {
+                       return FALSE;
+               } else {
+                       return TRUE;
+               }
+       }
+
+       if (strncmp(full_path, mmc_root_path, strlen(mmc_root_path)) == 0) {
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
+int _mb_svc_get_store_type_by_full(const char *full_path)
+{
+       if (full_path != NULL) {
+               if (strncmp
+                   (full_path, MB_SVC_PATH_PHONE,
+                    strlen(MB_SVC_PATH_PHONE)) == 0) {
+                       return MINFO_PHONE;
+               } else
+                   if (strncmp
+                       (full_path, MB_SVC_PATH_MMC,
+                        strlen(MB_SVC_PATH_MMC)) == 0) {
+                       return MINFO_MMC;
+               }
+       }
+
+       return MB_SVC_ERROR_INTERNAL;
+}
+
+int _mb_svc_get_rel_path_by_full(const char *full_path, char *path)
+{
+       int root_len = 0;
+       minfo_store_type store_type = 0;
+
+       store_type = _mb_svc_get_store_type_by_full(full_path);
+
+       switch (store_type) {
+       case MINFO_PHONE:
+               root_len = strlen(MB_SVC_PATH_PHONE);
+               break;
+       case MINFO_MMC:
+               root_len = strlen(MB_SVC_PATH_MMC);
+               break;
+       default:
+               return MB_SVC_ERROR_INTERNAL;
+       }
+       if (*(full_path + root_len) != '\0') {
+               strncpy(path, full_path + root_len, MB_SVC_FILE_PATH_LEN_MAX + 1);
+       } else {
+               strncpy(path, "/", MB_SVC_FILE_PATH_LEN_MAX + 1);
+       }
+
+       return 0;
+}
+
+bool _mb_svc_get_file_ext(const char *file_path, char *file_ext)
+{
+       int i = 0;
+
+       for (i = strlen(file_path); i >= 0; i--) {
+               if ((file_path[i] == '.') && (i < MB_SVC_FILE_PATH_LEN_MAX)) {
+                       strncpy(file_ext, &file_path[i + 1],
+                               MB_SVC_FILE_EXT_LEN_MAX + 1);
+                       return TRUE;
+               }
+
+               if (file_path[i] == '/') { /* meet the dir. no ext */
+                       return TRUE;
+               }
+       }
+       return TRUE;
+}
+
+bool _mb_svc_glist_free(GList **glist, bool is_free_element)
+{
+       int length = 0;
+       int i = 0;
+       void *p = NULL;
+
+       if (*glist == NULL) {
+               return TRUE;
+       }
+
+       if (is_free_element) {
+               length = g_list_length(*glist);
+               for (i = 0; i < length; i++) {
+                       p = g_list_nth_data(*glist, i);
+                       free(p);
+                       p = NULL;
+               }
+       }
+
+       if (*glist != NULL) {
+               g_list_free(*glist);
+               *glist = NULL;
+       }
+       return TRUE;
+}
+
+int _mb_svc_get_file_type(const char *file_full_path)
+{
+       int ret = 0;
+       char mimetype[255];
+
+       if (file_full_path == NULL)
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+
+       if (drm_svc_is_drm_file(file_full_path) == DRM_TRUE) {
+               DRM_FILE_TYPE drm_type = DRM_FILE_TYPE_NONE;
+               drm_type = drm_svc_get_drm_type(file_full_path);
+               if (drm_type == DRM_FILE_TYPE_NONE) {
+                       return MINFO_ITEM_NONE;
+               } 
+               else {
+                       drm_content_info_t contentInfo = { 0 };
+
+                       ret = drm_svc_get_content_info(file_full_path, &contentInfo);
+                       if (ret != DRM_RESULT_SUCCESS) {
+                               mb_svc_debug("drm_svc_get_content_info() fails. ");
+                               return MINFO_ITEM_NONE;
+                       }
+
+                       strncpy(mimetype, contentInfo.contentType, sizeof(mimetype));
+               }
+       } else {
+               /* get content type and mime type from file. */
+               ret =
+                       aul_get_mime_from_file(file_full_path, mimetype, sizeof(mimetype));
+               if (ret < 0) {
+                       mb_svc_debug
+                               ("aul_get_mime_from_file fail.. Now trying to get type by extension");
+       
+                       char ext[MB_SVC_FILE_EXT_LEN_MAX + 1] = { 0 };
+                       _mb_svc_get_file_ext(file_full_path, ext);
+       
+                       if (strcasecmp(ext, "JPG") == 0 ||
+                               strcasecmp(ext, "JPEG") == 0 ||
+                               strcasecmp(ext, "PNG") == 0 ||
+                               strcasecmp(ext, "GIF") == 0 ||
+                               strcasecmp(ext, "AGIF") == 0 ||
+                               strcasecmp(ext, "XWD") == 0 ||
+                               strcasecmp(ext, "BMP") == 0 ||
+                               strcasecmp(ext, "TIF") == 0 ||
+                               strcasecmp(ext, "TIFF") == 0 ||
+                               strcasecmp(ext, "WBMP") == 0) {
+                               return MINFO_ITEM_IMAGE;
+                       } else if (strcasecmp(ext, "AVI") == 0 ||
+                               strcasecmp(ext, "MPEG") == 0 ||
+                               strcasecmp(ext, "MP4") == 0 ||
+                               strcasecmp(ext, "DCF") == 0 ||
+                               strcasecmp(ext, "WMV") == 0 ||
+                               strcasecmp(ext, "ASF") == 0 ||
+                               strcasecmp(ext, "DIVX") == 0 ||
+                               strcasecmp(ext, "3GPP") == 0 ||
+                               strcasecmp(ext, "3GP") == 0) {
+                               return MINFO_ITEM_VIDEO;
+                       } else {
+                               return MINFO_ITEM_NONE;
+                       }
+               }
+       }
+
+       mb_svc_debug("mime type : %s", mimetype);
+
+       /* categorize from mimetype */
+       if (strstr(mimetype, "image") != NULL) {
+               return MINFO_ITEM_IMAGE;
+       } else if (strstr(mimetype, "video") != NULL) {
+               return MINFO_ITEM_VIDEO;
+       }
+
+       return MINFO_ITEM_NONE;
+}
+
diff --git a/src/visual/minfo-api.c b/src/visual/minfo-api.c
new file mode 100755 (executable)
index 0000000..f0450ba
--- /dev/null
@@ -0,0 +1,3143 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <string.h>
+#include "media-info-debug.h"
+#include "minfo-types.h"
+#include "minfo-api.h"
+#include "media-svc-db.h"
+#include "media-svc-api.h"
+#include "media-svc-util.h"
+#include "media-svc-thumb.h"
+#include "media-svc-debug.h"
+#include "minfo-cluster.h"
+#include "minfo-item.h"
+#include "minfo-tag.h"
+#include "minfo-meta.h"
+#include "minfo-bookmark.h"
+#include "minfo-streaming.h"
+#include "media-svc-db-util.h"
+#include "media-svc-error.h"
+
+static __thread int g_trans_valid_cnt = 1;
+static __thread int g_cur_trans_valid_cnt = 0;
+static __thread int g_trans_insert_cnt = 1;
+static __thread int g_cur_trans_insert_cnt = 0;
+
+int _minfo_svc_clear_database(void)
+{
+       return _mb_svc_truncate_tbl();
+}
+
+EXPORT_API int minfo_init(void)
+{
+       mb_svc_debug("");
+       return mb_svc_initialize();
+}
+
+EXPORT_API int minfo_finalize(void)
+{
+       mb_svc_debug("");
+       return mb_svc_finalize();
+}
+
+EXPORT_API int
+minfo_get_item_list(const char *cluster_id, const minfo_item_filter filter,
+                   minfo_item_ite_cb func, void *user_data)
+{
+       int record_cnt = 0;
+       int ret = -1;
+       mb_svc_media_record_s md_record = {"",};
+       mb_svc_iterator_s mb_svc_iterator = { 0 };
+       Mitem *mitem = NULL;
+
+       if (func == NULL) {
+               mb_svc_debug("Func is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+#ifdef _PERFORMANCE_CHECK_
+       long start = 0L, end = 0L;
+       start = mediainfo_get_debug_time();
+#endif
+
+       minfo_item_filter mb_filter;
+       memcpy(&mb_filter, &filter, sizeof(minfo_item_filter));
+
+       mb_svc_debug("minfo_get_item_list--enter\n");
+
+       mb_svc_debug("minfo_get_item_list#filter.file_type: %d",
+                    filter.file_type);
+       mb_svc_debug("minfo_get_item_list#filter.sort_type: %d",
+                    filter.sort_type);
+       mb_svc_debug("minfo_get_item_list#filter.start_pos: %d",
+                    filter.start_pos);
+       mb_svc_debug("minfo_get_item_list#filter.end_pos: %d", filter.end_pos);
+       mb_svc_debug("minfo_get_item_list#filter.with_meta: %d",
+                    filter.with_meta);
+       mb_svc_debug("minfo_get_item_list#filter.favorite: %d",
+                    filter.favorite);
+
+       ret =
+           mb_svc_media_iter_start_new(cluster_id, &mb_filter,
+                                       MINFO_CLUSTER_TYPE_ALL, TRUE, NULL,
+                                       &mb_svc_iterator);
+
+       if (ret < 0) {
+               mb_svc_debug("mb-svc iterator start failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       record_cnt = 0;
+
+       while (1) {
+               /* improve the performance of getting meida list. */
+               ret = mb_svc_media_iter_next(&mb_svc_iterator, &md_record);
+               if (ret == MB_SVC_NO_RECORD_ANY_MORE)
+                       break;
+
+               if (ret < 0) {
+                       mb_svc_debug("mb-svc iterator get next recrod failed");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       return ret;
+               }
+
+               record_cnt++;
+
+               mitem = minfo_media_item_new(NULL, &md_record);
+               if (filter.with_meta && mitem) {
+                       mitem->meta_info =
+                           minfo_mmeta_new(mitem->uuid, &md_record);
+               }
+
+               func(mitem, user_data);
+       }
+
+       mb_svc_iter_finish(&mb_svc_iterator);
+       mb_svc_debug("minfo_get_item_list--leave\n");
+
+#ifdef _PERFORMANCE_CHECK_
+       end = mediainfo_get_debug_time();
+
+       char msg[255];
+       snprintf(msg, sizeof(msg), "LIST count : %d", record_cnt);
+       mediainfo_print_debug_time_ex(start, end, __FUNCTION__, msg);
+#endif
+
+       if (record_cnt == 0)
+               return MB_SVC_ERROR_DB_NO_RECORD;
+       else
+               return 0;
+}
+
+EXPORT_API int
+minfo_get_item_list_search(minfo_search_field_t search_field,
+                                                               const char *search_str,
+                                                               minfo_folder_type folder_type,
+                                                               const minfo_item_filter filter,
+                                                               minfo_item_ite_cb func,
+                                                               void *user_data)
+{
+       mb_svc_debug("");
+       mb_svc_iterator_s mb_svc_iterator = { 0 };
+       int ret = -1;
+       int record_cnt = 0;
+
+       if (search_str == NULL) {
+               mb_svc_debug("search string is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (func == NULL) {
+               mb_svc_debug("User func is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (search_field < MINFO_SEARCH_BY_NAME || search_field >= MINFO_SEARCH_MAX) {
+               mb_svc_debug("search field is wrong");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (folder_type < MINFO_CLUSTER_TYPE_ALL || folder_type >= MINFO_CLUSTER_TYPE_MAX) {
+               mb_svc_debug("folder type is wrong");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_media_record_s md_record = {"",};
+       Mitem *mitem = NULL;
+
+       mb_svc_debug("minfo_get_item_list_search--enter\n");
+
+       ret =
+           mb_svc_media_search_iter_start(search_field, search_str, folder_type, filter, &mb_svc_iterator);
+
+       if (ret < 0) {
+               mb_svc_debug("mb-svc iterator start failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (1) {
+               /* improve the performance of getting meida list. */
+               ret = mb_svc_media_iter_next(&mb_svc_iterator, &md_record);
+               if (ret == MB_SVC_NO_RECORD_ANY_MORE)
+                       break;
+
+               if (ret < 0) {
+                       mb_svc_debug("mb-svc iterator get next recrod failed");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       return ret;
+               }
+
+               record_cnt++;
+
+               mitem = minfo_media_item_new(NULL, &md_record);
+
+               if (filter.with_meta && mitem) {
+                       mitem->meta_info =
+                           minfo_mmeta_new(mitem->uuid, &md_record);
+               }
+
+               func(mitem, user_data);
+       }
+
+       mb_svc_iter_finish(&mb_svc_iterator);
+
+       if (record_cnt == 0)
+               return MB_SVC_ERROR_DB_NO_RECORD;
+       else
+               return 0;
+}
+
+EXPORT_API int
+minfo_get_all_item_list(const minfo_folder_type cluster_type,
+                       const minfo_item_filter filter, minfo_item_ite_cb func,
+                       void *user_data)
+{
+       mb_svc_debug("");
+
+       mb_svc_iterator_s mb_svc_iterator = { 0 };
+       int ret = -1;
+       int record_cnt = 0;
+       GList *p_list = NULL;
+
+       if (func == NULL) {
+               mb_svc_debug("Func is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_media_record_s md_record = {"",};
+       Mitem *mitem = NULL;
+       minfo_item_filter mb_item_filter = { 0 };
+       minfo_cluster_filter mb_filter = { 0 };
+
+       mb_filter.cluster_type = cluster_type;
+       mb_filter.sort_type = MINFO_CLUSTER_SORT_BY_NAME_ASC;
+       mb_filter.start_pos = -1;
+       mb_filter.end_pos = -1;
+
+#ifdef _PERFORMANCE_CHECK_
+       long start = 0L, end = 0L;
+       start = mediainfo_get_debug_time();
+#endif
+       memcpy(&mb_item_filter, &filter, sizeof(minfo_item_filter));
+
+       mb_svc_debug("minfo_get_all_item_list--enter\n");
+       /* ret = mb_svc_media_iter_start(-1, &mb_item_filter, cluster_type, TRUE, p_list, &mb_svc_iterator); */
+       ret =
+           mb_svc_media_iter_start_new(NULL, &mb_item_filter, cluster_type, TRUE,
+                                       p_list, &mb_svc_iterator);
+
+       if (p_list) {
+               _mb_svc_glist_free(&p_list, FALSE);
+       }
+
+       if (ret < 0) {
+               mb_svc_debug("mb-svc iterator start failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (1) {
+               /* improve the performance of getting meida list. */
+               ret = mb_svc_media_iter_next(&mb_svc_iterator, &md_record);
+               if (ret == MB_SVC_NO_RECORD_ANY_MORE)
+                       break;
+
+               if (ret < 0) {
+                       mb_svc_debug("mb-svc iterator get next recrod failed");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       return ret;
+               }
+
+               record_cnt++;
+
+               mitem = minfo_media_item_new(NULL, &md_record);
+
+               if (mitem != NULL) {
+                       if (filter.with_meta) {
+                               mitem->meta_info =
+                                       minfo_mmeta_new(mitem->uuid, &md_record);
+                       }
+
+                       func(mitem, user_data);
+               } else {
+                       mb_svc_debug("Making media item failed");
+               }
+       }
+
+       mb_svc_iter_finish(&mb_svc_iterator);
+
+#ifdef _PERFORMANCE_CHECK_
+       end = mediainfo_get_debug_time();
+
+       char msg[255];
+       snprintf(msg, sizeof(msg), "LIST count : %d", record_cnt);
+       mediainfo_print_debug_time_ex(start, end, __FUNCTION__, msg);
+#endif
+
+       if (record_cnt == 0)
+               return MB_SVC_ERROR_DB_NO_RECORD;
+       else
+               return 0;
+}
+
+EXPORT_API int minfo_get_all_item_cnt(int *cnt)
+{
+       int ret = -1;
+
+       mb_svc_debug("");
+       if (cnt == NULL) {
+               mb_svc_debug("cnt == NULL \n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = mb_svc_get_all_item_count(cnt);
+       if (ret < 0) {
+               mb_svc_debug("Error: get image full pathfull failed\n");
+               return ret;
+       }
+
+       mb_svc_debug("record count = %d", *cnt);
+       return 0;
+}
+
+EXPORT_API int
+minfo_get_cluster_cover(const char *cluster_id, const int img_cnt,
+                       minfo_cover_ite_cb func, void *user_data)
+{
+       int record_cnt = 0;
+       int ret = -1;
+       mb_svc_media_record_s md_record = {"",};
+       mb_svc_iterator_s mb_svc_iterator = { 0 };
+       minfo_item_filter mb_filter = { 0 };
+
+       if (cluster_id == NULL) {
+               mb_svc_debug("cluster_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_get_item_list--enter\n");
+
+       mb_svc_debug("minfo_get_cluster_cover#cluster_id: %s", cluster_id);
+       mb_svc_debug("minfo_get_cluster_cover#img_cnt: %d", img_cnt);
+
+       if (func == NULL) {
+               mb_svc_debug("func is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_filter.start_pos = 0;
+       mb_filter.end_pos = img_cnt - 1;
+       mb_filter.sort_type = MINFO_MEDIA_SORT_BY_DATE_ASC;
+       mb_filter.file_type = MINFO_ITEM_ALL;
+       mb_filter.favorite = MINFO_MEDIA_FAV_ALL;
+       mb_filter.with_meta = FALSE;
+
+       ret =
+           mb_svc_media_iter_start_new(cluster_id, &mb_filter,
+                                       MINFO_CLUSTER_TYPE_ALL, TRUE, NULL,
+                                       &mb_svc_iterator);
+
+       if (ret < 0) {
+               mb_svc_debug("mb-svc iterator start failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (1) {
+               ret = mb_svc_media_iter_next(&mb_svc_iterator, &md_record);
+               if (ret == MB_SVC_NO_RECORD_ANY_MORE)
+                       break;
+
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_media_iter_next failed");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       return ret;
+               }
+
+               record_cnt++;
+               func(md_record.thumbnail_path, user_data);
+       }
+
+       mb_svc_iter_finish(&mb_svc_iterator);
+       mb_svc_debug("minfo_get_item_list--leave\n");
+
+       if (record_cnt == 0)
+               return MB_SVC_ERROR_DB_NO_RECORD;
+       else
+               return 0;
+}
+
+EXPORT_API int
+minfo_get_item_cnt(const char *cluster_id, const minfo_item_filter filter,
+                  int *cnt)
+{
+       int ret = -1;
+       int record_cnt = 0;
+       mb_svc_iterator_s mb_svc_iterator = { 0 };
+
+       minfo_item_filter mb_filter;
+       memcpy(&mb_filter, &filter, sizeof(minfo_item_filter));
+
+       mb_svc_debug("minfo_get_item_cnt--enter\n");
+       if (cnt == NULL) {
+               mb_svc_debug("cnt == NULL \n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+       
+       mb_svc_debug("minfo_get_item_cnt#filter.file_type: %d",
+                    filter.file_type);
+       mb_svc_debug("minfo_get_item_cnt#filter.sort_type: %d",
+                    filter.sort_type);
+       mb_svc_debug("minfo_get_item_cnt#filter.start_pos: %d",
+                    filter.start_pos);
+       mb_svc_debug("minfo_get_item_cnt#filter.end_pos: %d", filter.end_pos);
+       mb_svc_debug("minfo_get_item_cnt#filter.with_meta: %d",
+                    filter.with_meta);
+       mb_svc_debug("minfo_get_item_cnt#filter.favorite: %d", filter.favorite);
+
+       ret =
+           mb_svc_media_iter_start_new(cluster_id, &mb_filter,
+                                       MINFO_CLUSTER_TYPE_ALL, TRUE, NULL,
+                                       &mb_svc_iterator);
+
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_media_iter_start failed");
+               *cnt = -1;
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (1) {
+               ret = mb_svc_media_iter_next(&mb_svc_iterator, NULL);
+
+               if (ret == MB_SVC_NO_RECORD_ANY_MORE)
+                       break;
+
+               if (ret < 0) {
+                       mb_svc_debug("mb-svc iterator get next recrod failed");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       return ret;
+               }
+
+               record_cnt++;
+       }
+
+       mb_svc_iter_finish(&mb_svc_iterator);
+
+       *cnt = record_cnt;
+
+       if (record_cnt == 0)
+               return MB_SVC_ERROR_DB_NO_RECORD;
+       else
+               return 0;
+}
+
+EXPORT_API int
+minfo_get_cluster_cnt(const minfo_cluster_filter filter, int *cnt)
+{
+       mb_svc_iterator_s mb_svc_iterator = { 0 };
+       int ret = -1;
+       int record_cnt = 0;
+
+       minfo_cluster_filter mb_filter;
+
+       memcpy(&mb_filter, &filter, sizeof(minfo_cluster_filter));
+
+       mb_svc_debug("minfo_get_cluster_list enter\n");
+       if (cnt == NULL) {
+               mb_svc_debug("Error: cnt == NULL \n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_get_cluster_list#filter.file_type: %d",
+                    filter.cluster_type);
+       mb_svc_debug("minfo_get_cluster_list#filter.sort_type: %d",
+                    filter.sort_type);
+       mb_svc_debug("minfo_get_cluster_list#filter.start_pos: %d",
+                    filter.start_pos);
+       mb_svc_debug("minfo_get_cluster_list#filter.end_pos: %d",
+                    filter.end_pos);
+
+       ret = mb_svc_folder_iter_start(&mb_filter, &mb_svc_iterator);
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_folder_iter_start failed\n");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (1) {
+               ret = mb_svc_folder_iter_next(&mb_svc_iterator, NULL);
+
+               if (ret == MB_SVC_NO_RECORD_ANY_MORE)
+                       break;
+
+               if (ret < 0) {
+                       mb_svc_debug("mb-svc iterator get next recrod failed");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       return ret;
+               }
+
+               record_cnt++;
+       }
+
+       *cnt = record_cnt;
+       mb_svc_debug("record count = %d\n", *cnt);
+
+       mb_svc_iter_finish(&mb_svc_iterator);
+
+       if (record_cnt == 0)
+               return MB_SVC_ERROR_DB_NO_RECORD;
+       else
+               return 0;
+}
+
+EXPORT_API int
+minfo_get_cluster_list(const minfo_cluster_filter filter,
+                      minfo_cluster_ite_cb func, void *user_data)
+{
+       mb_svc_iterator_s mb_svc_iterator = { 0 };
+       mb_svc_folder_record_s fd_record = {"",};
+       int ret = -1;
+       int record_cnt = 0;
+       Mcluster *cluster = NULL;
+
+       if (func == NULL) {
+               mb_svc_debug("func is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       minfo_cluster_filter mb_filter;
+
+       memcpy(&mb_filter, &filter, sizeof(minfo_cluster_filter));
+
+       mb_svc_debug("minfo_get_cluster_list enter\n");
+
+       mb_svc_debug("minfo_get_cluster_list#filter.file_type: %d",
+                    filter.cluster_type);
+       mb_svc_debug("minfo_get_cluster_list#filter.sort_type: %d",
+                    filter.sort_type);
+       mb_svc_debug("minfo_get_cluster_list#filter.start_pos: %d",
+                    filter.start_pos);
+       mb_svc_debug("minfo_get_cluster_list#filter.end_pos: %d",
+                    filter.end_pos);
+
+       ret = mb_svc_folder_iter_start(&mb_filter, &mb_svc_iterator);
+       if (ret < 0) {
+               mb_svc_debug("mb-svc iterator start failed\n");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (1) {
+               ret = mb_svc_folder_iter_next(&mb_svc_iterator, &fd_record);
+
+               if (ret == MB_SVC_NO_RECORD_ANY_MORE)
+                       break;
+
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("mb-svc iterator get next recrod failed\n");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       return ret;
+               }
+
+               record_cnt++;
+
+               cluster = minfo_mcluster_new(fd_record.uuid);
+               func(cluster, user_data);
+       }
+
+       mb_svc_iter_finish(&mb_svc_iterator);
+
+       if (record_cnt == 0)
+               return MB_SVC_ERROR_DB_NO_RECORD;
+       else
+               return 0;
+}
+
+EXPORT_API int
+minfo_get_web_cluster_by_web_account_id(const char *web_account_id,
+                                       minfo_cluster_ite_cb func,
+                                       void *user_data)
+{
+       mb_svc_folder_record_s *fd_record;
+       int ret = -1;
+       int record_cnt = 0;
+       Mcluster *cluster = NULL;
+       GList *p_web_cluster_list = NULL;
+       char _web_account_id[MB_SVC_ARRAY_LEN_MAX + 1] = { 0 };
+       int i = 0;
+
+       if (func == NULL) {
+               mb_svc_debug("Func is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       strncpy(_web_account_id, web_account_id, MB_SVC_ARRAY_LEN_MAX + 1);
+       _web_account_id[MB_SVC_ARRAY_LEN_MAX] = '\0';
+
+       ret =
+           mb_svc_get_folder_list_by_web_account_id(_web_account_id,
+                                                    &p_web_cluster_list);
+
+       if (ret < 0) {
+               mb_svc_debug
+                   ("minfo_get_web_cluster_by_web_account_id failed\n");
+               return ret;
+       }
+
+       record_cnt = g_list_length(p_web_cluster_list);
+       for (; i < record_cnt; i++) {
+               fd_record = g_list_nth_data(p_web_cluster_list, i);
+               cluster = minfo_mcluster_new(fd_record->uuid);
+               func(cluster, user_data);
+       }
+
+       _mb_svc_glist_free(&p_web_cluster_list, TRUE);
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_get_bookmark_list(const char *media_id, minfo_bm_ite_cb func,
+                       void *user_data)
+{
+       int record_cnt = 0;
+       mb_svc_bookmark_record_s bookmark_record = { 0 };
+       int ret = -1;
+       mb_svc_iterator_s mb_svc_iterator = { 0 };
+       Mbookmark *mbookmark = NULL;
+
+       if (media_id == NULL) {
+               mb_svc_debug("media_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (func == NULL) {
+               mb_svc_debug("Func is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_get_bookmark_list#media_id: %s", media_id);
+
+       ret = mb_svc_bookmark_iter_start(media_id, &mb_svc_iterator);
+       if (ret < 0) {
+               mb_svc_debug("mb-svc iterator start failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (1) {
+               ret =
+                   mb_svc_bookmark_iter_next(&mb_svc_iterator,
+                                             &bookmark_record);
+
+               if (ret == MB_SVC_NO_RECORD_ANY_MORE)
+                       break;
+               if (ret < 0) {
+                       mb_svc_debug("mb-svc iterator get next recrod failed");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       return ret;
+               }
+
+               record_cnt++;
+
+               mbookmark = minfo_mbookmark_new(bookmark_record._id);
+               func(mbookmark, user_data);
+       }
+
+       mb_svc_iter_finish(&mb_svc_iterator);
+
+       mb_svc_debug("minfo_get_bookmark by media_id--leave\n");
+       if (record_cnt == 0)
+               return MB_SVC_ERROR_DB_NO_RECORD;
+       else
+               return 0;
+}
+
+EXPORT_API int
+minfo_get_geo_item_list(const char *cluster_id,
+                       minfo_folder_type store_filter,
+                       minfo_item_filter filter,
+                       double min_longitude,
+                       double max_longitude,
+                       double min_latitude,
+                       double max_latitude,
+                       minfo_item_ite_cb func, void *user_data)
+{
+       /* list of Mitem cluster_id == -1, All ?? cluster_id > 0, specified */
+       int record_cnt = 0;
+       int ret = -1;
+       mb_svc_media_record_s md_record = {"",};
+       mb_svc_iterator_s mb_svc_iterator = { 0 };
+       Mitem *mitem = NULL;
+
+       if (func == NULL) {
+               mb_svc_debug("Func is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+/*
+       mb_svc_debug ("minfo_get_geo_item_list--enter\n");    
+       mb_svc_debug("minfo_get_geo_item_list#filter.file_type: %d", filter.file_type);
+       mb_svc_debug("minfo_get_geo_item_list#filter.sort_type: %d", filter.sort_type);
+       mb_svc_debug("minfo_get_geo_item_list#filter.start_pos: %d", filter.start_pos);
+       mb_svc_debug("minfo_get_geo_item_list#filter.end_pos: %d", filter.end_pos);
+       mb_svc_debug("minfo_get_geo_item_list#filter.with_meta: %d", filter.with_meta);
+       mb_svc_debug("minfo_get_geo_item_list#filter.favorite: %d", filter.favorite);
+       mb_svc_debug("minfo_get_geo_item_list#min_longitude: %f",
+                    min_longitude);
+       mb_svc_debug("minfo_get_geo_item_list#max_longitude: %f",
+                    max_longitude);
+       mb_svc_debug("minfo_get_geo_item_list#min_latitude: %f", min_latitude);
+       mb_svc_debug("minfo_get_geo_item_list#max_latitude: %f", max_latitude);
+*/
+
+       if ((max_longitude < min_longitude) || (max_latitude < min_latitude)) {
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if ((max_longitude < -180.0) || (min_longitude > 180.0)) {
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if ((max_latitude < -90.0) || (min_latitude > 90.0)) {
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret =
+           mb_svc_geo_media_iter_start(cluster_id, store_filter, &filter,
+                                       &mb_svc_iterator, min_longitude,
+                                       max_longitude, min_latitude,
+                                       max_latitude);
+
+       if (ret < 0) {
+               mb_svc_debug("mb-svc iterator start failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (1) {
+               ret = mb_svc_media_iter_next(&mb_svc_iterator, &md_record);
+
+               if (ret == MB_SVC_NO_RECORD_ANY_MORE)
+                       break;
+
+               if (ret < 0) {
+                       mb_svc_debug("mb-svc iterator get next recrod failed");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       return ret;
+               }
+
+               record_cnt++;
+
+               mitem = minfo_media_item_new(md_record.media_uuid, &md_record);
+               if (filter.with_meta && mitem) {
+                       mitem->meta_info =
+                           minfo_mmeta_new(mitem->uuid, &md_record);
+               }
+
+               func(mitem, user_data);
+       }
+
+       mb_svc_iter_finish(&mb_svc_iterator);
+       mb_svc_debug("minfo_get_geo_item_list--leave\n");
+
+       if (record_cnt == 0)
+               return MB_SVC_ERROR_DB_NO_RECORD;
+       else
+               return 0;
+}
+
+EXPORT_API int minfo_get_streaming_list(GList **p_list)
+{
+       Mstreaming *mstreaming = NULL;
+       int record_cnt = 0;
+       mb_svc_web_streaming_record_s webstreaming_record = { 0 };
+       int ret = -1;
+       mb_svc_iterator_s mb_svc_iterator = { 0 };
+
+       mb_svc_debug("minfo_get_streaming_list--enter");
+       if (p_list == NULL) {
+               mb_svc_debug("Error:p_list == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = mb_svc_webstreaming_iter_start(&mb_svc_iterator);
+       if (ret < 0) {
+               mb_svc_debug("mb-svc iterator start failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (1) {
+               memset(&webstreaming_record, 0x00,
+                      sizeof(mb_svc_web_streaming_record_s));
+               ret =
+                   mb_svc_webstreaming_iter_next(&mb_svc_iterator,
+                                                 &webstreaming_record);
+
+               if (ret == MB_SVC_NO_RECORD_ANY_MORE)
+                       break;
+
+               if (ret < 0) {
+                       mb_svc_debug("mb-svc iterator get next recrod failed");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       return ret;
+               }
+
+               record_cnt++;
+
+               mstreaming = minfo_mstreaming_new(webstreaming_record._id);
+               *p_list = g_list_append(*p_list, mstreaming);
+       }
+
+       mb_svc_iter_finish(&mb_svc_iterator);
+       mb_svc_debug("minfo_get_streaming_list--leave");
+
+       if (record_cnt == 0)
+               return MB_SVC_ERROR_DB_NO_RECORD;
+       else
+               return 0;
+}
+
+EXPORT_API int minfo_get_meta_info(const char *media_id, Mmeta **meta)
+{
+       if (media_id == NULL) {
+               mb_svc_debug("media_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_get_meta_info#media_id: %s", media_id);
+       Mmeta *mmeta = NULL;
+
+       mmeta = minfo_mmeta_new(media_id, NULL);
+       if (mmeta == NULL) {
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       *meta = mmeta;
+       return 0;
+}
+
+EXPORT_API int
+minfo_update_video_meta_info_int(const char *media_id,
+                                minfo_video_meta_field_t meta_field,
+                                const int updated_value)
+{
+       if (media_id == NULL) {
+               mb_svc_debug("media_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_update_video_meta_info_int#media_id: %s", media_id);
+       int ret = -1;
+       mb_svc_video_meta_record_s video_meta_record = {0,};
+
+       ret = mb_svc_get_video_record_by_media_id(media_id, &video_meta_record);
+
+       if (ret < 0) {
+               mb_svc_debug
+                   ("minfo_update_video_meta_info_int--load video meta fails! err%d",
+                    ret);
+               return ret;
+       }
+       switch (meta_field) {
+       case MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED:
+               video_meta_record.last_played_time = updated_value;
+               break;
+       default:
+               break;
+       }
+       ret = mb_svc_update_record_video_meta(&video_meta_record);
+
+       if (ret < 0) {
+               mb_svc_debug
+                   ("minfo_update_video_meta_info_int--update video meta fails! err%d",
+                    ret);
+               return ret;
+       }
+
+       return ret;
+}
+
+EXPORT_API int
+minfo_update_image_meta_info_int(const char *media_id,
+                               minfo_image_meta_field_t meta_field,
+                               const int updated_value,
+                               ...)
+{
+       if (media_id == NULL) {
+               mb_svc_debug("media_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_update_image_meta_info_int#media_id: %s", media_id);
+       int ret = -1;
+       mb_svc_image_meta_record_s image_meta_record = {0,};
+
+       ret = mb_svc_get_image_record_by_media_id(media_id, &image_meta_record);
+
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_get_image_record_by_media_id fails! err%d", ret);
+               return ret;
+       }
+
+       va_list var_args;
+       minfo_image_meta_field_t field;
+       int value = 0;
+       field = meta_field;
+       value = updated_value;
+
+       va_start(var_args, updated_value);
+
+       do {
+               if (field == meta_field) {
+                       value = updated_value;
+               } else {
+                       value = va_arg((var_args), int);
+               }
+
+               mb_svc_debug("Field:%d, Value:%d", field, value);
+
+               switch (field) {
+                       case MINFO_IMAGE_META_WIDTH:
+                               image_meta_record.width = value;
+                               break;
+                       case MINFO_IMAGE_META_HEIGHT:
+                               image_meta_record.height = value;
+                               break;
+                       case MINFO_IMAGE_META_ORIENTATION:
+                               image_meta_record.orientation = value;
+                               break;
+                       case MINFO_VIDEO_META_DATE_TAKEN:
+                               image_meta_record.datetaken = value;
+                               break;
+                       default:
+                               break;
+               }
+
+               /* next field */
+               field = va_arg(var_args, int);
+       } while (field > 0 && field < 5);
+
+       va_end(var_args);
+
+       ret = mb_svc_update_record_image_meta(&image_meta_record);
+
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_update_record_image_meta fails! err%d", ret);
+               return ret;
+       }
+
+       return ret;
+}
+
+EXPORT_API int
+minfo_add_media_start(int trans_count)
+{
+       mb_svc_debug("Transaction count : %d", trans_count);
+       g_trans_insert_cnt = trans_count;
+       g_cur_trans_insert_cnt = 0;
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_add_media_end()
+{
+       mb_svc_debug("");
+
+       if (g_cur_trans_insert_cnt > 0) {
+               int ret = -1;
+
+               ret = mb_svc_sqlite3_begin_trans();
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+
+                       g_cur_trans_insert_cnt = 0;
+                       g_trans_insert_cnt = 1;
+
+                       return ret;
+               }
+
+               ret = mb_svc_insert_items();
+               if (ret < 0) {
+                       mb_svc_debug
+                               ("mb_svc_insert_items failed...");
+                       return ret;
+               }
+
+               ret = mb_svc_sqlite3_commit_trans();
+               if (ret < 0) {
+                       mb_svc_debug
+                               ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+                       mb_svc_sqlite3_rollback_trans();
+
+                       g_cur_trans_insert_cnt = 0;
+                       g_trans_insert_cnt = 1;
+
+                       return ret;
+               }
+       }
+
+       g_cur_trans_insert_cnt = 0;
+       g_trans_insert_cnt = 1;
+
+       return 0;
+}
+
+EXPORT_API int minfo_add_media_batch(const char *file_url, minfo_file_type content_type)
+{
+       int err = 0;
+
+       if (file_url == NULL) {
+               mb_svc_debug("File URL is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("file_full_path is %s\n", file_url);
+
+       if (g_cur_trans_insert_cnt < g_trans_insert_cnt) {
+               err = mb_svc_insert_file_batch(file_url, content_type);
+
+               if (err < 0) {
+                       mb_svc_debug("mb_svc_insert_file_batch failed\n");
+                       return err;
+               }
+
+               g_cur_trans_insert_cnt++;
+
+               return 0;
+       }
+
+       if (g_cur_trans_insert_cnt == g_trans_insert_cnt) {
+               err = mb_svc_insert_file_batch(file_url, content_type);
+               if (err < 0) {
+                       mb_svc_debug("mb_svc_insert_file_batch failed\n");
+                       return err;
+               }
+
+               g_cur_trans_insert_cnt = 0;
+
+               err = mb_svc_sqlite3_begin_trans();
+               if (err < 0) {
+                       mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+                       return err;
+               }
+
+               err = mb_svc_insert_items();
+               if (err < 0) {
+                       mb_svc_debug
+                               ("mb_svc_insert_items failed.. Now start to rollback\n");
+                       mb_svc_sqlite3_rollback_trans();
+                       return err;
+               }
+
+               err = mb_svc_sqlite3_commit_trans();
+               if (err < 0) {
+                       mb_svc_debug
+                               ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+                       mb_svc_sqlite3_rollback_trans();
+                       return err;
+               }
+       }
+
+       return err;
+}
+
+EXPORT_API int minfo_add_media(const char *file_url, minfo_file_type content_type)
+{
+       int err = 0;
+
+       if (file_url == NULL) {
+               mb_svc_debug("File URL is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("file_full_path is %s\n", file_url);
+
+       err = mb_svc_insert_file(file_url, content_type);
+
+       if (err < 0) {
+               mb_svc_debug("mb_svc_insert_file failed (%d) ", err);
+       }
+
+       return err;
+}
+
+EXPORT_API int minfo_delete_media(const char *file_url)
+{
+       int ret = -1;
+
+       if (file_url == NULL) {
+               mb_svc_debug("File URL is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = mb_svc_sqlite3_begin_trans();
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+               return ret;
+       }
+
+       ret = mb_svc_delete_file(file_url);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("minfo delete media, delete media file info failed.. Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+
+               return ret;
+       }
+
+       ret = mb_svc_sqlite3_commit_trans();
+
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+               return ret;
+       }
+
+       return 0;
+}
+
+EXPORT_API int minfo_delete_media_id(const char *media_id)
+{
+       int ret = -1;
+       mb_svc_media_record_s media_record = {"",};
+
+       if (media_id == NULL) {
+               mb_svc_debug("media_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = mb_svc_get_media_record_by_id(media_id, &media_record);
+       if (ret < 0) {
+               mb_svc_debug("minfo delete media, get media record failed\n");
+               return ret;
+       }
+
+       mb_svc_debug("media uuid : %s", media_record.media_uuid);
+       mb_svc_debug("media folder uuid : %s", media_record.folder_uuid);
+       mb_svc_debug("media path : %s", media_record.path);
+
+       /* handle web image case. */
+       if (strncmp(media_record.http_url, "", 1) != 0) {
+               ret = mb_svc_delete_record_media_by_id(media_record.media_uuid);
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("minfo delete media, delete media record by media_id failed\n");
+                       return ret;
+               }
+
+               /* delete file info in image_meta table & (video_meta table and bookmark table if it's video file) */
+               ret =
+                   mb_svc_delete_bookmark_meta_by_media_id(media_record.media_uuid,
+                                                           media_record.
+                                                           content_type);
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("mb_svc_delete_record_video_or_image_by_media_id fail:media id is %d\n",
+                            media_id);
+               }
+               return ret;
+       }
+
+       return minfo_delete_media(media_record.path);
+}
+
+DEPRECATED_API int
+minfo_add_web_media(const char *cluster_id, const char *http_url, const char *file_name,
+                   const char *thumb_path)
+{
+       int ret = -1;
+       mb_svc_media_record_s media_record = {"",};
+       mb_svc_image_meta_record_s image_meta_record = {0,};
+       mb_svc_video_meta_record_s video_meta_record = {0,};
+       mb_svc_folder_record_s folder_record = {"",};
+       minfo_file_type content_type;
+
+       if (cluster_id == NULL) {
+               mb_svc_debug("cluster_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_add_web_media#cluster_uuid: %s", cluster_id);
+       mb_svc_debug("minfo_add_web_media#http_url: %s", http_url);
+       mb_svc_debug("minfo_add_web_media#file_name: %s", file_name);
+
+       ret = mb_svc_get_folder_record_by_id(cluster_id, &folder_record);
+       if ((ret < 0) || (folder_record.storage_type != MINFO_WEB)) {
+               mb_svc_debug
+                   ("minfo_add_web_media, get web folder record by id failed\n");
+               return ret;
+       }
+
+       ret =
+           mb_svc_get_media_record_by_fid_name(cluster_id, file_name,
+                                               &media_record);
+       if (ret < 0) {
+               strncpy(media_record.folder_uuid, cluster_id, MB_SVC_UUID_LEN_MAX + 1);
+
+               strncpy(media_record.http_url, http_url,
+                       MB_SVC_DIR_PATH_LEN_MAX + 1);
+               strncpy(media_record.display_name, file_name,
+                       MB_SVC_FILE_NAME_LEN_MAX + 1);
+               strncpy(media_record.thumbnail_path, thumb_path,
+                       MB_SVC_FILE_PATH_LEN_MAX + 1);
+
+               /* need to get the web media modified date */
+               content_type = _mb_svc_get_file_type(file_name);
+
+               mb_svc_debug("content_type is %d\n", content_type);
+
+               media_record.content_type = content_type;
+               media_record.rate = MB_SVC_DEFAULT;
+
+               ret = mb_svc_insert_record_media(&media_record, MINFO_WEB);
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("minfo_add_web_media, insert new media record failed\n");
+                       return ret;
+               }
+
+               if (content_type == MINFO_ITEM_IMAGE) {
+                       strncpy(image_meta_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+                       /* Couldn't extract meta information from an web image, which hasn't downloaded yet */
+                       image_meta_record.longitude = MINFO_DEFAULT_GPS;
+                       image_meta_record.latitude = MINFO_DEFAULT_GPS;
+
+                       ret =
+                           mb_svc_insert_record_image_meta(&image_meta_record,
+                                                           MINFO_WEB);
+                       if (ret < 0) {
+                               mb_svc_debug
+                                   ("minfo_add_web_media, insert new image_meta record failed\n");
+                               return ret;
+                       }
+               }
+
+               else if (content_type == MINFO_ITEM_VIDEO) {
+                       strncpy(video_meta_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+                       ret =
+                           mb_svc_insert_record_video_meta(&video_meta_record,
+                                                           MINFO_WEB);
+                       if (ret < 0) {
+                               mb_svc_debug
+                                   ("minfo_add_web_media, insert new video_meta record failed\n");
+                               return ret;
+                       }
+               }
+               return 0;
+       }
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_add_web_media_with_type(const char *cluster_id, const char *http_url,
+                             const char *file_name,
+                             minfo_file_type content_type,
+                             const char *thumb_path)
+{
+       int ret = -1;
+       mb_svc_media_record_s media_record = {"",};
+       mb_svc_image_meta_record_s image_meta_record = {0,};
+       mb_svc_video_meta_record_s video_meta_record = {0,};
+       mb_svc_folder_record_s folder_record = {"",};
+
+       if (cluster_id == NULL) {
+               mb_svc_debug("cluster_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (http_url == NULL || file_name == NULL
+           || thumb_path == NULL || content_type <= 0
+           || content_type > MINFO_ITEM_VIDEO) {
+               mb_svc_debug
+                   ("http_url == NULL || file_name == NULL || thumb_path == NULL || content_type <= 0 || content_type > MINFO_ITEM_VIDEO");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("cluster_uuid: %s", cluster_id);
+       mb_svc_debug("http_url: %s", http_url);
+       mb_svc_debug("file_name: %s", file_name);
+
+       ret = mb_svc_get_folder_record_by_id(cluster_id, &folder_record);
+       if ((ret < 0) || (folder_record.storage_type != MINFO_WEB)) {
+               mb_svc_debug("get web folder record by id failed\n");
+               return ret;
+       }
+
+       ret =
+           mb_svc_get_media_record_by_fid_name(cluster_id, file_name,
+                                               &media_record);
+       if (ret < 0) {
+               strncpy(media_record.folder_uuid, cluster_id, MB_SVC_UUID_LEN_MAX + 1);
+
+               strncpy(media_record.http_url, http_url,
+                       MB_SVC_DIR_PATH_LEN_MAX + 1);
+               strncpy(media_record.display_name, file_name,
+                       MB_SVC_FILE_NAME_LEN_MAX + 1);
+               strncpy(media_record.thumbnail_path, thumb_path,
+                       MB_SVC_FILE_PATH_LEN_MAX + 1);
+               media_record.content_type = content_type;
+               media_record.rate = MB_SVC_DEFAULT;
+
+               ret = mb_svc_sqlite3_begin_trans();
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+                       return ret;
+               }
+
+               ret = mb_svc_insert_record_media(&media_record, MINFO_WEB);
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("insert new media record failed..Now start to rollback\n");
+                       mb_svc_sqlite3_rollback_trans();
+                       return ret;
+               }
+
+               if (content_type == MINFO_ITEM_IMAGE) {
+                       strncpy(image_meta_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+                       /* Couldn't extract meta information from an web image, which hasn't downloaded yet */
+                       image_meta_record.longitude = MINFO_DEFAULT_GPS;
+                       image_meta_record.latitude = MINFO_DEFAULT_GPS;
+
+                       ret =
+                           mb_svc_insert_record_image_meta(&image_meta_record,
+                                                           MINFO_WEB);
+                       if (ret < 0) {
+                               mb_svc_debug
+                                   ("minfo_add_web_media, insert new image_meta record failed..Now start to rollback\n");
+                               mb_svc_sqlite3_rollback_trans();
+                               return ret;
+                       }
+               }
+
+               else if (content_type == MINFO_ITEM_VIDEO) {
+                       strncpy(video_meta_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+                       ret =
+                           mb_svc_insert_record_video_meta(&video_meta_record,
+                                                           MINFO_WEB);
+
+                       /* Couldn't extract meta information from an web video, which hasn't downloaded yet */
+                       video_meta_record.longitude = MINFO_DEFAULT_GPS;
+                       video_meta_record.latitude = MINFO_DEFAULT_GPS;
+
+                       if (ret < 0) {
+                               mb_svc_debug
+                                   ("minfo_add_web_media, insert new video_meta record failed..Now start to rollback\n");
+                               mb_svc_sqlite3_rollback_trans();
+                               return ret;
+                       }
+               }
+
+               ret = mb_svc_sqlite3_commit_trans();
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+                       mb_svc_sqlite3_rollback_trans();
+                       return ret;
+               }
+
+               return 0;
+       }
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_move_media(const char *old_file_url, const char *new_file_url,
+                minfo_file_type content_type)
+{
+       mb_svc_debug("");
+
+       int ret = -1;
+       char thumb_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+       char old_dir_full_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       char new_dir_full_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       char old_file_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       char new_file_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       bool is_renamed = false;
+       bool is_moved = false;
+
+       if (old_file_url == NULL || new_file_url == NULL) {
+               mb_svc_debug("old_file_url == NULL || new_file_url == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+       _mb_svc_get_file_parent_path(old_file_url, old_dir_full_path);
+       _mb_svc_get_file_parent_path(new_file_url, new_dir_full_path);
+
+       _mb_svc_get_file_display_name(old_file_url, old_file_name);
+       _mb_svc_get_file_display_name(new_file_url, new_file_name);
+
+       if ((strncmp
+            (old_dir_full_path, new_dir_full_path,
+             MB_SVC_FILE_PATH_LEN_MAX) == 0)
+           && (strncmp(old_file_name, new_file_name, MB_SVC_FILE_NAME_LEN_MAX)
+               != 0)) {
+               is_renamed = TRUE;
+       } else
+           if ((strncmp
+                (old_dir_full_path, new_dir_full_path,
+                 MB_SVC_FILE_NAME_LEN_MAX) != 0)
+               &&
+               (strncmp(old_file_name, new_file_name, MB_SVC_FILE_NAME_LEN_MAX)
+                == 0)) {
+               is_moved = TRUE;
+       } else
+           if ((strncmp
+                (old_dir_full_path, new_dir_full_path,
+                 MB_SVC_FILE_PATH_LEN_MAX) != 0)
+               &&
+               (strncmp(old_file_name, new_file_name, MB_SVC_FILE_NAME_LEN_MAX)
+                != 0)) {
+               is_moved = TRUE;
+       } else {
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (is_moved) {
+               ret =
+                   mb_svc_move_file(old_file_url, new_file_url, content_type,
+                                    thumb_path);
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("file move failed.. Now start to rollback\n");
+                       return ret;
+               } else {
+                       mb_svc_debug("move success");
+                       return 0;
+               }
+       }
+
+       ret = mb_svc_sqlite3_begin_trans();
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+               return ret;
+       }
+
+       if (is_renamed) {
+               ret =
+                   mb_svc_rename_file(old_file_url, new_file_url, content_type,
+                                      thumb_path);
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("file rename failed.. Now start to rollback\n");
+                       mb_svc_sqlite3_rollback_trans();
+                       return ret;
+               }
+       }
+
+       ret = mb_svc_sqlite3_commit_trans();
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+               return ret;
+       }
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_copy_media(const char *old_file_url, const char *new_file_url,
+                minfo_file_type content_type)
+{
+       int ret = -1;
+       char thumb_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+
+       if (old_file_url == NULL || new_file_url == NULL) {
+               mb_svc_debug("old_file_url == NULL || new_file_url == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = mb_svc_sqlite3_begin_trans();
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+               return ret;
+       }
+
+       ret = mb_svc_copy_file(old_file_url, new_file_url, content_type, thumb_path);
+       if (ret < 0) {
+               mb_svc_debug("file copy failed.. Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+       }
+
+       ret = mb_svc_sqlite3_commit_trans();
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+               return ret;
+       }
+
+       return ret;
+}
+
+EXPORT_API int minfo_update_media_name(const char *media_id, const char *new_name)
+{
+       int ret = -1;
+       mb_svc_media_record_s media_record = {"",};
+       mb_svc_folder_record_s folder_record = {"",};
+       char old_file_full_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+       char new_file_full_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+       char dest_thumb_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+
+       if (media_id == NULL) {
+               mb_svc_debug("media_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (new_name == NULL) {
+               mb_svc_debug(" new name is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = mb_svc_get_media_record_by_id(media_id, &media_record);
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_get_media_record_by_id failed: %s\n",
+                            media_id);
+               return ret;
+       }
+
+       ret =
+           mb_svc_get_folder_record_by_id(media_record.folder_uuid,
+                                          &folder_record);
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_get_folder_record_by_id failed: %s\n",
+                            media_id);
+               return ret;
+       }
+
+       if (strlen(folder_record.uri) > MB_SVC_FILE_PATH_LEN_MAX) {
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       snprintf(old_file_full_path, sizeof(old_file_full_path), "%s/",
+                folder_record.uri);
+       strncpy(new_file_full_path, old_file_full_path,
+               sizeof(new_file_full_path));
+
+       strncat(old_file_full_path, media_record.display_name,
+               MB_SVC_FILE_PATH_LEN_MAX - strlen(old_file_full_path));
+       strncat(new_file_full_path, new_name,
+               MB_SVC_FILE_PATH_LEN_MAX - strlen(new_file_full_path));
+
+       ret = mb_svc_sqlite3_begin_trans();
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+               return ret;
+       }
+
+       ret =
+           mb_svc_rename_file(old_file_full_path, new_file_full_path,
+                              media_record.content_type, dest_thumb_path);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_rename_file fails.. Now start to rollback");
+               mb_svc_sqlite3_rollback_trans();
+       }
+
+       ret = mb_svc_sqlite3_commit_trans();
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+               return ret;
+       }
+
+       return 0;
+}
+
+
+EXPORT_API int
+minfo_update_media_thumb(const char *media_id, const char *thumb_path)
+{
+       int ret = -1;
+
+       if (media_id == NULL) {
+               mb_svc_debug("media_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (thumb_path == NULL) {
+               mb_svc_debug("thumb path is invalid");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_update_media_thumb: %s", thumb_path);
+
+       ret = mb_svc_update_thumb_path_by_id(media_id, thumb_path);
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_update_thumb_by_media_id failed\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_update_media_favorite(const char *media_id, const int favorite_level)
+{
+       int ret = -1;
+
+       if (media_id == NULL) {
+               mb_svc_debug("media_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (favorite_level != 0 && favorite_level != 1) {
+               mb_svc_debug("favorite_level is invalid");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = mb_svc_update_favorite_by_media_id(media_id, favorite_level);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("minfo_update_media_favorite, update media record failed\n");
+               return ret;
+       }
+       return 0;
+}
+
+int minfo_update_media_date(const char *media_id, time_t modified_date)
+{
+       int ret = -1;
+
+       if (media_id == NULL) {
+               mb_svc_debug("media_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_update_media_date: %s", media_id);
+       mb_svc_debug("minfo_update_media_date: %d", modified_date);
+
+       ret = mb_svc_update_date_by_id(media_id, modified_date);
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_update_date_by_media_id failed\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+EXPORT_API int minfo_cp_media(const char *src_media_id, const char *dst_cluster_id)
+{
+       int ret = -1;
+
+       if (src_media_id == NULL || dst_cluster_id == NULL) {
+               mb_svc_debug("src_media_id == NULL || dst_cluster_id == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = mb_svc_sqlite3_begin_trans();
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+               return ret;
+       }
+
+       ret = mb_svc_copy_file_by_id(src_media_id, dst_cluster_id);
+
+       if (ret < 0) {
+               mb_svc_debug("file copy failed.. Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+       }
+
+       ret = mb_svc_sqlite3_commit_trans();
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+               return ret;
+       }
+
+       return ret;
+}
+
+EXPORT_API int minfo_mv_media(const char *src_media_id, const char *dst_cluster_id)
+{
+       int ret = -1;
+
+       if (src_media_id == NULL || dst_cluster_id == NULL) {
+               mb_svc_debug("src_media_id == NULL || dst_cluster_id == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = mb_svc_sqlite3_begin_trans();
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+               return ret;
+       }
+
+       ret = mb_svc_move_file_by_id(src_media_id, dst_cluster_id);
+       if (ret < 0) {
+               mb_svc_debug("file move failed.. Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+       }
+
+       ret = mb_svc_sqlite3_commit_trans();
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+               return ret;
+       }
+
+       return ret;
+}
+
+EXPORT_API int minfo_add_cluster(const char *cluster_url, char *id, int max_length)    /* only for local folder path */
+{
+       int ret = -1;
+       mb_svc_folder_record_s folder_record = {"",};
+       char parent_dir_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       char dir_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+       int folder_modified_date = 0;
+       int store_type = 0;
+
+       if (cluster_url == NULL || id == NULL) {
+               mb_svc_debug("cluster_url == NULL || id == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       /* <Example> cluster_url:/opt/media/tmp */
+       mb_svc_debug("minfo_add_cluster#cluster_url:%s\n", cluster_url);
+
+       store_type = _mb_svc_get_store_type_by_full(cluster_url);
+
+       if (store_type == MB_SVC_ERROR_INTERNAL) {
+               mb_svc_debug("Failed to get storage type : %s", cluster_url);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       /* dir_display_name : tmp */
+       _mb_svc_get_dir_display_name(cluster_url, dir_display_name);
+
+       folder_modified_date = _mb_svc_get_file_dir_modified_date(cluster_url);
+
+       mb_svc_debug("store_type is %d\n", store_type);
+       mb_svc_debug("dir_display_name is %s\n", dir_display_name);
+       mb_svc_debug("parent_dir_path is %s\n", parent_dir_path);
+       mb_svc_debug("folder_modified_date is %d\n", folder_modified_date);
+
+       folder_record.modified_date = folder_modified_date;
+       folder_record.storage_type = (minfo_store_type) store_type;
+       strncpy(folder_record.uri, cluster_url,
+               MB_SVC_DIR_PATH_LEN_MAX + 1);
+       strncpy(folder_record.display_name, dir_display_name,
+               MB_SVC_FILE_NAME_LEN_MAX + 1);
+       strncpy(folder_record.web_account_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
+       strncpy(folder_record.web_album_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
+       folder_record.sns_type = 0;
+
+       mb_svc_debug("folder_record.uri is %s\n", folder_record.uri);
+       mb_svc_debug
+           ("no record in %s, ready insert the folder record into db\n",
+            cluster_url);
+
+       ret = mb_svc_insert_record_folder(&folder_record);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("insert file info into folder table failed\n");
+               return ret;
+       }
+
+       strncpy(id, folder_record.uuid, max_length);
+
+       return 0;
+}
+
+DEPRECATED_API int
+minfo_add_web_cluster(int sns_type, const char *name, const char *account_id,
+                     char *id, int max_length)
+{
+       int ret = -1;
+
+       if (name == NULL || account_id == NULL || id == 0) {
+               mb_svc_debug("the parameters are invalid!\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_folder_record_s folder_record = {"",};
+
+       folder_record.sns_type = sns_type;
+       folder_record.storage_type = MINFO_WEB;
+       strncpy(folder_record.web_account_id, account_id, MB_SVC_ARRAY_LEN_MAX + 1);
+       strncpy(folder_record.display_name, name, MB_SVC_FILE_NAME_LEN_MAX + 1);
+       strncpy(folder_record.uri, "", MB_SVC_DIR_PATH_LEN_MAX + 1);
+       strncpy(folder_record.web_album_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
+       folder_record.modified_date = 0;
+
+       /* first, check whether the same web cluster has existed. */
+       ret = mb_svc_get_web_album_cluster_record(sns_type, name, account_id, NULL, &folder_record);
+
+       if (ret == 0) {
+               strncpy(id, folder_record.uuid, MB_SVC_UUID_LEN_MAX + 1);
+               return 0;
+       }
+
+       ret = mb_svc_insert_record_folder(&folder_record);
+       if (ret < 0) {
+               mb_svc_debug("insert record into folder table failed\n");
+               return ret;
+       }
+
+       strncpy(id, folder_record.uuid, max_length);
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_add_web_cluster_album_id(int sns_type, const char *name,
+                              const char *account_id, const char *album_id,
+                              char *id, int max_length)
+{
+       int ret = -1;
+       mb_svc_folder_record_s folder_record = {"",};
+
+       if (name == NULL || account_id == NULL || album_id == NULL || id == NULL) {
+               mb_svc_debug("the parameters are invalid!\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       folder_record.sns_type = sns_type;
+       folder_record.storage_type = MINFO_WEB;
+       strncpy(folder_record.web_account_id, account_id, MB_SVC_ARRAY_LEN_MAX + 1);
+       strncpy(folder_record.display_name, name, MB_SVC_FILE_NAME_LEN_MAX + 1);
+       strncpy(folder_record.uri, "", MB_SVC_DIR_PATH_LEN_MAX + 1);
+       strncpy(folder_record.web_album_id, album_id, MB_SVC_ARRAY_LEN_MAX + 1);
+       folder_record.modified_date = 0;
+
+       /* first, check whether the same web cluster has existed. */
+       ret = mb_svc_get_web_album_cluster_record(sns_type, name, account_id, album_id, &folder_record);
+
+       if (ret == 0) {
+               strncpy(id, folder_record.uuid, MB_SVC_UUID_LEN_MAX + 1);
+               return 0;
+       }
+
+       ret = mb_svc_insert_record_folder(&folder_record);
+       if (ret < 0) {
+               mb_svc_debug("insert record into folder table failed\n");
+               return ret;
+       }
+
+       strncpy(id, folder_record.uuid, max_length);
+       return 0;
+}
+
+EXPORT_API int minfo_delete_web_cluster(const char *cluster_id)
+{
+       /* delete id & all media items */
+       int ret = -1;
+       mb_svc_folder_record_s folder_record = {"",};
+
+       if (cluster_id == NULL) {
+               mb_svc_debug("cluster_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_delete_web_cluster#cluster_id: %s", cluster_id);
+
+       ret = mb_svc_get_folder_record_by_id(cluster_id, &folder_record);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("minfo_delete_web_cluster: get folder record by id failed\n");
+               return ret;
+       }
+
+       if (folder_record.storage_type == MINFO_WEB) {
+
+               ret = mb_svc_delete_folder(cluster_id, MINFO_WEB);
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("mb_svc_delete_folder: delete web cluster failed..Now start to rollback\n");
+                       mb_svc_sqlite3_rollback_trans();
+                       return ret;
+               }
+
+       } else {
+               mb_svc_debug
+                   ("minfo_delete_web_cluster: the folder is not web folder\n");
+       }
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_get_web_cluster_web_album_id(const char *web_album_id,
+                                  Mcluster **mcluster)
+{
+       int ret = 0;
+       int folder_id = 0;
+       Mcluster *cluster = NULL;
+       char folder_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+
+       if (web_album_id == NULL || *mcluster != NULL) {
+               mb_svc_debug("web_album_id == NULL || *mcluster != NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_get_web_cluster_web_album_id#album_id: %s",
+                    web_album_id);
+       ret = mb_svc_get_folder_id_by_web_album_id(web_album_id, folder_uuid);
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_get_folder_id_by_web_album_id fails:%s\n",
+                            web_album_id);
+               return ret;
+       }
+
+       cluster = minfo_mcluster_new(folder_uuid);
+       if (cluster == NULL) {
+               mb_svc_debug("minfo_mcluster_new: %d\n", folder_id);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       *mcluster = cluster;
+       return 0;
+
+}
+
+EXPORT_API int minfo_delete_cluster(const char *cluster_id)
+{
+       if (cluster_id == NULL) {
+               mb_svc_debug("cluster_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_delete_cluster#cluster_id: %s", cluster_id);
+
+       return mb_svc_delete_folder(cluster_id, MINFO_SYSTEM);
+}
+
+EXPORT_API int
+minfo_update_cluster_name(const char *cluster_id, const char *new_name)
+{
+       int ret = -1;
+
+       if (cluster_id == NULL || new_name == NULL) {
+               mb_svc_debug("cluster_id == NULL || new_name == NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = mb_svc_sqlite3_begin_trans();
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+               return ret;
+       }
+
+       ret = mb_svc_update_cluster_name(cluster_id, new_name);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_update_cluster_name failed.. Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+       }
+
+       ret = mb_svc_sqlite3_commit_trans();
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+               return ret;
+       }
+
+       return ret;
+}
+
+EXPORT_API int
+minfo_update_cluster_date(const char *cluster_id, time_t modified_date)
+{
+       int ret = -1;
+       mb_svc_folder_record_s folder_record;
+
+       if (cluster_id == NULL) {
+               mb_svc_debug("cluster_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_update_cluster_date#cluster_id: %s", cluster_id);
+       mb_svc_debug("minfo_update_cluster_date#modified_date: %d",
+                    modified_date);
+
+       ret = mb_svc_get_folder_record_by_id(cluster_id, &folder_record);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("minfo_update_cluster_date: no folder record matched with the folder id\n");
+               return ret;
+       }
+
+       folder_record.modified_date = modified_date;
+
+       ret = mb_svc_update_record_folder(&folder_record);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("minfo_update_cluster_date: update cluster date failed\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_add_bookmark(const char *media_id, const int position,
+                  const char *thumb_path)
+{
+       int ret = -1;
+       mb_svc_bookmark_record_s bookmark_record = { 0 };
+
+       if (thumb_path == NULL || media_id == NULL) {
+               mb_svc_debug("Thumb path or media_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_add_bookmark#media_id: %s", media_id);
+       mb_svc_debug("minfo_add_bookmark#position: %d", position);
+       mb_svc_debug("minfo_add_bookmark#thumb_path: %s", thumb_path);
+
+       //bookmark_record.media_id = media_id;
+       strncpy(bookmark_record.media_uuid, media_id, MB_SVC_UUID_LEN_MAX + 1);
+       bookmark_record.marked_time = position;
+       strncpy(bookmark_record.thumbnail_path, thumb_path,
+               MB_SVC_FILE_PATH_LEN_MAX + 1);
+       ret = mb_svc_insert_record_bookmark(&bookmark_record);
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_insert_record_bookmark fail\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+EXPORT_API int minfo_delete_bookmark(const int bookmark_id)
+{
+       int ret = -1;
+       mb_svc_debug("minfo_delete_bookmark#bookmark_id: %d", bookmark_id);
+
+       ret = mb_svc_delete_record_bookmark_by_id(bookmark_id);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("minfo_delete_bookmark: delete matched bookmark record by id failed\n");
+               return ret;
+       }
+       return 0;
+}
+
+EXPORT_API int
+minfo_add_streaming(const char *title, const char *url, uint duration,
+                   const char *thumb_path, int *id)
+{
+       /* "> 0 : SuccessOthers : fail" */
+       int ret = -1;
+       mb_svc_web_streaming_record_s webstreaming_record = { 0 };
+       char folder_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+
+       mb_svc_debug("minfo_add_streaming#title: %s", title);
+       mb_svc_debug("minfo_add_streaming#url: %s", url);
+       mb_svc_debug("minfo_add_streaming#duration: %d", duration);
+       mb_svc_debug("minfo_add_streaming#thumb_path: %s", thumb_path);
+
+       ret = mb_svc_get_web_streaming_folder_uuid(folder_uuid, sizeof(folder_uuid));
+       if (ret < 0) {
+               mb_svc_debug("not add web streaming foler yet, so insert it.");
+               ret = mb_svc_add_web_streaming_folder(folder_uuid);
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_add_web_streaming_folder failed : %d", ret);
+                       return ret;
+               }
+       }
+
+       //webstreaming_record.folder_id = folder_id;
+       strncpy(webstreaming_record.folder_uuid, folder_uuid, MB_SVC_UUID_LEN_MAX + 1);
+       webstreaming_record.duration = duration;
+       strncpy(webstreaming_record.title, title, MB_SVC_FILE_NAME_LEN_MAX + 1);
+       strncpy(webstreaming_record.url, url,  MB_SVC_FILE_PATH_LEN_MAX + 1);
+       strncpy(webstreaming_record.thumb_path, thumb_path,
+               MB_SVC_FILE_PATH_LEN_MAX + 1);
+       ret = mb_svc_insert_record_web_streaming(&webstreaming_record);
+       if (ret < 0) {
+               return ret;
+       }
+
+       *id = webstreaming_record._id;
+       mb_svc_debug("minfo_add_streaming: new webstreaming record id is %d\n",
+                    webstreaming_record._id);
+
+       return 0;
+}
+
+EXPORT_API int minfo_delete_streaming(int streaming_id)
+{
+       int ret = -1;
+       mb_svc_web_streaming_record_s webstreaming_record = { 0 };
+
+       mb_svc_debug("minfo_delete_streaming#streaming_id: %d", streaming_id);
+
+       ret =
+           mb_svc_get_web_streaming_record_by_id(streaming_id,
+                                                 &webstreaming_record);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("minfo_delete_streaming, get webstreaming record failed\n");
+               return ret;
+       }
+       /* delete webstreaming record */
+       ret = mb_svc_delete_record_web_streaming_by_id(webstreaming_record._id);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("minfo_delete_streaming, delete webstreaming record by _id failed\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_get_thumb_path(const char *file_url, char *thumb_path,
+                    size_t max_thumb_path)
+{
+       int err = -1;
+       char media_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+       Mitem *item = NULL;
+
+       if (file_url == NULL || thumb_path == NULL || max_thumb_path <= 0) {
+               mb_svc_debug
+                   ("file_url == NULL || thumb_path == NULL || max_thumb_path <= 0 \n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       err = mb_svc_get_media_id_by_full_path(file_url, media_uuid);
+
+       if (err < 0) {
+               mb_svc_debug("There is no ( %s ) file in DB", file_url);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       item = minfo_media_item_new(media_uuid, NULL);
+
+       if (item == NULL) {
+               mb_svc_debug("minfo_media_item_new fails: %s\n", file_url);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       } else {
+               mb_svc_debug("thumb path :%s", item->thumb_url);
+               if (strlen(item->thumb_url) == 0) {
+                       thumb_path[0] = '\0';
+               } else {
+                       strncpy(thumb_path, item->thumb_url, max_thumb_path);
+               }
+       }
+
+       minfo_destroy_mtype_item(item);
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_get_thumb_path_for_video(const char *file_url, char *thumb_path,
+                              size_t max_thumb_path)
+{
+       int err = -1;
+       char media_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+       Mitem *item = NULL;
+
+       if (file_url == NULL || thumb_path == NULL || max_thumb_path <= 0) {
+               mb_svc_debug
+                   ("file_url == NULL || thumb_path == NULL || max_thumb_path <= 0 \n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       err = mb_svc_get_media_id_by_full_path(file_url, media_uuid);
+
+       if (err < 0) {
+               mb_svc_debug("There is no ( %s ) file in DB", file_url);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       item = minfo_media_item_new(media_uuid, NULL);
+
+       if (item == NULL) {
+               mb_svc_debug("minfo_media_item_new fails: %s\n", file_url);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       } else {
+               mb_svc_debug("thumb path :%s", item->thumb_url);
+               strncpy(thumb_path, item->thumb_url, max_thumb_path);
+       }
+
+       minfo_destroy_mtype_item(item);
+       return 0;
+}
+
+EXPORT_API int minfo_destroy_mtype_item(void *item)
+{
+       if (item == NULL) {
+               mb_svc_debug("item == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (IS_MINFO_MITEM(item)) {
+               minfo_mitem_destroy((Mitem *) item);
+       } else if (IS_MINFO_MMETA(item)) {
+               minfo_mmeta_destroy((Mmeta *) item);
+       } else if (IS_MINFO_MBOOKMARK(item)) {
+               minfo_mbookmark_destroy((Mbookmark *) item);
+       } else if (IS_MINFO_MCLUSTER(item)) {
+               minfo_mcluster_destroy((Mcluster *) item);
+       } else if (IS_MINFO_MSTREAMING(item)) {
+               minfo_mstreaming_destroy((Mstreaming *) item);
+       } else if (IS_MINFO_MTAG(item)) {
+               minfo_media_tag_destroy((Mtag *) item);
+       } else {
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return 0;
+}
+
+EXPORT_API int minfo_get_item_by_id(const char *media_id, Mitem **mitem)
+{
+       Mitem *item = NULL;
+
+       item = minfo_media_item_new(media_id, NULL);
+       if (item == NULL) {
+               mb_svc_debug("minfo_mitem_new: %s\n", media_id);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       *mitem = item;
+       return 0;
+}
+
+EXPORT_API int minfo_get_item(const char *file_url, Mitem ** mitem)
+{
+       int ret = 0;
+       Mitem *item = NULL;
+       char _media_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+
+       if (file_url == NULL) {
+               mb_svc_debug("file_url == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+       mb_svc_debug("minfo_get_item#file_url: %s", file_url);
+       ret = mb_svc_get_media_id_by_full_path(file_url, _media_uuid);
+
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_get_media_id_by_full_path fails:%s\n",
+                            file_url);
+               return ret;
+       }
+
+       item = minfo_media_item_new(_media_uuid, NULL);
+
+       if (item == NULL) {
+               mb_svc_debug("minfo_mitem_new: %s\n", file_url);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       *mitem = item;
+       return 0;
+}
+
+EXPORT_API int minfo_get_item_by_http_url(const char *http_url, Mitem ** mitem)
+{
+       int ret = 0;
+       char media_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+       Mitem *item = NULL;
+
+       if (http_url == NULL) {
+               mb_svc_debug("http_url == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_get_item_by_http_url#http_url: %s", http_url);
+
+       ret = mb_svc_get_media_id_by_http_url(http_url, media_uuid);
+
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_get_media_id_by_http_url fails:%s\n",
+                            http_url);
+               return ret;
+       }
+
+       item = minfo_media_item_new(media_uuid, NULL);
+
+       if (item == NULL) {
+               mb_svc_debug("minfo_mitem_new: %s\n", http_url);
+               return MB_SVC_ERROR_INTERNAL;
+       }
+
+       *mitem = item;
+       return 0;
+}
+
+EXPORT_API int
+minfo_get_cluster(const char *cluster_url, const char *cluster_id,
+                 Mcluster **mcluster)
+{
+       int ret = 0;
+       char folder_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+       char *_uuid = NULL;
+       Mcluster *cluster = NULL;
+
+       if (*mcluster != NULL) {
+               mb_svc_debug("cluster_url == NULL || *mcluster != NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (cluster_url != NULL) {
+               mb_svc_debug("minfo_get_item#file_url: %d", cluster_url);
+               ret =
+                   mb_svc_get_folder_id_by_full_path(cluster_url, folder_uuid, sizeof(folder_uuid));
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("mb_svc_get_folder_id_by_full_path fails:%s\n",
+                            cluster_url);
+                       return ret;
+               }
+
+               _uuid = folder_uuid;
+       } else if (cluster_id != NULL) {
+               strncpy(folder_uuid, cluster_id, MB_SVC_UUID_LEN_MAX + 1);
+               _uuid = folder_uuid;
+       }
+
+       cluster = minfo_mcluster_new(_uuid);
+       if (cluster == NULL) {
+               mb_svc_debug("minfo_mcluster_new: %s\n", folder_uuid);
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       *mcluster = cluster;
+       return 0;
+}
+
+EXPORT_API int minfo_get_cluster_id_by_url(const char *url, char *cluster_id, int max_length)
+{
+       return mb_svc_get_folder_id_by_full_path(url, cluster_id, max_length);
+}
+
+EXPORT_API int
+minfo_get_cluster_name_by_id(const char *cluster_id, char *cluster_name, int max_length)
+{
+       return mb_svc_get_folder_name_by_id(cluster_id, cluster_name,
+                                           max_length);
+}
+
+EXPORT_API int
+minfo_get_cluster_fullpath_by_id(const char *cluster_id, char *folder_path,
+                                int max_length)
+{
+       int ret = 0;
+
+       if (cluster_id == NULL) {
+               mb_svc_debug("cluster_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (folder_path == NULL) {
+               mb_svc_debug("folder_path: NULL!\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret =
+           mb_svc_get_folder_fullpath_by_folder_id(cluster_id, folder_path,
+                                                   max_length);
+
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_get_folder_fullpath_by_folder_id fail %d\n", ret);
+               return ret;
+       }
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_set_cluster_lock_status(const char *cluster_id, int lock_status)
+{
+       mb_svc_debug("");
+       int ret = 0;
+
+       ret =
+           mb_svc_update_album_lock_status(cluster_id, lock_status,
+                                           MINFO_PHONE);
+       return ret;
+}
+
+EXPORT_API int
+minfo_get_cluster_lock_status(const char *cluster_id, int *lock_status)
+{
+       mb_svc_debug("");
+       int ret = 0;
+       mb_svc_folder_record_s record;
+
+       if (cluster_id == NULL) {
+               mb_svc_debug("cluster_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (lock_status == NULL) {
+               mb_svc_debug("password is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = mb_svc_get_folder_record_by_id(cluster_id, &record);
+
+       if (ret != 0) {
+               mb_svc_debug("minfo_get_cluster_lock_status fails");
+               return ret;
+       }
+
+       *lock_status = record.lock_status;
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_get_media_path(minfo_store_type storage_type, char *media_path,
+                    size_t max_media_path)
+{
+       mb_svc_debug("");
+       int len = 0;
+
+       if (media_path == NULL) {
+               mb_svc_debug("Passed media path is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (storage_type == MINFO_PHONE) {
+               if (max_media_path < strlen(MB_SVC_PATH_PHONE) + 1) {
+                       mb_svc_debug("max_media_path is too short");
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       } else if (storage_type == MINFO_MMC) {
+               if (max_media_path < strlen(MB_SVC_PATH_MMC) + 1) {
+                       mb_svc_debug("max_media_path is too short");
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       if (storage_type == MINFO_PHONE) {
+               len = strlen(MB_SVC_PATH_PHONE) + 1;
+               if (len > max_media_path) {
+                       mb_svc_debug("String length violation");
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+
+               strncpy(media_path, MB_SVC_PATH_PHONE, max_media_path);
+               media_path[max_media_path - 1] = '\0';
+       } else if (storage_type == MINFO_MMC) {
+               len = strlen(MB_SVC_PATH_MMC) + 1;
+               if (len > max_media_path) {
+                       mb_svc_debug("String length violation");
+                       return MB_SVC_ERROR_INVALID_PARAMETER;
+               }
+
+               strncpy(media_path, MB_SVC_PATH_MMC, max_media_path);
+               media_path[max_media_path - 1] = '\0';
+       }
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_set_db_valid(const minfo_store_type storage_type, int valid)
+{
+       mb_svc_debug("storage:%d", storage_type);
+       int ret;
+
+       if (storage_type != MINFO_PHONE && storage_type != MINFO_MMC) {
+               mb_svc_debug("storage type should be phone or mmc");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (valid != 0 && valid != 1) {
+               mb_svc_debug("valid should be 0 or 1");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = mb_svc_sqlite3_begin_trans();
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+               return ret;
+       }
+
+       ret = mb_svc_set_media_records_as_valid(storage_type, valid);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_set_media_records_as_valid failed..Now Start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+               return ret;
+       }
+
+       ret = mb_svc_sqlite3_commit_trans();
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+               return ret;
+       }
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_set_item_valid_start(int trans_count)
+{
+       mb_svc_debug("Transaction count : %d", trans_count);
+       g_trans_valid_cnt = trans_count;
+       g_cur_trans_valid_cnt = 0;
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_set_item_valid_end()
+{
+       mb_svc_debug("");
+
+       if (g_cur_trans_valid_cnt > 0) {
+               int ret = -1;
+
+               ret = mb_svc_sqlite3_begin_trans();
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+
+                       g_cur_trans_valid_cnt = 0;
+                       g_trans_valid_cnt = 1;
+
+                       return ret;
+               }
+
+               ret = mb_svc_set_item_as_valid();
+
+               ret = mb_svc_sqlite3_commit_trans();
+               if (ret < 0) {
+                       mb_svc_debug
+                               ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+                       mb_svc_sqlite3_rollback_trans();
+
+                       g_cur_trans_valid_cnt = 0;
+                       g_trans_valid_cnt = 1;
+
+                       return ret;
+               }
+       }
+
+       g_cur_trans_valid_cnt = 0;
+       g_trans_valid_cnt = 1;
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_set_item_valid(const minfo_store_type storage_type, const char *full_path,
+                    int valid)
+{
+       mb_svc_debug("storage:%d", storage_type);
+       int ret;
+
+       if (storage_type != MINFO_PHONE && storage_type != MINFO_MMC) {
+               mb_svc_debug("storage type should be phone or mmc");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (g_cur_trans_valid_cnt < g_trans_valid_cnt) {
+               ret = mb_svc_set_item_as_valid_sql_add(full_path, valid);
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_set_item_as_valid_sql_add failed\n");
+                       return ret;
+               }
+
+               g_cur_trans_valid_cnt++;
+
+               return 0;
+       }
+
+       if (g_cur_trans_valid_cnt == g_trans_valid_cnt) {
+               ret = mb_svc_set_item_as_valid_sql_add(full_path, valid);
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_set_item_as_valid_sql_add failed\n");
+                       return ret;
+               }
+
+               g_cur_trans_valid_cnt = 0;
+
+               ret = mb_svc_sqlite3_begin_trans();
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+                       return ret;
+               }
+
+               ret = mb_svc_set_item_as_valid();
+               if (ret < 0) {
+                       mb_svc_debug
+                               ("mb_svc_set_item_as_valid failed.. Now start to rollback\n");
+                       mb_svc_sqlite3_rollback_trans();
+                       return ret;
+               }
+
+               ret = mb_svc_sqlite3_commit_trans();
+               if (ret < 0) {
+                       mb_svc_debug
+                               ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+                       mb_svc_sqlite3_rollback_trans();
+                       return ret;
+               }
+       }
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_delete_invalid_media_records(const minfo_store_type storage_type)
+{
+       mb_svc_debug("storage:%d", storage_type);
+       int ret;
+
+       if (storage_type != MINFO_PHONE && storage_type != MINFO_MMC) {
+               mb_svc_debug("storage type should be phone or mmc");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+#ifdef _PERFORMANCE_CHECK_
+       long start = 0L, end = 0L;
+       start = mediainfo_get_debug_time();
+#endif
+
+       ret = mb_svc_delete_invalid_media_records(storage_type);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_delete_invalid_media_records failed..Now Start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+               return ret;
+       }
+
+#ifdef _PERFORMANCE_CHECK_
+       end = mediainfo_get_debug_time();
+       mediainfo_print_debug_time_ex(start, end, __FUNCTION__, "time");
+#endif
+
+       return 0;
+}
+
+EXPORT_API int minfo_delete_tag(const char *media_id, const char *tag_name)
+{
+       int ret = -1;
+
+       if (tag_name == NULL) {
+               mb_svc_debug("tag_name is NULL!");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_delete_tag#tag_name: %s!", tag_name);
+#ifdef _PERFORMANCE_CHECK_
+       long start = mediainfo_get_debug_time();
+#endif
+       ret = mb_svc_sqlite3_begin_trans();
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+               return ret;
+       }
+
+       ret = mb_svc_delete_record_tag(tag_name, media_id);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_delete_record_tag fail..Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+               return ret;
+       }
+
+       ret = mb_svc_sqlite3_commit_trans();
+       if (ret < 0) {
+               mb_svc_debug
+                   ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+               mb_svc_sqlite3_rollback_trans();
+               return ret;
+       }
+
+#ifdef _PERFORMANCE_CHECK_
+       long end = mediainfo_get_debug_time();
+
+       double tag = ((double)(end - start) / (double)CLOCKS_PER_SEC);
+       mb_svc_debug("Delete Tag : %f", tag);
+#endif
+
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_rename_tag(const char *src_tagname, const char *dst_tag_name)
+{
+       int ret = -1;
+
+       if (src_tagname == NULL || dst_tag_name == NULL) {
+               mb_svc_debug("tag_name is NULL!");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (strlen(src_tagname) > MB_SVC_ARRAY_LEN_MAX
+           || strlen(dst_tag_name) > MB_SVC_ARRAY_LEN_MAX) {
+               mb_svc_debug("tag_name length is violation!");
+               return MB_SVC_ERROR_INTERNAL;
+       }
+
+       char *src_tag_escape = NULL;
+       char *dst_tag_escape = NULL;
+
+       src_tag_escape = sqlite3_mprintf("%q", src_tagname);
+       dst_tag_escape = sqlite3_mprintf("%q", dst_tag_name);
+
+       mb_svc_debug("minfo_rename_tag#src_tagname: %s!", src_tagname);
+       mb_svc_debug("minfo_rename_tag#dst_tag_name: %s!", dst_tag_name);
+
+       ret = mb_svc_rename_record_tag(src_tagname, dst_tag_name);
+
+       sqlite3_free(src_tag_escape);
+       sqlite3_free(dst_tag_escape);
+
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_rename_record_tag fail: %d!\n", ret);
+               return ret;
+       }
+
+       return 0;
+}
+
+EXPORT_API int
+minfo_rename_tag_by_id(const char *media_id, const char *src_tagname,
+                      const char *dst_tag_name)
+{
+       int ret = -1;
+
+       if (src_tagname == NULL || dst_tag_name == NULL) {
+               mb_svc_debug("tag_name is NULL!");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (strlen(src_tagname) > MB_SVC_ARRAY_LEN_MAX
+           || strlen(dst_tag_name) > MB_SVC_ARRAY_LEN_MAX) {
+               mb_svc_debug("tag_name length is violation!");
+               return MB_SVC_ERROR_INTERNAL;
+       }
+
+       char *src_tag_escape = NULL;
+       char *dst_tag_escape = NULL;
+       src_tag_escape = sqlite3_mprintf("%q", src_tagname);
+       dst_tag_escape = sqlite3_mprintf("%q", dst_tag_name);
+
+       mb_svc_debug("src_tagname: %s!", src_tagname);
+       mb_svc_debug("dst_tag_name: %s!", dst_tag_name);
+
+       ret =
+           mb_svc_rename_record_tag_by_id(media_id, src_tagname, dst_tag_name);
+
+       sqlite3_free(src_tag_escape);
+       sqlite3_free(dst_tag_escape);
+
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_rename_record_tag fail: %d!\n", ret);
+               return ret;
+       }
+
+       return 0;
+}
+
+EXPORT_API int minfo_add_tag(const char *media_id, const char *tag_name)
+{
+       int ret = -1;
+       bool tag_exist = FALSE;
+       mb_svc_tag_record_s tag_record = { 0 };
+
+       if (tag_name == NULL) {
+               mb_svc_debug("tag_name is NULL!");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+#ifdef _PERFORMANCE_CHECK_
+       long start = mediainfo_get_debug_time();
+#endif
+
+       mb_svc_debug("minfo_add_tag#media_id: %s!", media_id);
+       mb_svc_debug("minfo_add_tag#tag_name: %s!", tag_name);
+
+       if ((tag_record._id = mb_svc_get_tagid_by_tagname(tag_name)) > 0) {
+               mb_svc_debug("This tagname %s is exist");
+               tag_exist = TRUE;
+       }
+
+       strncpy(tag_record.tag_name, tag_name, MB_SVC_ARRAY_LEN_MAX + 1);
+
+       if (!tag_exist) {
+               ret = mb_svc_insert_record_tag(&tag_record);
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_insert_record_tag fail\n");
+                       return ret;
+               }
+       }
+
+       if (media_id != NULL) {
+               ret =
+                   mb_svc_insert_record_tag_map(media_id,
+                                                tag_record._id);
+               if (ret < 0) {
+                       mb_svc_debug("mb_svc_insert_record_tag_map fail\n");
+                       return ret;
+               }
+       }
+
+#ifdef _PERFORMANCE_CHECK_
+               long end = mediainfo_get_debug_time();
+
+               double tag = ((double)(end - start) / (double)CLOCKS_PER_SEC);
+               mb_svc_debug("Insert Tag : %f", tag);
+#endif
+       return 0;
+}
+
+EXPORT_API int
+minfo_get_media_list_by_tagname(const char *tag_name, bool with_meta,
+                               minfo_item_ite_cb func, void *user_data)
+{
+       mb_svc_debug("");
+       int err = 0;
+       int record_cnt = 0;
+       mb_svc_iterator_s mb_svc_iterator = { 0 };
+       mb_svc_tag_record_s tag_record = { 0 };
+       Mitem *mitem = NULL;
+       char *tag_name_escape_char = NULL;
+
+       if (tag_name == NULL) {
+               mb_svc_debug("tag_name is NULL!");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (func == NULL) {
+               mb_svc_debug("Func is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("tag_name:%s", tag_name);
+       tag_name_escape_char = sqlite3_mprintf("%q", tag_name);
+       err = mb_svc_tag_iter_start(tag_name_escape_char, NULL, &mb_svc_iterator);
+       sqlite3_free(tag_name_escape_char);
+
+       if (err < 0) {
+               mb_svc_debug("mb-svc iterator start failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (1) {
+               /* improve the performance of getting meida list. */
+               err =
+                   mb_svc_media_id_list_by_tag_iter_next(&mb_svc_iterator,
+                                                         &tag_record);
+
+               if (err == MB_SVC_NO_RECORD_ANY_MORE)
+                       break;
+
+               if (err < 0) {
+                       mb_svc_debug("mb-svc iterator get next recrod failed");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       return err;
+               }
+
+               record_cnt++;
+
+               mitem = minfo_media_item_new(tag_record.media_uuid, NULL);
+               if (with_meta && mitem) {
+                       mitem->meta_info = minfo_mmeta_new(mitem->uuid, NULL);
+               }
+
+               if (mitem) {
+                       func(mitem, user_data);
+               }
+       }
+
+       mb_svc_iter_finish(&mb_svc_iterator);
+
+       if (record_cnt == 0)
+               return MB_SVC_ERROR_DB_NO_RECORD;
+       else
+               return 0;
+}
+
+EXPORT_API int
+minfo_get_media_list_by_tagname_with_filter(const char *tag_name,
+                                           minfo_tag_filter filter,
+                                           minfo_item_ite_cb func,
+                                           void *user_data)
+{
+       mb_svc_debug("");
+       int err = 0;
+       int record_cnt = 0;
+       mb_svc_iterator_s mb_svc_iterator = { 0 };
+       mb_svc_tag_record_s tag_record = { 0 };
+       Mitem *mitem = NULL;
+       char *tag_name_escape_char = NULL;
+
+       if (tag_name == NULL) {
+               mb_svc_debug("tag_name is NULL!");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (func == NULL) {
+               mb_svc_debug("Func is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("tag_name:%s", tag_name);
+       tag_name_escape_char = sqlite3_mprintf("%q", tag_name);
+       err =
+           mb_svc_tag_iter_with_filter_start(tag_name_escape_char, filter,
+                                             &mb_svc_iterator);
+       sqlite3_free(tag_name_escape_char);
+
+       if (err < 0) {
+               mb_svc_debug("mb-svc iterator start failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (1) {
+               /* improve the performance of getting meida list. */
+               err =
+                   mb_svc_media_id_list_by_tag_iter_next(&mb_svc_iterator,
+                                                         &tag_record);
+
+               if (err == MB_SVC_NO_RECORD_ANY_MORE)
+                       break;
+
+               if (err < 0) {
+                       mb_svc_debug("mb-svc iterator get next recrod failed");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       return err;
+               }
+
+               record_cnt++;
+
+               mitem = minfo_media_item_new(tag_record.media_uuid, NULL);
+               if (filter.with_meta && mitem) {
+                       mitem->meta_info = minfo_mmeta_new(mitem->uuid, NULL);
+               }
+
+               if (mitem) {
+                       func(mitem, user_data);
+               }
+       }
+
+       mb_svc_iter_finish(&mb_svc_iterator);
+
+       if (record_cnt == 0)
+               return MB_SVC_ERROR_DB_NO_RECORD;
+       else
+               return 0;
+}
+
+EXPORT_API int
+minfo_get_media_count_by_tagname(const char *tag_name, int *count)
+{
+       mb_svc_debug("");
+       int ret = -1;
+
+       if (tag_name == NULL || count == NULL) {
+               mb_svc_debug("tag_name == NULL || count == NULL\n");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = mb_svc_get_media_count_by_tagname(tag_name, count);
+       if (ret < 0) {
+               mb_svc_debug
+                   ("Error: mb_svc_get_media_count_by_tagname failed\n");
+               return ret;
+       }
+
+       mb_svc_debug("record count = %d", *count);
+       return 0;
+}
+
+EXPORT_API int
+minfo_get_tag_list_by_media_id(const char *media_id, minfo_tag_ite_cb func,
+                              void *user_data)
+{
+       mb_svc_debug("");
+       int err = 0;
+       int record_cnt = 0;
+       mb_svc_iterator_s mb_svc_iterator = { 0 };
+       mb_svc_tag_record_s tag_record = { 0 };
+       Mtag *i_tag = NULL;
+
+       if (func == NULL) {
+               mb_svc_debug("Func is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       err = mb_svc_tag_iter_start(NULL, media_id, &mb_svc_iterator);
+
+       if (err < 0) {
+               mb_svc_debug("mb-svc iterator start failed");
+               return MB_SVC_ERROR_DB_INTERNAL;
+       }
+
+       while (1) {
+               /* improve the performance of getting meida list. */
+               err = mb_svc_tag_iter_next(&mb_svc_iterator, &tag_record);
+               if (err == MB_SVC_NO_RECORD_ANY_MORE)
+                       break;
+
+               if (err < 0) {
+                       mb_svc_debug("mb-svc iterator get next recrod failed");
+                       mb_svc_iter_finish(&mb_svc_iterator);
+                       return err;
+               }
+
+               record_cnt++;
+
+               i_tag = minfo_media_tag_new(-1, &tag_record);
+               if (i_tag) {
+                       err =
+                           mb_svc_get_media_count_by_tagname(i_tag->tag_name,
+                                                             &(i_tag->count));
+                       if (err < 0) {
+                               mb_svc_debug
+                                   ("mb_svc_get_media_count_by_tagname fails : %s",
+                                    i_tag->tag_name);
+                               minfo_destroy_mtype_item( i_tag );
+                       } else {
+                               mb_svc_debug("Tagname : %s  [%d]",
+                                            i_tag->tag_name, i_tag->count);
+                               func(i_tag, user_data);
+                       }
+               }
+       }
+
+       mb_svc_iter_finish(&mb_svc_iterator);
+
+       if (record_cnt == 0)
+               return MB_SVC_ERROR_DB_NO_RECORD;
+       else
+               return 0;
+}
+
+EXPORT_API int
+minfo_extract_thumbnail(const char *media_id, minfo_file_type content_type)
+{
+       mb_svc_debug("");
+
+       if (media_id == NULL || content_type <= MINFO_ITEM_NONE
+           || content_type >= MINFO_ITEM_ALL) {
+               mb_svc_debug
+                   ("media_id == NULL || content_type <= MINFO_ITEM_NONE || content_type >= MINFO_ITEM_ALL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       int err = -1;
+       mb_svc_media_record_s media_record = {"",};
+
+       err = mb_svc_get_media_record_by_id(media_id, &media_record);
+       if (err < 0) {
+               mb_svc_debug("mb_svc_get_media_record_by_id failed\n");
+               return err;
+       }
+
+       err =
+           _mb_svc_thumb_generate_hash_name(media_record.path,
+                                            media_record.thumbnail_path,
+                                            sizeof(media_record.
+                                                   thumbnail_path));
+
+       if (err < 0) {
+               mb_svc_debug("_mb_svc_thumb_generate_hash_name failed\n");
+               return err;
+       }
+
+       if (content_type == MINFO_ITEM_IMAGE) {
+
+               mb_svc_image_meta_record_s img_meta_record = {0,};
+               err =
+                   mb_svc_image_create_thumb_new(media_record.path,
+                                                 media_record.thumbnail_path,
+                                                 sizeof(media_record.
+                                                        thumbnail_path),
+                                                 &img_meta_record);
+               if (err < 0) {
+                       mb_svc_debug("mb_svc_image_create_thumb_new fails : %d",
+                                    err);
+                       return err;
+               }
+
+               err = mb_svc_update_record_media(&media_record);
+               if (err < 0) {
+                       mb_svc_debug("mb_svc_update_record_media fails : %d",
+                                    err);
+                       return err;
+               }
+               /* Update width and heigth to image meta table at this time, because of performance */
+               err =
+                   mb_svc_update_width_and_height(media_record.media_uuid,
+                                                  MINFO_ITEM_IMAGE,
+                                                  img_meta_record.width,
+                                                  img_meta_record.height);
+               if (err < 0) {
+                       mb_svc_debug
+                           ("mb_svc_update_width_and_height fails : %d", err);
+                       return err;
+               }
+
+       } else if (content_type == MINFO_ITEM_VIDEO) {
+
+               err =
+                   mb_svc_video_create_thumb(media_record.path,
+                                             media_record.thumbnail_path,
+                                             sizeof(media_record.
+                                                    thumbnail_path));
+               if (err < 0) {
+                       mb_svc_debug("mb_svc_video_create_thumb fails : %d",
+                                    err);
+                       return err;
+               }
+
+       } else {
+               mb_svc_debug("This is not image and not video");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       return 0;
+}
diff --git a/src/visual/minfo-bookmark.c b/src/visual/minfo-bookmark.c
new file mode 100755 (executable)
index 0000000..2fac8c5
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "minfo-bookmark.h"
+#include "media-svc-api.h"
+#include "media-svc-debug.h"
+#include "media-svc-error.h"
+#include <string.h>
+
+static void _minfo_mbookmark_init(Mbookmark *mbookmark);
+
+int minfo_mbookmark_load(Mbookmark *mbookmark)
+{
+       mb_svc_bookmark_record_s bookmark_record = { 0 };
+       int ret = 0;
+       int length = 0;
+
+       ret =
+           mb_svc_get_bookmark_record_by_id(mbookmark->_id, &bookmark_record);
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_get_bookmark_record_by_id failed");
+               return ret;
+       }
+
+       mbookmark->_id = bookmark_record._id;
+       mbookmark->position = bookmark_record.marked_time;
+
+       /* length = strlen(bookmark_record.thumbnail_path) + 1; */
+       length = MB_SVC_FILE_PATH_LEN_MAX + 1;
+       mbookmark->thumb_url = (char *)malloc(length);
+       if (mbookmark->thumb_url == NULL) {
+               return MB_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       memset(mbookmark->thumb_url, 0x00, length);
+       strncpy(mbookmark->thumb_url, bookmark_record.thumbnail_path, length);
+
+       mbookmark->media_uuid = (char *)malloc(MB_SVC_UUID_LEN_MAX + 1);
+       if (mbookmark->media_uuid == NULL) {
+               return MB_SVC_ERROR_OUT_OF_MEMORY;
+       }
+
+       memset(mbookmark->media_uuid, 0x00, MB_SVC_UUID_LEN_MAX + 1);
+       strncpy(mbookmark->media_uuid, bookmark_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+       return 0;
+}
+
+Mbookmark *minfo_mbookmark_new(int id)
+{
+       Mbookmark *bookmark = NULL;
+       int ret = 0;
+
+       bookmark = malloc(sizeof(Mbookmark));
+       if (bookmark == NULL) {
+               return NULL;
+       }
+
+       _minfo_mbookmark_init(bookmark);
+       if (id != -1) {
+               bookmark->_id = id;
+               ret = minfo_mbookmark_load(bookmark);
+               if (ret < 0) {
+                       free(bookmark);
+                       return NULL;
+               }
+       }
+
+       return bookmark;
+}
+
+void minfo_mbookmark_destroy(Mbookmark *mbookmark)
+{
+       if (mbookmark != NULL && IS_MINFO_MBOOKMARK(mbookmark)) {
+               mb_svc_debug("do free resource\n");
+               if (mbookmark->media_uuid) {
+                       free(mbookmark->media_uuid);
+               }
+               if (mbookmark->thumb_url) {
+                       free(mbookmark->thumb_url);
+               }
+               free(mbookmark);
+               mbookmark = NULL;
+       }
+
+}
+
+static void _minfo_mbookmark_init(Mbookmark *mbookmark)
+{
+       mbookmark->gtype = MINFO_TYPE_MBOOKMARK;
+
+       mbookmark->_id = -1;
+       mbookmark->media_uuid = NULL;
+       mbookmark->position = 0;
+       mbookmark->thumb_url = NULL;
+}
+
diff --git a/src/visual/minfo-cluster.c b/src/visual/minfo-cluster.c
new file mode 100755 (executable)
index 0000000..f08b5a9
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "minfo-cluster.h"
+#include "media-svc-api.h"
+#include "media-svc-util.h"
+#include "media-svc-error.h"
+#include <string.h>
+
+static void _minfo_mcluster_init(Mcluster *mcluster);
+
+int minfo_mcluster_load(Mcluster *mcluster)
+{
+       mb_svc_folder_record_s fd_record;
+       int ret = 0;
+       int length = 0;
+
+       ret = mb_svc_get_folder_record_by_id(mcluster->uuid, &fd_record);
+       if (ret < 0) {
+               return ret;
+       }
+
+       mcluster->thumb_url = NULL;
+       mcluster->mtime = (time_t) fd_record.modified_date;
+       mcluster->type = fd_record.storage_type;
+
+       mcluster->display_name = (char *)malloc(MB_SVC_FILE_NAME_LEN_MAX + 1);
+       if (mcluster->display_name == NULL) {
+               return MB_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       strncpy(mcluster->display_name, fd_record.display_name,
+               MB_SVC_FILE_NAME_LEN_MAX);
+
+       mcluster->count =
+           mb_svc_get_folder_content_count_by_folder_id(mcluster->uuid);
+       mcluster->sns_type = fd_record.sns_type;
+
+       length = strlen(fd_record.web_account_id) + 1;
+       mcluster->account_id = (char *)malloc(length);
+       if (mcluster->account_id == NULL) {
+               return MB_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       strncpy(mcluster->account_id, fd_record.web_account_id, length);
+
+       mcluster->lock_status = fd_record.lock_status;
+
+       length = strlen(fd_record.web_album_id) + 1;
+       mcluster->web_album_id = (char *)malloc(length);
+       if (mcluster->web_album_id == NULL) {
+               return MB_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       strncpy(mcluster->web_album_id, fd_record.web_album_id, length);
+
+       mcluster->_reserved = NULL;
+
+       return 0;
+}
+
+Mcluster *minfo_mcluster_new(const char *uuid)
+{
+       Mcluster *mcluster = NULL;
+       int ret = 0;
+
+       mcluster = (Mcluster *) malloc(sizeof(Mcluster));
+       if (mcluster == NULL) {
+               return NULL;
+       }
+
+       _minfo_mcluster_init(mcluster);
+
+       if (uuid != NULL) {
+               mcluster->uuid = (char *)malloc(MB_SVC_UUID_LEN_MAX + 1);
+               strncpy(mcluster->uuid, uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+               ret = minfo_mcluster_load(mcluster);
+               if (ret < 0) {
+                       minfo_mcluster_destroy(mcluster);
+                       return NULL;
+               }
+       }
+
+       return mcluster;
+}
+
+void minfo_mcluster_destroy(Mcluster *mcluster)
+{
+       if (mcluster != NULL) {
+               if (mcluster->uuid) {
+                       free(mcluster->uuid);
+               }
+               if (mcluster->display_name) {
+                       free(mcluster->display_name);
+               }
+               if (mcluster->account_id) {
+                       free(mcluster->account_id);
+               }
+               if (mcluster->web_album_id) {
+                       free(mcluster->web_album_id);
+               }
+               free(mcluster);
+               mcluster = NULL;
+       }
+}
+
+static void _minfo_mcluster_init(Mcluster *mcluster)
+{
+       mcluster->gtype = MINFO_TYPE_MCLUSTER;
+
+       mcluster->uuid = NULL;
+       mcluster->thumb_url = NULL;
+       mcluster->mtime = 0;
+       mcluster->type = 0;
+       mcluster->display_name = NULL;
+       mcluster->count = 0;
+       mcluster->sns_type = 0;
+       mcluster->account_id = NULL;
+       mcluster->web_album_id = NULL;
+       mcluster->_reserved = NULL;
+}
+
diff --git a/src/visual/minfo-item.c b/src/visual/minfo-item.c
new file mode 100755 (executable)
index 0000000..d8c8a42
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "minfo-item.h"
+#include "minfo-meta.h"
+#include "media-svc-api.h"
+#include "media-svc-util.h"
+#include "media-svc-debug.h"
+#include "media-svc-error.h"
+#include <string.h>
+
+static void _minfo_mitem_init(Mitem *mitem);
+
+static int minfo_mitem_load(Mitem *mitem, mb_svc_media_record_s * p_md_record)
+{
+       mb_svc_media_record_s md_record = {"",};
+       int ret = 0;
+       int length = 0;
+
+       if (p_md_record == NULL) {
+               ret = mb_svc_get_media_record_by_id(mitem->uuid, &md_record);
+       } else {
+               md_record = *p_md_record;
+       }
+
+       if (ret < 0) {
+               return ret;
+       }
+
+       //mitem->cluster_id = md_record.folder_id;
+       if (mitem->cluster_uuid == NULL) 
+               mitem->cluster_uuid = (char *)malloc(MB_SVC_UUID_LEN_MAX + 1);
+
+       strncpy(mitem->cluster_uuid, md_record.folder_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+       if (strlen(md_record.http_url) != 0) {
+               length = MB_SVC_DIR_PATH_LEN_MAX + 1;
+               mitem->file_url = (char *)malloc(length);
+               if (mitem->file_url == NULL) {
+                       return MB_SVC_ERROR_OUT_OF_MEMORY;
+               }
+               strncpy(mitem->file_url, md_record.http_url, length);
+               mitem->file_url[length - 1] = '\0';
+       } else {
+               length = strlen(md_record.path) + 1;
+               mitem->file_url = (char *)malloc(length);
+               if (mitem->file_url == NULL) {
+                       return MB_SVC_ERROR_OUT_OF_MEMORY;
+               }
+               strncpy(mitem->file_url, md_record.path, length);
+               mitem->file_url[length - 1] = '\0';
+       }
+
+       length = MB_SVC_FILE_PATH_LEN_MAX + 1;
+       mitem->thumb_url = (char *)malloc(length);
+       if (mitem->thumb_url == NULL) {
+               return MB_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       memset(mitem->thumb_url, 0x00, length);
+       strncpy(mitem->thumb_url, md_record.thumbnail_path, length);
+       mitem->thumb_url[length - 1] = '\0';
+
+       mitem->mtime = (time_t) md_record.modified_date;
+
+       length = MB_SVC_FILE_EXT_LEN_MAX + 1;
+       mitem->ext = (char *)malloc(length);
+       if (mitem->ext == NULL) {
+               return MB_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       memset(mitem->ext, 0x00, length);
+       _mb_svc_get_file_ext(md_record.display_name, mitem->ext);
+
+       mitem->type = md_record.content_type;
+       length = MB_SVC_FILE_NAME_LEN_MAX + 1;
+       mitem->display_name = (char *)malloc(length);
+       if (mitem->display_name == NULL) {
+               return MB_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       memset(mitem->display_name, 0x00, length);
+       strncpy(mitem->display_name, md_record.display_name, length);
+
+       mitem->rate = md_record.rate;
+       mitem->_reserved = NULL;
+
+       return 0;
+}
+
+Mitem *minfo_mitem_new(const char *uuid)
+{
+       return minfo_media_item_new(uuid, NULL);
+}
+
+Mitem *minfo_media_item_new(const char *uuid, mb_svc_media_record_s * p_md_record)
+{
+       Mitem *mitem = NULL;
+       int ret = 0;
+
+       mitem = (Mitem *) malloc(sizeof(Mitem));
+       if (mitem == NULL) {
+               return NULL;
+       }
+
+       _minfo_mitem_init(mitem);
+
+       if (p_md_record) {
+               mitem->uuid = (char *)malloc(MB_SVC_UUID_LEN_MAX + 1);
+               strncpy(mitem->uuid, p_md_record->media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+               ret = minfo_mitem_load(mitem, p_md_record);
+       } else if (uuid != NULL) {
+               mitem->uuid = (char *)malloc(MB_SVC_UUID_LEN_MAX + 1);
+               strncpy(mitem->uuid, uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+               ret = minfo_mitem_load(mitem, NULL);
+               if (ret < 0) {
+                       free(mitem);
+                       return NULL;
+               }
+       }
+
+       return mitem;
+}
+
+void minfo_mitem_destroy(Mitem *mitem)
+{
+       if (mitem != NULL && IS_MINFO_MITEM(mitem)) {
+               mb_svc_debug("do free resource %s\n", mitem->file_url);
+               if (mitem->uuid) {
+                       free(mitem->uuid);
+               }
+               if (mitem->cluster_uuid) {
+                       free(mitem->cluster_uuid);
+               }
+               if (mitem->file_url) {
+                       free(mitem->file_url);
+               }
+               if (mitem->thumb_url) {
+                       free(mitem->thumb_url);
+               }
+               if (mitem->ext) {
+                       free(mitem->ext);
+               }
+               if (mitem->display_name) {
+                       free(mitem->display_name);
+               }
+               if (mitem->meta_info) {
+                       minfo_mmeta_destroy(mitem->meta_info);
+               }
+               mitem->gtype = 0;
+               free(mitem);
+
+               mitem = NULL;
+       }
+}
+
+static void _minfo_mitem_init(Mitem *mitem)
+{
+       mitem->gtype = MINFO_TYPE_MITEM;
+
+       //mitem->_id = -1;
+       mitem->uuid = NULL;
+       mitem->file_url = NULL;
+       mitem->thumb_url = NULL;;
+       mitem->mtime = 0;
+       mitem->ext = NULL;
+       mitem->type = 0;
+       //mitem->cluster_id = 0;
+       mitem->cluster_uuid = NULL;
+       mitem->display_name = NULL;
+       mitem->rate = 0;
+       mitem->meta_info = NULL;
+       mitem->_reserved = NULL;
+}
diff --git a/src/visual/minfo-meta.c b/src/visual/minfo-meta.c
new file mode 100755 (executable)
index 0000000..33b6089
--- /dev/null
@@ -0,0 +1,369 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "minfo-meta.h"
+#include "minfo-api.h"
+#include "minfo-bookmark.h"
+#include "media-svc-api.h"
+#include "media-svc-util.h"
+#include "media-svc-debug.h"
+#include "media-svc-error.h"
+#include <string.h>
+
+static void _minfo_mmeta_init(Mmeta *mmeta);
+
+int minfo_mmeta_load(Mmeta *mmeta, mb_svc_media_record_s *p_md_record)
+{
+       int ret = -1;
+       mb_svc_media_record_s media_record = {"",};
+       mb_svc_image_meta_record_s image_meta_record = {0,};
+       mb_svc_video_meta_record_s video_meta_record = {0,};
+
+       if (p_md_record == NULL) {
+               ret =
+                   mb_svc_get_media_record_by_id(mmeta->media_uuid,
+                                                 &media_record);
+               if (ret < 0) {
+                       mb_svc_debug
+                           ("minfo_get_meta_info:get media record by id failed\n");
+                       return ret;
+               }
+       } else {
+               media_record = *p_md_record;
+       }
+
+       if (media_record.content_type == MINFO_ITEM_IMAGE) {
+               ret =
+                   mb_svc_get_image_record_by_media_id(mmeta->media_uuid,
+                                                       &image_meta_record);
+               if (ret < 0) {
+                       return ret;
+               }
+
+               mmeta->longitude = image_meta_record.longitude;
+               mmeta->latitude = image_meta_record.latitude;
+               mmeta->type = media_record.content_type;
+               mmeta->description = NULL;
+
+               mmeta->width = image_meta_record.width;
+               mmeta->height = image_meta_record.height;
+               mmeta->datetaken = image_meta_record.datetaken;
+
+               mmeta->image_info = minfo_mimage_new(NULL);
+               if (mmeta->image_info == NULL) {
+                       return MB_SVC_ERROR_INTERNAL;
+               }
+               mmeta->image_info->orientation = image_meta_record.orientation;
+       }
+
+       else if (media_record.content_type == MINFO_ITEM_VIDEO) {
+               ret =
+                   mb_svc_get_video_record_by_media_id(mmeta->media_uuid,
+                                                       &video_meta_record);
+               if (ret < 0) {
+                       return ret;
+               }
+
+               mmeta->type = media_record.content_type;
+               mmeta->description = NULL;
+               mmeta->longitude = video_meta_record.longitude;
+               mmeta->latitude = video_meta_record.latitude;
+
+               mmeta->width = video_meta_record.width;
+               mmeta->height = video_meta_record.height;
+               mmeta->datetaken = video_meta_record.datetaken;
+
+               mmeta->video_info = minfo_mvideo_new(mmeta->media_uuid);
+
+               if (mmeta->video_info == NULL) {
+                       return MB_SVC_ERROR_INTERNAL;
+               }
+       }
+
+       return 0;
+}
+
+static void _minfo_mmeta_init(Mmeta *mmeta)
+{
+       mmeta->gtype = MINFO_TYPE_MMETA;
+
+       mmeta->media_uuid = NULL;
+       mmeta->type = 0;
+       mmeta->description = NULL;
+       mmeta->image_info = NULL;
+       mmeta->video_info = NULL;
+       mmeta->_reserved = NULL;
+       mmeta->longitude = 0.0f;
+       mmeta->latitude = 0.0f;
+}
+
+Mmeta *minfo_mmeta_new(const char *media_uuid, mb_svc_media_record_s *p_md_record)
+{
+       Mmeta *mmeta = NULL;
+       int ret = 0;
+
+       mmeta = (Mmeta *) malloc(sizeof(Mmeta));
+       if (mmeta == NULL) {
+               return NULL;
+       }
+
+       _minfo_mmeta_init(mmeta);
+
+       mmeta->media_uuid = (char *)malloc(MB_SVC_UUID_LEN_MAX + 1);
+
+       if (p_md_record) {
+               strncpy(mmeta->media_uuid, p_md_record->media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+               ret = minfo_mmeta_load(mmeta, p_md_record);
+       } else if (media_uuid != NULL) {
+               strncpy(mmeta->media_uuid, media_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+               ret = minfo_mmeta_load(mmeta, NULL);
+               if (ret < 0) {
+                       free(mmeta);
+                       return NULL;
+               }
+       } else {
+               free(mmeta);
+               return NULL;
+       }
+
+       return mmeta;
+}
+
+void minfo_mmeta_destroy(Mmeta *mmeta)
+{
+       if (mmeta != NULL && IS_MINFO_MMETA(mmeta)) {
+               if (mmeta->type == MINFO_ITEM_IMAGE && mmeta->image_info) {
+                       minfo_mimage_destroy(mmeta->image_info);
+               }
+               if (mmeta->type == MINFO_ITEM_VIDEO && mmeta->video_info) {
+                       minfo_mvideo_destroy(mmeta->video_info);
+               }
+               if (mmeta->media_uuid) {
+                       free(mmeta->media_uuid);
+               }
+               if (mmeta->description) {
+                       free(mmeta->description);
+               }
+               free(mmeta);
+               mmeta = NULL;
+       }
+}
+
+/*--------------------------mvideo-----------------------------*/
+static void _minfo_mvideo_init(Mvideo *mvideo);
+
+static int _minfo_bm_ite_fn(Mbookmark *bookmark, void *user_data)
+{
+       GList **list = (GList **) user_data;
+       *list = g_list_append(*list, bookmark);
+
+       return 0;
+}
+
+int minfo_mvideo_load(const char *media_id, Mvideo *mvideo)
+{
+       mb_svc_video_meta_record_s video_meta_record = { 0 };
+       int ret = 0;
+       int length = 0;
+
+       ret = mb_svc_get_video_record_by_media_id(media_id, &video_meta_record);
+       if (ret < 0) {
+               return ret;
+       }
+
+       length = strlen(video_meta_record.album) + 1;
+       mvideo->album_name = (char *)malloc(length);
+       if (mvideo->album_name == NULL) {
+               return MB_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       memset(mvideo->album_name, 0x00, length);
+       strncpy(mvideo->album_name, video_meta_record.album, length);
+
+       length = strlen(video_meta_record.artist) + 1;
+       mvideo->artist_name = (char *)malloc(length);
+       if (mvideo->artist_name == NULL) {
+               return MB_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       memset(mvideo->artist_name, 0x00, length);
+       strncpy(mvideo->artist_name, video_meta_record.artist, length);
+
+       length = strlen(video_meta_record.title) + 1;
+       mvideo->title = (char *)malloc(length);
+       if (mvideo->title == NULL) {
+               return MB_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       memset(mvideo->title, 0x00, length);
+       strncpy(mvideo->title, video_meta_record.title, length);
+
+       mvideo->last_played_pos = video_meta_record.last_played_time;
+       mvideo->duration = video_meta_record.duration;
+
+       length = strlen(video_meta_record.youtube_category) + 1;
+       mvideo->web_category = (char *)malloc(length);
+       if (mvideo->web_category == NULL) {
+               return MB_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       memset(mvideo->web_category, 0x00, length);
+
+       strncpy(mvideo->web_category, video_meta_record.youtube_category,
+               length);
+
+       GList *tmp_list = NULL;
+       minfo_get_bookmark_list(media_id, _minfo_bm_ite_fn, &tmp_list);
+
+       mvideo->bookmarks = tmp_list;
+
+       mvideo->_reserved = NULL;
+
+       return 0;
+}
+
+static void _minfo_mvideo_init(Mvideo *mvideo)
+{
+       mvideo->gtype = MINFO_TYPE_MVIDEO;
+
+       mvideo->album_name = NULL;
+       mvideo->artist_name = NULL;
+       mvideo->title = NULL;
+       mvideo->last_played_pos = 0;
+       mvideo->duration = 0;
+       mvideo->web_category = NULL;
+       mvideo->bookmarks = NULL;
+       mvideo->_reserved = NULL;
+}
+
+Mvideo *minfo_mvideo_new(const char *id)
+{
+       Mvideo *mvideo = NULL;
+       int ret = 0;
+
+       mvideo = (Mvideo *) malloc(sizeof(Mvideo));
+       if (mvideo == NULL) {
+               return NULL;
+       }
+
+       if (id == NULL) {
+               _minfo_mvideo_init(mvideo);
+       } else {
+               ret = minfo_mvideo_load(id, mvideo);
+               if (ret < 0) {
+                       minfo_mvideo_destroy(mvideo);
+                       return NULL;
+               }
+       }
+
+       return mvideo;
+}
+
+void minfo_mvideo_destroy(Mvideo *mvideo)
+{
+       int i = 0;
+       Mbookmark *bookmark;
+       if (mvideo != NULL && IS_MINFO_MVIDEO(mvideo)) {
+               if (mvideo->album_name) {
+                       free(mvideo->album_name);
+               }
+               if (mvideo->artist_name) {
+                       free(mvideo->artist_name);
+               }
+               if (mvideo->title) {
+                       free(mvideo->title);
+               }
+               if (mvideo->web_category) {
+                       free(mvideo->web_category);
+               }
+               if (mvideo->bookmarks) {
+                       for (i = 0;
+                            i < g_list_length((GList *) mvideo->bookmarks);
+                            i++) {
+                               bookmark =
+                                   (Mbookmark *) g_list_nth_data((GList *)
+                                                                 mvideo->
+                                                                 bookmarks, i);
+                               if (bookmark)
+                                       minfo_mbookmark_destroy(bookmark);
+                       }
+                       g_list_free(mvideo->bookmarks);
+               }
+               free(mvideo);
+               mvideo = NULL;
+       }
+
+}
+
+/*-------------------------mimage--------------------------*/
+static void _minfo_mimage_init(Mimage *mimage);
+
+int minfo_mimage_load(const char *media_id, Mimage *mimage)
+{
+       mb_svc_image_meta_record_s image_meta_record = { 0 };
+       int ret = 0;
+
+       ret = mb_svc_get_image_record_by_media_id(media_id, &image_meta_record);
+       if (ret < 0) {
+               return ret;
+       }
+
+       mimage->orientation = image_meta_record.orientation;
+       mimage->_reserved = NULL;
+
+       return 0;
+}
+
+Mimage *minfo_mimage_new(const char *id)
+{
+       Mimage *mimage = NULL;
+       int ret = 0;
+
+       mimage = (Mimage *) malloc(sizeof(Mimage));
+       if (mimage == NULL) {
+               return NULL;
+       }
+
+       if (id == NULL) {
+               _minfo_mimage_init(mimage);
+       } else {
+               ret = minfo_mimage_load(id, mimage);
+               if (ret < 0) {
+                       free(mimage);
+                       return NULL;
+               }
+       }
+
+       return mimage;
+}
+
+void minfo_mimage_destroy(Mimage *mimage)
+{
+       if (mimage != NULL && IS_MINFO_MIMAGE(mimage)) {
+               free(mimage);
+               mimage = NULL;
+       }
+}
+
+static void _minfo_mimage_init(Mimage *mimage)
+{
+       mimage->gtype = MINFO_TYPE_MIMAGE;
+
+       mimage->orientation = 0;
+       mimage->_reserved = NULL;
+}
diff --git a/src/visual/minfo-streaming.c b/src/visual/minfo-streaming.c
new file mode 100755 (executable)
index 0000000..170906e
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "minfo-streaming.h"
+#include "media-svc-api.h"
+#include "media-svc-util.h"
+
+static void _minfo_mstreaming_init(Mstreaming *mstreaming);
+
+int minfo_mstreaming_load(Mstreaming *mstreaming)
+{
+       return 0;
+}
+
+Mstreaming *minfo_mstreaming_new(int id)
+{
+       Mstreaming *mstreaming = NULL;
+       int ret = 0;
+
+       mstreaming = (Mstreaming *) malloc(sizeof(Mstreaming));
+       if (mstreaming == NULL) {
+               return NULL;
+       }
+
+       _minfo_mstreaming_init(mstreaming);
+       if (id != -1) {
+               mstreaming->_id = id;
+               ret = minfo_mstreaming_load(mstreaming);
+               if (ret < 0) {
+                       free(mstreaming);
+                       return NULL;
+               }
+       }
+
+       return mstreaming;
+}
+
+void minfo_mstreaming_destroy(Mstreaming *mstreaming)
+{
+       if (mstreaming != NULL) {
+               /* todo free resource */
+               free(mstreaming);
+       }
+}
+
+static void _minfo_mstreaming_init(Mstreaming *mstreaming)
+{
+       mstreaming->gtype = MINFO_TYPE_MSTREAMING;
+
+       mstreaming->_id = -1;
+       mstreaming->cluster_id = 0;
+       mstreaming->http_url = NULL;
+       mstreaming->thumb_url = NULL;
+       mstreaming->duration = 0;
+       mstreaming->title = NULL;
+       mstreaming->description = NULL;
+}
+
diff --git a/src/visual/minfo-tag.c b/src/visual/minfo-tag.c
new file mode 100755 (executable)
index 0000000..be0e077
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "minfo-tag.h"
+#include "minfo-meta.h"
+#include "media-svc-api.h"
+#include "media-svc-util.h"
+#include "media-svc-debug.h"
+#include "media-svc-error.h"
+#include <string.h>
+
+static bool _minfo_mtag_load(Mtag *mtag, mb_svc_tag_record_s *p_tag_record);
+
+static bool _minfo_mtag_load(Mtag *mtag, mb_svc_tag_record_s *p_tag_record)
+{
+       mb_svc_tag_record_s mtag_record = { 0 };
+       int ret = 0;
+
+       if (p_tag_record == NULL) {
+               ret = mb_svc_get_media_tag_by_id(mtag->_id, &mtag_record);
+       } else {
+               mtag_record = *p_tag_record;
+       }
+
+       if (ret < 0) {
+               return ret;
+       }
+
+       mtag->tag_name = (char *)malloc(MB_SVC_ARRAY_LEN_MAX + 1);
+       if (mtag->tag_name == NULL) {
+               return MB_SVC_ERROR_OUT_OF_MEMORY;
+       }
+       strncpy(mtag->tag_name, mtag_record.tag_name, MB_SVC_ARRAY_LEN_MAX + 1);
+
+       return 0;
+}
+
+Mtag *minfo_media_tag_new(int id, mb_svc_tag_record_s * p_tag_record)
+{
+       Mtag *mtag = NULL;
+       int ret = 0;
+
+       mtag = (Mtag *) malloc(sizeof(Mtag));
+       if (mtag == NULL) {
+               return NULL;
+       }
+
+       mtag->gtype = MINFO_TYPE_MTAG;
+       mtag->tag_name = NULL;
+
+       if (p_tag_record) {
+               //mtag->media_id = p_tag_record->media_id;
+               mtag->_id = p_tag_record->_id;
+               ret = _minfo_mtag_load(mtag, p_tag_record);
+       } else if (id != -1) {
+               mtag->_id = id;
+               ret = _minfo_mtag_load(mtag, NULL);
+               if (ret < 0) {
+                       minfo_media_tag_destroy(mtag);
+                       return NULL;
+               }
+       }
+
+       return mtag;
+}
+
+void minfo_media_tag_destroy(Mtag *i_tag)
+{
+       if (i_tag != NULL && IS_MINFO_MTAG(i_tag)) {
+               mb_svc_debug("do free resource %p\n", i_tag);
+               if (i_tag->tag_name) {
+                       free(i_tag->tag_name);
+               }
+
+               i_tag->gtype = 0;
+               free(i_tag);
+
+               i_tag = NULL;
+       }
+}
+
diff --git a/test/audio/Makefile b/test/audio/Makefile
new file mode 100644 (file)
index 0000000..c00667e
--- /dev/null
@@ -0,0 +1,14 @@
+CC =gcc
+LIBS = libmedia-info
+
+OBJS = audio_svc_test.o
+SRCS = audio_svc_test.c
+TARGET = audio-svc-test
+
+TARGET : $(OBJS)
+       $(CC) -o $(TARGET) $(OBJS) `pkg-config $(LIBS) --cflags --libs` -g
+$(OBJS) : $(SRCS)
+       $(CC) -c $(SRCS) `pkg-config $(LIBS) --cflags --libs` -g
+clean :
+       rm $(TARGET)
+       rm $(OBJS)
diff --git a/test/audio/audio_svc_test.c b/test/audio/audio_svc_test.c
new file mode 100755 (executable)
index 0000000..02897fd
--- /dev/null
@@ -0,0 +1,663 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <audio-svc.h>
+#include <audio-svc-error.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <dirent.h>
+
+void insert_into_db(const char * dir_path);
+//void list_items(int count, mp_search_record_t *tracks);
+void msg_print(int line, char *msg);
+
+int main()
+{
+       int ret = AUDIO_SVC_ERROR_NONE;;
+       char * audio_id = NULL;
+       int size = 0;
+       int idx=0, j;
+       int rows = -1;
+       AudioHandleType *tracks = NULL;
+       AudioHandleType *item = NULL;
+       AudioHandleType  *groups = NULL;
+       
+       //db open ==================================================
+       ret = audio_svc_open();
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer to open music database");
+               return -1;
+       }
+#if 0
+       //create table test ==================================================
+       ret = audio_svc_create_table();
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer to create table");
+               return -1;
+       }
+#endif
+#if 0
+       //insert music files to db ==================================================
+       ret = audio_svc_delete_all(AUDIO_SVC_STORAGE_PHONE);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer to delete all items on phone");
+               return -1;
+       }
+       //insert_into_db("/opt/media/Sounds/Music");
+#endif
+       //iterate all tracks and get the info of tracks ==================================================
+       msg_print(__LINE__, "iterate all tracks");
+       ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &rows);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer to delete all items on phone");
+               return -1;
+       }
+
+       if(rows < 1) {
+               msg_print(__LINE__, "there is no item");
+               return -1;
+       }
+       else
+               fprintf(stderr, "rows = [%d]\n", rows);
+       
+       ret = audio_svc_list_item_new(&tracks, rows);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer to alloc memory for list item");
+               return -1;
+       }
+       
+       ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,
+               NULL, //type_string,
+               NULL, //type_string2,
+               NULL, //filter_string,
+               NULL, //filter_string2,
+               0, //offset,
+               rows, //rows,
+               tracks
+               );
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer to get list item");
+               return -1;
+       }
+       
+       ret = audio_svc_item_new(&item);
+       for (idx = 0; idx < rows; idx++)
+       {
+               ret = audio_svc_list_item_get_val(tracks, idx, AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, &size, -1);
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       msg_print(__LINE__, "errer audio_svc_list_item_get_val");
+                       return -1;
+               }
+               fprintf(stderr, "[audio_id] = %s \n", audio_id);
+               ret = audio_svc_get_item_by_audio_id(audio_id, item);
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       msg_print(__LINE__, "errer to get item by audio_id");
+                       return -1;
+               }
+               
+               {
+                       char *audio_id = NULL, *path = NULL, *title = NULL, *album = NULL, *artist = NULL, *thumbname = NULL, *year = NULL;
+                       char thumb_path[AUDIO_SVC_PATHNAME_SIZE] = {0};
+                       int size = -1;
+                       ret = audio_svc_item_get_val(item,
+                               AUDIO_SVC_TRACK_DATA_AUDIO_ID, &audio_id, &size,
+                               AUDIO_SVC_TRACK_DATA_PATHNAME, &path, &size,
+                               AUDIO_SVC_TRACK_DATA_TITLE, &title, &size,
+                               AUDIO_SVC_TRACK_DATA_ALBUM, &album, &size,
+                               AUDIO_SVC_TRACK_DATA_ARTIST, &artist, &size,
+                               AUDIO_SVC_TRACK_DATA_THUMBNAIL_PATH, &thumbname, &size,
+                               AUDIO_SVC_TRACK_DATA_YEAR, &year, &size,
+                               -1);
+                       if (ret != AUDIO_SVC_ERROR_NONE) {
+                               msg_print(__LINE__, "errer audio_svc_item_get_val");
+                               return -1;
+                       }
+                       fprintf(stderr, "**** ITEM INFO[%d] ****\n", idx);
+                       fprintf(stderr, "       **audio_id = %s\n", audio_id);
+                       fprintf(stderr, "       **path = %s\n", path);
+                       fprintf(stderr, "       **title = %s\n", title);
+                       fprintf(stderr, "       **album = %s\n", album);
+                       fprintf(stderr, "       **artist = %s\n", artist);
+                       fprintf(stderr, "       **thumb = %s\n", thumbname);
+                       fprintf(stderr, "       **album = %s\n", album);
+                       fprintf(stderr, "       **year = %s\n", year);
+                       
+
+                       ret = audio_svc_get_thumbnail_path_by_path(path, thumb_path, AUDIO_SVC_PATHNAME_SIZE);
+                       if (ret != AUDIO_SVC_ERROR_NONE) {
+                               msg_print(__LINE__, "errer audio_svc_item_get_val");
+                               return -1;
+                       }
+                       fprintf(stderr, "       **thumb_path = %s\n\n", thumb_path);
+               }
+
+       }
+       
+       ret = audio_svc_item_free(item);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_item_free");
+               return -1;
+       }
+       ret = audio_svc_list_item_free(tracks);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_list_item_free");
+               return -1;
+       }
+
+#if 0
+       ret = audio_svc_update_item_metadata(audio_id, 
+                       AUDIO_SVC_TRACK_DATA_PLAYED_COUNT, 5,
+                       AUDIO_SVC_TRACK_DATA_PLAYED_TIME, 5,
+                       AUDIO_SVC_TRACK_DATA_ADDED_TIME, 5,
+                       AUDIO_SVC_TRACK_DATA_RATING,     AUDIO_SVC_RATING_5,
+                       AUDIO_SVC_TRACK_DATA_TITLE, "Test title", strlen("Test title"),
+                       AUDIO_SVC_TRACK_DATA_ARTIST, NULL, 0,
+                       AUDIO_SVC_TRACK_DATA_ALBUM, "Test album", strlen("Test album"),
+                       AUDIO_SVC_TRACK_DATA_GENRE, "Test genre", strlen("Test genre"),
+                       AUDIO_SVC_TRACK_DATA_AUTHOR, "Test author", strlen("Test author"),
+                       AUDIO_SVC_TRACK_DATA_DESCRIPTION, "Test description", strlen("Test description"),
+                       AUDIO_SVC_TRACK_DATA_YEAR, 2011,
+                       AUDIO_SVC_TRACK_DATA_TRACK_NUM, 10,
+                       AUDIO_SVC_TRACK_DATA_ALBUM_RATING, AUDIO_SVC_RATING_5,
+                       -1);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_update_item_metadata");
+               return -1;
+       }
+#endif
+       //iterate all albums and its tracks ==================================================
+       msg_print(__LINE__, "iterate all albums and its tracks");
+
+       ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ALBUM, NULL, NULL, NULL, NULL, &rows);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_count_group_item");
+               return -1;
+       }
+       if(rows < 1) {
+               msg_print(__LINE__, "there is no group item");
+               return -1;
+       }
+       else
+               fprintf(stderr, "rows = [%d]\n", rows);
+       
+       ret = audio_svc_group_item_new(&groups, rows);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_list_item_new");
+               return -1;
+       }
+       
+       ret = audio_svc_get_group_item(         AUDIO_SVC_GROUP_BY_ALBUM, //group_type,
+               NULL, //limit_string1,
+               NULL, //limit_string2,
+               NULL, //filter_string,
+               NULL, //filter_string2,
+               0, //offset,
+               rows, //rows,
+               groups);
+
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_get_group_item");
+               return -1;
+       }
+       
+       for (idx = 0; idx < rows; idx++) {
+               char *main_info = NULL, *sub_info = NULL, *thumbname = NULL;
+               int album_rating = 0;
+               int size = 0;
+               int count = 0;
+               
+               ret = audio_svc_group_item_get_val(groups, idx , 
+                       AUDIO_SVC_GROUP_ITEM_THUMBNAIL_PATH, &thumbname, &size,
+                       AUDIO_SVC_GROUP_ITEM_MAIN_INFO, &main_info, &size,
+                       AUDIO_SVC_GROUP_ITEM_SUB_INFO, &sub_info, &size,
+                       AUDIO_SVC_GROUP_ITEM_RATING, &album_rating,
+                       -1);
+
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       msg_print(__LINE__, "errer audio_svc_group_item_get_val");
+                       return -1;
+               }
+               
+               fprintf(stderr, "**** GROUP INFO[%d] ****\n", idx);
+               fprintf(stderr, "       **main_info = %s\n", main_info);
+               fprintf(stderr, "       **sub_info = %s\n", sub_info);
+               fprintf(stderr, "       **thumbname = %s\n", thumbname);
+               fprintf(stderr, "       **album_rating = %d\n\n", album_rating);
+               
+               //iterate tracks of albums ==================================================
+               ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_BY_ALBUM, main_info, "", "", "", &count);
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       msg_print(__LINE__, "errer audio_svc_count_list_item");
+                       return -1;
+               }
+               if(count < 1) {
+                       msg_print(__LINE__, "there is no item");
+                       return -1;
+               }
+               else
+                       fprintf(stderr, "       rows = [%d]\n", count);
+
+               ret = audio_svc_list_item_new(&tracks, count);
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       msg_print(__LINE__, "errer audio_svc_list_item_new");
+                       return -1;
+               }
+
+               ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_BY_ALBUM, main_info, NULL, NULL, NULL, 0, count, tracks);
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       msg_print(__LINE__, "errer audio_svc_list_item_new");
+                       ret = audio_svc_group_item_free(groups);
+                       if (ret != AUDIO_SVC_ERROR_NONE) {
+                               msg_print(__LINE__, "errer audio_svc_list_item_free");
+                               return -1;
+                       }
+                       return -1;
+               }
+               
+               for (j = 0; j < count; j++)
+               {
+                       char *audio_id = NULL, *title = NULL, *artist = NULL, *thumbname = NULL, *pathname = NULL;
+                       int rating = 0;
+                       int duration = 0;
+                       int size = 0;
+                                               
+                       ret = audio_svc_list_item_get_val(tracks, j , 
+                               AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, &size,
+                               AUDIO_SVC_LIST_ITEM_THUMBNAIL_PATH, &thumbname, &size,
+                               AUDIO_SVC_LIST_ITEM_TITLE, &title, &size,
+                               AUDIO_SVC_LIST_ITEM_ARTIST, &artist, &size,
+                               AUDIO_SVC_LIST_ITEM_PATHNAME, &pathname, &size,
+                               AUDIO_SVC_LIST_ITEM_DURATION, &duration,
+                               AUDIO_SVC_LIST_ITEM_RATING, &rating,
+                               -1);
+                       if (ret != AUDIO_SVC_ERROR_NONE) {
+                               msg_print(__LINE__, "errer audio_svc_list_item_get_val");
+                               ret = audio_svc_list_item_free(tracks);
+                               if (ret != AUDIO_SVC_ERROR_NONE) {
+                                       msg_print(__LINE__, "errer audio_svc_list_item_free");
+                                       return -1;
+                               }
+                               return -1;
+                       }
+
+                       fprintf(stderr, "       **audio_id = %s\n", audio_id);
+                       fprintf(stderr, "       **thumbnail_path = %s\n", thumbname);
+                       fprintf(stderr, "       **title = %s\n", title);
+                       fprintf(stderr, "       **artist = %s\n", artist);
+                       fprintf(stderr, "       **path = %s\n", pathname);
+                       fprintf(stderr, "       **duration = %d\n", duration);
+                       fprintf(stderr, "       **rating = %d\n\n", rating);
+               }
+               
+               ret = audio_svc_list_item_free(tracks);
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       msg_print(__LINE__, "errer audio_svc_list_item_free");
+                       return -1;
+               }
+
+       }
+       
+       ret = audio_svc_group_item_free(groups);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_list_item_free");
+               return -1;
+       }
+
+
+       //iterate all Folder and its tracks ==================================================
+       msg_print(__LINE__, "iterate all Folder and its tracks");
+       //AudioHandleType  *groups = NULL;
+       ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_FOLDER, NULL, NULL, NULL, NULL, &rows);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_count_group_item");
+               return -1;
+       }
+       if(rows < 1) {
+               msg_print(__LINE__, "there is no group item");
+               return -1;
+       }
+       else
+               fprintf(stderr, "rows = [%d]\n", rows);
+       
+       ret = audio_svc_group_item_new(&groups, rows);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_group_item_new");
+               return -1;
+       }
+       
+       ret = audio_svc_get_group_item(AUDIO_SVC_GROUP_BY_FOLDER, //group_type,
+               NULL, //limit_string1,
+               NULL, //limit_string2,
+               NULL, //filter_string,
+               NULL, //filter_string2,
+               0, //offset,
+               rows, //rows,
+               groups);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+                       msg_print(__LINE__, "errer audio_svc_get_group_item of get folder");
+                       ret = audio_svc_list_item_free(tracks);
+                       if (ret != AUDIO_SVC_ERROR_NONE) {
+                               msg_print(__LINE__, "errer audio_svc_list_item_free");
+                               return -1;
+                       }
+                       return -1;
+       }
+       
+       for (idx = 0; idx < rows; idx++) {
+               char *main_info = NULL, *sub_info = NULL, *thumbname = NULL;
+               int rating = 0;
+               int size = 0;
+               int count = 0;
+
+               ret = audio_svc_group_item_get_val(groups, idx , 
+                       AUDIO_SVC_GROUP_ITEM_THUMBNAIL_PATH, &thumbname, &size,
+                       AUDIO_SVC_GROUP_ITEM_MAIN_INFO, &main_info, &size,
+                       AUDIO_SVC_GROUP_ITEM_SUB_INFO, &sub_info, &size,
+                       AUDIO_SVC_GROUP_ITEM_RATING, &rating,
+                       -1);
+
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       msg_print(__LINE__, "errer audio_svc_list_item_get_val of get folder");
+                       ret = audio_svc_list_item_free(tracks);
+                       if (ret != AUDIO_SVC_ERROR_NONE) {
+                               msg_print(__LINE__, "errer audio_svc_list_item_free");
+                               return -1;
+                       }
+                       return -1;
+               }
+               
+               fprintf(stderr, "**** FOLDER INFO[%d] ****\n", idx);
+               fprintf(stderr, "       **main_info = %s\n", main_info);
+               fprintf(stderr, "       **sub_info = %s\n", sub_info);
+               fprintf(stderr, "       **thumbname = %s\n", thumbname);
+               fprintf(stderr, "       **rating = %d\n\n", rating);
+               
+               //iterate tracks of albums ==================================================
+               ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_BY_FOLDER, sub_info, "", "", "", &count);
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       msg_print(__LINE__, "errer audio_svc_count_list_item");
+                       return -1;
+               }
+               if(count < 1) {
+                       msg_print(__LINE__, "there is no item");
+                       return -1;
+               }
+               else
+                       fprintf(stderr, "       rows = [%d]\n", count);
+
+               ret = audio_svc_list_item_new(&tracks, count);
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       msg_print(__LINE__, "errer audio_svc_list_item_new");
+                       return -1;
+               }
+
+               ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_BY_FOLDER, sub_info, NULL, NULL, NULL, 0, count, tracks);
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       msg_print(__LINE__, "errer audio_svc_list_item_new");
+                       return -1;
+               }
+               
+               for (j = 0; j < count; j++)
+               {
+                       char *audio_id = NULL, *title = NULL, *artist = NULL, *thumbname = NULL, *pathname = NULL;
+                       int rating = 0;
+                       int duration = 0;
+                       int size = 0;
+                                               
+                       ret = audio_svc_list_item_get_val(tracks, j , 
+                               AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, &size,
+                               AUDIO_SVC_LIST_ITEM_THUMBNAIL_PATH, &thumbname, &size,
+                               AUDIO_SVC_LIST_ITEM_TITLE, &title, &size,
+                               AUDIO_SVC_LIST_ITEM_ARTIST, &artist, &size,
+                               AUDIO_SVC_LIST_ITEM_PATHNAME, &pathname, &size,
+                               AUDIO_SVC_LIST_ITEM_DURATION, &duration,
+                               AUDIO_SVC_LIST_ITEM_RATING, &rating,
+                               -1);
+                       if (ret != AUDIO_SVC_ERROR_NONE) {
+                               msg_print(__LINE__, "errer audio_svc_list_item_get_val");
+                               ret = audio_svc_list_item_free(tracks);
+                               if (ret != AUDIO_SVC_ERROR_NONE) {
+                                       msg_print(__LINE__, "errer audio_svc_list_item_free");
+                                       return -1;
+                               }
+                               return -1;
+                       }
+
+                       fprintf(stderr, "       **audio_id = %s\n\n", audio_id);
+                       fprintf(stderr, "       **thumbnail_path = %s\n", thumbname);
+                       fprintf(stderr, "       **title = %s\n", title);
+                       fprintf(stderr, "       **artist = %s\n", artist);
+                       fprintf(stderr, "       **path = %s\n", pathname);
+                       fprintf(stderr, "       **duration = %d\n", duration);
+                       fprintf(stderr, "       **rating = %d\n\n", rating);
+               }
+               
+               ret = audio_svc_list_item_free(tracks);
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       msg_print(__LINE__, "errer audio_svc_list_item_free");
+                       return -1;
+               }
+
+       }
+       
+       ret = audio_svc_group_item_free(groups);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_list_item_free");
+               return -1;
+       }
+
+       //iterate all playlist and its tracks ==================================================
+       int plst_idx = -1;
+       int plst_count = -1;
+       AudioHandleType*playlists = NULL;
+       char plst_name[AUDIO_SVC_PLAYLIST_NAME_SIZE] = {0};
+
+       ret = audio_svc_count_playlist(NULL, NULL, &plst_count);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_count_playlist");
+               return -1;
+       }
+       if(plst_count < 1) {
+               msg_print(__LINE__, "there is no playlist");
+               return -1;
+       }
+       else
+               fprintf(stderr, "plst_count = [%d]\n", plst_count);
+       
+       ret = audio_svc_playlist_new(&playlists, plst_count);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_playlist_new");
+               return -1;
+       }
+
+       ret = audio_svc_get_playlist(
+                               NULL, //filter_string,
+                               NULL, //filter_string2,
+                               0, //offset,
+                               plst_count, //rows
+                               playlists);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_playlist_new");
+               return -1;
+       }
+
+       int plst_id = -1;
+       for (idx = 0; idx < plst_count; idx++) {
+               int size;
+               char *playlist_name = NULL;
+               char *playlist_thumbnail_path = NULL;
+               
+               audio_svc_playlist_get_val(playlists, idx, AUDIO_SVC_PLAYLIST_ID, &plst_id, AUDIO_SVC_PLAYLIST_NAME, &playlist_name, &size, AUDIO_SVC_PLAYLIST_THUMBNAIL_PATH, &playlist_thumbnail_path, &size,-1);
+               fprintf(stderr, "**** Playlist Item Info****\n");
+               fprintf(stderr, "** plst id: [%d], name: [%s], thumbnail_path: [%s]\n\n", plst_id, playlist_name, playlist_thumbnail_path);
+       }
+
+       ret = audio_svc_playlist_free(playlists);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_playlist_new");
+               return -1;
+       }
+
+       ret = audio_svc_count_playlist_item(plst_id, "", "", &rows);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_count_list_item");
+               return -1;
+       }
+
+       if(rows < 1) {
+               msg_print(__LINE__, "there is no item");
+               return -1;
+       }
+       else
+               fprintf(stderr, "rows = [%d]\n", rows);
+
+       ret = audio_svc_playlist_item_new(&tracks, rows);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer to alloc memory for list item");
+               return -1;
+       }
+       
+       ret = audio_svc_get_playlist_item(
+               plst_id,
+               NULL, //filter_string,
+               NULL, //filter_string2,
+               0, //offset,
+               rows, //rows,
+               tracks
+               );
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer to get list item");
+               return -1;
+       }
+
+       for (idx = 0; idx < rows; idx++) {
+               char *audio_id = NULL, *title = NULL, *artist = NULL, *thumbname = NULL, *pathname = NULL;
+               int uid = -1;
+               int rating = 0;
+               int duration = 0;
+               int size = 0;
+               int play_order = 0;     
+                                       
+               ret = audio_svc_playlist_item_get_val(tracks, idx , 
+                       AUDIO_SVC_PLAYLIST_ITEM_UID, &uid,
+                       AUDIO_SVC_PLAYLIST_ITEM_AUDIO_ID, &audio_id, &size,
+                       AUDIO_SVC_PLAYLIST_ITEM_THUMBNAIL_PATH, &thumbname, &size,
+                       AUDIO_SVC_PLAYLIST_ITEM_TITLE, &title, &size,
+                       AUDIO_SVC_PLAYLIST_ITEM_ARTIST, &artist, &size,
+                       AUDIO_SVC_PLAYLIST_ITEM_PATHNAME, &pathname, &size,
+                       AUDIO_SVC_PLAYLIST_ITEM_DURATION, &duration,
+                       AUDIO_SVC_PLAYLIST_ITEM_RATING, &rating,
+                       AUDIO_SVC_PLAYLIST_ITEM_PLAY_ORDER, &play_order,
+                       -1);
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       msg_print(__LINE__, "errer audio_svc_list_item_get_val");
+                       return -1;
+               }
+
+               fprintf(stderr, "       **uid = %d\n", uid);
+               fprintf(stderr, "       **audio_id = %s\n", audio_id);
+               fprintf(stderr, "       **thumbnail_path = %s\n", thumbname);
+               fprintf(stderr, "       **title = %s\n", title);
+               fprintf(stderr, "       **artist = %s\n", artist);
+               fprintf(stderr, "       **path = %s\n", pathname);
+               fprintf(stderr, "       **duration = %d\n", duration);
+               fprintf(stderr, "       **rating = %d\n", rating);
+               fprintf(stderr, "       **play_order = %d\n\n", play_order);
+       }       
+
+       ret = audio_svc_playlist_item_free(tracks);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_list_item_free");
+               return -1;
+       }
+       
+       ret = audio_svc_get_playlist_name_by_playlist_id(plst_id, plst_name, AUDIO_SVC_PLAYLIST_NAME_SIZE);
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer audio_svc_get_playlist_name_by_playlist_id");
+               return -1;
+       }
+       fprintf(stderr,"playlist id = %d, playlist name = %s\n", plst_id, plst_name);
+
+       //db close ==================================================
+       ret = audio_svc_close();
+       if (ret != AUDIO_SVC_ERROR_NONE) {
+               msg_print(__LINE__, "errer to close music database");
+               return -1;
+       }
+
+       return 0;
+}
+
+
+void insert_into_db(const char * dir_path)
+{
+       int audio_id = 300;
+       char thumb_path[AUDIO_SVC_PATHNAME_SIZE+1] = {0};
+
+       struct dirent *dp;
+
+       DIR *dir = opendir(dir_path);
+       while ((dp=readdir(dir)) != NULL) {
+               char fpath[_POSIX_PATH_MAX];
+
+               if (dp->d_name[0] == '.') {
+                       continue;
+               }
+               snprintf(fpath, sizeof(fpath), "%s/%s", dir_path, dp->d_name);
+
+               fprintf(stderr,"[file path] : %s\n", fpath);
+
+               int ret = audio_svc_insert_item(AUDIO_SVC_STORAGE_PHONE, fpath, AUDIO_SVC_CATEGORY_MUSIC);
+               if (ret != AUDIO_SVC_ERROR_NONE) {
+                       fprintf(stderr,"[errer to insert music] : %s\n", fpath);
+               }
+
+               audio_id++;
+       }
+
+
+}
+/*
+void list_items(int count, mp_search_record_t *tracks)
+{
+       int i;
+       for (i = 0; i < count; i++)
+       {
+               fprintf(stderr, "--- [audio_id]         : %d ---\n", tracks[i].audio_id);
+               fprintf(stderr, "--- [firstname]        : %s ---\n", tracks[i].firstname);
+               fprintf(stderr, "--- [secondname]       : %s ---\n", tracks[i].secondname);
+               fprintf(stderr, "--- [thumbnail_path]   : %s ---\n\n", tracks[i].thumbnail_path);
+       }
+}
+*/
+
+void msg_print(int line, char *msg)
+{
+       //fprintf(stderr, "\n");
+       //fprintf(stderr,"%s:%d\n", __FUNCTION__, __LINE__);
+       //fprintf(stderr, "+++++++++++++++++++++++++++++++++\n");
+       fprintf(stderr, "[%d]%s +++++\n", line, msg);
+       //fprintf(stderr, "+++++++++++++++++++++++++++++++++\n");
+       //fprintf(stderr, "+++++++++++++++++++++++++++++++++\n");
+       //fprintf(stderr, "\n");
+}
+
diff --git a/test/test_media_info.c b/test/test_media_info.c
new file mode 100755 (executable)
index 0000000..17b45a3
--- /dev/null
@@ -0,0 +1,913 @@
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <glib/gstdio.h>
+#include <pthread.h>
+
+#include "media-info.h"
+#include "media-info-util.h"
+#include "media-info-debug.h"
+
+#include "audio-svc.h"
+#include "audio-svc-error.h"
+#include "media-svc.h"
+
+void test_connect_disconn();
+int test_query(sqlite3* handle);
+void *do_newjob();
+
+static int _ite_cluster_fn( Mcluster* item, void* user_data) 
+{
+       GList** list = (GList**) user_data;
+       *list = g_list_append( *list, item );
+
+       return 0;
+}
+
+static int _ite_fn( Mitem* item, void* user_data) 
+{
+       GList** list = (GList**) user_data;
+       *list = g_list_append( *list, item );
+
+       return 0;
+}
+
+static int _ite_tag_fn(Mtag* t_item, void* user_data) 
+{
+       GList** list = (GList**) user_data;
+       *list = g_list_append( *list, t_item );
+
+       return 0;
+}
+
+static int _bm_ite_fn( Mbookmark *bookmark, void *user_data )
+{
+       if (!bookmark) {
+               printf("bookmark is NULL!\n");
+               return -1;
+       }
+
+       GList** list = (GList**) user_data;
+       *list = g_list_append(*list, bookmark);
+
+       return 0;
+}
+
+int main(int argc, char *argv[])
+{
+       int err = -1;
+       int test_case = -1;
+       int i;
+       int count = 0;
+    GList *p_list = NULL;
+       Mtag* tag = NULL;
+       Mitem* item = NULL;
+       Mcluster* cluster = NULL;
+       minfo_cluster_filter cluster_filter;
+       minfo_item_filter item_filter;
+
+
+       if(argc < 2) return -1;
+
+       err = mediainfo_open();
+       if(err < 0) {
+               mediainfo_dbg("mediainfo_open fails");
+       }
+
+       mediainfo_dbg("mediainfo_open succeeds");
+
+       test_case = atoi(argv[1]);
+
+       switch( test_case ) {
+               case 0: 
+                       test_connect_disconn();
+                       break;
+               case 1: 
+                       audio_svc_create_table();
+                       break;
+               
+               case 2: 
+                       // Test for tag
+
+                       //err = minfo_add_tag("1bf63a42-0530-3cb8-94a1-564d603d85e8", "ZZOON");
+                       //err = minfo_add_tag("1bf63a42-0530-3cb8-94a1-564d603d85e8", "HELLO");
+
+                       //err = minfo_add_tag("2ba2cd51-e93f-af54-c1c2-b29a19fd97d0", "ZZOON");
+                       //err = minfo_rename_tag("HIHI", "ZZOON");
+                       //err = minfo_rename_tag_by_id("2ba2cd51-e93f-af54-c1c2-b29a19fd97d0", "ZZOON", "HELLOHELLO");
+                       //err = minfo_delete_tag("2ba2cd51-e93f-af54-c1c2-b29a19fd97d0", "HELLOHELLO");
+
+
+                       // Test for tag or media list
+                       err = minfo_get_media_list_by_tagname("ZZOON", FALSE, _ite_fn, &p_list);
+                       if( err < 0 ) {
+                               printf("minfo_get_media_list_by_tagname fails : %d\n", err );
+                               break;
+                       }
+
+                       for( i = 0; i < g_list_length(p_list); i++ ) {
+                               item = (Mitem*)g_list_nth_data(p_list, i);
+                               printf("media ID[%d]:%s\n", i, item->uuid );
+                               printf("path[%d]:%s\n", i, item->file_url );
+                               printf("display_name[%d]:%s\n", i, item->display_name );
+                       }
+
+                       g_list_free(p_list);
+                       p_list = NULL;
+
+                       printf("\n-------------------------------------------\n");
+
+                       err = minfo_get_tag_list_by_media_id("2ba2cd51-e93f-af54-c1c2-b29a19fd97d0", _ite_tag_fn, &p_list);
+                       if( err < 0 ) {
+                               printf("minfo_get_media_list_by_tagname fails : %d\n", err );
+                               break;
+                       }
+
+                       for( i = 0; i < g_list_length(p_list); i++ ) {
+                               tag = (Mtag*)g_list_nth_data(p_list, i);
+                               printf("media ID[%d]:%s\n", i, tag->media_uuid );
+                               printf("tag name[%d]:%s\n", i, tag->tag_name );
+                               printf("count[%d]:%d\n", i, tag->count );
+                       }
+                       g_list_free(p_list);
+                       p_list = NULL;
+
+                       printf("\n-------------------------------------------\n");
+
+                       err = minfo_get_tag_list_by_media_id("1bf63a42-0530-3cb8-94a1-564d603d85e8", _ite_tag_fn, &p_list);
+                       if( err < 0 ) {
+                               printf("minfo_get_media_list_by_tagname fails : %d\n", err );
+                               break;
+                       }
+
+                       for( i = 0; i < g_list_length(p_list); i++ ) {
+                               tag = (Mtag*)g_list_nth_data(p_list, i);
+                               printf("media ID[%d]:%s\n", i, tag->media_uuid );
+                               printf("tag name[%d]:%s\n", i, tag->tag_name );
+                               printf("count[%d]:%d\n", i, tag->count );
+                       }
+                       g_list_free(p_list);
+
+                       break;
+
+               case 3:
+                       // Test for cluster
+                       printf("Test for cluster\n");
+                       memset(&cluster_filter, 0x00, sizeof(minfo_cluster_filter));
+                       //filter.sort_type =  MINFO_CLUSTER_SORT_BY_NAME_ASC;
+                       cluster_filter.sort_type =  MINFO_CLUSTER_SORT_BY_NAME_DESC;
+                       //filter.start_pos = filter.end_pos = -1;
+                       cluster_filter.start_pos = 0;
+                       cluster_filter.end_pos = 5;
+
+                       err = minfo_get_cluster_list(cluster_filter, _ite_cluster_fn, &p_list);
+                       if( err < 0 ) {
+                               printf("minfo_get_cluster_list fail : %d\n", err);
+                               break;
+                       }
+
+                       for( i = 0; i < g_list_length(p_list); i++ ) {
+                               cluster = (Mcluster*)g_list_nth_data(p_list, i);
+                               printf("cluster UUID[%d]:%s\n", i,  cluster->uuid );
+                               printf("display_name[%d]:%s\n", i, cluster->display_name );
+                       }
+
+                       break;
+
+               case 4:
+                       // Test for multi-threads
+                       printf("Test for multi-threads\n");
+                       pthread_t p_thread[1];
+                       int thr_id;
+                       int status;
+                       //int media_id = 1;
+                       const char *media_id = "2b0a4efe-c3cb-cb62-fe12-3f4f7aef4ab9";
+
+                       thr_id = pthread_create(&p_thread[0], NULL, do_newjob, NULL);
+
+                       pthread_join(p_thread[0], (void **) &status);
+
+                       err = minfo_update_media_name(media_id, "New.JPG");
+                       if( err < 0)
+                       {
+                               printf("minfo_update_media_name failed\n");
+                               return err;
+                       }
+                       
+                       break;
+
+               case 5:
+                       printf("Test minfo_get_item_list\n");
+                       memset(&item_filter, 0x00, sizeof(minfo_item_filter));
+
+                       item_filter.file_type =  MINFO_ITEM_ALL;
+                       item_filter.sort_type = MINFO_MEDIA_SORT_BY_DATE_ASC;
+                       item_filter.start_pos = 3;
+                       item_filter.end_pos = 10;
+                       item_filter.with_meta = 0;
+                       item_filter.favorite = MINFO_MEDIA_FAV_ALL;
+                       const char *_id = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+
+                       //get a set of items
+                       err = minfo_get_item_list(_id, item_filter, _ite_fn, &p_list);
+                       if( err < 0)
+                       {
+                               printf("minfo_get_item_list failed\n");
+                               return err;
+                       }
+
+                       if( p_list == NULL ) printf("failed!\n");
+       
+                       for( i = 0; i < g_list_length(p_list); i++ ) {
+                               item = (Mitem*)g_list_nth_data(p_list, i);
+                               printf("media ID[%d]:%s\n", i, item->uuid );
+                               printf("path[%d]:%s\n", i, item->file_url );
+                               printf("display_name[%d]:%s\n", i, item->display_name );
+                               printf("thumb url[%d]:%s(length:%d)\n", i, item->thumb_url, strlen(item->thumb_url) );
+                       }
+       
+                       /* delete list to avoid memory leak */
+                       for( i = 0; i < g_list_length(p_list); i++ ) {
+                               item = (Mitem*)g_list_nth_data(p_list, i);
+                               minfo_destroy_mtype_item(item);
+                       }
+       
+                       g_list_free(p_list);
+                       p_list = NULL;
+
+                       break;
+               
+               case 6:
+                       printf("Test minfo_get_all_item_list\n");
+                       memset(&item_filter, 0x00, sizeof(minfo_item_filter));
+
+                       item_filter.file_type = MINFO_ITEM_ALL;
+                       item_filter.sort_type = MINFO_MEDIA_SORT_BY_DATE_ASC;
+                       item_filter.start_pos = 0;
+                       item_filter.end_pos = 10;
+                       item_filter.with_meta = true;
+                       item_filter.favorite = MINFO_MEDIA_FAV_ALL;
+
+                       //get a set of items
+                       err = minfo_get_all_item_list(MINFO_CLUSTER_TYPE_ALL, item_filter, _ite_fn, &p_list);
+                       if( err < 0)
+                       {
+                               printf("minfo_get_all_item_list failed\n");
+                               return err;
+                       }
+
+                       if( p_list == NULL ) printf("failed!\n");
+       
+                       for( i = 0; i < g_list_length(p_list); i++ ) {
+                               item = (Mitem*)g_list_nth_data(p_list, i);
+                               printf("media ID[%d]:%s\n", i, item->uuid );
+                               printf("path[%d]:%s\n", i, item->file_url );
+                               printf("display_name[%d]:%s\n", i, item->display_name );
+                               printf("thumb url[%d]:%s(length:%d)\n", i, item->thumb_url, strlen(item->thumb_url) );
+                       }
+       
+                       /* delete list to avoid memory leak */
+                       for( i = 0; i < g_list_length(p_list); i++ ) {
+                               item = (Mitem*)g_list_nth_data(p_list, i);
+                               minfo_destroy_mtype_item(item);
+                       }
+       
+                       g_list_free(p_list);
+                       p_list = NULL;
+                       break;
+
+               case 7:
+                       printf("Test minfo_delete_media_id\n");
+                       
+                       err = minfo_delete_media_id("12ca468c-994d-f62c-7229-a361c3a6c2a1");
+                       if( err < 0)
+                       {
+                               printf("minfo_delete_media_id failed\n");
+                               return err;
+                       }
+                       break;
+
+               case 8:
+                       // Test for cluster
+                       printf("Test for minfo_get_cluster\n");
+                       Mcluster *cluster = NULL;
+
+                       err = minfo_get_cluster(NULL, NULL, &cluster);
+                       if( err < 0 ) {
+                               printf("minfo_get_cluster_list fail : %d\n", err);
+                               break;
+                       }
+
+                       break;
+
+               case 9:
+                       printf("Test minfo_get_media_list_by_tagname_with_filter\n");
+
+                       GList *p_list = NULL;
+                       minfo_tag_filter filter;
+               
+                       filter.start_pos = 1;
+                       filter.end_pos = 3;
+                       filter.file_type =  MINFO_ITEM_VIDEO;
+                       filter.with_meta = 0;
+               
+                       //get a media items' list who are included to the same tag with 'test tag'.
+                       err = minfo_get_media_list_by_tagname_with_filter("gd", filter, _ite_fn, &p_list);
+                       if (err < 0)
+                       {
+                               printf( "failed to get a media items' list. error code->%d", err);
+                               break;
+                       }
+                       
+                       for( i = 0; i < g_list_length(p_list); i++ ) {
+                               item = (Mitem*)g_list_nth_data(p_list, i);
+                               printf("media ID[%d]:%s\n", i, item->uuid );
+                               printf("path[%d]:%s\n", i, item->file_url );
+                               printf("display_name[%d]:%s\n", i, item->display_name );
+                       }
+
+                       g_list_free(p_list);
+                       p_list = NULL;
+
+                       break;
+
+               case 10:
+                       printf("Test get count\n");
+                       count = 0;
+                       const char *cluster_id = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+                       minfo_cluster_filter c_filter;
+                       minfo_item_filter m_filter;
+
+                       memset(&c_filter, 0x00, sizeof(minfo_cluster_filter));
+                       c_filter.cluster_type = MINFO_CLUSTER_TYPE_ALL;
+                       c_filter.sort_type =  MINFO_CLUSTER_SORT_BY_NAME_DESC;
+                       c_filter.start_pos = c_filter.end_pos = -1;
+
+                       memset(&m_filter, 0x00, sizeof(minfo_item_filter));
+                       m_filter.file_type =  MINFO_ITEM_ALL;
+                       m_filter.sort_type = MINFO_MEDIA_SORT_BY_DATE_ASC;
+                       m_filter.start_pos = -1;
+                       m_filter.end_pos = -1;
+                       m_filter.with_meta = 0;
+                       m_filter.favorite = MINFO_MEDIA_FAV_ALL;
+
+                       err = minfo_get_cluster_cnt(c_filter, &count);
+
+                       if (err < 0) {
+                               printf( "failed to get a media items' list. error code->%d", err);
+                       } else {
+                               printf( "Clouster count : %d\n", count);
+                       }
+
+                       err = minfo_get_item_cnt(cluster_id, m_filter, &count);
+
+                       if (err < 0) {
+                               printf( "failed to get a media items' list. error code->%d", err);
+                       } else {
+                               printf( "media count in cluster[%s] : %d\n", cluster_id, count);
+                       }
+
+                       break;
+
+       case 11:
+               printf("test minfo_add_media\n");
+               char path[255];
+               int type;
+               while(1) {
+                       printf("Enter path and type(  \"exit 0\" to quit ) : ");
+                       scanf("%s %d", path, &type);
+
+                       if( strcmp(path, "exit") == 0 ) break;
+
+                       struct timeval time1;
+                       struct timeval time2;
+                       gettimeofday(&time1, NULL);
+
+                       err = minfo_add_media(path, type);
+                       if( err < 0 ) {
+                               printf("minfo_add_media fails ( path : %s, type : %d )\n", path, type );
+                       } else {
+                               printf("minfo_add_media succeed ( path : %s, type : %d )\n", path, type );
+                       }
+
+                       gettimeofday(&time2, NULL);
+
+                       printf("Time : %ld\n", (time2.tv_sec * 1000000 + time2.tv_usec) - 
+                                                                       (time1.tv_sec * 1000000 + time1.tv_usec));
+               }
+
+               break;
+
+       case 12:
+               printf("Test minfo_delete_media_id\n");
+
+               char inserted_media_uuid[256] = {0,};
+               printf("Enter media id: ");
+               scanf("%s", inserted_media_uuid);
+
+               err = minfo_delete_media_id(inserted_media_uuid);
+               if( err < 0 ) {
+                       printf("minfo_delete_media_id fails\n");
+               } else {
+                       printf("minfo_delete_media_id succeeds\n");
+               }
+
+               break;
+
+       case 13:
+       {
+               printf("test minfo_add_web_media\n");
+               //char path[255];
+               //int type;
+               const char *cluster_id = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+
+               //add a web media to a web album.
+               err = minfo_add_web_media_with_type(cluster_id, "http://user/specifying/address",  "web_media", MINFO_ITEM_IMAGE, "thumbnail name");
+               if (err < 0)
+               {
+                       printf( "failed to add to a web album. error code->%d", err);
+               }
+       }
+       break;
+
+       case 14:
+       {
+               printf("test minfo_update_cluster_name\n");
+               //char path[255];
+               //int type;
+
+               //add a web media to a web album.
+               err = minfo_update_cluster_name("8ddcdba9-9df4-72b4-4890-8d21d13854ad", "hey");
+               if (err < 0)
+               {
+                       printf( "failed to add to a web album. error code->%d", err);
+               }
+       }
+       break;
+
+       case 15:
+       {
+               printf("test to get the latest item in camera shots\n");                
+               char cluster_id[256] = {0,};
+
+               //add a web media to a web album.
+               err = minfo_get_cluster_id_by_url("/opt/media/Images and videos/hey", cluster_id, sizeof(cluster_id));
+               if (err < 0)
+               {
+                       printf( "failed to minfo_get_cluster_id_by_url. error code->%d", err);
+                       break;
+               }
+
+               printf("Cluster ID : %s\n", cluster_id);
+
+               memset(&item_filter, 0x00, sizeof(minfo_item_filter));
+
+               item_filter.file_type = MINFO_ITEM_ALL;
+               item_filter.sort_type = MINFO_MEDIA_SORT_BY_DATE_DESC;
+               item_filter.start_pos = 0;
+               item_filter.end_pos = 1;
+               item_filter.with_meta = false;
+               item_filter.favorite = MINFO_MEDIA_FAV_ALL;
+               p_list = NULL;
+               //get a set of items
+               err = minfo_get_item_list(cluster_id, item_filter, _ite_fn, &p_list);
+               if( err < 0)
+               {
+                       printf("minfo_get_item_list failed\n");
+                       return err;
+               }
+
+               if( p_list == NULL ) printf("failed!\n");
+
+               for( i = 0; i < g_list_length(p_list); i++ ) {
+                       item = (Mitem*)g_list_nth_data(p_list, i);
+                       printf("media ID[%d]:%s\n", i, item->uuid );
+                       printf("path[%d]:%s\n", i, item->file_url );
+                       printf("display_name[%d]:%s\n", i, item->display_name );
+               }
+
+               /* delete list to avoid memory leak */
+               for( i = 0; i < g_list_length(p_list); i++ ) {
+                       item = (Mitem*)g_list_nth_data(p_list, i);
+                       minfo_destroy_mtype_item(item);
+               }
+
+               g_list_free(p_list);
+               p_list = NULL;
+       }
+       break;
+       
+       case 16:
+       {
+               printf("Test minfo_get_item_list_search\n");
+               memset(&item_filter, 0x00, sizeof(minfo_item_filter));
+
+               const char *search_str = "Ima";
+               minfo_search_field_t search_field = MINFO_SEARCH_BY_HTTP_URL | MINFO_SEARCH_BY_PATH | MINFO_SEARCH_BY_NAME;
+               minfo_folder_type folder_type = MINFO_CLUSTER_TYPE_ALL;
+
+               item_filter.file_type =  MINFO_ITEM_ALL;
+               item_filter.sort_type = MINFO_MEDIA_SORT_BY_NAME_ASC;
+               item_filter.start_pos = 0;
+               item_filter.end_pos = 9;
+               item_filter.with_meta = 0;
+               item_filter.favorite = MINFO_MEDIA_FAV_ALL;
+               p_list = NULL;
+
+               //get a set of items
+               err = minfo_get_item_list_search(search_field, search_str, folder_type, item_filter, _ite_fn, &p_list);
+               if (err < 0) {
+                       printf("minfo_get_item_list_search failed\n");
+                       return err;
+               }
+
+               if (p_list == NULL) printf("failed!\n");
+               else printf("success\n");
+
+               for (i = 0; i < g_list_length(p_list); i++) {
+                       item = (Mitem*)g_list_nth_data(p_list, i);
+                       printf("media ID[%d]:%s\n", i, item->uuid );
+                       printf("path[%d]:%s\n", i, item->file_url );
+                       printf("display_name[%d]:%s\n", i, item->display_name );
+                       printf("thumb url[%d]:%s(length:%d)\n", i, item->thumb_url, strlen(item->thumb_url) );
+               }
+
+               /* delete list to avoid memory leak */
+               for (i = 0; i < g_list_length(p_list); i++) {
+                       item = (Mitem*)g_list_nth_data(p_list, i);
+                       minfo_destroy_mtype_item(item);
+               }
+
+               g_list_free(p_list);
+               p_list = NULL;
+
+               break;
+       }
+
+       case 17:
+       {
+               printf("test minfo_update_image_meta_info_int\n");
+               const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";
+               int width = 640;
+               int height = 480;
+
+               //add a web media to a web album.
+               err = minfo_update_image_meta_info_int(media_uuid, MINFO_IMAGE_META_WIDTH, width,
+                                                                                               MINFO_IMAGE_META_HEIGHT, height, -1);
+               if (err < 0) {
+                       printf( "minfo_update_image_meta_info_int failed->%d\n", err);
+               } else {
+                       printf( "minfo_update_image_meta_info_int success\n");
+               }
+
+               break;
+       }
+
+       case 18:
+       {
+               printf("test _media_info_generate_uuid\n");
+               printf("UUID : %s\n", (char*)_media_info_generate_uuid());
+               break;
+       }
+
+       case 19:
+               printf("test minfo_get_bookmark_list\n");
+       GList *_list = NULL;
+               const char *media_uuid = NULL;
+
+               p_list = NULL;
+               if (p_list) printf("p list does exist\n");
+               if (argv[2]) {
+                       media_uuid = argv[2];
+               } else {
+                       printf("please insert media id\n");
+                       break;
+               }
+
+               //add a web media to a web album.
+               err = minfo_get_bookmark_list(media_uuid, _bm_ite_fn, &_list);
+               if (err < 0) {
+                       printf( "minfo_get_bookmark_list failed->%d\n", err);
+               } else {
+                       printf( "minfo_get_bookmark_list success\n");
+                       
+                       if (_list) {
+                       int i;
+                       Mbookmark* bm = NULL;
+                       for( i = 0; i < g_list_length(_list); i++ ) {
+                               bm = (Mbookmark*)g_list_nth_data(_list, i);
+                               printf("Thumb[%d]:%s\n", i, bm->thumb_url );
+                       }
+                       }
+               }
+
+               break;
+       
+
+       case 35:
+               printf("test minfo_extract_thumbnail \n");
+
+               if(argv[2] && argv[3]) {
+                       char media_id[256] = {0,};
+                       strncpy(media_id, argv[2], sizeof(media_id));
+                       int type = atoi(argv[3]);
+
+                       err = minfo_extract_thumbnail(media_id, type );
+
+                       if(err < 0 ) {
+                               printf("minfo_extract_thumbnail fails(%d)\n", err );
+                               return -1;
+                       }
+               }
+
+               printf("minfo_extract_thumbnail success\n" );
+               break;
+
+       case 36:
+               printf("test minfo_get_thumb_path \n");
+               char thumb_path[255] = {0,};
+
+               if(argv[2] && argv[3]) {
+                       int type = atoi(argv[3]);
+                       if( type == 1 ) {
+                               err = minfo_get_thumb_path(argv[2], thumb_path, 255);
+                       } else if( type == 2) {
+                               err = minfo_get_thumb_path_for_video(argv[2], thumb_path, 255);
+                       } else {
+                               printf("minfo_get_thumb_path fails( invalid type )\n" );
+                               return -1;
+                       }
+                       if(err < 0)
+                       {
+                               printf("minfo_get_thumb_path fails\n" );
+                               return -1;
+                       }
+               }
+
+               printf("minfo_get_thumb_path : %s\n", thumb_path);
+               break;
+
+               case 37:
+               printf("test minfo_delete_invalid_media_records \n");
+               
+               err = minfo_delete_invalid_media_records(1);
+
+               if(err < 0)
+               {
+                       printf("minfo_delete_invalid_media_records fails\n");
+                       return -1;
+               }
+               
+
+               printf("minfo_delete_invalid_media_records succeeds.\n");
+               break;
+
+       /* ------------------- Test for audio ---------------- */
+       case 101:
+       {
+               printf("test audio_svc_insert_item\n");
+               char path[255];
+
+               while(1) {
+                       printf("Enter path (  \"exit\" to quit ) : ");
+                       scanf("%s", path );
+
+                       if( strcmp(path, "exit") == 0 ) break;
+
+                       err = audio_svc_insert_item(AUDIO_SVC_STORAGE_PHONE, path, AUDIO_SVC_CATEGORY_MUSIC);
+                       if (err != AUDIO_SVC_ERROR_NONE) {
+                               fprintf(stderr,"[errer to insert music] : %s\n", path);
+                       }
+               }
+       }
+       break;
+
+       case 102:
+       {
+               printf("test audio_svc_delete_item_by_path\n");
+               char path[255];
+
+               while(1) {
+                       printf("Enter path (  \"exit\" to quit ) : ");
+                       scanf("%s", path );
+
+                       if( strcmp(path, "exit") == 0 ) break;
+
+                       err = audio_svc_delete_item_by_path(path);
+                       if (err != AUDIO_SVC_ERROR_NONE) {
+                               fprintf(stderr,"[errer to delete music] : %s\n", path);
+                       }
+               }
+       }
+       break;
+
+       case 103:
+       {
+               printf("test audio_svc_get_list_item - AUDIO_SVC_TRACK_BY_SEARCH\n");
+               int offset = 0, count = 10, i = 0;
+               const char *str = "Sa";
+               AudioHandleType *handle = NULL;
+
+               err = audio_svc_search_item_new(&handle, count);
+               if (err < 0) {
+                       printf("audio_svc_search_item_new failed:%d\n", err);
+                       return err;
+               }
+
+               err = audio_svc_list_by_search(handle, AUDIO_SVC_ORDER_BY_TITLE_ASC, offset, count, AUDIO_SVC_SEARCH_TITLE, str, strlen(str), AUDIO_SVC_SEARCH_ALBUM, str, strlen(str), AUDIO_SVC_SEARCH_ARTIST, str, strlen(str), -1);
+
+               if (err != AUDIO_SVC_ERROR_NONE) {
+                       mediainfo_dbg("Fail to get items : %d", err);
+                       return err;
+               }
+               
+               for (i = 0; i < count; i++) {
+                       AudioHandleType *item = NULL;
+                       err = audio_svc_search_item_get(handle, i, &item);
+                       char *title = NULL, *artist = NULL, *pathname = NULL, *album = NULL;
+                       char *audio_id = NULL;
+                       int size = 0;
+
+                       if (err < 0) {
+                               printf("[%d] audio_svc_search_item_get failed : %d\n", i, err);
+                       } else {
+                               audio_svc_item_get_val(item,  
+                                               AUDIO_SVC_TRACK_DATA_AUDIO_ID, &audio_id, &size,
+                                               AUDIO_SVC_TRACK_DATA_PATHNAME, &pathname, &size,
+                                               AUDIO_SVC_TRACK_DATA_TITLE, &title, &size,
+                                               AUDIO_SVC_TRACK_DATA_ARTIST, &artist, &size,
+                                               AUDIO_SVC_TRACK_DATA_ALBUM, &album, &size,
+                                               -1);
+
+                               if( audio_id == NULL ) break;
+
+                               printf("[%d] ID: %s\n", i, audio_id);
+                               printf("[%d] Path: %s\n", i, pathname);
+                               printf("[%d] Title: %s\n", i, title);
+                               printf("[%d] Artist: %s\n", i, artist);
+                               printf("[%d] Album: %s\n", i, album);
+                       }
+               }
+
+               audio_svc_search_item_free(handle); 
+       }
+       break;
+
+       case 104:
+       {
+#if 0
+                       printf("Test audio_svc_update_item_metadata\n");
+                       count = 4;
+                       
+                       err = audio_svc_update_item_metadata(31, AUDIO_SVC_TRACK_DATA_PLAYED_COUNT, count, -1);
+
+                       if( err < 0)
+                       {
+                               printf("audio_svc_update_item_metadata failed\n");
+                               return err;
+                       } else {
+                               printf("play count is now %d\n", count);
+                       }
+#endif
+       }       
+       break;
+
+       default:
+               break;
+       }
+
+       err = mediainfo_close();
+       if(err < 0) {
+               mediainfo_dbg("mediainfo_close fails");
+       }
+
+       printf("End of Test\n");
+    return err;
+}
+
+void *do_newjob()
+{
+       int err;
+       err = mediainfo_open();
+
+       if(err < 0) {
+               mediainfo_dbg("mediainfo_open fails");
+       }
+
+       const char *media_id = "2b0a4efe-c3cb-cb62-fe12-3f4f7aef4ab9";
+
+       err = minfo_update_media_name(media_id, "New1.JPG");
+       if( err < 0)
+       {
+               printf("minfo_update_media_name failed\n");
+               return NULL;
+       }
+
+       printf("Calling mediainfo_close in do_newjob \n");
+       err = mediainfo_close();
+       if(err < 0) {
+               mediainfo_dbg("mediainfo_close fails");
+               return NULL;
+       }
+
+       printf("do_newjob done\n");
+
+       return NULL;
+}
+
+
+void test_connect_disconn()
+{
+       mediainfo_dbg("");
+       int err = -1;
+       sqlite3* my_handle = NULL;
+
+       err = mediainfo_connect_db_with_handle(&my_handle);
+       if( err < 0 ) {
+               mediainfo_dbg("Error");
+               return;
+       }
+       if(my_handle == NULL) mediainfo_dbg("NULL!!!!!"); 
+
+       test_query(my_handle);
+
+       err = mediainfo_disconnect_db_with_handle(my_handle);
+       if( err < 0 ) {
+               mediainfo_dbg("Error");
+               return;
+       }
+
+       mediainfo_dbg("test_connect_disconn success");
+
+       return;
+}
+
+int test_query(sqlite3* handle)
+{
+       int err = -1;
+       sqlite3_stmt* stmt = NULL;
+       char query_string[255];
+       memset(query_string, 0, sizeof(query_string) );
+
+       if( handle == NULL ) {
+               mediainfo_dbg( "handle is NULL" );
+       }
+
+       snprintf(query_string, sizeof(query_string), "select * from folder where _id = 1");
+
+       err = sqlite3_prepare_v2(handle, query_string, strlen(query_string), &stmt, NULL);      
+
+       if (SQLITE_OK != err) 
+       {
+                mediainfo_dbg ("prepare error [%s]\n", sqlite3_errmsg(handle));
+                mediainfo_dbg ("query string is %s\n", query_string);
+                return -1;
+       }
+       err = sqlite3_step(stmt);       
+       if (err != SQLITE_ROW) 
+       {
+                mediainfo_dbg ("end of row [%s]\n", sqlite3_errmsg(handle));
+                mediainfo_dbg ("query string is %s\n", query_string);
+                sqlite3_finalize(stmt);
+                return -1;
+       }
+
+       mediainfo_dbg("ID: %d", sqlite3_column_int (stmt, 0));
+       mediainfo_dbg("Display name: %s", (const char*)sqlite3_column_text (stmt, 2));
+
+       if(err < 0)
+       {
+               mediainfo_dbg ("mb-svc load data failed");
+               sqlite3_finalize(stmt);
+               return -1;
+       }
+
+       sqlite3_finalize(stmt);
+
+       return 0;
+}
+
diff --git a/test/test_visual.c b/test/test_visual.c
new file mode 100755 (executable)
index 0000000..8a1958b
--- /dev/null
@@ -0,0 +1,1138 @@
+/*\r
+ * libmedia-service\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include "media-svc.h"\r
+#include <glib.h>\r
+#include <glib-object.h>\r
+#include <glib/gstdio.h>\r
+#include "media-svc-debug.h"\r
+\r
+static int _ite_fn( Mitem* item, void* user_data) \r
+{\r
+       GList** list = (GList**) user_data;\r
+       *list = g_list_append( *list, item );\r
+\r
+       return 0;\r
+}\r
+\r
+static int _cluster_ite_fn( Mcluster* cluster, void* user_data)\r
+{\r
+       GList** list = (GList**) user_data;\r
+       *list = g_list_append( *list, cluster );\r
+\r
+       return 0;\r
+}\r
+\r
+static int _cover_ite_fn( char* thumb_path, void* user_data)\r
+{\r
+       GList** list = (GList**) user_data;\r
+       *list = g_list_append( *list, thumb_path );\r
+\r
+       return 0;\r
+}\r
+\r
+static int _minfo_bm_ite_fn( Mbookmark *bookmark, void *user_data )\r
+{\r
+       GList** list = (GList**) user_data;\r
+       *list = g_list_append( *list, bookmark );\r
+\r
+       return 0;\r
+}\r
+\r
+static int _ite_tag_fn(Mtag* t_item, void* user_data) \r
+{\r
+       GList** list = (GList**) user_data;\r
+       *list = g_list_append( *list, t_item );\r
+\r
+       return 0;\r
+}\r
+\r
+\r
+int main(int argc, char *argv[])\r
+{\r
+    int test_sequence = 0;\r
+       int media_id = 0;\r
+       Mmeta* mt = NULL;\r
+       Mcluster* cluster = NULL;\r
+       Mitem* mitem = NULL;\r
+       int type = 0;\r
+    int favorite_level = 0;\r
+    int cluster_id = 0;\r
+    int position = 0;\r
+    int bookmark_id = 0;\r
+    int duration= 0,id = 0;\r
+    int err = -1, ret = -1;\r
+       int streaming_id = 0;\r
+    int img_cnt = 0;\r
+       int cnt = 0, i = 0;\r
+       char file_url[MB_SVC_FILE_PATH_LEN_MAX] ={0};\r
+       char new_file_url[MB_SVC_FILE_PATH_LEN_MAX] ={0};\r
+       double min_longitude = 0.0;\r
+       double max_longitude = 0.0;\r
+       double min_latitude = 0.0;\r
+       double max_latitude = 0.0;\r
+    int sns_type = 0;\r
+    GList *p_list = NULL;\r
+               \r
+    printf("################################################\n");\r
+       printf("---this is self-test program for media service---\n");\r
+    printf("################################################\n");\r
+\r
+       \r
+       if ((argc <2)||(argv[0] == NULL)||(argv[1] == NULL))\r
+       {\r
+               printf("parameter count typed in console is wrong!!\n");\r
+               return -1;\r
+       }\r
+\r
+       g_type_init(); \r
+\r
+       err = minfo_init();\r
+       if(err<0)\r
+       {\r
+               printf("minfo_init error\n");\r
+        return -1;\r
+       }\r
+\r
+    test_sequence =atoi(argv[1]);\r
+    //printf("test_sequence is %d\n",test_sequence);                \r
+       \r
+    switch(test_sequence)\r
+       {\r
+       case 0: \r
+               printf("reset database of media service.......\n");\r
+               //mb_svc_reset_db();\r
+               printf("sync image and video files to media service database.......\n");\r
+               break;\r
+        \r
+       case 1: \r
+               printf("test minfo_get_bookmark_list.......\n");\r
+               if(argv[2] != NULL)\r
+               {\r
+                   media_id = atoi(argv[2]);\r
+                       printf("parameter media_id is %d\n",media_id);\r
+                       \r
+                       ret = minfo_get_bookmark_list(media_id, _minfo_bm_ite_fn, &p_list);\r
+\r
+                   if( ret < 0)\r
+                   {\r
+                       printf("minfo get bookmark failed, media_id is %d\n",media_id);\r
+                       return -1;\r
+                   } \r
+                       else {\r
+                               int i;\r
+                               Mbookmark* bm = NULL;\r
+                               for( i = 0; i < g_list_length(p_list); i++ ) {\r
+                                       bm = (Mbookmark*)g_list_nth_data(p_list, i);\r
+                                       printf("Thumb[%d]:%s\n", i, bm->thumb_url );\r
+                               }\r
+                       }\r
+                       //minfo_free_glist(&p_list);            \r
+               }\r
+               else \r
+               {\r
+                   printf("minfo get bookmark: media_id is null\n");\r
+                       return -1;               \r
+               }\r
+       break;\r
+        \r
+       case 2:   \r
+               printf("test minfo_add_media.......\n");\r
+               if((argv[2] != NULL)&&(argv[3] != NULL))//minfo_add_media\r
+               {                                       //type: 1-image, 2-video\r
+                        memcpy(file_url,argv[2],MB_SVC_FILE_PATH_LEN_MAX);\r
+                        type = atoi(argv[3]);\r
+                        printf("parameter file url is %s, type is %d\n",file_url,type);\r
+                        err = minfo_add_media(file_url, type);\r
+                        if( err < 0)\r
+                        {\r
+                           printf("minfo_add_media failed\n");\r
+                           return -1;\r
+                        }\r
+               }\r
+               else \r
+               {\r
+                   printf("minfo_add_media: file url or type  is null\n");\r
+                       return -1;\r
+                \r
+               }\r
+\r
+       break; \r
+\r
+       case 3: \r
+               printf("test minfo_delete_media.......\n");\r
+               if(argv[2] != NULL) //minfo_delete_media\r
+               {\r
+\r
+                       memcpy(file_url,argv[2],MB_SVC_FILE_PATH_LEN_MAX);\r
+                       printf("parameter file url is %s\n",file_url);\r
+                       err = minfo_delete_media(file_url);\r
+                       if( err < 0)\r
+                       {\r
+                               printf("minfo_delete_media failed\n");\r
+                               return -1;\r
+                       }\r
+               }\r
+               else \r
+               {\r
+                       printf("minfo_delete_media: file url is null\n");\r
+                       return -1;\r
+               }\r
+               break;\r
+\r
+       case 4:                                  \r
+               printf("test minfo_delete_media_id.......\n");\r
+               if(argv[2] != NULL) //minfo_delete_media_id\r
+               {\r
+                       media_id = atoi(argv[2]);\r
+                       printf("parameter media_id is %d\n",media_id);\r
+                       err = minfo_delete_media_id(media_id);\r
+                       if( err < 0)\r
+                       {\r
+                               printf("minfo_delete_media_id failed\n");\r
+                               return -1;\r
+                       }\r
+               }\r
+               else \r
+               {\r
+                       printf("minfo_delete_media_id: media id  is null\n");\r
+                       return -1;\r
+\r
+               }\r
+       \r
+       break;\r
+        \r
+\r
+       case 5:           \r
+               printf("minfo_move_media.......\n");\r
+               if((argv[2] != NULL)&&(argv[3] !=NULL)&&(argv[4] != NULL))//minfo_update_media\r
+               {\r
+\r
+                       memcpy(file_url,argv[2],MB_SVC_FILE_PATH_LEN_MAX);\r
+                       memcpy(new_file_url,argv[3],MB_SVC_FILE_PATH_LEN_MAX);\r
+                       type = atoi(argv[4]);\r
+                       printf("parameter old_file_url is %s, new_file_url is %s, type is %d\n",file_url,new_file_url,type);\r
+                       err = minfo_move_media(file_url, new_file_url, type);\r
+                       if( err < 0)\r
+                       {\r
+                               printf("minfo_update_media failed\n");\r
+                               return -1;\r
+                       }\r
+               }\r
+               else \r
+               {\r
+                       printf("minfo_update_media: old file url or new file url or type  is null\n");\r
+                       return -1;\r
+               }\r
+               printf("minfo_update_media leave\n");\r
+               break;   \r
+\r
+       case 6:                              \r
+               printf("minfo_update_media_name.......\n");\r
+\r
+               if((argv[2] != NULL)&&(argv[3] !=NULL))//minfo_update_media_name\r
+               {\r
+                       media_id = atoi(argv[2]);\r
+                       printf("parameter media_id is %d, new name is %s",media_id,argv[3]);\r
+                       err = minfo_update_media_name(media_id, argv[3]);\r
+                       if( err < 0)\r
+                       {\r
+                       printf("minfo_update_media_name failed\n");\r
+                       return -1;\r
+                       }\r
+               }\r
+               else \r
+               {\r
+                       printf("minfo_update_media_name: media id or new file name  is null\n");\r
+                       return -1;\r
+\r
+               }               \r
+               break;\r
+        \r
+        \r
+       case 7:                         //minfo update meida favorite     \r
+               printf("minfo_update_media_favorite.......\n");\r
+\r
+               if((argv[2] != NULL)&&(argv[3] !=NULL))\r
+               {\r
+                       media_id = atoi(argv[2]);\r
+                       favorite_level = atoi(argv[3]);\r
+                       printf("parameter media_id is %d, favorite_level is %d",cluster_id,favorite_level);\r
+                       err = minfo_update_media_favorite(media_id, favorite_level);\r
+                       if( err < 0)\r
+                       {\r
+                       printf("minfo_update_media_favorite failed\n");\r
+                       return -1;\r
+                       }\r
+               }\r
+               else \r
+               {\r
+                       printf("minfo_update_media_favorite: media id or favorite_level  is null\n");\r
+                       return -1;\r
+\r
+               }\r
+        break;\r
+        \r
+\r
+       case 8:                                   //minfo_delete_cluster\r
+               printf("minfo_update_media_favorite.......\n");\r
+               if(argv[2] != NULL) \r
+               {\r
+                       cluster_id = atoi(argv[2]);\r
+                       printf("parameter cluster_id is %d",cluster_id);\r
+                       err = minfo_delete_cluster(cluster_id);\r
+                       if( err < 0)\r
+                       {\r
+                               printf("minfo_delete_cluster failed\n");\r
+                               return -1;\r
+                       }\r
+               }    \r
+               else\r
+               {\r
+                       printf("minfo_update_media_favorite: cluster id is null\n");\r
+                       return -1;\r
+               }\r
+               break;  \r
+        \r
+       case 9:                                   //minfo_update_cluster_name\r
+               printf("minfo_update_cluster_name.......\n");\r
+               if((argv[2] != NULL)&&(argv[3] != NULL)) \r
+               {\r
+                       cluster_id = atoi(argv[2]);\r
+                       printf("parameter cluster_id is %d, new name is %s",cluster_id,argv[3]);\r
+                       err = minfo_update_cluster_name(cluster_id,argv[3]);\r
+                       if( err < 0)\r
+                       {\r
+                               printf("minfo_update_cluster_name failed\n");\r
+                               return -1;\r
+                       }\r
+               }    \r
+               else\r
+               {\r
+                       printf("minfo_update_cluster_name: cluster id or new cluster name is null\n");\r
+                       return -1;\r
+               }\r
+        break;  \r
+\r
+       case 10:                                   //minfo_add_bookmark\r
+               printf("minfo_add_bookmark.......\n");\r
+               if((argv[2] != NULL)&&(argv[3] != NULL)&&(argv[4] != NULL)) \r
+               {\r
+                       media_id = atoi(argv[2]);\r
+                       position = atoi(argv[3]);\r
+                       printf("parameter media_id is %d,position is %d,thumb path is %s",media_id,position,argv[4]);\r
+                       err = minfo_add_bookmark(media_id,position,argv[4]);\r
+                       if( err < 0)\r
+                       {\r
+                               printf("minfo_add_bookmark failed\n");\r
+                               return -1;\r
+                       }\r
+               }    \r
+               else\r
+               {\r
+                       printf("minfo_add_bookmark: media id or position or new thumb path is null\n");\r
+                       return -1;\r
+               }\r
+        break;   \r
+\r
+       case 11:                                   //minfo_delete_bookmark\r
+               printf("minfo_delete_bookmark.......\n");\r
+               if(argv[2] != NULL)\r
+               {\r
+                       bookmark_id = atoi(argv[2]);\r
+                       printf("parameter bookmark_id is %d",bookmark_id);\r
+                       err = minfo_delete_bookmark(bookmark_id);\r
+                       if( err < 0)\r
+                       {\r
+                       printf("minfo_delete_bookmark failed\n");\r
+                       return -1;\r
+                       }\r
+               }    \r
+               else\r
+               {\r
+                       printf("minfo_delete_bookmark: bookmark id is null\n");\r
+                       return -1;\r
+               }\r
+               break; \r
+\r
+\r
+       case 12:                                   //minfo_add_streaming\r
+               printf("minfo_add_streaming.......\n");\r
+               if((argv[2] != NULL)&&(argv[3] != NULL)&&(argv[4] != NULL)&&(argv[5] != NULL))\r
+               {\r
+                       duration = atoi(argv[4]);\r
+                       printf("parameter duration is %d",duration);\r
+                       err = minfo_add_streaming(argv[2], argv[3], duration, argv[5],&id);\r
+                       printf("id is %d\n",id);\r
+                       if( err < 0)\r
+                       {\r
+                       printf("minfo_add_streaming failed\n");\r
+                       return -1;\r
+                       }\r
+               }    \r
+               else\r
+               {\r
+               printf("minfo_add_streaming: title or url or duration or thumb path is null\n");\r
+               return -1;\r
+               }\r
+               printf("minfo_add_streaming leave\n");\r
+        break; \r
+\r
+\r
+       case 13:                                   //minfo_delete_streaming\r
+               printf("minfo_delete_streaming.......\n");\r
+               if(argv[2] != NULL)\r
+               {\r
+                       streaming_id = atoi(argv[2]);\r
+                       printf("parameter streaming_id is %d",streaming_id);\r
+                       err = minfo_delete_streaming(streaming_id);\r
+                       if( err < 0)\r
+                       {\r
+                               printf("minfo_delete_streaming failed\n");\r
+                               return -1;\r
+                       }\r
+               }    \r
+               else\r
+               {\r
+                       printf("minfo_delete_streaming: streaming id is null\n");\r
+                       return -1;\r
+               }\r
+        break;                                         \r
+\r
+       case 14:                                   //minfo_get_item_list\r
+               printf("minfo_get_item_list.......\n");\r
+               if(argv[2] != NULL)\r
+               {\r
+                       minfo_item_filter item_filter1 = {MINFO_ITEM_ALL,MINFO_MEDIA_SORT_BY_NONE,-1,-1,false,MINFO_MEDIA_FAV_ALL};\r
+                       //minfo_item_filter item_filter1 = {MINFO_ITEM_IMAGE,MINFO_MEDIA_SORT_BY_DATE_DESC,0,1,FALSE,FALSE};\r
+                       minfo_item_filter item_filter2 = {MINFO_ITEM_IMAGE,MINFO_MEDIA_SORT_BY_DATE_ASC,0,2,true,MINFO_MEDIA_FAV_ALL};\r
+                       minfo_item_filter item_filter3 = {MINFO_ITEM_IMAGE,MINFO_MEDIA_SORT_BY_DATE_ASC,1,10,true,MINFO_MEDIA_FAV_ALL};\r
+                       minfo_item_filter item_filter4 = {MINFO_ITEM_IMAGE,MINFO_MEDIA_SORT_BY_DATE_ASC,1,2,true,MINFO_MEDIA_FAV_ONLY};\r
+\r
+                       cluster_id = atoi(argv[2]);     \r
+                       err = minfo_get_item_list(cluster_id, item_filter1, _ite_fn, &p_list);\r
+\r
+                       if( err < 0)\r
+                       {\r
+                               printf("minfo_get_item_list failed\n");\r
+                               //return -1;\r
+                       }\r
+                       img_cnt = g_list_length(p_list);\r
+                       printf("img_cnt1 is %d,p_list is %p\n",img_cnt,p_list);\r
+                       \r
+                       for(i=0; i<img_cnt; i++)\r
+                       {\r
+                               mitem = (Mitem*)g_list_nth_data(p_list, i);\r
+                               printf("mitem ID=%d, %s\n",mitem->_id, mitem->file_url);\r
+                               printf("case14 count is %d\n",((GObject *)mitem)->ref_count); \r
+                               //printf("mitem->meta_info->type =%d,\n",mitem->meta_info->type);       \r
+                               //printf("mitem->meta_info->video_info =%p,\n",mitem->meta_info->video_info);   \r
+                       }\r
+\r
+//                     minfo_free_glist(&p_list);\r
+\r
+/*\r
+                       err = minfo_get_item_list(cluster_id, item_filter2, &p_list);\r
+                       if( err < 0)\r
+                       {\r
+                               printf("minfo_get_item_list failed\n");\r
+                               //return -1;\r
+                       }\r
+                       img_cnt = g_list_length(p_list);\r
+                       printf("img_cnt2 is %d,p_list is %p\n",img_cnt,p_list);\r
+                       \r
+                       for(i=0; i<img_cnt; i++)\r
+                       {\r
+                               mitem = (Mitem*)g_list_nth_data(p_list, i);\r
+                               printf("mitem ID=%d, %p\n",mitem->_id, mitem);\r
+                               printf("mitem->meta_info =%p,\n",mitem->meta_info);\r
+                       }\r
+//                     minfo_free_glist(&p_list);      \r
+\r
+\r
\r
+           err = minfo_get_item_list(cluster_id, item_filter3, &p_list);\r
+                       if( err < 0)\r
+                       {\r
+                               printf("minfo_get_item_list failed\n");\r
+                               //return -1;\r
+                       }\r
+                       img_cnt = g_list_length(p_list);\r
+                       printf("img_cnt3 is %d,p_list is %p\n",img_cnt,p_list);\r
+                       \r
+                       for(i=0; i<img_cnt; i++)\r
+                       {\r
+                               mitem = (Mitem*)g_list_nth_data(p_list, i);\r
+                               printf("mitem ID=%d, %p\n",mitem->_id, mitem);\r
+                               printf("mitem->meta_info =%p,\n",mitem->meta_info);\r
+                       }\r
+                       minfo_free_glist(&p_list);      \r
+\r
+\r
+\r
+            err = minfo_get_item_list(cluster_id, item_filter4, &p_list);\r
+                       if( err < 0)\r
+                       {\r
+                               printf("minfo_get_item_list failed\n");\r
+                               return -1;\r
+                       }\r
+                       img_cnt = g_list_length(p_list);\r
+                       printf("img_cnt4 is %d,p_list is %p\n",img_cnt,p_list);\r
+                       \r
+                       for(i=0; i<img_cnt; i++)\r
+                       {\r
+                               mitem = (Mitem*)g_list_nth_data(p_list, i);\r
+                               printf("mitem ID=%d, %p\n",mitem->_id, mitem);\r
+                               printf("mitem->meta_info =%p,\n",mitem->meta_info);\r
+                       }\r
+//                     minfo_free_glist(&p_list);      \r
+*/\r
+\r
+               }    \r
+               else\r
+               {\r
+                       printf("minfo_get_item_list: cluster id is null\n");\r
+                       return -1;\r
+               }\r
+               break;  \r
+\r
+       case 15:                                                                        //minfo_get_cluster_cover\r
+               printf("minfo_get_cluster_cover.......\n");\r
+               if((argv[2] != NULL)&&(argv[3] != NULL))\r
+               {\r
+                       cluster_id = atoi(argv[2]);\r
+                       img_cnt = atoi(argv[3]);\r
+                       printf("parameter cluster_id is %d, img_cnt is %d\n",cluster_id,img_cnt);\r
+\r
+                       err = minfo_get_cluster_cover(cluster_id, img_cnt, _cover_ite_fn, &p_list);\r
+\r
+                       if( err < 0)\r
+                       {\r
+                       printf("minfo_get_cluster_cover failed\n");\r
+                       return -1;\r
+                       }\r
+                       for(i=0; i<img_cnt; i++)\r
+                       {\r
+                       printf("thumb_path=%s\n",(char *)g_list_nth_data(p_list, i));\r
+                       }\r
+               }    \r
+               else\r
+               {\r
+                       printf("minfo_get_cluster_cover: cluster id or img_cnt is null\n");\r
+                       return -1;\r
+               }\r
+       break;  \r
+\r
+       case 16:                                                                        //minfo_get_item_cnt\r
+               printf("minfo_get_item_cnt.......\n");\r
+               if(argv[2] != NULL)\r
+               {\r
+                       cluster_id = atoi(argv[2]);\r
+                       minfo_item_filter filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,-1,10,true,true};\r
+                       printf("parameter cluster_id is %d\n",cluster_id);\r
+                       err = minfo_get_item_cnt(cluster_id, filter, &cnt);\r
+                       printf("cnt is %d\n",cnt);\r
+                       if( err < 0)\r
+                       {\r
+                       printf("minfo_get_item_cnt failed\n");\r
+                       return -1;\r
+                       }\r
+               }    \r
+               else\r
+               {\r
+                       printf("minfo_get_item_cnt: cluster id is null\n");\r
+                       return -1;\r
+               }\r
+               printf("minfo_get_item_cnt leave\n");\r
+       break;  \r
+\r
+\r
+       case 17:                                                                 //minfo_get_cluster_cnt\r
+               printf("minfo_get_cluster_cnt.......\n");\r
+               minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_DATE_ASC,0,10};\r
+\r
+               err = minfo_get_cluster_cnt(cluster_filter, &cnt);\r
+               printf("cnt is %d\n",cnt);\r
+               if( err < 0)\r
+               {\r
+                       printf("minfo_get_cluster_cnt failed\n");\r
+                       return -1;\r
+               }\r
+               printf("minfo_get_cluster_cnt leave\n");\r
+               break; \r
+\r
+\r
+       case 18:                                                                 //minfo_get_cluster_list\r
+               printf("test minfo_get_cluster_list...\n");\r
+               minfo_cluster_filter cluster_filter1 ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_DATE_ASC,0,10};\r
+               minfo_cluster_filter cluster_filter2 ={MINFO_CLUSTER_TYPE_LOCAL_ALL,MINFO_CLUSTER_SORT_BY_NAME_DESC,0,10};\r
+                       \r
+               err = minfo_get_cluster_list(cluster_filter1, _cluster_ite_fn, &p_list);\r
+\r
+               if( err < 0)\r
+               {\r
+                        printf("minfo_get_cluster_list failed\n");\r
+                        return -1;\r
+               }\r
+               img_cnt = g_list_length(p_list);\r
+               for(i=0; i<img_cnt; i++)\r
+               {\r
+                       cluster = (Mcluster*)g_list_nth_data(p_list, i);\r
+                       printf("%p: cluster ID=%d, sns_type = %d, display_name= %s, \n", cluster, cluster->_id, cluster->sns_type,cluster->display_name);\r
+               }               \r
+//             minfo_free_glist(&p_list);\r
+               \r
+               err = minfo_get_cluster_list(cluster_filter2, _cluster_ite_fn, &p_list);\r
+\r
+               if( err < 0)\r
+               {\r
+                        printf("minfo_get_cluster_list failed\n");\r
+                        return -1;\r
+               }\r
+\r
+               img_cnt = g_list_length(p_list);\r
+               for(i=0; i<img_cnt; i++)\r
+               {\r
+                       cluster = (Mcluster*)g_list_nth_data(p_list, i);\r
+                       printf("%p: cluster ID=%d, sns_type = %d, display_name= %s, \n", cluster, cluster->_id, cluster->sns_type,cluster->display_name);\r
+               }               \r
+//             minfo_free_glist(&p_list);\r
+               break;\r
+\r
+       case 19:                                                                 //minfo_get_geo_item_list\r
+               printf("test minfo_get_geo_item_list...\n");\r
+               minfo_item_filter filter ={0};\r
+\r
+               for (i=0;i<5;i++)\r
+               {\r
+                       if (argv[2+i] == NULL)\r
+                       {\r
+                           printf("at least one parameter is null\n");\r
+                               return -1;\r
+                       }\r
+               }\r
+               cluster_id = atoi(argv[2]);\r
+               min_longitude = atof(argv[3]);\r
+               max_longitude = atof(argv[4]);\r
+               min_latitude = atof(argv[5]);\r
+               max_latitude = atof(argv[6]);\r
+\r
+               minfo_folder_type folder_type = MINFO_CLUSTER_TYPE_LOCAL_ALL;\r
+\r
+               minfo_item_filter item_filter1 = {MINFO_ITEM_ALL,MINFO_MEDIA_SORT_BY_NONE,-1,-1,true,MINFO_MEDIA_FAV_ALL};\r
+                       //minfo_item_filter item_filter1 = {MINFO_ITEM_IMAGE,MINFO_MEDIA_SORT_BY_DATE_DESC,0,1,FALSE,FALSE};\r
+               minfo_item_filter item_filter2 = {MINFO_ITEM_IMAGE,MINFO_MEDIA_SORT_BY_DATE_ASC,0,2,true,MINFO_MEDIA_FAV_ALL};\r
+               minfo_item_filter item_filter3 = {MINFO_ITEM_IMAGE,MINFO_MEDIA_SORT_BY_DATE_ASC,1,10,true,MINFO_MEDIA_FAV_ALL};\r
+               minfo_item_filter item_filter4 = {MINFO_ITEM_IMAGE,MINFO_MEDIA_SORT_BY_DATE_ASC,1,2,true,MINFO_MEDIA_FAV_ONLY};\r
+\r
+               err = minfo_get_geo_item_list(cluster_id, \r
+                                                                       folder_type,\r
+                                                           item_filter1, \r
+                                                           min_longitude, \r
+                                                           max_longitude, \r
+                                                           min_latitude, \r
+                                                           max_latitude,\r
+                                                                       _ite_fn,\r
+                                                           &p_list);\r
+\r
+               if( err < 0)\r
+               {\r
+                        printf("minfo_get_geo_item_list failed\n");\r
+                        return -1;\r
+               }\r
+\r
+               img_cnt = g_list_length(p_list);\r
+               printf("minfo_get_geo_item_list len = %d\n",img_cnt);\r
+               \r
+               for(i=0; i<img_cnt; i++)\r
+               {\r
+                       mitem = (Mitem*)g_list_nth_data(p_list, i);\r
+                       printf("item ID=%d, %s, %p\n",mitem->_id, mitem->file_url, mitem);\r
+                       minfo_mitem_destroy(mitem);\r
+               }\r
+               _mb_svc_glist_free(&p_list, false);\r
+               printf("minfo_get_geo_item_list leave\n");\r
+               break;  \r
+\r
+\r
+       case 20:                                                                 //minfo_delete_web_cluster\r
+                       printf("test minfo_delete_web_cluster...\n");\r
+                       if(argv[2] != NULL)\r
+                       {\r
+                               cluster_id = atoi(argv[2]);\r
+                               printf("parameter cluster_id is %d\n",cluster_id);\r
+                               err = minfo_delete_web_cluster(cluster_id);\r
+                               if( err < 0)\r
+                               {\r
+                                       printf("minfo_delete_web_cluster failed\n");\r
+                                       return -1;\r
+                               }\r
+                       }    \r
+                       else\r
+                       {\r
+                               printf("minfo_delete_web_cluster: cluster id is null\n");\r
+                               return -1;\r
+                       }\r
+                       printf("minfo_delete_web_cluster leave\n");\r
+                       break;\r
+\r
+\r
+\r
+       case 21:                                                                 //minfo_add_web_media\r
+                       printf("test minfo_delete_web_cluster...\n");\r
+                       if((argv[2] != NULL)&&(argv[3] != NULL)&&(argv[4] != NULL)&&(argv[5] != NULL))\r
+                       {\r
+                               cluster_id = atoi(argv[2]);\r
+                               printf("parameter cluster_id is %d, http_url is %s,file name is %s,thumb path is %s\n",cluster_id,argv[3],argv[4],argv[5]);\r
+                               err = minfo_add_web_media(cluster_id, argv[3], argv[4], argv[5]);\r
+                               if( err < 0)\r
+                               {\r
+                               printf("minfo_add_web_media failed\n");\r
+                               return -1;\r
+                               }\r
+                       }    \r
+                       else\r
+                       {\r
+                               printf("minfo_add_web_media: at least one parameter is null\n");\r
+                               return -1;\r
+                       }\r
+                       break; \r
+       case 22:                                                                 //minfo_add_web_cluster\r
+                       printf("test minfo_add_web_cluster...\n");\r
+                       if((argv[2] != NULL)&&(argv[3] != NULL)&&(argv[4] != NULL))\r
+                       {\r
+                               sns_type = atoi(argv[2]);\r
+                               printf("parameter sns_type is %d, name is %s,web_account_id is %s\n",sns_type,argv[3],argv[4]);\r
+                               err = minfo_add_web_cluster(sns_type, argv[3],argv[4],&id);\r
+                               if( err < 0)\r
+                               {\r
+                               printf("minfo_add_web_cluster failed\n");\r
+                               return -1;\r
+                               }\r
+                       }    \r
+                       else\r
+                       {\r
+                               printf("minfo_add_web_cluster: at least one parameter is null\n");\r
+                               return -1;\r
+                       }\r
+       break; \r
+\r
+\r
+\r
+       case 23:                                                                 //minfo_add_cluster\r
+                       printf("test minfo_add_cluster...\n");\r
+                       if(argv[2] != NULL)\r
+                       {\r
+                               printf("parameter cluster_url is %s\n",argv[2]);\r
+                               err = minfo_add_cluster(argv[2],&id);\r
+                               if( err < 0)\r
+                               {\r
+                               printf("minfo_add_cluster failed\n");\r
+                               return -1;\r
+                               }\r
+                       }    \r
+                       else\r
+                       {\r
+                               printf("minfo_add_cluster: cluster_url is null\n");\r
+                               return -1;\r
+                       }\r
+       break; \r
+       case 24:                                                                 //minfo_delete_web_cluster\r
+                       printf("test minfo_delete_web_cluster...\n");\r
+                       if(argv[2] != NULL)\r
+                       {\r
+                               cluster_id = atoi(argv[2]); \r
+                               printf("parameter cluster_id is %d\n",cluster_id);\r
+                               err = minfo_delete_web_cluster(cluster_id);\r
+                               if( err < 0)\r
+                               {\r
+                               printf("minfo_delete_web_cluster failed\n");\r
+                               return -1;\r
+                               }\r
+                       }    \r
+                       else\r
+                       {\r
+                               printf("minfo_delete_web_cluster: cluster_id is null\n");\r
+                               return -1;\r
+                       }\r
+       break; \r
+\r
+\r
+       case 25:                                                                 //minfo_get_meta_info\r
+                       printf("test minfo_delete_web_cluster...\n");\r
+                       if(argv[2] != NULL)\r
+                       {\r
+\r
+                               media_id = atoi(argv[2]); \r
+                               printf("parameter media_id is %d\n",media_id);\r
+                               ret = minfo_get_meta_info(media_id, &mt);\r
+                               if( ret < 0)\r
+                               {\r
+                                       printf("minfo_get_meta_info failed\n");\r
+                                       return -1;\r
+                               }\r
+                               if(mt->type == MINFO_ITEM_IMAGE) {\r
+                               printf("item_id =%d, mt->image_info--address%p", mt->item_id, mt->image_info);\r
+                               }\r
+                               else if(mt->type == MINFO_ITEM_VIDEO) {\r
+                               printf("item_id =%d, mt->video_info--address%p, duration+%d", mt->item_id, mt->video_info, mt->video_info->duration);\r
+                       }    \r
+                       }    \r
+                       else\r
+                       {\r
+                               printf("minfo_get_meta_info: media_id is null\n");\r
+                               return -1;\r
+                       }\r
+                       break; \r
+\r
+       case 26:\r
+/*\r
+                       _mb_svc_drop_tbl();     \r
+                       _mb_svc_create_tbl();\r
+                       test_insert_record_bookmark();\r
+                       test_insert_record_folder();\r
+                       test_insert_record_media();\r
+                       test_insert_record_video_meta();\r
+                       test_insert_record_image_meta();\r
+                       test_insert_record_webstreaming();\r
+*/\r
+                       break; \r
+       case 27:\r
+               printf("test minfo_move_media...\n");\r
+               if(argv[2] != NULL && argv[3] != NULL)\r
+               {\r
+                       printf("parameter old path is %s\n",argv[2]);\r
+                       printf("parameter new path is %s\n",argv[3]);\r
+                       minfo_move_media( argv[2], argv[3], MINFO_ITEM_IMAGE);\r
+               }\r
+               break;\r
+       case 28:\r
+               printf("minfo_copy_mediaminfo_move_media...\n");\r
+               if(argv[2] != NULL && argv[3] != NULL)\r
+               {\r
+                       printf("parameter old path is %s\n",argv[2]);\r
+                       printf("parameter new path is %s\n",argv[3]);\r
+                       minfo_copy_media( argv[2], argv[3], MINFO_ITEM_IMAGE);\r
+               }\r
+               break;  \r
+       case 29:\r
+               printf("minfo_mv_media...\n");\r
+               if(argv[2] != NULL && argv[3] != NULL)\r
+               {\r
+                       media_id = atoi(argv[2]);\r
+                       cluster_id = atoi(argv[3]);\r
+                       printf("parameter media idis %d\n",media_id);\r
+                       printf("parameter cluster id is %d\n",cluster_id);\r
+                       minfo_mv_media( media_id,  cluster_id);\r
+               }\r
+               break;\r
+       case 30:\r
+               printf("minfo_cp_media...\n");\r
+               if(argv[2] != NULL && argv[3] != NULL)\r
+               {\r
+                       media_id = atoi(argv[2]);\r
+                       cluster_id = atoi(argv[3]);\r
+                       printf("parameter media idis %d\n",media_id);\r
+                       printf("parameter cluster id is %d\n",cluster_id);\r
+                       minfo_cp_media( media_id,  cluster_id);\r
+               }\r
+               break;\r
+       case 31:\r
+               printf("test minfo_get_item \n");\r
+               if(argv[2] != NULL )\r
+               {\r
+                       Mitem* mi = NULL;\r
+                       ret = minfo_get_item(argv[2], &mi);\r
+                       if(ret < 0)\r
+                       {\r
+                               printf("minfo_get_item fail: %s \n", argv[2]);\r
+                               return -1;\r
+                       }\r
+\r
+                       printf("minfo_get_item:%s, %s \n", mi->thumb_url,mi->display_name);\r
+               }\r
+               break;\r
+       case 32:\r
+               printf("test minfo_get_cluster \n");\r
+               if(argv[2] != NULL )\r
+               {\r
+                       Mcluster* mc = NULL;\r
+                       ret = minfo_get_cluster(argv[2], 0, &mc);\r
+                       if(ret < 0)\r
+                       {\r
+                               printf("minfo_get_cluster fail: %s \n", argv[2]);\r
+                               return -1;\r
+                       }\r
+\r
+                       printf("minfo_get_cluster:%s, %s \n", mc->thumb_url,mc->display_name);\r
+               }\r
+       break;\r
+\r
+       case 33:\r
+               printf("test minfo_set_cluster_lock_status \n");\r
+               \r
+               ret = minfo_set_cluster_lock_status(2, 1);\r
+               if(ret < 0)\r
+               {\r
+                       printf("minfo_set_cluster_lock_status fail: \n" );\r
+                       return -1;\r
+               }\r
+\r
+               printf("minfo_set_cluster_lock\n");\r
+       break;\r
+\r
+       case 34:\r
+               printf("test minfo_get_cluster_lock_status \n");\r
+               int status = -1;\r
+               ret = minfo_get_cluster_lock_status(2, &status);\r
+               if(ret < 0)\r
+               {\r
+                       printf("minfo_get_cluster_lock_status fail\n" );\r
+                       return -1;\r
+               }\r
+\r
+               printf("minfo_get_cluster_lock_status : %d\n", status);\r
+       break;\r
+\r
+       case 35:\r
+               printf("test minfo_get_media_path \n");\r
+               char media_path[255] = {0,};\r
+\r
+               ret = minfo_get_media_path(MINFO_PHONE, media_path, 255);\r
+               if(ret < 0)\r
+               {\r
+                       printf("minfo_get_media_path fails\n" );\r
+                       return -1;\r
+               }\r
+\r
+               printf("minfo_get_media_path : %s\n", media_path);\r
+       break;\r
+\r
+       case 36:\r
+               printf("test minfo_get_thumb_path \n");\r
+               char thumb_path[255] = {0,};\r
+\r
+               if(argv[2] && argv[3]) {\r
+                       int type = atoi(argv[3]);\r
+                       if( type == 1 ) {\r
+                               ret = minfo_get_thumb_path(argv[2], thumb_path, 255);\r
+                       } else if( type == 2) {\r
+                               ret = minfo_get_thumb_path_for_video(argv[2], thumb_path, 255);\r
+                       } else {\r
+                               printf("minfo_get_thumb_path fails( invalid type )\n" );\r
+                               return -1;\r
+                       }\r
+                       if(ret < 0)\r
+                       {\r
+                               printf("minfo_get_thumb_path fails\n" );\r
+                               return -1;\r
+                       }\r
+               }\r
+\r
+               printf("minfo_get_thumb_path : %s\n", thumb_path);\r
+       break;\r
+\r
+       case 37:\r
+               printf("test minfo_set_db_valid...\n");\r
+               if(argv[2] != NULL && argv[3] != NULL)\r
+               {\r
+                       printf("parameter one is %s\n",argv[2]);\r
+                       printf("parameter two is %s\n",argv[3]);\r
+                       minfo_set_db_valid(atoi(argv[2]), atoi(argv[3]));\r
+               }\r
+                       \r
+       break;\r
+\r
+\r
+       case 38:\r
+               printf("test minfo_get_cluster_name_by_id...\n");\r
+               int ret = -1;\r
+               char folder_name[100];\r
+\r
+               if(argv[2] != NULL )\r
+               {\r
+                       printf("parameter id is %s\n",argv[2]);\r
+                       \r
+                       ret = minfo_get_cluster_name_by_id(atoi(argv[2]), folder_name, 100 );\r
+                       if( ret < 0 ) {\r
+                               printf("Fail : %d", ret );\r
+                       } \r
+                       else {\r
+                               printf("Success : folder name is %s\n", folder_name);\r
+                       }\r
+               }\r
+                       \r
+       break;\r
+\r
+       case 39:\r
+               printf("test minfo_set_item_valid...\n");\r
+               if(argv[2] != NULL && argv[3] != NULL)\r
+               {\r
+                       printf("parameter store type is %s\n",argv[2]);\r
+                       printf("parameter valid is %s\n",argv[3]);\r
+                       minfo_set_item_valid(atoi(argv[2]), "/opt/media/Frinsd/seo1.jpg", atoi(argv[3]));\r
+               }\r
+                       \r
+       break;\r
+\r
+       case 40:\r
+               printf("test minfo_delete_invalid_media_records...\n");\r
+               if(argv[2] != NULL )\r
+               {\r
+                       printf("parameter store type is %s\n",argv[2]);\r
+                       ret = minfo_delete_invalid_media_records(atoi(argv[2]));\r
+                       if( ret < 0 ) {\r
+                               printf("minfo_delete_invalid_media_records fails : %d\n", ret );\r
+                       }\r
+               }\r
+                       \r
+       break;\r
+\r
+       case 41:\r
+               printf("test minfo_add_tag...\n");\r
+               if (argc < 4) {\r
+                       printf("test minfo_add_tag the count of arguments is wrong!\n");\r
+                       break;\r
+               }\r
+                       \r
+               if (argv[2] != NULL)\r
+               {\r
+                       printf("parameter store type is %s\n",argv[2]);\r
+                       ret = minfo_add_tag(atoi(argv[2]), argv[3]);\r
+                       if( ret < 0 ) {\r
+                               printf("minfo_add_tag fails : %d\n", ret );\r
+                       }\r
+               }\r
+                       \r
+       break;\r
+\r
+       case 42:\r
+               printf("test minfo_get_media_list_by_tagname...\n");\r
+                       \r
+               if (argv[2] != NULL)\r
+               {\r
+                       printf("parameter store type is %s\n",argv[2]);\r
+                       ret = minfo_get_media_list_by_tagname(argv[2], FALSE, _ite_fn, &p_list);\r
+                       if( ret < 0 ) {\r
+                               printf("minfo_get_media_list_by_tagname fails : %d\n", ret );\r
+                       }\r
+               }\r
+                       \r
+       break;\r
+\r
+       case 43:\r
+               printf("test minfo_get_tag_list_by_media_id...\n");\r
+                       \r
+               if (argv[2] != NULL)\r
+               {\r
+                       printf("parameter store type is %s\n",argv[2]);\r
+                       ret = minfo_get_tag_list_by_media_id(atoi(argv[2]), _ite_tag_fn, &p_list);\r
+                       if( ret < 0 ) {\r
+                               printf("minfo_get_tag_list_by_media_id fails : %d\n", ret );\r
+                       }\r
+               }\r
+                       \r
+       break;\r
+\r
+       case 44:\r
+               printf("test minfo_get_item_by_id \n");\r
+               if(argv[2] != NULL )\r
+               {\r
+                       Mitem* mi = NULL;\r
+                       ret = minfo_get_item_by_id(atoi(argv[2]), &mi);\r
+                       if(ret < 0)\r
+                       {\r
+                               printf("minfo_get_item_by_id fail: %s \n", argv[2]);\r
+                               return -1;\r
+                       }\r
+\r
+                       printf("minfo_get_item_by_id:%s, %s \n", mi->thumb_url,mi->display_name);\r
+               }\r
+               break;\r
+\r
+       case 45:\r
+               printf("test minfo_get_cluster_fullpath_by_id \n");\r
+               char __folder_path[MB_SVC_FILE_PATH_LEN_MAX+1] = {0};\r
+               if(argv[2] != NULL )\r
+               {\r
+                       Mitem* mi = NULL;\r
+                       ret = minfo_get_cluster_fullpath_by_id(atoi(argv[2]), __folder_path, sizeof(__folder_path));\r
+                       if(ret < 0)\r
+                       {\r
+                               printf("minfo_get_cluster_fullpath_by_id fail: %d \n", ret);\r
+                               return -1;\r
+                       }\r
+\r
+                       printf("minfo_get_cluster_fullpath_by_id:%s\n", __folder_path);\r
+               }\r
+               break;\r
+\r
+       \r
+       case 46:\r
+                       printf("test minfo_rename_tag \n");\r
+                       if(argv[2] != NULL && argv[3] != NULL)\r
+                       {\r
+                               Mitem* mi = NULL;\r
+                               ret = minfo_rename_tag(argv[2], argv[3]);\r
+                               if(ret < 0)\r
+                               {\r
+                                       printf("minfo_rename_tag fail: %d \n", ret);\r
+                                       return -1;\r
+                               }\r
+                       }\r
+                       break;\r
+                       \r
+       case 47:\r
+                       printf("test minfo_rename_tag_by_id! \n");\r
+                       if(argv[2] != NULL && argv[3] != NULL && argv[4] != NULL)\r
+                       {\r
+                               Mitem* mi = NULL;\r
+                               ret = minfo_rename_tag_by_id(atoi(argv[2]), argv[3], argv[4]);\r
+                               if(ret < 0)\r
+                               {\r
+                                       printf("minfo_rename_tag_by_id fail: %d \n", ret);\r
+                                       return -1;\r
+                               }\r
+                       }\r
+                       break;\r
+                       \r
+       default:\r
+                 printf("wrong test sequence, no matched test case exist!!\n");                          \r
+                 return -1;\r
+       }        \r
+\r
+       err = minfo_finalize();\r
+\r
+       if(err<0)\r
+       {\r
+               printf("minfo_finalize error\n");\r
+               return -1;\r
+       }\r
+    printf("this is test programe------------leave\n");\r
+    return 0;\r
+\r
+       printf("################################################\n");\r
+       printf("---------------self-test problem succeed---------\n");\r
+       printf("################################################\n");\r
+}\r
+\r
diff --git a/uuid/COPYING b/uuid/COPYING
new file mode 100644 (file)
index 0000000..3c0180c
--- /dev/null
@@ -0,0 +1,36 @@
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, and the entire permission notice in its entirety,
+   including the disclaimer of warranties.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote
+   products derived from this software without specific prior
+   written permission.
+
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+
+This package, the EXT2 filesystem utilities, are made available under
+the GNU Public License version 2, with the exception of the lib/ext2fs
+and lib/e2p libraries, which are made available under the GNU Library
+General Public License Version 2, the lib/uuid library which is made
+available under a BSD-style license and the lib/et and lib/ss
+libraries which are made available under an MIT-style license.  Please
+see lib/uuid/COPYING for more details for the license for the files
+comprising the libuuid library, and the source file headers of the 
+libet and libss libraries for more information.
+
diff --git a/uuid/clear.c b/uuid/clear.c
new file mode 100644 (file)
index 0000000..2d91fee
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * clear.c -- Clear a UUID
+ *
+ * Copyright (C) 1996, 1997 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * %End-Header%
+ */
+
+#include "string.h"
+
+#include "uuidP.h"
+
+void uuid_clear(uuid_t uu)
+{
+       memset(uu, 0, 16);
+}
+
diff --git a/uuid/compare.c b/uuid/compare.c
new file mode 100644 (file)
index 0000000..f28a726
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * compare.c --- compare whether or not two UUID's are the same
+ *
+ * Returns 0 if the two UUID's are different, and 1 if they are the same.
+ *
+ * Copyright (C) 1996, 1997 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * %End-Header%
+ */
+
+#include "uuidP.h"
+#include <string.h>
+
+#define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1);
+
+int uuid_compare(const uuid_t uu1, const uuid_t uu2)
+{
+       struct uuid     uuid1, uuid2;
+
+       uuid_unpack(uu1, &uuid1);
+       uuid_unpack(uu2, &uuid2);
+
+       UUCMP(uuid1.time_low, uuid2.time_low);
+       UUCMP(uuid1.time_mid, uuid2.time_mid);
+       UUCMP(uuid1.time_hi_and_version, uuid2.time_hi_and_version);
+       UUCMP(uuid1.clock_seq, uuid2.clock_seq);
+       return memcmp(uuid1.node, uuid2.node, 6);
+}
+
diff --git a/uuid/copy.c b/uuid/copy.c
new file mode 100644 (file)
index 0000000..ead33aa
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * copy.c --- copy UUIDs
+ *
+ * Copyright (C) 1996, 1997 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * %End-Header%
+ */
+
+#include "uuidP.h"
+
+void uuid_copy(uuid_t dst, const uuid_t src)
+{
+       unsigned char           *cp1;
+       const unsigned char     *cp2;
+       int                     i;
+
+       for (i=0, cp1 = dst, cp2 = src; i < 16; i++)
+               *cp1++ = *cp2++;
+}
diff --git a/uuid/gen_uuid.c b/uuid/gen_uuid.c
new file mode 100644 (file)
index 0000000..48a7f4a
--- /dev/null
@@ -0,0 +1,672 @@
+/*
+ * gen_uuid.c --- generate a DCE-compatible uuid
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * %End-Header%
+ */
+
+/*
+ * Force inclusion of SVID stuff since we need it if we're compiling in
+ * gcc-wall wall mode
+ */
+#define _SVID_SOURCE
+
+#ifdef _WIN32
+#define _WIN32_WINNT 0x0500
+#include <windows.h>
+#define UUID MYUUID
+#endif
+#include <stdio.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <sys/wait.h>
+#include <sys/stat.h>
+#ifdef HAVE_SYS_FILE_H
+#include <sys/file.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_SYS_UN_H
+#include <sys/un.h>
+#endif
+#ifdef HAVE_SYS_SOCKIO_H
+#include <sys/sockio.h>
+#endif
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_NET_IF_DL_H
+#include <net/if_dl.h>
+#endif
+#if defined(__linux__) && defined(HAVE_SYS_SYSCALL_H)
+#include <sys/syscall.h>
+#endif
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
+#include "uuidP.h"
+#include "uuidd.h"
+
+#ifdef HAVE_SRANDOM
+#define srand(x)       srandom(x)
+#define rand()                 random()
+#endif
+
+#ifdef TLS
+#define THREAD_LOCAL static TLS
+#else
+#define THREAD_LOCAL static
+#endif
+
+#if defined(__linux__) && defined(__NR_gettid) && defined(HAVE_JRAND48)
+#define DO_JRAND_MIX
+THREAD_LOCAL unsigned short jrand_seed[3];
+#endif
+
+#ifdef _WIN32
+static void gettimeofday (struct timeval *tv, void *dummy)
+{
+       FILETIME        ftime;
+       uint64_t        n;
+
+       GetSystemTimeAsFileTime (&ftime);
+       n = (((uint64_t) ftime.dwHighDateTime << 32)
+            + (uint64_t) ftime.dwLowDateTime);
+       if (n) {
+               n /= 10;
+               n -= ((369 * 365 + 89) * (uint64_t) 86400) * 1000000;
+       }
+
+       tv->tv_sec = n / 1000000;
+       tv->tv_usec = n % 1000000;
+}
+
+static int getuid (void)
+{
+       return 1;
+}
+#endif
+
+static int get_random_fd(void)
+{
+       struct timeval  tv;
+       static int      fd = -2;
+       int             i;
+
+       if (fd == -2) {
+               gettimeofday(&tv, 0);
+#ifndef _WIN32
+               fd = open("/dev/urandom", O_RDONLY);
+               if (fd == -1)
+                       fd = open("/dev/random", O_RDONLY | O_NONBLOCK);
+               if (fd >= 0) {
+                       i = fcntl(fd, F_GETFD);
+                       if (i >= 0)
+                               fcntl(fd, F_SETFD, i | FD_CLOEXEC);
+               }
+#endif
+               srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
+#ifdef DO_JRAND_MIX
+               jrand_seed[0] = getpid() ^ (tv.tv_sec & 0xFFFF);
+               jrand_seed[1] = getppid() ^ (tv.tv_usec & 0xFFFF);
+               jrand_seed[2] = (tv.tv_sec ^ tv.tv_usec) >> 16;
+#endif
+       }
+       /* Crank the random number generator a few times */
+       gettimeofday(&tv, 0);
+       for (i = (tv.tv_sec ^ tv.tv_usec) & 0x1F; i > 0; i--)
+               rand();
+       return fd;
+}
+
+
+/*
+ * Generate a series of random bytes.  Use /dev/urandom if possible,
+ * and if not, use srandom/random.
+ */
+static void get_random_bytes(void *buf, int nbytes)
+{
+       int i, n = nbytes, fd = get_random_fd();
+       int lose_counter = 0;
+       unsigned char *cp = (unsigned char *) buf;
+#ifdef DO_JRAND_MIX
+       unsigned short tmp_seed[3];
+#endif
+
+       if (fd >= 0) {
+               while (n > 0) {
+                       i = read(fd, cp, n);
+                       if (i <= 0) {
+                               if (lose_counter++ > 16)
+                                       break;
+                               continue;
+                       }
+                       n -= i;
+                       cp += i;
+                       lose_counter = 0;
+               }
+       }
+
+       /*
+        * We do this all the time, but this is the only source of
+        * randomness if /dev/random/urandom is out to lunch.
+        */
+       for (cp = buf, i = 0; i < nbytes; i++)
+               *cp++ ^= (rand() >> 7) & 0xFF;
+#ifdef DO_JRAND_MIX
+       memcpy(tmp_seed, jrand_seed, sizeof(tmp_seed));
+       jrand_seed[2] = jrand_seed[2] ^ syscall(__NR_gettid);
+       for (cp = buf, i = 0; i < nbytes; i++)
+               *cp++ ^= (jrand48(tmp_seed) >> 7) & 0xFF;
+       memcpy(jrand_seed, tmp_seed,
+              sizeof(jrand_seed)-sizeof(unsigned short));
+#endif
+
+       return;
+}
+
+/*
+ * Get the ethernet hardware address, if we can find it...
+ *
+ * XXX for a windows version, probably should use GetAdaptersInfo:
+ * http://www.codeguru.com/cpp/i-n/network/networkinformation/article.php/c5451
+ * commenting out get_node_id just to get gen_uuid to compile under windows
+ * is not the right way to go!
+ */
+static int get_node_id(unsigned char *node_id)
+{
+#ifdef HAVE_NET_IF_H
+       int             sd;
+       struct ifreq    ifr, *ifrp;
+       struct ifconf   ifc;
+       char buf[1024];
+       int             n, i;
+       unsigned char   *a;
+#ifdef HAVE_NET_IF_DL_H
+       struct sockaddr_dl *sdlp;
+#endif
+
+/*
+ * BSD 4.4 defines the size of an ifreq to be
+ * max(sizeof(ifreq), sizeof(ifreq.ifr_name)+ifreq.ifr_addr.sa_len
+ * However, under earlier systems, sa_len isn't present, so the size is
+ * just sizeof(struct ifreq)
+ */
+#ifdef HAVE_SA_LEN
+#ifndef max
+#define max(a,b) ((a) > (b) ? (a) : (b))
+#endif
+#define ifreq_size(i) max(sizeof(struct ifreq),\
+     sizeof((i).ifr_name)+(i).ifr_addr.sa_len)
+#else
+#define ifreq_size(i) sizeof(struct ifreq)
+#endif /* HAVE_SA_LEN*/
+
+       sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
+       if (sd < 0) {
+               return -1;
+       }
+       memset(buf, 0, sizeof(buf));
+       ifc.ifc_len = sizeof(buf);
+       ifc.ifc_buf = buf;
+       if (ioctl (sd, SIOCGIFCONF, (char *)&ifc) < 0) {
+               close(sd);
+               return -1;
+       }
+       n = ifc.ifc_len;
+       for (i = 0; i < n; i+= ifreq_size(*ifrp) ) {
+               ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i);
+               strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ);
+#ifdef SIOCGIFHWADDR
+               if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0)
+                       continue;
+               a = (unsigned char *) &ifr.ifr_hwaddr.sa_data;
+#else
+#ifdef SIOCGENADDR
+               if (ioctl(sd, SIOCGENADDR, &ifr) < 0)
+                       continue;
+               a = (unsigned char *) ifr.ifr_enaddr;
+#else
+#ifdef HAVE_NET_IF_DL_H
+               sdlp = (struct sockaddr_dl *) &ifrp->ifr_addr;
+               if ((sdlp->sdl_family != AF_LINK) || (sdlp->sdl_alen != 6))
+                       continue;
+               a = (unsigned char *) &sdlp->sdl_data[sdlp->sdl_nlen];
+#else
+               /*
+                * XXX we don't have a way of getting the hardware
+                * address
+                */
+               close(sd);
+               return 0;
+#endif /* HAVE_NET_IF_DL_H */
+#endif /* SIOCGENADDR */
+#endif /* SIOCGIFHWADDR */
+               if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5])
+                       continue;
+               if (node_id) {
+                       memcpy(node_id, a, 6);
+                       close(sd);
+                       return 1;
+               }
+       }
+       close(sd);
+#endif
+       return 0;
+}
+
+/* Assume that the gettimeofday() has microsecond granularity */
+#define MAX_ADJUSTMENT 10
+
+static int get_clock(uint32_t *clock_high, uint32_t *clock_low,
+                    uint16_t *ret_clock_seq, int *num)
+{
+       THREAD_LOCAL int                adjustment = 0;
+       THREAD_LOCAL struct timeval     last = {0, 0};
+       THREAD_LOCAL int                state_fd = -2;
+       THREAD_LOCAL FILE               *state_f;
+       THREAD_LOCAL uint16_t           clock_seq;
+       struct timeval                  tv;
+       struct flock                    fl;
+       uint64_t                        clock_reg;
+       mode_t                          save_umask;
+       int                             len;
+
+       if (state_fd == -2) {
+               save_umask = umask(0);
+               state_fd = open("/var/lib/libuuid/clock.txt",
+                               O_RDWR|O_CREAT, 0660);
+               (void) umask(save_umask);
+               state_f = fdopen(state_fd, "r+");
+               if (!state_f) {
+                       close(state_fd);
+                       state_fd = -1;
+               }
+       }
+       fl.l_type = F_WRLCK;
+       fl.l_whence = SEEK_SET;
+       fl.l_start = 0;
+       fl.l_len = 0;
+       fl.l_pid = 0;
+       if (state_fd >= 0) {
+               rewind(state_f);
+               while (fcntl(state_fd, F_SETLKW, &fl) < 0) {
+                       if ((errno == EAGAIN) || (errno == EINTR))
+                               continue;
+                       fclose(state_f);
+                       close(state_fd);
+                       state_fd = -1;
+                       break;
+               }
+       }
+       if (state_fd >= 0) {
+               unsigned int cl;
+               unsigned long tv1, tv2;
+               int a;
+
+               if (fscanf(state_f, "clock: %04x tv: %lu %lu adj: %d\n",
+                          &cl, &tv1, &tv2, &a) == 4) {
+                       clock_seq = cl & 0x3FFF;
+                       last.tv_sec = tv1;
+                       last.tv_usec = tv2;
+                       adjustment = a;
+               }
+       }
+
+       if ((last.tv_sec == 0) && (last.tv_usec == 0)) {
+               get_random_bytes(&clock_seq, sizeof(clock_seq));
+               clock_seq &= 0x3FFF;
+               gettimeofday(&last, 0);
+               last.tv_sec--;
+       }
+
+try_again:
+       gettimeofday(&tv, 0);
+       if ((tv.tv_sec < last.tv_sec) ||
+           ((tv.tv_sec == last.tv_sec) &&
+            (tv.tv_usec < last.tv_usec))) {
+               clock_seq = (clock_seq+1) & 0x3FFF;
+               adjustment = 0;
+               last = tv;
+       } else if ((tv.tv_sec == last.tv_sec) &&
+           (tv.tv_usec == last.tv_usec)) {
+               if (adjustment >= MAX_ADJUSTMENT)
+                       goto try_again;
+               adjustment++;
+       } else {
+               adjustment = 0;
+               last = tv;
+       }
+
+       clock_reg = tv.tv_usec*10 + adjustment;
+       clock_reg += ((uint64_t) tv.tv_sec)*10000000;
+       clock_reg += (((uint64_t) 0x01B21DD2) << 32) + 0x13814000;
+
+       if (num && (*num > 1)) {
+               adjustment += *num - 1;
+               last.tv_usec += adjustment / 10;
+               adjustment = adjustment % 10;
+               last.tv_sec += last.tv_usec / 1000000;
+               last.tv_usec = last.tv_usec % 1000000;
+       }
+
+       if (state_fd > 0) {
+               rewind(state_f);
+               len = fprintf(state_f, 
+                             "clock: %04x tv: %016lu %08lu adj: %08d\n",
+                             clock_seq, last.tv_sec, last.tv_usec, adjustment);
+               fflush(state_f);
+               if (ftruncate(state_fd, len) < 0) {
+                       fprintf(state_f, "                   \n");
+                       fflush(state_f);
+               }
+               rewind(state_f);
+               fl.l_type = F_UNLCK;
+               fcntl(state_fd, F_SETLK, &fl);
+       }
+
+       *clock_high = clock_reg >> 32;
+       *clock_low = clock_reg;
+       *ret_clock_seq = clock_seq;
+       return 0;
+}
+
+#if defined(USE_UUIDD) && defined(HAVE_SYS_UN_H)
+static ssize_t read_all(int fd, char *buf, size_t count)
+{
+       ssize_t ret;
+       ssize_t c = 0;
+       int tries = 0;
+
+       memset(buf, 0, count);
+       while (count > 0) {
+               ret = read(fd, buf, count);
+               if (ret <= 0) {
+                       if ((errno == EAGAIN || errno == EINTR || ret == 0) &&
+                           (tries++ < 5))
+                               continue;
+                       return c ? c : -1;
+               }
+               if (ret > 0)
+                       tries = 0;
+               count -= ret;
+               buf += ret;
+               c += ret;
+       }
+       return c;
+}
+
+/*
+ * Close all file descriptors
+ */
+#define HAVE_GETDTABLESIZE 1
+static void close_all_fds(void)
+{
+       int i, max;
+
+#if defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX)
+       max = sysconf(_SC_OPEN_MAX);
+#elif defined(HAVE_GETDTABLESIZE)
+       max = getdtablesize();
+#elif defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
+       struct rlimit rl;
+
+       getrlimit(RLIMIT_NOFILE, &rl);
+       max = rl.rlim_cur;
+#else
+       max = OPEN_MAX;
+#endif
+
+       for (i=0; i < max; i++) {
+               close(i);
+               if (i <= 2)
+                       open("/dev/null", O_RDWR);
+       }
+}
+#endif
+
+/*
+ * Try using the uuidd daemon to generate the UUID
+ *
+ * Returns 0 on success, non-zero on failure.
+ */
+static int get_uuid_via_daemon(int op, uuid_t out, int *num)
+{
+#if defined(USE_UUIDD) && defined(HAVE_SYS_UN_H)
+       char op_buf[64];
+       int op_len;
+       int s;
+       ssize_t ret;
+       int32_t reply_len = 0, expected = 16;
+       struct sockaddr_un srv_addr;
+       struct stat st;
+       pid_t pid;
+       static const char *uuidd_path = UUIDD_PATH;
+       static int access_ret = -2;
+       static int start_attempts = 0;
+
+       if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
+               return -1;
+
+       srv_addr.sun_family = AF_UNIX;
+       strcpy(srv_addr.sun_path, UUIDD_SOCKET_PATH);
+
+       if (connect(s, (const struct sockaddr *) &srv_addr,
+                   sizeof(struct sockaddr_un)) < 0) {
+               if (access_ret == -2)
+                       access_ret = access(uuidd_path, X_OK);
+               if (access_ret == 0)
+                       access_ret = stat(uuidd_path, &st);
+               if (access_ret == 0 && (st.st_mode & (S_ISUID | S_ISGID)) == 0)
+                       access_ret = access(UUIDD_DIR, W_OK);
+               if (access_ret == 0 && start_attempts++ < 5) {
+                       if ((pid = fork()) == 0) {
+                               close_all_fds();
+                               execl(uuidd_path, "uuidd", "-qT", "300",
+                                     (char *) NULL);
+                               exit(1);
+                       }
+                       (void) waitpid(pid, 0, 0);
+                       if (connect(s, (const struct sockaddr *) &srv_addr,
+                                   sizeof(struct sockaddr_un)) < 0)
+                               goto fail;
+               } else
+                       goto fail;
+       }
+       op_buf[0] = op;
+       op_len = 1;
+       if (op == UUIDD_OP_BULK_TIME_UUID) {
+               memcpy(op_buf+1, num, sizeof(*num));
+               op_len += sizeof(*num);
+               expected += sizeof(*num);
+       }
+
+       ret = write(s, op_buf, op_len);
+       if (ret < 1)
+               goto fail;
+
+       ret = read_all(s, (char *) &reply_len, sizeof(reply_len));
+       if (ret < 0)
+               goto fail;
+
+       if (reply_len != expected)
+               goto fail;
+
+       ret = read_all(s, op_buf, reply_len);
+
+       if (op == UUIDD_OP_BULK_TIME_UUID)
+               memcpy(op_buf+16, num, sizeof(int));
+
+       memcpy(out, op_buf, 16);
+
+       close(s);
+       return ((ret == expected) ? 0 : -1);
+
+fail:
+       close(s);
+#endif
+       return -1;
+}
+
+void uuid__generate_time(uuid_t out, int *num)
+{
+       static unsigned char node_id[6];
+       static int has_init = 0;
+       struct uuid uu;
+       uint32_t        clock_mid;
+
+       if (!has_init) {
+               if (get_node_id(node_id) <= 0) {
+                       get_random_bytes(node_id, 6);
+                       /*
+                        * Set multicast bit, to prevent conflicts
+                        * with IEEE 802 addresses obtained from
+                        * network cards
+                        */
+                       node_id[0] |= 0x01;
+               }
+               has_init = 1;
+       }
+       get_clock(&clock_mid, &uu.time_low, &uu.clock_seq, num);
+       uu.clock_seq |= 0x8000;
+       uu.time_mid = (uint16_t) clock_mid;
+       uu.time_hi_and_version = ((clock_mid >> 16) & 0x0FFF) | 0x1000;
+       memcpy(uu.node, node_id, 6);
+       uuid_pack(&uu, out);
+}
+
+void uuid_generate_time(uuid_t out)
+{
+#ifdef TLS
+       THREAD_LOCAL int                num = 0;
+       THREAD_LOCAL struct uuid        uu;
+       THREAD_LOCAL time_t             last_time = 0;
+       time_t                          now;
+
+       if (num > 0) {
+               now = time(0);
+               if (now > last_time+1)
+                       num = 0;
+       }
+       if (num <= 0) {
+               num = 1000;
+               if (get_uuid_via_daemon(UUIDD_OP_BULK_TIME_UUID,
+                                       out, &num) == 0) {
+                       last_time = time(0);
+                       uuid_unpack(out, &uu);
+                       num--;
+                       return;
+               }
+               num = 0;
+       }
+       if (num > 0) {
+               uu.time_low++;
+               if (uu.time_low == 0) {
+                       uu.time_mid++;
+                       if (uu.time_mid == 0)
+                               uu.time_hi_and_version++;
+               }
+               num--;
+               uuid_pack(&uu, out);
+               return;
+       }
+#else
+       if (get_uuid_via_daemon(UUIDD_OP_TIME_UUID, out, 0) == 0)
+               return;
+#endif
+
+       uuid__generate_time(out, 0);
+}
+
+
+void uuid__generate_random(uuid_t out, int *num)
+{
+       uuid_t  buf;
+       struct uuid uu;
+       int i, n;
+
+       if (!num || !*num)
+               n = 1;
+       else
+               n = *num;
+
+       for (i = 0; i < n; i++) {
+               get_random_bytes(buf, sizeof(buf));
+               uuid_unpack(buf, &uu);
+
+               uu.clock_seq = (uu.clock_seq & 0x3FFF) | 0x8000;
+               uu.time_hi_and_version = (uu.time_hi_and_version & 0x0FFF)
+                       | 0x4000;
+               uuid_pack(&uu, out);
+               out += sizeof(uuid_t);
+       }
+}
+
+void uuid_generate_random(uuid_t out)
+{
+       int     num = 1;
+       /* No real reason to use the daemon for random uuid's -- yet */
+
+       uuid__generate_random(out, &num);
+}
+
+
+/*
+ * This is the generic front-end to uuid_generate_random and
+ * uuid_generate_time.  It uses uuid_generate_random only if
+ * /dev/urandom is available, since otherwise we won't have
+ * high-quality randomness.
+ */
+void uuid_generate(uuid_t out)
+{
+       if (get_random_fd() >= 0)
+               uuid_generate_random(out);
+       else
+               uuid_generate_time(out);
+}
diff --git a/uuid/isnull.c b/uuid/isnull.c
new file mode 100644 (file)
index 0000000..931e7e7
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * isnull.c --- Check whether or not the UUID is null
+ *
+ * Copyright (C) 1996, 1997 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * %End-Header%
+ */
+
+#include "uuidP.h"
+
+/* Returns 1 if the uuid is the NULL uuid */
+int uuid_is_null(const uuid_t uu)
+{
+       const unsigned char     *cp;
+       int                     i;
+
+       for (i=0, cp = uu; i < 16; i++)
+               if (*cp++)
+                       return 0;
+       return 1;
+}
+
diff --git a/uuid/pack.c b/uuid/pack.c
new file mode 100644 (file)
index 0000000..097516d
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Internal routine for packing UUID's
+ *
+ * Copyright (C) 1996, 1997 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * %End-Header%
+ */
+
+#include <string.h>
+#include "uuidP.h"
+
+void uuid_pack(const struct uuid *uu, uuid_t ptr)
+{
+       uint32_t        tmp;
+       unsigned char   *out = ptr;
+
+       tmp = uu->time_low;
+       out[3] = (unsigned char) tmp;
+       tmp >>= 8;
+       out[2] = (unsigned char) tmp;
+       tmp >>= 8;
+       out[1] = (unsigned char) tmp;
+       tmp >>= 8;
+       out[0] = (unsigned char) tmp;
+
+       tmp = uu->time_mid;
+       out[5] = (unsigned char) tmp;
+       tmp >>= 8;
+       out[4] = (unsigned char) tmp;
+
+       tmp = uu->time_hi_and_version;
+       out[7] = (unsigned char) tmp;
+       tmp >>= 8;
+       out[6] = (unsigned char) tmp;
+
+       tmp = uu->clock_seq;
+       out[9] = (unsigned char) tmp;
+       tmp >>= 8;
+       out[8] = (unsigned char) tmp;
+
+       memcpy(out+10, uu->node, 6);
+}
+
diff --git a/uuid/parse.c b/uuid/parse.c
new file mode 100644 (file)
index 0000000..074383e
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * parse.c --- UUID parsing
+ *
+ * Copyright (C) 1996, 1997 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * %End-Header%
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+
+#include "uuidP.h"
+
+int uuid_parse(const char *in, uuid_t uu)
+{
+       struct uuid     uuid;
+       int             i;
+       const char      *cp;
+       char            buf[3];
+
+       if (strlen(in) != 36)
+               return -1;
+       for (i=0, cp = in; i <= 36; i++,cp++) {
+               if ((i == 8) || (i == 13) || (i == 18) ||
+                   (i == 23)) {
+                       if (*cp == '-')
+                               continue;
+                       else
+                               return -1;
+               }
+               if (i== 36)
+                       if (*cp == 0)
+                               continue;
+               if (!isxdigit(*cp))
+                       return -1;
+       }
+       uuid.time_low = strtoul(in, NULL, 16);
+       uuid.time_mid = strtoul(in+9, NULL, 16);
+       uuid.time_hi_and_version = strtoul(in+14, NULL, 16);
+       uuid.clock_seq = strtoul(in+19, NULL, 16);
+       cp = in+24;
+       buf[2] = 0;
+       for (i=0; i < 6; i++) {
+               buf[0] = *cp++;
+               buf[1] = *cp++;
+               uuid.node[i] = strtoul(buf, NULL, 16);
+       }
+
+       uuid_pack(&uuid, uu);
+       return 0;
+}
diff --git a/uuid/unpack.c b/uuid/unpack.c
new file mode 100644 (file)
index 0000000..beaaff3
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Internal routine for unpacking UUID
+ *
+ * Copyright (C) 1996, 1997 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * %End-Header%
+ */
+
+#include <string.h>
+#include "uuidP.h"
+
+void uuid_unpack(const uuid_t in, struct uuid *uu)
+{
+       const uint8_t   *ptr = in;
+       uint32_t                tmp;
+
+       tmp = *ptr++;
+       tmp = (tmp << 8) | *ptr++;
+       tmp = (tmp << 8) | *ptr++;
+       tmp = (tmp << 8) | *ptr++;
+       uu->time_low = tmp;
+
+       tmp = *ptr++;
+       tmp = (tmp << 8) | *ptr++;
+       uu->time_mid = tmp;
+
+       tmp = *ptr++;
+       tmp = (tmp << 8) | *ptr++;
+       uu->time_hi_and_version = tmp;
+
+       tmp = *ptr++;
+       tmp = (tmp << 8) | *ptr++;
+       uu->clock_seq = tmp;
+
+       memcpy(uu->node, ptr, 6);
+}
+
diff --git a/uuid/unparse.c b/uuid/unparse.c
new file mode 100644 (file)
index 0000000..a95bbb0
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * unparse.c -- convert a UUID to string
+ *
+ * Copyright (C) 1996, 1997 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * %End-Header%
+ */
+
+#include <stdio.h>
+
+#include "uuidP.h"
+
+static const char *fmt_lower =
+       "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x";
+
+static const char *fmt_upper =
+       "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X";
+
+#ifdef UUID_UNPARSE_DEFAULT_UPPER
+#define FMT_DEFAULT fmt_upper
+#else
+#define FMT_DEFAULT fmt_lower
+#endif
+
+static void uuid_unparse_x(const uuid_t uu, char *out, const char *fmt)
+{
+       struct uuid uuid;
+
+       uuid_unpack(uu, &uuid);
+       sprintf(out, fmt,
+               uuid.time_low, uuid.time_mid, uuid.time_hi_and_version,
+               uuid.clock_seq >> 8, uuid.clock_seq & 0xFF,
+               uuid.node[0], uuid.node[1], uuid.node[2],
+               uuid.node[3], uuid.node[4], uuid.node[5]);
+}
+
+void uuid_unparse_lower(const uuid_t uu, char *out)
+{
+       uuid_unparse_x(uu, out, fmt_lower);
+}
+
+void uuid_unparse_upper(const uuid_t uu, char *out)
+{
+       uuid_unparse_x(uu, out, fmt_upper);
+}
+
+void uuid_unparse(const uuid_t uu, char *out)
+{
+       uuid_unparse_x(uu, out, FMT_DEFAULT);
+}
diff --git a/uuid/uuid.h b/uuid/uuid.h
new file mode 100644 (file)
index 0000000..ca846da
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Public include file for the UUID library
+ *
+ * Copyright (C) 1996, 1997, 1998 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * %End-Header%
+ */
+
+#ifndef _UUID_UUID_H
+#define _UUID_UUID_H
+
+#include <sys/types.h>
+#ifndef _WIN32
+#include <sys/time.h>
+#endif
+#include <time.h>
+
+typedef unsigned char uuid_t[16];
+
+/* UUID Variant definitions */
+#define UUID_VARIANT_NCS       0
+#define UUID_VARIANT_DCE       1
+#define UUID_VARIANT_MICROSOFT 2
+#define UUID_VARIANT_OTHER     3
+
+/* UUID Type definitions */
+#define UUID_TYPE_DCE_TIME   1
+#define UUID_TYPE_DCE_RANDOM 4
+
+/* Allow UUID constants to be defined */
+#ifdef __GNUC__
+#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
+       static const uuid_t name __attribute__ ((unused)) = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
+#else
+#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
+       static const uuid_t name = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* clear.c */
+void uuid_clear(uuid_t uu);
+
+/* compare.c */
+int uuid_compare(const uuid_t uu1, const uuid_t uu2);
+
+/* copy.c */
+void uuid_copy(uuid_t dst, const uuid_t src);
+
+/* gen_uuid.c */
+void uuid_generate(uuid_t out);
+void uuid_generate_random(uuid_t out);
+void uuid_generate_time(uuid_t out);
+
+/* isnull.c */
+int uuid_is_null(const uuid_t uu);
+
+/* parse.c */
+int uuid_parse(const char *in, uuid_t uu);
+
+/* unparse.c */
+void uuid_unparse(const uuid_t uu, char *out);
+void uuid_unparse_lower(const uuid_t uu, char *out);
+void uuid_unparse_upper(const uuid_t uu, char *out);
+
+/* uuid_time.c */
+time_t uuid_time(const uuid_t uu, struct timeval *ret_tv);
+int uuid_type(const uuid_t uu);
+int uuid_variant(const uuid_t uu);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _UUID_UUID_H */
diff --git a/uuid/uuidP.h b/uuid/uuidP.h
new file mode 100644 (file)
index 0000000..86d86c5
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * uuid.h -- private header file for uuids
+ *
+ * Copyright (C) 1996, 1997 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * %End-Header%
+ */
+
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#include <uuid/uuid_types.h>
+#endif
+#include <sys/types.h>
+
+#include <uuid/uuid.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+/*
+ * Offset between 15-Oct-1582 and 1-Jan-70
+ */
+#define TIME_OFFSET_HIGH 0x01B21DD2
+#define TIME_OFFSET_LOW  0x13814000
+
+struct uuid {
+       uint32_t        time_low;
+       uint16_t        time_mid;
+       uint16_t        time_hi_and_version;
+       uint16_t        clock_seq;
+       uint8_t node[6];
+};
+
+
+/*
+ * prototypes
+ */
+void uuid_pack(const struct uuid *uu, uuid_t ptr);
+void uuid_unpack(const uuid_t in, struct uuid *uu);
diff --git a/uuid/uuid_time.c b/uuid/uuid_time.c
new file mode 100644 (file)
index 0000000..f25f5c9
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * uuid_time.c --- Interpret the time field from a uuid.  This program
+ *     violates the UUID abstraction barrier by reaching into the guts
+ *     of a UUID and interpreting it.
+ *
+ * Copyright (C) 1998, 1999 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * %End-Header%
+ */
+
+#ifdef _WIN32
+#define _WIN32_WINNT 0x0500
+#include <windows.h>
+#define UUID MYUUID
+#endif
+
+#include <stdio.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <stdlib.h>
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <time.h>
+
+#include "uuidP.h"
+
+time_t uuid_time(const uuid_t uu, struct timeval *ret_tv)
+{
+       struct timeval          tv;
+       struct uuid             uuid;
+       uint32_t                high;
+       uint64_t                clock_reg;
+
+       uuid_unpack(uu, &uuid);
+
+       high = uuid.time_mid | ((uuid.time_hi_and_version & 0xFFF) << 16);
+       clock_reg = uuid.time_low | ((uint64_t) high << 32);
+
+       clock_reg -= (((uint64_t) 0x01B21DD2) << 32) + 0x13814000;
+       tv.tv_sec = clock_reg / 10000000;
+       tv.tv_usec = (clock_reg % 10000000) / 10;
+
+       if (ret_tv)
+               *ret_tv = tv;
+
+       return tv.tv_sec;
+}
+
+int uuid_type(const uuid_t uu)
+{
+       struct uuid             uuid;
+
+       uuid_unpack(uu, &uuid);
+       return ((uuid.time_hi_and_version >> 12) & 0xF);
+}
+
+int uuid_variant(const uuid_t uu)
+{
+       struct uuid             uuid;
+       int                     var;
+
+       uuid_unpack(uu, &uuid);
+       var = uuid.clock_seq;
+
+       if ((var & 0x8000) == 0)
+               return UUID_VARIANT_NCS;
+       if ((var & 0x4000) == 0)
+               return UUID_VARIANT_DCE;
+       if ((var & 0x2000) == 0)
+               return UUID_VARIANT_MICROSOFT;
+       return UUID_VARIANT_OTHER;
+}
+
+#ifdef DEBUG
+static const char *variant_string(int variant)
+{
+       switch (variant) {
+       case UUID_VARIANT_NCS:
+               return "NCS";
+       case UUID_VARIANT_DCE:
+               return "DCE";
+       case UUID_VARIANT_MICROSOFT:
+               return "Microsoft";
+       default:
+               return "Other";
+       }
+}
+
+
+int
+main(int argc, char **argv)
+{
+       uuid_t          buf;
+       time_t          time_reg;
+       struct timeval  tv;
+       int             type, variant;
+
+       if (argc != 2) {
+               fprintf(stderr, "Usage: %s uuid\n", argv[0]);
+               exit(1);
+       }
+       if (uuid_parse(argv[1], buf)) {
+               fprintf(stderr, "Invalid UUID: %s\n", argv[1]);
+               exit(1);
+       }
+       variant = uuid_variant(buf);
+       type = uuid_type(buf);
+       time_reg = uuid_time(buf, &tv);
+
+       printf("UUID variant is %d (%s)\n", variant, variant_string(variant));
+       if (variant != UUID_VARIANT_DCE) {
+               printf("Warning: This program only knows how to interpret "
+                      "DCE UUIDs.\n\tThe rest of the output is likely "
+                      "to be incorrect!!\n");
+       }
+       printf("UUID type is %d", type);
+       switch (type) {
+       case 1:
+               printf(" (time based)\n");
+               break;
+       case 2:
+               printf(" (DCE)\n");
+               break;
+       case 3:
+               printf(" (name-based)\n");
+               break;
+       case 4:
+               printf(" (random)\n");
+               break;
+       default:
+               printf("\n");
+       }
+       if (type != 1) {
+               printf("Warning: not a time-based UUID, so UUID time "
+                      "decoding will likely not work!\n");
+       }
+       printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, tv.tv_usec,
+              ctime(&time_reg));
+
+       return 0;
+}
+#endif
diff --git a/uuid/uuid_types.h b/uuid/uuid_types.h
new file mode 100644 (file)
index 0000000..169a88a
--- /dev/null
@@ -0,0 +1,50 @@
+/* 
+ * If linux/types.h is already been included, assume it has defined
+ * everything we need.  (cross fingers)  Other header files may have 
+ * also defined the types that we need.
+ */
+#if (!defined(_STDINT_H) && !defined(_UUID_STDINT_H))
+#define _UUID_STDINT_H
+
+typedef unsigned char uint8_t;
+typedef signed char int8_t;
+
+#if (4 == 8)
+typedef int            int64_t;
+typedef unsigned int   uint64_t;
+#elif (4 == 8)
+typedef long           int64_t;
+typedef unsigned long  uint64_t;
+#elif (8 == 8)
+#if defined(__GNUC__)
+typedef __signed__ long long   int64_t;
+#else
+typedef signed long long       int64_t;
+#endif
+typedef unsigned long long     uint64_t;
+#endif
+
+#if (4 == 2)
+typedef        int             int16_t;
+typedef        unsigned int    uint16_t;
+#elif (2 == 2)
+typedef        short           int16_t;
+typedef        unsigned short  uint16_t;
+#else
+  ?==error: undefined 16 bit type
+#endif
+
+#if (4 == 4)
+typedef        int             int32_t;
+typedef        unsigned int    uint32_t;
+#elif (4 == 4)
+typedef        long            int32_t;
+typedef        unsigned long   uint32_t;
+#elif (2 == 4)
+typedef        short           int32_t;
+typedef        unsigned short  uint32_t;
+#else
+ ?== error: undefined 32 bit type
+#endif
+
+#endif
diff --git a/uuid/uuidd.h b/uuid/uuidd.h
new file mode 100644 (file)
index 0000000..c71f4b7
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Definitions used by the uuidd daemon
+ *
+ * Copyright (C) 2007 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * %End-Header%
+ */
+
+#ifndef _UUID_UUIDD_H
+#define _UUID_UUIDD_H
+
+#define UUIDD_DIR              "/var/lib/libuuid"
+#define UUIDD_SOCKET_PATH      UUIDD_DIR "/request"
+#define UUIDD_PIDFILE_PATH     UUIDD_DIR "/uuidd.pid"
+#define UUIDD_PATH             "/usr/sbin/uuidd"
+
+#define UUIDD_OP_GETPID                        0
+#define UUIDD_OP_GET_MAXOP             1
+#define UUIDD_OP_TIME_UUID             2
+#define UUIDD_OP_RANDOM_UUID           3
+#define UUIDD_OP_BULK_TIME_UUID                4
+#define UUIDD_OP_BULK_RANDOM_UUID      5
+#define UUIDD_MAX_OP                   UUIDD_OP_BULK_RANDOM_UUID
+
+extern void uuid__generate_time(uuid_t out, int *num);
+extern void uuid__generate_random(uuid_t out, int *num);
+
+#endif /* _UUID_UUID_H */