upload tizen1.0 source
authorKim Kibum <kb0929.kim@samsung.com>
Sun, 29 Apr 2012 08:01:15 +0000 (17:01 +0900)
committerKim Kibum <kb0929.kim@samsung.com>
Sun, 29 Apr 2012 08:01:15 +0000 (17:01 +0900)
27 files changed:
CMakeLists.txt
TC/utc/audio/Makefile
debian/changelog
debian/control
include/audio-svc-types.h
include/visual-svc.h
packaging/libmedia-service.spec
plugin/media-svc-plugin.c [new file with mode: 0755]
src/audio/audio-svc-db-utils.c
src/audio/audio-svc-music-table.c
src/audio/audio-svc-utils.c
src/audio/audio-svc.c
src/common/media-svc-util.c
src/include/audio/audio-svc-types-priv.h
src/include/common/media-svc-util.h
src/include/visual/media-svc-structures.h
src/include/visual/visual-svc-util.h
src/visual/media-svc-api.c
src/visual/media-svc-db.c
src/visual/minfo-api.c
src/visual/minfo-bookmark.c
src/visual/minfo-meta.c
src/visual/visual-svc-util.c
test/audio/audio_svc_test.c
test/plugin/Makefile [new file with mode: 0644]
test/plugin/media_svc_plugin_test.c [new file with mode: 0755]
test/test_media_info.c

index 6e915b4..66f1d7a 100644 (file)
@@ -5,6 +5,7 @@ SET(VERSION "${VERSION_MAJOR}.0.0")
 
 SET(MEDIASERVICE-LIB "media-service")
 SET(MEDIASERVICE-HASH-LIB "media-svc-hash")
+SET(MEDIASERVICE-PLUGIN-LIB "media-svc-plugin")
 SET(SRCS 
        src/visual/media-svc-db.c
        src/visual/media-svc-db-util.c
@@ -53,6 +54,10 @@ SET(HASH_SRCS
        md5/media-svc-hash.c
        )
 
+SET(PLUGIN_SRCS
+       plugin/media-svc-plugin.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)
@@ -77,7 +82,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src/include/
 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
+dlog sqlite3 db-util mm-common  mm-fileinfo drm-service aul media-thumbnail
 libexif gthread-2.0 vconf ecore-evas evas mmutil-imgp mmutil-jpeg dbus-1)
 
 
@@ -118,9 +123,14 @@ 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})
+ADD_LIBRARY(${MEDIASERVICE-PLUGIN-LIB} SHARED ${PLUGIN_SRCS})
+TARGET_LINK_LIBRARIES(${MEDIASERVICE-PLUGIN-LIB} ${MEDIASERVICE-LIB})
+SET_TARGET_PROPERTIES(${MEDIASERVICE-PLUGIN-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${MEDIASERVICE-PLUGIN-LIB} PROPERTIES VERSION ${VERSION})
 
 INSTALL(TARGETS ${MEDIASERVICE-LIB} LIBRARY DESTINATION lib)
 INSTALL(TARGETS ${MEDIASERVICE-HASH-LIB} LIBRARY DESTINATION lib)
+INSTALL(TARGETS ${MEDIASERVICE-PLUGIN-LIB} LIBRARY DESTINATION lib)
 
 #ADD_EXECUTABLE( media_service_test ${TEST-SRCS})
 #TARGET_LINK_LIBRARIES(media_service_test ${pkgs_LDFLAGS} ${MEDIASERVICE-LIB} )
index 8004771..56f3cca 100755 (executable)
@@ -13,6 +13,7 @@ endif
 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
@@ -36,6 +37,7 @@ TS30=utc_audio_svc_list_item_get_func
 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
index 20abb9a..696382a 100755 (executable)
@@ -1,3 +1,27 @@
+libmedia-service (0.2.0-6) unstable; urgency=low
+
+  * Fix build errors
+  * Git : pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.2.0-6
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 21 Mar 2012 16:35:00 +0900
+
+libmedia-service (0.2.0-5) unstable; urgency=low
+
+  * Fix build errors
+  * Git : pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.2.0-5
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 21 Mar 2012 16:30:00 +0900
+
+libmedia-service (0.2.0-4) unstable; urgency=low
+
+  * Push for tizen 1.0 release
+  * Git : pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.2.0-4
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 19 Mar 2012 18:30:00 +0900
+
 libmedia-service (0.2.0-3) unstable; urgency=low
 
   * Change that makes user managing db handle
index 6a5cd6a..36cdd7a 100755 (executable)
@@ -13,6 +13,7 @@ Build-Depends: debhelper (>= 5), libglib2.0-dev,
                libexif-dev,
                libevas-dev,
                libecore-dev,
+               libmedia-thumbnail-dev,
                libaul-1-dev
 Standards-Version: 0.1
 Homepage: N/A
@@ -26,7 +27,7 @@ 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
+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, libmedia-thumbnail, libaul-1-dev
 Description: Media information service library for multimedia applications. (development)
 
 Package: libmedia-service-dbg
index b0abe5a..aeae010 100755 (executable)
@@ -146,6 +146,7 @@ typedef enum{
        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_ALBUM,                                      /**< Album of media file*/\r
 }audio_svc_list_item_type_e;\r
 \r
 /**\r
index 544a0fa..8eb6f97 100755 (executable)
@@ -261,7 +261,7 @@ DEPRECATED_API int
 minfo_get_all_item_cnt(MediaSvcHandle *mb_svc_handle, int *cnt);
 
 /**
- * minfo_get_all_item_conut
+ * minfo_get_all_item_count
  * This function gets count of all records in the specific storage.
  * User can specify folder type like MINFO_CLUSTER_TYPE_ALL, MINFO_CLUSTER_TYPE_LOCAL_PHONE, etc.
  * Please refer 'visual-svc-types.h' to know what folder type exists.
@@ -283,7 +283,7 @@ minfo_get_all_item_cnt(MediaSvcHandle *mb_svc_handle, int *cnt);
 
 #include <media-svc.h>
 
-void test_minfo_get_all_item_conut(MediaSvcHandle *mb_svc_handle)
+void test_minfo_get_all_item_count(MediaSvcHandle *mb_svc_handle)
 {
        int ret = -1;
        int cnt = 0;
@@ -291,7 +291,7 @@ void test_minfo_get_all_item_conut(MediaSvcHandle *mb_svc_handle)
        minfo_file_type file_type = MINFO_ITEM_ALL;
        minfo_media_favorite_type fav_type = MINFO_MEDIA_FAV_ALL;
 
-       ret = minfo_get_all_item_conut(mb_svc_handle, folder_type, file_type, fav_type, &cnt);
+       ret = minfo_get_all_item_count(mb_svc_handle, folder_type, file_type, fav_type, &cnt);
        if(ret< 0) {
                printf("minfo_get_all_item_cnt error\n");
                return;
index e53573c..6690c9f 100644 (file)
@@ -1,76 +1,80 @@
-Name:      libmedia-service
-Summary:    Media Service
-Version:       0.2.0
-Release:    0
+Name:       libmedia-service
+Summary:    Media information service library for multimedia applications.
+Version: 0.2.0
+Release:    6
 Group:      System/Libraries
 License:    Apache-2.0
 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(dbus-1)
-BuildRequires: pkgconfig(libexif)
-BuildRequires: pkgconfig(xdmcp)
-BuildRequires: pkgconfig(x11)
-BuildRequires: pkgconfig(xrender)
-BuildRequires: pkgconfig(xcb)
-BuildRequires: pkgconfig(xau)
-BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(ecore-evas)
-BuildRequires: pkgconfig(evas)
-BuildRequires: pkgconfig(mmutil-imgp)
-
+BuildRequires:  cmake
+BuildRequires:  edje-tools
+BuildRequires:  expat-devel 
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(ecore)
+BuildRequires:  pkgconfig(evas)
+BuildRequires:  pkgconfig(edje)
+BuildRequires:  pkgconfig(utilX)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(mmutil-imgp)
+BuildRequires:  pkgconfig(x11)
+BuildRequires:  pkgconfig(mm-common)
+BuildRequires:  pkgconfig(mmutil-jpeg)
+BuildRequires:  pkgconfig(dbus-1)
+BuildRequires:  pkgconfig(libexif)
+BuildRequires:  pkgconfig(xdmcp)
+BuildRequires:  pkgconfig(xrender)
+BuildRequires:  pkgconfig(libpng)
+BuildRequires:  pkgconfig(libpng12)
+BuildRequires:  pkgconfig(sqlite3)
+BuildRequires:  pkgconfig(db-util)
+BuildRequires:  pkgconfig(mm-fileinfo)
+BuildRequires:  pkgconfig(media-thumbnail)
+BuildRequires:  pkgconfig(drm-service)
+BuildRequires:  pkgconfig(aul)
 
 %description
 Media information service library for multimedia applications.
 
-
 %package devel
-Summary:    Media Service
+Summary:    Media information service library for multimedia applications. (development)
 Group:      Development/Libraries
 Requires:   %{name} = %{version}-%{release}
 
 %description devel
-Media information service library for multimedia applications. (developement files)
+Media information service library for multimedia applications. (development files)
 
-%prep
-%setup -q
 
+%prep
+%setup -q 
 
-%build
 cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
 
-
+%build
 make %{?jobs:-j%jobs}
 
 %install
+rm -rf %{buildroot}
 %make_install
 
-
 %post -p /sbin/ldconfig
 
 %postun -p /sbin/ldconfig
 
-
 %files
-/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
+%defattr(-,root,root,-)
+%{_libdir}/libmedia-service.so
+%{_libdir}/libmedia-service.so.1
+%{_libdir}/libmedia-service.so.1.0.0
+%{_libdir}/libmedia-svc-hash.so
+%{_libdir}/libmedia-svc-hash.so.1
+%{_libdir}/libmedia-svc-hash.so.1.0.0
+%{_libdir}/libmedia-svc-plugin.so
+%{_libdir}/libmedia-svc-plugin.so.1
+%{_libdir}/libmedia-svc-plugin.so.1.0.0
 
 %files devel
-/usr/lib/libmedia-service.so
-/usr/lib/libmedia-svc-hash.so
-/usr/lib/pkgconfig/libmedia-service.pc
-/usr/include/media-service/*.h
+%{_libdir}/pkgconfig/libmedia-service.pc
+%{_includedir}/media-service/*.h
diff --git a/plugin/media-svc-plugin.c b/plugin/media-svc-plugin.c
new file mode 100755 (executable)
index 0000000..4dc92a2
--- /dev/null
@@ -0,0 +1,925 @@
+/*
+ * 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 <mm_file.h>
+#include <media-thumbnail.h>
+#include "media-svc.h"
+#include "audio-svc.h"
+#include "visual-svc.h"
+
+#define MEDIA_SVC_PLUGIN_ERROR_NONE            0
+#define MEDIA_SVC_PLUGIN_ERROR                 -1
+#define MEDIA_SVC_PLUGIN_STORAGE_INTERNAL      0
+#define MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL      1
+
+#define STRING_VALID(str)      \
+       ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
+#define STORAGE_VALID(storage)\
+       (((storage == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL) || (storage == MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL)) ? TRUE : FALSE)
+
+typedef enum{
+       CONTENT_TYPE_SOUND,
+       CONTENT_TYPE_MUSIC,
+       CONTENT_TYPE_IMAGE,
+       CONTENT_TYPE_VIDEO,
+       CONTENT_TYPE_MAX,
+}media_svc_content_type_e;
+
+typedef enum{
+       ERR_FILE_PATH = 1,
+       ERR_HANDLE,
+       ERR_MIME_TYPE,
+       ERR_NOT_MEDIAFILE,
+       ERR_STORAGE_TYPE,
+       ERR_CHECK_ITEM,
+       ERR_MAX,
+}media_svc_error_type_e;
+
+#define MS_CATEGORY_UNKNOWN    0x00000000      /**< Default */
+#define MS_CATEGORY_ETC                0x00000001      /**< ETC category */
+#define MS_CATEGORY_IMAGE              0x00000002      /**< Image category */
+#define MS_CATEGORY_VIDEO              0x00000004      /**< Video category */
+#define MS_CATEGORY_MUSIC              0x00000008      /**< Music category */
+#define MS_CATEGORY_SOUND      0x00000010      /**< Sound category */
+
+#define CONTENT_TYPE_NUM 4
+#define MUSIC_MIME_NUM 28
+#define SOUND_MIME_NUM 1
+#define MIME_TYPE_LENGTH 255
+#define MIME_LENGTH 50
+#define _3GP_FILE ".3gp"
+#define _MP4_FILE ".mp4"
+
+
+typedef struct {
+       char content_type[15];
+       int category_by_mime;
+} fex_content_table_t;
+
+static const fex_content_table_t content_category[CONTENT_TYPE_NUM] = {
+       {"audio", MS_CATEGORY_SOUND},
+       {"image", MS_CATEGORY_IMAGE},
+       {"video", MS_CATEGORY_VIDEO},
+       {"application", MS_CATEGORY_ETC},
+};
+
+static const char music_mime_table[MUSIC_MIME_NUM][MIME_LENGTH] = {
+       /*known mime types of normal files*/
+       "mpeg",
+       "ogg",
+       "x-ms-wma",
+       "x-flac",
+       "mp4",
+       /* known mime types of drm files*/
+       "mp3",
+       "x-mp3", /*alias of audio/mpeg*/
+       "x-mpeg", /*alias of audio/mpeg*/
+       "3gpp",
+       "x-ogg", /*alias of  audio/ogg*/
+       "vnd.ms-playready.media.pya:*.pya", /*playready*/
+       "wma",
+       "aac",
+       "x-m4a", /*alias of audio/mp4*/
+       /* below mimes are rare*/
+       "x-vorbis+ogg",
+       "x-flac+ogg",
+       "x-matroska",
+       "ac3",
+       "mp2",
+       "x-ape",
+       "x-ms-asx",
+       "vnd.rn-realaudio",
+
+       "x-vorbis", /*alias of audio/x-vorbis+ogg*/
+       "vorbis", /*alias of audio/x-vorbis+ogg*/
+       "x-oggflac",
+       "x-mp2", /*alias of audio/mp2*/
+       "x-pn-realaudio", /*alias of audio/vnd.rn-realaudio*/
+       "vnd.m-realaudio", /*alias of audio/vnd.rn-realaudio*/
+};
+
+static const char sound_mime_table[SOUND_MIME_NUM][MIME_LENGTH] = {
+       "x-smaf",
+};
+
+static int __get_content_type_from_mime(const char * path, const char * mimetype, int * category);
+static int __get_content_type(const char * file_path, const char * mime_type);
+static void __set_error_message(int err_type, char ** err_msg);
+
+static int __get_content_type_from_mime(const char * path, const char * mimetype, int * category)
+{
+       int i = 0;
+       int err = 0;
+
+       *category = MS_CATEGORY_UNKNOWN;
+
+       //MS_DBG("mime type : %s", mimetype);
+
+       /*categorize from mimetype */
+       for (i = 0; i < CONTENT_TYPE_NUM; i++) {
+               if (strstr(mimetype, content_category[i].content_type) != NULL) {
+                       *category = (*category | content_category[i].category_by_mime);
+                       break;
+               }
+       }
+
+       /*in application type, exitst sound file ex) x-smafs */
+       if (*category & MS_CATEGORY_ETC) {
+               int prefix_len = strlen(content_category[0].content_type);
+
+               for (i = 0; i < SOUND_MIME_NUM; i++) {
+                       if (strstr(mimetype + prefix_len, sound_mime_table[i]) != NULL) {
+                               *category ^= MS_CATEGORY_ETC;
+                               *category |= MS_CATEGORY_SOUND;
+                               break;
+                       }
+               }
+       }
+
+       /*check music file in soun files. */
+       if (*category & MS_CATEGORY_SOUND) {
+               int prefix_len = strlen(content_category[0].content_type) + 1;
+
+               //MS_DBG("mime_type : %s", mimetype + prefix_len);
+
+               for (i = 0; i < MUSIC_MIME_NUM; i++) {
+                       if (strcmp(mimetype + prefix_len, music_mime_table[i]) == 0) {
+                               *category ^= MS_CATEGORY_SOUND;
+                               *category |= MS_CATEGORY_MUSIC;
+                               break;
+                       }
+               }
+       } else if (*category & MS_CATEGORY_VIDEO) {
+               /*some video files don't have video stream. in this case it is categorize as music. */
+               char *ext;
+               /*"3gp" and "mp4" must check video stream and then categorize in directly. */
+               ext = strrchr(path, '.');
+               if (ext != NULL) {
+                       if ((strncasecmp(ext, _3GP_FILE, 4) == 0) || (strncasecmp(ext, _MP4_FILE, 5) == 0)) {
+                               int audio = 0;
+                               int video = 0;
+
+                               err = mm_file_get_stream_info(path, &audio, &video);
+                               if (err == 0) {
+                                       if (audio > 0 && video == 0) {
+                                               *category ^= MS_CATEGORY_VIDEO;
+                                               *category |= MS_CATEGORY_MUSIC;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       //MS_DBG("category_from_ext : %d", *category);
+
+       return err;
+}
+
+static int __get_content_type(const char * file_path, const char * mime_type)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+       int category = 0;
+
+       ret = __get_content_type_from_mime(file_path, mime_type, &category);
+       if(ret < 0)
+               return ret;
+
+       if (category & MS_CATEGORY_SOUND)               return CONTENT_TYPE_SOUND;
+       else if (category & MS_CATEGORY_MUSIC)  return CONTENT_TYPE_MUSIC;
+       else if (category & MS_CATEGORY_IMAGE)  return CONTENT_TYPE_IMAGE;
+       else if (category & MS_CATEGORY_VIDEO)  return CONTENT_TYPE_VIDEO;
+       else    return CONTENT_TYPE_MAX;
+
+}
+
+static void __set_error_message(int err_type, char ** err_msg)
+{
+       if (err_msg)
+               *err_msg = NULL;
+
+       if(err_type == ERR_FILE_PATH)
+               *err_msg = strdup("invalid file path");
+       if(err_type == ERR_HANDLE)
+               *err_msg = strdup("invalid handle");
+       else if(err_type == ERR_MIME_TYPE)
+               *err_msg = strdup("invalid mime type");
+       else if(err_type == ERR_NOT_MEDIAFILE)
+               *err_msg = strdup("not media content");
+       else if(err_type == ERR_STORAGE_TYPE)
+                       *err_msg = strdup("invalid storage type");
+       else if(err_type == ERR_CHECK_ITEM)
+               *err_msg = strdup("item does not exist");
+       else if(err_type == MEDIA_INFO_ERROR_DATABASE_CONNECT)
+               *err_msg = strdup("DB connect error");
+       else if(err_type == MEDIA_INFO_ERROR_DATABASE_DISCONNECT)
+               *err_msg = strdup("DB disconnect error");
+       else if((err_type == AUDIO_SVC_ERROR_INVALID_PARAMETER) || (err_type == MB_SVC_ERROR_INVALID_PARAMETER))
+               *err_msg = strdup("invalid parameter");
+       else if((err_type == AUDIO_SVC_ERROR_DB_INTERNAL) ||(err_type == MB_SVC_ERROR_DB_INTERNAL))
+               *err_msg = strdup("DB internal error");
+       else if((err_type == AUDIO_SVC_ERROR_INTERNAL) || (err_type == MB_SVC_ERROR_INTERNAL))
+               *err_msg = strdup("media service internal error");
+       else
+               *err_msg = strdup("error unknown");
+
+}
+
+int check_item(const char *file_path, const char * mime_type, char ** err_msg)
+{
+       int content_type = 0;
+
+       if (!STRING_VALID(file_path)) {
+               __set_error_message(ERR_FILE_PATH, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STRING_VALID(mime_type)) {
+               __set_error_message(ERR_MIME_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       content_type = __get_content_type(file_path, mime_type);
+
+       if(content_type == CONTENT_TYPE_MAX) {
+               __set_error_message(ERR_NOT_MEDIAFILE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;          //not media file
+       }
+       else
+               return MEDIA_SVC_PLUGIN_ERROR_NONE;     //media file
+
+}
+
+int connect(void ** handle, char ** err_msg)
+{
+       int ret = media_svc_connect(handle);
+
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int disconnect(void * handle, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_disconnect(handle);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int check_item_exist(void* handle, const char *file_path, int storage_type, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STRING_VALID(file_path)) {
+               __set_error_message(ERR_FILE_PATH, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if(!STORAGE_VALID(storage_type)) {
+               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = audio_svc_check_item_exist(handle, file_path);
+       if(ret == 0)
+               return MEDIA_SVC_PLUGIN_ERROR_NONE;     //exist
+
+       ret = minfo_check_item_exist(handle, file_path);
+       if(ret == 0)
+               return MEDIA_SVC_PLUGIN_ERROR_NONE;     //exist
+
+       __set_error_message(ERR_CHECK_ITEM, err_msg);
+       return MEDIA_SVC_PLUGIN_ERROR;          //not exist
+
+}
+
+int insert_item_begin(void * handle, int item_cnt, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = audio_svc_insert_item_start(handle, item_cnt);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = minfo_add_media_start(handle, item_cnt);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int insert_item_end(void * handle, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = audio_svc_insert_item_end(handle);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = minfo_add_media_end(handle);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int insert_item(void * handle, const char *file_path, int storage_type, const char * mime_type, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STRING_VALID(file_path)) {
+               __set_error_message(ERR_FILE_PATH, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STRING_VALID(mime_type)) {
+               __set_error_message(ERR_MIME_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if(!STORAGE_VALID(storage_type)) {
+               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       media_svc_content_type_e content_type = __get_content_type(file_path, mime_type);
+
+       if(content_type == CONTENT_TYPE_SOUND || content_type == CONTENT_TYPE_MUSIC)    {
+
+               if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL) {
+
+                       if(content_type == CONTENT_TYPE_SOUND)
+                               ret = audio_svc_insert_item(handle, AUDIO_SVC_STORAGE_PHONE, file_path, AUDIO_SVC_CATEGORY_SOUND);
+                       else
+                               ret = audio_svc_insert_item(handle, AUDIO_SVC_STORAGE_PHONE, file_path, AUDIO_SVC_CATEGORY_MUSIC);
+
+               } else if (storage_type == MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL) {
+
+                       if(content_type == CONTENT_TYPE_SOUND)
+                               ret = audio_svc_insert_item(handle, AUDIO_SVC_STORAGE_MMC, file_path, AUDIO_SVC_CATEGORY_SOUND);
+                       else
+                               ret = audio_svc_insert_item(handle, AUDIO_SVC_STORAGE_MMC, file_path, AUDIO_SVC_CATEGORY_MUSIC);
+
+               }
+
+       } else if (content_type == CONTENT_TYPE_IMAGE || content_type == CONTENT_TYPE_VIDEO) {
+
+               if(content_type == CONTENT_TYPE_IMAGE)
+                       ret = minfo_add_media_batch(handle, file_path, MINFO_ITEM_IMAGE);
+               else
+                       ret = minfo_add_media_batch(handle, file_path, MINFO_ITEM_VIDEO);
+
+       } else {
+
+               __set_error_message(ERR_NOT_MEDIAFILE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+
+       }
+
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int insert_item_immediately(void * handle, const char *file_path, int storage_type, const char * mime_type, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STRING_VALID(file_path)) {
+               __set_error_message(ERR_FILE_PATH, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STRING_VALID(mime_type)) {
+               __set_error_message(ERR_MIME_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if(!STORAGE_VALID(storage_type)) {
+               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       media_svc_content_type_e content_type = __get_content_type(file_path, mime_type);
+
+       if(content_type == CONTENT_TYPE_SOUND || content_type == CONTENT_TYPE_MUSIC)    {
+
+               if(storage_type == 0) {
+
+                       if(content_type == CONTENT_TYPE_SOUND)
+                               ret = audio_svc_insert_item_immediately(handle, AUDIO_SVC_STORAGE_PHONE, file_path, AUDIO_SVC_CATEGORY_SOUND);
+                       else
+                               ret = audio_svc_insert_item_immediately(handle, AUDIO_SVC_STORAGE_PHONE, file_path, AUDIO_SVC_CATEGORY_MUSIC);
+
+               } else if (storage_type == 1) {
+
+                       if(content_type == CONTENT_TYPE_SOUND)
+                               ret = audio_svc_insert_item_immediately(handle, AUDIO_SVC_STORAGE_MMC, file_path, AUDIO_SVC_CATEGORY_SOUND);
+                       else
+                               ret = audio_svc_insert_item_immediately(handle, AUDIO_SVC_STORAGE_MMC, file_path, AUDIO_SVC_CATEGORY_MUSIC);
+
+               }
+
+       } else if (content_type == CONTENT_TYPE_IMAGE || content_type == CONTENT_TYPE_VIDEO) {
+
+               if(content_type == CONTENT_TYPE_IMAGE)
+                       ret = minfo_add_media(handle, file_path, MINFO_ITEM_IMAGE);
+               else
+                       ret = minfo_add_media(handle, file_path, MINFO_ITEM_VIDEO);
+
+       } else {
+
+               __set_error_message(ERR_NOT_MEDIAFILE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+
+       }
+
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+
+int move_item_begin(void * handle, int item_cnt, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = audio_svc_move_item_start(handle, item_cnt);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = minfo_move_media_start(handle, item_cnt);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int move_item_end(void * handle, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = audio_svc_move_item_end(handle);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = minfo_move_media_end(handle);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int move_item(void * handle, const char *src_path, int src_storage_type, const char *dest_path, int dest_storage_type, const char * mime_type, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if ((!STRING_VALID(src_path)) || (!STRING_VALID(dest_path))) {
+               __set_error_message(ERR_FILE_PATH, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STRING_VALID(mime_type)) {
+               __set_error_message(ERR_MIME_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if((!STORAGE_VALID(src_storage_type)) || (!STORAGE_VALID(dest_storage_type))) {
+               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       media_svc_content_type_e content_type = __get_content_type(src_path, mime_type);
+
+       if(content_type == CONTENT_TYPE_SOUND || content_type == CONTENT_TYPE_MUSIC)    {
+
+               ret = audio_svc_move_item(handle, src_storage_type, src_path, dest_storage_type, dest_path);
+
+       } else if (content_type == CONTENT_TYPE_IMAGE || content_type == CONTENT_TYPE_VIDEO) {
+
+               if(content_type == CONTENT_TYPE_IMAGE)
+                       ret = minfo_move_media(handle, src_path, dest_path, MINFO_ITEM_IMAGE);
+               else
+                       ret = minfo_move_media(handle, src_path, dest_path, MINFO_ITEM_VIDEO);
+
+       } else {
+
+               __set_error_message(ERR_NOT_MEDIAFILE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+
+       }
+
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+
+int set_all_storage_items_validity(void * handle, int storage_type, int validity, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if(!STORAGE_VALID(storage_type)) {
+               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL) {
+               ret = audio_svc_set_db_valid(handle, AUDIO_SVC_STORAGE_PHONE, validity);
+               if(ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               }
+
+               ret = minfo_set_db_valid(handle, MINFO_PHONE, validity);
+               if(ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               }
+
+       } else if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL) {
+
+               ret = audio_svc_set_db_valid(handle, AUDIO_SVC_STORAGE_MMC, validity);
+               if(ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               }
+
+               ret = minfo_set_db_valid(handle, MINFO_MMC, validity);
+               if(ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               }
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int set_item_validity_begin(void * handle, int item_cnt, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = audio_svc_set_item_valid_start(handle, item_cnt);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = minfo_set_item_valid_start(handle, item_cnt);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int set_item_validity_end(void * handle, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = audio_svc_set_item_valid_end(handle);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = minfo_set_item_valid_end(handle);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int set_item_validity(void * handle, const char *file_path, int storage_type, const char * mime_type, int validity, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STRING_VALID(file_path)) {
+               __set_error_message(ERR_FILE_PATH, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STRING_VALID(mime_type)) {
+               __set_error_message(ERR_MIME_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if(!STORAGE_VALID(storage_type)) {
+               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       media_svc_content_type_e content_type = __get_content_type(file_path, mime_type);
+
+       if(content_type == CONTENT_TYPE_SOUND || content_type == CONTENT_TYPE_MUSIC)    {
+
+               ret = audio_svc_set_item_valid(handle, file_path, validity);
+
+       } else if (content_type == CONTENT_TYPE_IMAGE || content_type == CONTENT_TYPE_VIDEO) {
+
+                       if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL)
+                               ret = minfo_set_item_valid(handle, MINFO_PHONE, file_path, validity);
+                       else if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL)
+                               ret = minfo_set_item_valid(handle, MINFO_MMC, file_path, validity);
+
+       } else {
+
+               __set_error_message(ERR_NOT_MEDIAFILE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+
+       }
+
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int delete_item(void * handle, const char *file_path, int storage_type, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if (!STRING_VALID(file_path)) {
+               __set_error_message(ERR_FILE_PATH, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if(!STORAGE_VALID(storage_type)) {
+               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = audio_svc_check_item_exist(handle, file_path);
+       if(ret == 0) {          /*audio file*/
+               ret = audio_svc_delete_item_by_path(handle, file_path);
+
+               if(ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               } else
+                       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+       }
+
+       ret = minfo_check_item_exist(handle, file_path);
+       if(ret == 0) {          /*visual file*/
+               ret = minfo_delete_media(handle, file_path);
+
+               if(ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               }
+               else
+                       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+       } 
+
+       __set_error_message(ERR_CHECK_ITEM, err_msg);   //not exist in DB so can't delete item.
+       return MEDIA_SVC_PLUGIN_ERROR;
+}
+
+int delete_all_items_in_storage(void * handle, int storage_type, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if(!STORAGE_VALID(storage_type)) {
+               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL) {
+
+               ret = audio_svc_delete_all(handle, AUDIO_SVC_STORAGE_PHONE);
+               if(ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               }
+
+               ret = minfo_delete_all_media_records(handle, MINFO_PHONE);
+               if(ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               }
+
+       } else if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL) {
+
+               ret = audio_svc_delete_all(handle,AUDIO_SVC_STORAGE_MMC);
+               if(ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               }
+               ret = minfo_delete_all_media_records(handle, MINFO_MMC);
+               if(ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               }
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int delete_all_invalid_items_in_storage(void * handle, int storage_type, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if(!STORAGE_VALID(storage_type)) {
+               __set_error_message(ERR_STORAGE_TYPE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL) {
+
+               ret =  audio_svc_delete_invalid_items(handle,AUDIO_SVC_STORAGE_PHONE);
+               if(ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               }
+
+               ret = minfo_delete_invalid_media_records(handle, MINFO_PHONE);
+               if(ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               }
+
+       } else if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL) {
+
+               ret =  audio_svc_delete_invalid_items(handle,AUDIO_SVC_STORAGE_MMC);
+               if(ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               }
+
+               ret = minfo_delete_invalid_media_records(handle, MINFO_MMC);
+               if(ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+               }
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int delete_all_items(void * handle, char ** err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = delete_all_items_in_storage(handle, MEDIA_SVC_PLUGIN_STORAGE_INTERNAL, err_msg);
+       if(ret < 0)
+               return MEDIA_SVC_PLUGIN_ERROR;
+
+       ret = delete_all_items_in_storage(handle, MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL, err_msg);
+       if(ret < 0)
+               return MEDIA_SVC_PLUGIN_ERROR;
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int update_begin(void)
+{
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int update_end(void)
+{
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
index 5865e82..64b9cd6 100755 (executable)
@@ -86,6 +86,7 @@ int _audio_svc_sql_query_list(sqlite3 *handle, GList **query_list)
                        sqlite3_free(sql);
                        sql = NULL;
                        if (err != SQLITE_OK) {
+                               _audio_svc_sql_query_release(query_list);
                                return AUDIO_SVC_ERROR_DB_INTERNAL;
                        }
                }
index b14ae5a..7f1539e 100755 (executable)
@@ -42,6 +42,7 @@
 typedef enum {
        AUDIO_SVC_AUDIO_INFO_AUDIO_ID,
        AUDIO_SVC_AUDIO_INFO_PATH,
+       AUDIO_SVC_AUDIO_INFO_FILE_NAME,
        AUDIO_SVC_AUDIO_INFO_THUMBNAIL_PATH,
        AUDIO_SVC_AUDIO_INFO_TITLE,
        AUDIO_SVC_AUDIO_INFO_ALBUM,
@@ -78,10 +79,6 @@ typedef enum {
 #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_uuid, 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_uuid, 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;
@@ -466,6 +463,9 @@ int _audio_svc_insert_item_with_data(sqlite3 *handle, audio_svc_audio_item_s *it
        char folder_id[AUDIO_SVC_UUID_SIZE+1] = {0,};
        int year = -1;
        char *audio_id = NULL;
+       char *g_audio_svc_music_fields = "audio_uuid, path, file_name, 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_uuid, storage_type";
+       char * file_name = NULL;
 
        if (item == NULL) {
                audio_svc_error("Invalid handle");
@@ -496,12 +496,15 @@ int _audio_svc_insert_item_with_data(sqlite3 *handle, audio_svc_audio_item_s *it
        ret = _audio_svc_get_and_append_folder_id_by_path(handle, item->pathname,  item->storage_type, folder_id);
        audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
 
+       file_name = g_path_get_basename( item->pathname);
+
        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);",
+           ("insert into %s (%s) values ('%q', '%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,
+            file_name,
             item->thumbname,
             item->audio.title,
             item->audio.album,
@@ -528,6 +531,8 @@ int _audio_svc_insert_item_with_data(sqlite3 *handle, audio_svc_audio_item_s *it
 
        audio_svc_debug("query : %s", sql);
 
+       SAFE_FREE(file_name);
+
        if(!stack_query) {
                err = _audio_svc_sql_query(handle, sql);
                sqlite3_free(sql);
@@ -2182,8 +2187,7 @@ int _audio_svc_get_music_track_records(sqlite3 *handle, audio_svc_track_type_e t
                                       int rows, audio_svc_list_item_s *track)
 {
        char query[AUDIO_SVC_QUERY_SIZE] = { 0 };
-       char *result_field =
-           "audio_uuid, path, thumbnail_path, title, artist, duration, rating";
+       char *result_field = "audio_uuid, path, thumbnail_path, title, artist, duration, rating, album";
 
        char tail_query[70] = { 0 };
        char filter_query[AUDIO_SVC_METADATA_LEN_MAX + 5] = { 0 };
@@ -2500,7 +2504,7 @@ int _audio_svc_get_music_track_records(sqlite3 *handle, audio_svc_track_type_e t
        case AUDIO_SVC_TRACK_BY_PLAYLIST:
                {
                        char *result_field_for_playlist =
-                           "b.audio_uuid, b.path, b.thumbnail_path, b.title, b.artist, b.duration, b.rating";
+                           "b.audio_uuid, b.path, b.thumbnail_path, b.title, b.artist, b.duration, b.rating, b.album";
                        len =
                            snprintf(query, sizeof(query),
                                     "select %s from %s a, %s b where a.playlist_id=%d and b.audio_uuid=a.audio_uuid and b.valid=1 and b.category=%d ",
@@ -2642,6 +2646,9 @@ int _audio_svc_get_music_track_records(sqlite3 *handle, audio_svc_track_type_e t
                              (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));
+               _strncpy_safe(track[idx].album,
+                             (const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_LIST_ITEM_ALBUM), 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_uuid = %s, title = %s, pathname = %s, duration = %d",
@@ -2846,6 +2853,23 @@ int _audio_svc_delete_invalid_music_records(sqlite3 *handle, audio_svc_storage_t
                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) {
index 0f1c57a..e54a024 100755 (executable)
@@ -147,6 +147,11 @@ int _audio_svc_extract_metadata_audio(audio_svc_storage_type_e storage_type, con
        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));
@@ -550,6 +555,18 @@ int _audio_svc_extract_metadata_audio(audio_svc_storage_type_e storage_type, con
 
                /* extract thumbnail image */
                /* 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) {
@@ -1109,9 +1126,10 @@ int _audio_svc_get_order_field_str(audio_svc_search_order_e order_field,
  
 int _audio_svc_get_file_dir_modified_date(const char *full_path)
 {
-       struct stat statbuf = { 0 };
+       struct stat statbuf;
        int fd = 0;
+
+       memset(&statbuf, 0, sizeof(struct stat));
        fd = stat(full_path, &statbuf);
        if (fd == -1) {
                 audio_svc_debug("stat(%s) fails.", full_path);
index 9335deb..0e32d46 100755 (executable)
@@ -100,6 +100,11 @@ int audio_svc_delete_all(MediaSvcHandle *handle, audio_svc_storage_type_e storag
        ret = _audio_svc_delete_folder(db_handle, 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;
 }
 
@@ -338,6 +343,16 @@ int audio_svc_delete_item_by_path(MediaSvcHandle *handle, const char *path)
        ret = _audio_svc_check_and_update_folder_table(db_handle, 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.");
@@ -1234,6 +1249,11 @@ int audio_svc_delete_invalid_items(MediaSvcHandle *handle, audio_svc_storage_typ
        ret = _audio_svc_update_folder_table(db_handle);
        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;
 }
 
@@ -1298,6 +1318,11 @@ int audio_svc_set_item_valid(MediaSvcHandle *handle, const char *path, int valid
                return AUDIO_SVC_ERROR_INVALID_PARAMETER;
        }
        
+#if 0  //original code
+       return _audio_svc_update_valid_in_music_record(path, valid);
+
+#else  //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 );
 
@@ -1327,6 +1352,7 @@ int audio_svc_set_item_valid(MediaSvcHandle *handle, const char *path, int valid
        }
 
        return AUDIO_SVC_ERROR_NONE;
+#endif
 }
 
 int audio_svc_get_path_by_audio_id(MediaSvcHandle *handle, const char *audio_id, char *path,
@@ -1650,6 +1676,20 @@ int audio_svc_list_item_get_val(AudioHandleType *record, int index,
 
                                break;
                        }
+               case AUDIO_SVC_LIST_ITEM_ALBUM:
+                       {
+                               char **val = va_arg((var_args), char **);
+                               int *size = va_arg((var_args), int *);
+                               if (strlen(item[index].album) == 0) {
+                                       audio_svc_debug("album is NULL");
+                                       *size = 0;
+                               } else {
+                                       *val = item[index].album;
+                                       *size = strlen(item[index].album);
+                               }
+
+                               break;
+                       }
                default:
                        {
                                audio_svc_error("Invalid arguments");
@@ -2673,6 +2713,7 @@ int audio_svc_list_by_search(MediaSvcHandle *handle, AudioHandleType *record,
        char query_where[AUDIO_SVC_QUERY_SIZE] = { 0 };
        char search_str[AUDIO_SVC_METADATA_LEN_MAX] = { 0 };
        char *condition_str = NULL;
+       char *escaped_search_str = NULL;
        
        audio_svc_audio_item_s *item = (audio_svc_audio_item_s *)record;
        sqlite3 * db_handle = (sqlite3 *)handle;
@@ -2729,7 +2770,14 @@ int audio_svc_list_by_search(MediaSvcHandle *handle, AudioHandleType *record,
                                                          sizeof(search_str)));
                                }
 
-                               condition_str = sqlite3_mprintf(" or title like '%%%q%%' ", search_str);
+                               escaped_search_str = _media_svc_escape_str((char *)search_str, strlen(search_str));
+                               if (escaped_search_str == NULL) {
+                                       audio_svc_error("Failed to escape");
+                                       return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               }
+
+                               condition_str = sqlite3_mprintf(" or title like '%%%q%%' ESCAPE('#') ", escaped_search_str);
+                               SAFE_FREE(escaped_search_str);
 
                                len =
                                        g_strlcat(query_where, condition_str,
@@ -2757,7 +2805,14 @@ int audio_svc_list_by_search(MediaSvcHandle *handle, AudioHandleType *record,
                                                          sizeof(search_str)));
                                }
 
-                               condition_str = sqlite3_mprintf(" or artist like '%%%q%%' ", search_str);
+                               escaped_search_str = _media_svc_escape_str((char *)search_str, strlen(search_str));
+                               if (escaped_search_str == NULL) {
+                                       audio_svc_error("Failed to escape");
+                                       return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               }
+
+                               condition_str = sqlite3_mprintf(" or artist like '%%%q%%' ESCAPE('#') ", escaped_search_str);
+                               SAFE_FREE(escaped_search_str);
 
                                len =
                                        g_strlcat(query_where, condition_str,
@@ -2785,7 +2840,14 @@ int audio_svc_list_by_search(MediaSvcHandle *handle, AudioHandleType *record,
                                                          sizeof(search_str)));
                                }
 
-                               condition_str = sqlite3_mprintf(" or album like '%%%q%%' ", search_str);
+                               escaped_search_str = _media_svc_escape_str((char *)search_str, strlen(search_str));
+                               if (escaped_search_str == NULL) {
+                                       audio_svc_error("Failed to escape");
+                                       return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               }
+
+                               condition_str = sqlite3_mprintf(" or album like '%%%q%%' ESCAPE('#') ", escaped_search_str);
+                               SAFE_FREE(escaped_search_str);
 
                                len =
                                        g_strlcat(query_where, condition_str,
@@ -2813,7 +2875,14 @@ int audio_svc_list_by_search(MediaSvcHandle *handle, AudioHandleType *record,
                                                          sizeof(search_str)));
                                }
 
-                               condition_str = sqlite3_mprintf(" or genre like '%%%q%%' ", search_str);
+                               escaped_search_str = _media_svc_escape_str((char *)search_str, strlen(search_str));
+                               if (escaped_search_str == NULL) {
+                                       audio_svc_error("Failed to escape");
+                                       return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               }
+
+                               condition_str = sqlite3_mprintf(" or genre like '%%%q%%' ESCAPE('#') ", escaped_search_str);
+                               SAFE_FREE(escaped_search_str);
 
                                len =
                                        g_strlcat(query_where, condition_str,
@@ -2839,7 +2908,14 @@ int audio_svc_list_by_search(MediaSvcHandle *handle, AudioHandleType *record,
                                                          sizeof(search_str)));
                                }
 
-                               condition_str = sqlite3_mprintf(" or author like '%%%q%%' ", search_str);
+                               escaped_search_str = _media_svc_escape_str((char *)search_str, strlen(search_str));
+                               if (escaped_search_str == NULL) {
+                                       audio_svc_error("Failed to escape");
+                                       return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+                               }
+
+                               condition_str = sqlite3_mprintf(" or author like '%%%q%%' ESCAPE('#') ", escaped_search_str);
+                               SAFE_FREE(escaped_search_str);
 
                                len =
                                        g_strlcat(query_where, condition_str,
index 006f837..c159313 100755 (executable)
@@ -20,6 +20,7 @@
  */
 
 #include "uuid.h"
+#include <stdlib.h>
 
 char *_media_info_generate_uuid(void)
 {
@@ -33,3 +34,44 @@ char *_media_info_generate_uuid(void)
        return uuid_unparsed;
 }
 
+int _media_svc_check_escape_char(char ch)
+{
+       int i;
+       char escape_char[3] = {'%', '_' ,'#'};
+
+       for (i = 0; i < 3; i++) {
+               if (ch == escape_char[i]) {
+                       return 1;
+               }
+       }
+
+       return 0;
+}
+
+char *_media_svc_escape_str(char *input, int len)
+{
+       int i = 0;
+       int j = 0;
+       char *result = NULL;
+       
+       result = (char*)malloc(len * 2 * sizeof(char) + 1);
+       if (result == NULL) {
+               return NULL;
+       }
+
+       for (i = 0; i < len; i++, j++) {
+               if (input[i] == '\0') break;
+
+               if (_media_svc_check_escape_char(input[i])) {
+                       result[j] = '#';
+                       result[++j] = input[i];
+               } else {
+                       result[j] = input[i];
+               }
+       }
+
+       result[j] = '\0';
+       
+       return result;
+}
+
index 1588d11..8f3eed2 100755 (executable)
@@ -103,6 +103,7 @@ typedef struct{
        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 */
+       char album[AUDIO_SVC_METADATA_LEN_MAX];                 /**< album of track */
        int duration;                                                                                   /**< track duration*/
        int rating;                                                                                     /**< track rating*/
 }audio_svc_list_item_s;
index 88bd774..4d46d2f 100755 (executable)
@@ -29,6 +29,7 @@ extern "C" {
 #endif
 
 char *_media_info_generate_uuid(void);
+char *_media_svc_escape_str(char *input, int len);
 
 #ifdef __cplusplus
 }
index 626b146..ca47ada 100755 (executable)
@@ -47,7 +47,7 @@ extern "C" {
 
 #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_FILE_PATH_LEN_MAX               4095 * 2                                                                /**< 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 */
index 41e59b7..61933ea 100755 (executable)
@@ -35,8 +35,8 @@
 */
 
 
-#ifndef _MEDIA_SVC_UTIL_H_
-#define _MEDIA_SVC_UTIL_H_
+#ifndef _VISUAL_SVC_UTIL_H_
+#define _VISUAL_SVC_UTIL_H_
        
 #include <glib.h>
 #include <stdbool.h>
@@ -209,7 +209,7 @@ _mb_svc_get_path_by_full(const char* full_path, char* path, int max_length);
 #endif /* __cplusplus */
 
 
-#endif /*_MEDIA_SVC_UTIL_H_*/
+#endif /*_VISUAL_SVC_UTIL_H_*/
 
 /**
 * @}
index 5c96c09..0da6aff 100755 (executable)
@@ -24,6 +24,7 @@
 #include <dirent.h>
 #include <sys/types.h>
 #include <string.h>
+#include <media-thumbnail.h>
 #include "media-svc-debug.h"
 #include "media-svc-api.h"
 #include "media-svc-thumb.h"
@@ -225,11 +226,10 @@ mb_svc_insert_file_batch(MediaSvcHandle *mb_svc_handle, const char *file_full_pa
            _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);
-       
+       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;
@@ -311,6 +311,14 @@ mb_svc_insert_file_batch(MediaSvcHandle *mb_svc_handle, const char *file_full_pa
                mb_svc_sql_list_add(&g_insert_sql_list, &meta_sql);
        }
 
+       /* Extracting thumbnail */
+       ret = thumbnail_request_from_db(file_full_path, media_record.thumbnail_path, sizeof(media_record.thumbnail_path));
+       if (ret < 0) {
+               mb_svc_debug("thumbnail_request_from_db failed: %d", ret);
+       } else {
+               mb_svc_debug("thumbnail_request_from_db success: %s", media_record.thumbnail_path);
+       }
+
        return 0;
 }
 
@@ -318,6 +326,7 @@ int
 mb_svc_insert_file(MediaSvcHandle *mb_svc_handle, const char *file_full_path, minfo_file_type content_type)
 {
        char dir_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+       char thumb_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 = {"",};
@@ -584,6 +593,14 @@ mb_svc_insert_file(MediaSvcHandle *mb_svc_handle, const char *file_full_path, mi
                return ret;
        }
 
+       /* Extracting thumbnail */
+       ret = thumbnail_request_from_db(file_full_path, thumb_path, sizeof(thumb_path));
+       if (ret < 0) {
+               mb_svc_debug("thumbnail_request_from_db failed: %d", ret);
+       } else {
+               mb_svc_debug("thumbnail_request_from_db success: %s", thumb_path);
+       }
+
 #ifdef _PERFORMANCE_CHECK_
        end = mediainfo_get_debug_time();
 
@@ -2300,7 +2317,7 @@ mb_svc_media_search_iter_start(MediaSvcHandle *mb_svc_handle,
        char condition_str[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
        int len = 0;
        char *like_str = NULL;
-
+       char *escaped_search_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",
@@ -2465,6 +2482,7 @@ mb_svc_media_search_iter_start(MediaSvcHandle *mb_svc_handle,
                        break;
        }
 */
+/*
        if (search_field & MINFO_SEARCH_BY_NAME) {
                like_str = sqlite3_mprintf("and (display_name like '%%%q%%' ", search_str);
 
@@ -2508,6 +2526,58 @@ mb_svc_media_search_iter_start(MediaSvcHandle *mb_svc_handle,
                        return MB_SVC_ERROR_INVALID_PARAMETER;
                }
        }
+*/
+       escaped_search_str = _media_svc_escape_str((char *)search_str, strlen(search_str));
+       if (escaped_search_str == NULL) {
+               mb_svc_debug("Failed to escape");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (search_field & MINFO_SEARCH_BY_NAME) {
+               like_str = sqlite3_mprintf("and (display_name like '%%%q%%' ESCAPE('#') ", escaped_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%%' ESCAPE('#') ", escaped_search_str);
+               } else {
+                       like_str = sqlite3_mprintf("and (m.path like '%%%q%%' ESCAPE('#') ", escaped_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%%' ESCAPE('#') ", escaped_search_str);
+               } else {
+                       like_str = sqlite3_mprintf("and (http_url like '%%%q%%' ESCAPE('#') ", escaped_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 (escaped_search_str) free(escaped_search_str);
 
        len = g_strlcat(query_where, ") ", sizeof(query_where));
 
@@ -4375,7 +4445,6 @@ mb_svc_bookmark_iter_next(mb_svc_iterator_s *mb_svc_iterator,
                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",
index dc394e5..7d5073c 100755 (executable)
@@ -1823,10 +1823,10 @@ mb_svc_load_record_video_meta(sqlite3_stmt *stmt,
            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->width = sqlite3_column_int(stmt, MB_SVC_VIDEO_META_WIDTH);
+       record->height = sqlite3_column_int(stmt, MB_SVC_VIDEO_META_HEIGHT);
        record->datetaken =
-           sqlite3_column_int(stmt, MB_SVC_VIDEO_META_LATITUDE);
+           sqlite3_column_int(stmt, MB_SVC_VIDEO_META_DATETAKEN);
 
        return 0;
 }
index e2abae2..c5096ac 100755 (executable)
@@ -713,10 +713,12 @@ minfo_get_bookmark_list(MediaSvcHandle *mb_svc_handle,
                                        minfo_bm_ite_cb func,
                                        void *user_data)
 {
-       int record_cnt = 0;
-       mb_svc_bookmark_record_s bookmark_record = { 0 };
+       mb_svc_debug("");
        int ret = -1;
-       mb_svc_iterator_s mb_svc_iterator = { 0 };
+       int record_cnt = 0;
+
+       mb_svc_bookmark_record_s bookmark_record = { 0, };
+       mb_svc_iterator_s mb_svc_iterator = { 0, };
        Mbookmark *mbookmark = NULL;
 
        if (mb_svc_handle == NULL) {
@@ -744,8 +746,7 @@ minfo_get_bookmark_list(MediaSvcHandle *mb_svc_handle,
 
        while (1) {
                ret =
-                   mb_svc_bookmark_iter_next(&mb_svc_iterator,
-                                             &bookmark_record);
+                   mb_svc_bookmark_iter_next(&mb_svc_iterator, &bookmark_record);
 
                if (ret == MB_SVC_NO_RECORD_ANY_MORE)
                        break;
@@ -762,7 +763,6 @@ minfo_get_bookmark_list(MediaSvcHandle *mb_svc_handle,
        }
 
        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;
index 873cf69..d302fb6 100755 (executable)
@@ -29,9 +29,9 @@ static void _minfo_mbookmark_init(Mbookmark *mbookmark);
 
 int minfo_mbookmark_load(MediaSvcHandle *mb_svc_handle, Mbookmark *mbookmark)
 {
-       mb_svc_bookmark_record_s bookmark_record = { 0 };
        int ret = 0;
        int length = 0;
+       mb_svc_bookmark_record_s bookmark_record = { 0, };
 
        ret =
            mb_svc_get_bookmark_record_by_id(mb_svc_handle, mbookmark->_id, &bookmark_record);
index 7afeacc..446d29b 100755 (executable)
@@ -181,9 +181,9 @@ static int _minfo_bm_ite_fn(Mbookmark *bookmark, void *user_data)
 
 int minfo_mvideo_load(MediaSvcHandle *mb_svc_handle, const char *media_id, Mvideo *mvideo)
 {
-       mb_svc_video_meta_record_s video_meta_record = { 0 };
        int ret = 0;
        int length = 0;
+       mb_svc_video_meta_record_s video_meta_record = { 0 };
 
        ret = mb_svc_get_video_record_by_media_id(mb_svc_handle, media_id, &video_meta_record);
        if (ret < 0) {
@@ -232,12 +232,10 @@ int minfo_mvideo_load(MediaSvcHandle *mb_svc_handle, const char *media_id, Mvide
        }
        memset(mvideo->web_category, 0x00, length);
 
-       strncpy(mvideo->web_category, video_meta_record.youtube_category,
-               length);
+       strncpy(mvideo->web_category, video_meta_record.youtube_category, length);
 
        GList *tmp_list = NULL;
        minfo_get_bookmark_list(mb_svc_handle, media_id, _minfo_bm_ite_fn, &tmp_list);
-
        mvideo->bookmarks = tmp_list;
 
        mvideo->_reserved = NULL;
@@ -308,9 +306,7 @@ void minfo_mvideo_destroy(Mvideo *mvideo)
                             i < g_list_length((GList *) mvideo->bookmarks);
                             i++) {
                                bookmark =
-                                   (Mbookmark *) g_list_nth_data((GList *)
-                                                                 mvideo->
-                                                                 bookmarks, i);
+                                   (Mbookmark *) g_list_nth_data((GList *)mvideo->bookmarks, i);
                                if (bookmark)
                                        minfo_mbookmark_destroy(bookmark);
                        }
index 9b6fcbf..904e313 100755 (executable)
@@ -30,6 +30,7 @@
 #include <drm-service.h>
 #include <string.h>
 #include <aul/aul.h>
+#include <sys/stat.h>
 
 bool _mb_svc_get_file_display_name(const char *file_path, char *file_name)
 {
@@ -109,10 +110,11 @@ bool _mb_svc_get_dir_parent_path(const char *dir_path, char *parent_path)
 
 int _mb_svc_get_file_dir_modified_date(const char *full_path)
 {
-       struct stat statbuf = { 0 };
+       struct stat statbuf;
        int fd = 0;
        int err = 0;
 
+       memset(&statbuf, 0, sizeof(struct stat));
        fd = stat(full_path, &statbuf);
        if (fd == -1) {
                err = errno;
index de58d7b..aaf4806 100755 (executable)
@@ -275,7 +275,7 @@ int main()
                
                for (j = 0; j < count; j++)
                {
-                       char *audio_id = NULL, *title = NULL, *artist = NULL, *thumbname = NULL, *pathname = NULL;
+                       char *audio_id = NULL, *title = NULL, *artist = NULL, *thumbname = NULL, *pathname = NULL, *album = NULL;
                        int rating = 0;
                        int duration = 0;
                        int size = 0;
@@ -285,6 +285,7 @@ int main()
                                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_ALBUM, &album, &size,
                                AUDIO_SVC_LIST_ITEM_PATHNAME, &pathname, &size,
                                AUDIO_SVC_LIST_ITEM_DURATION, &duration,
                                AUDIO_SVC_LIST_ITEM_RATING, &rating,
@@ -303,6 +304,7 @@ int main()
                        fprintf(stderr, "       **thumbnail_path = %s\n", thumbname);
                        fprintf(stderr, "       **title = %s\n", title);
                        fprintf(stderr, "       **artist = %s\n", artist);
+                       fprintf(stderr, "       **album = %s\n", album);
                        fprintf(stderr, "       **path = %s\n", pathname);
                        fprintf(stderr, "       **duration = %d\n", duration);
                        fprintf(stderr, "       **rating = %d\n\n", rating);
diff --git a/test/plugin/Makefile b/test/plugin/Makefile
new file mode 100644 (file)
index 0000000..fb92639
--- /dev/null
@@ -0,0 +1,14 @@
+CC =gcc
+LIBS = libmedia-service
+
+OBJS = media_svc_plugin_test.o
+SRCS = media_svc_plugin_test.c
+TARGET = plugin_test
+
+TARGET : $(OBJS)
+       $(CC) -o $(TARGET) $(OBJS) -ldl `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/plugin/media_svc_plugin_test.c b/test/plugin/media_svc_plugin_test.c
new file mode 100755 (executable)
index 0000000..2503ee5
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * 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 <stdlib.h>
+#include <stdio.h>
+#include <dlfcn.h>
+#include <media-svc.h>
+
+#define PLUGIN_SO_FILE_NAME  "/usr/lib/libmedia-svc-plugin.so"
+void *funcHandle = NULL;
+
+static void msg_print(int line, char *msg);
+
+int (*svc_check_item)                  (const char *file_path, const char * mime_type, char ** err_msg);
+int (*svc_connect)                             (void ** handle, char ** err_msg);
+int (*svc_disconnect)                  (void * handle, char ** err_msg);
+int (*svc_check_item_exist)            (void* handle, const char *file_path, int storage_type, char ** err_msg);
+
+int __load_functions()
+{
+       msg_print(__LINE__, "__load_functions");
+
+       funcHandle = dlopen (PLUGIN_SO_FILE_NAME, RTLD_LAZY);
+       if (!funcHandle) {
+               fprintf (stderr,"error: %s\n", dlerror());
+       }
+
+       svc_check_item          = dlsym (funcHandle, "check_item");
+       svc_connect                     = dlsym (funcHandle, "connect");
+       svc_disconnect          = dlsym (funcHandle, "disconnect");
+       svc_check_item_exist    = dlsym (funcHandle, "check_item_exist");
+
+       if ( !svc_check_item ||
+                !svc_connect ||
+                !svc_disconnect ||
+                !svc_check_item_exist) {
+               fprintf(stderr,"error: %s\n", dlerror());
+               return -1;
+       }
+
+       return 0;
+}
+
+int __unload_functions(void)
+{
+       msg_print(__LINE__, "__unload_functions");
+
+       if (funcHandle)
+       {
+               dlclose (funcHandle);
+       }
+
+       return 0;
+}
+
+int main()
+{
+       int ret = 0;
+       MediaSvcHandle * db_handle = NULL;
+       char * err_msg = NULL;
+
+       ret = __load_functions();
+       if(ret < 0) {
+               msg_print(__LINE__, "__load_functions error");
+               return -1;
+       }
+
+       //check_item ================================================
+       ret = svc_check_item("/opt/media/Music/Over the horizon.mp3", "audio/mpeg", &err_msg);
+       if(ret < 0) {
+               msg_print(__LINE__, "svc_check_item error");
+               if(err_msg != NULL) {
+                       printf("err_msg[%s]\n", err_msg);
+                       free(err_msg);
+                       err_msg = NULL;
+               }
+               __unload_functions();
+               return -1;
+       }
+
+       //db open ==================================================
+       ret = svc_connect(&db_handle, &err_msg);
+       if(ret < 0) {
+               msg_print(__LINE__, "svc_connect error");
+               if(err_msg != NULL) {
+                       printf("err_msg[%s]\n", err_msg);
+                       free(err_msg);
+                       err_msg = NULL;
+               }
+               __unload_functions();
+               return -1;
+       }
+
+       //check_item_exist ============================================
+       ret = svc_check_item_exist(db_handle, "/opt/media/Music/Over the horizon.mp3", 0, &err_msg);
+       if(ret < 0) {
+               msg_print(__LINE__, "svc_check_item_exist error");
+               if(err_msg != NULL) {
+                       printf("err_msg[%s]\n", err_msg);
+                       free(err_msg);
+                       err_msg = NULL;
+               }
+               __unload_functions();
+               return -1;
+       }
+
+       //db close ==================================================
+       ret = svc_disconnect(db_handle, &err_msg);
+       if(ret < 0) {
+               msg_print(__LINE__, "svc_disconnect error");
+               if(err_msg != NULL) {
+                       printf("err_msg[%s]\n", err_msg);
+                       free(err_msg);
+                       err_msg = NULL;
+               }
+               __unload_functions();
+               return -1;
+       }
+
+       __unload_functions();
+
+       return 0;
+}
+
+
+static void msg_print(int line, char *msg)
+{
+       fprintf(stderr, "[%d]%s\n", line, msg);
+}
+
index 71e6d74..0e934b2 100755 (executable)
@@ -669,6 +669,23 @@ int main(int argc, char *argv[])
                printf("count : %d\n", cnt);
                break;
 
+       case 22:
+               printf("test minfo_get_meta_info\n");
+               const char *video_media_id = "77b876ed-5db9-4114-82c0-d08e814b5051";
+               Mmeta *mmeta = NULL;
+
+               err = minfo_get_meta_info(handle, video_media_id, &mmeta);
+
+               if (err < 0) {
+                       printf("minfo_get_meta_info failed");
+                       return -1;
+               }
+
+               if (mmeta->video_info) {
+                       printf("Album name : %s\n", mmeta->video_info->album_name);
+               }
+               break;
+
        case 36:
                printf("test minfo_get_thumb_path \n");
                char thumb_path[255] = {0,};
@@ -769,7 +786,7 @@ int main(int argc, char *argv[])
                
                for (i = 0; i < count; i++) {
                        AudioHandleType *item = NULL;
-                       err = audio_svc_search_item_get(handle, i, &item);
+                       err = audio_svc_search_item_get(a_handle, i, &item);
                        char *title = NULL, *artist = NULL, *pathname = NULL, *album = NULL;
                        char *audio_id = NULL;
                        int size = 0;
@@ -795,7 +812,7 @@ int main(int argc, char *argv[])
                        }
                }
 
-               audio_svc_search_item_free(handle); 
+               audio_svc_search_item_free(a_handle);
        }
        break;