Tizen 2.0 beta
authorHyunjun Ko <zzoon.ko@samsung.com>
Tue, 21 Aug 2012 08:45:05 +0000 (17:45 +0900)
committerHyunjun Ko <zzoon.ko@samsung.com>
Tue, 21 Aug 2012 08:45:05 +0000 (17:45 +0900)
46 files changed:
CMakeLists.txt [changed mode: 0644->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_open_func.c [new file with mode: 0755]
TC/utc/audio/utc_audio_svc_open_func.h [new file with mode: 0755]
debian/changelog
debian/control
include/audio-svc.h
include/media-svc-error.h
include/media-svc-types.h
include/media-svc.h
include/visual-svc-types.h
include/visual-svc.h
packaging/libmedia-service.spec
plugin/media-content-plugin.c [new file with mode: 0755]
plugin/media-svc-plugin.c
src/audio/audio-svc-music-table.c
src/audio/audio-svc-utils.c
src/common/media-svc-album.c [new file with mode: 0755]
src/common/media-svc-db-utils.c [new file with mode: 0755]
src/common/media-svc-debug.c
src/common/media-svc-media-folder.c [new file with mode: 0755]
src/common/media-svc-media.c [new file with mode: 0755]
src/common/media-svc-util.c
src/common/media-svc.c
src/include/audio/audio-svc-utils.h
src/include/common/media-svc-album.h [new file with mode: 0755]
src/include/common/media-svc-db-utils.h [new file with mode: 0755]
src/include/common/media-svc-debug.h
src/include/common/media-svc-env.h
src/include/common/media-svc-media-folder.h [new file with mode: 0755]
src/include/common/media-svc-media.h [new file with mode: 0755]
src/include/common/media-svc-util.h
src/include/visual/visual-svc-db-util.h [moved from src/include/visual/media-svc-db-util.h with 99% similarity]
src/include/visual/visual-svc-db.h [moved from src/include/visual/media-svc-db.h with 99% similarity]
src/include/visual/visual-svc-util.h
src/visual/media-img-codec-osal.c
src/visual/media-svc-api.c
src/visual/media-svc-thumb.c
src/visual/minfo-api.c
src/visual/visual-svc-db-util.c [moved from src/visual/media-svc-db-util.c with 99% similarity]
src/visual/visual-svc-db.c [moved from src/visual/media-svc-db.c with 98% similarity]
src/visual/visual-svc-util.c
test/plugin/Makefile
test/plugin/media_svc_plugin_test.c
test/test_media_info.c

old mode 100644 (file)
new mode 100755 (executable)
index 66f1d7a..4bc06fc
@@ -6,9 +6,10 @@ 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(MEDIACONTENT-PLUGIN-LIB "media-content-plugin")
 SET(SRCS 
-       src/visual/media-svc-db.c
-       src/visual/media-svc-db-util.c
+       src/visual/visual-svc-db.c
+       src/visual/visual-svc-db-util.c
        src/visual/visual-svc-util.c
        src/visual/media-svc-api.c
        src/visual/media-svc-thumb.c   
@@ -45,6 +46,10 @@ SET(SRCS
        uuid/uuid_time.c
 
        src/common/media-svc.c
+       src/common/media-svc-media.c
+       src/common/media-svc-album.c
+       src/common/media-svc-media-folder.c
+       src/common/media-svc-db-utils.c
        src/common/media-svc-util.c
        src/common/media-svc-debug.c
        )
@@ -57,6 +62,9 @@ SET(HASH_SRCS
 SET(PLUGIN_SRCS
        plugin/media-svc-plugin.c
        )
+SET(CONTENTPLUGIN_SRCS
+       plugin/media-content-plugin.c
+       )
 
 SET(TEST-SRCS test/test_media_info.c)
 SET(TEST-AUDIO-SRCS test/audio/audio_svc_test.c)
@@ -82,7 +90,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 media-thumbnail
+dlog sqlite3 db-util mm-common  mm-fileinfo drm-client aul media-thumbnail
 libexif gthread-2.0 vconf ecore-evas evas mmutil-imgp mmutil-jpeg dbus-1)
 
 
@@ -106,6 +114,7 @@ ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
 ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
 ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
 ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64")
 #ADD_DEFINITIONS("-D_PERFORMANCE_CHECK_")
 #ADD_DEFINITIONS("-D_USE_LOG_FILE_")
 #ADD_DEFINITIONS("-D_USE_DBUS_")
@@ -127,10 +136,15 @@ 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})
+ADD_LIBRARY(${MEDIACONTENT-PLUGIN-LIB} SHARED ${CONTENTPLUGIN_SRCS})
+TARGET_LINK_LIBRARIES(${MEDIACONTENT-PLUGIN-LIB} ${MEDIASERVICE-LIB})
+SET_TARGET_PROPERTIES(${MEDIACONTENT-PLUGIN-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${MEDIACONTENT-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)
+INSTALL(TARGETS ${MEDIACONTENT-PLUGIN-LIB} LIBRARY DESTINATION lib)
 
 #ADD_EXECUTABLE( media_service_test ${TEST-SRCS})
 #TARGET_LINK_LIBRARIES(media_service_test ${pkgs_LDFLAGS} ${MEDIASERVICE-LIB} )
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_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
index 696382a..0908b49 100755 (executable)
-libmedia-service (0.2.0-6) unstable; urgency=low
+libmedia-service (0.1.121) unstable; urgency=low
 
-  * Fix build errors
-  * Git : pkgs/l/libmedia-service
-  * Tag : libmedia-service_0.2.0-6
+  * insert Content info to DB even though fail extract metadata information
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.121
 
- -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 21 Mar 2012 16:35:00 +0900
+ -- Haejeong Kim <backto.kim@samsung.com>  Fri, 17 Aug 2012 10:57:03 +0900
 
-libmedia-service (0.2.0-5) unstable; urgency=low
+libmedia-service (0.1.120) unstable; urgency=low
 
-  * Fix build errors
-  * Git : pkgs/l/libmedia-service
-  * Tag : libmedia-service_0.2.0-5
+  * Fix a crash because of data type
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.120
 
- -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 21 Mar 2012 16:30:00 +0900
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 14 Aug 2012 19:00:00 +0900
 
-libmedia-service (0.2.0-4) unstable; urgency=low
+libmedia-service (0.1.119) unstable; urgency=low
 
-  * Push for tizen 1.0 release
-  * Git : pkgs/l/libmedia-service
-  * Tag : libmedia-service_0.2.0-4
+  * Remove drm-trusted dependancy
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.119
 
- -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 19 Mar 2012 18:30:00 +0900
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 14 Aug 2012 19:00:00 +0900
 
-libmedia-service (0.2.0-3) unstable; urgency=low
+libmedia-service (0.1.118) unstable; urgency=low
+
+  * Change type of size to long long
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.118
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 13 Aug 2012 19:00:00 +0900
+
+libmedia-service (0.1.117) unstable; urgency=low
+
+  * Fix a bug when extracting width and height in video
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.117
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Fri, 10 Aug 2012 18:00:00 +0900
+
+libmedia-service (0.1.116) unstable; urgency=low
+
+  * Use new api thumbnail_request_from_db_with_size when insert items
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.116
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 31 Jul 2012 18:00:00 +0900
+
+libmedia-service (0.1.115) unstable; urgency=low
+
+  * Doesnt do rollback when a query fails in batch jobs
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.115
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 30 Jul 2012 18:00:00 +0900
+
+libmedia-service (0.1.114) unstable; urgency=low
+
+  * Modify packaging file to make stripped lib
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.114
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 9 Jul 2012 18:00:00 +0900
+
+libmedia-service (0.1.113) unstable; urgency=low
+
+  * Create new api media_svc_rename_folder
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.113
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Fri, 6 Jul 2012 19:00:00 +0900
+
+libmedia-service (0.1.112) unstable; urgency=low
+
+  * bug fix of get thumbnail path
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.112
+
+ -- root <backto.kim@samsung.com>  Thu, 05 Jul 2012 18:04:07 +0900
+
+libmedia-service (0.1.111) unstable; urgency=low
+
+  * separate plug-in for old and new DB 
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.111
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Thu, 28 Jun 2012 19:15:05 +0900
+
+libmedia-service (0.1.110) unstable; urgency=low
+
+  * make added time value to time_t
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.110
+
+ -- root <backto.kim@samsung.com>  Wed, 20 Jun 2012 11:53:33 +0900
+
+libmedia-service (0.1.109) unstable; urgency=low
+
+  * enable other type support
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.109
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Mon, 04 Jun 2012 16:45:52 +0900
+
+libmedia-service (0.1.108) unstable; urgency=low
+
+  * Remove hiding field in new media db
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.108
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Fri, 1 Jun 2012 15:00:00 +0900
+
+libmedia-service (0.1.107) unstable; urgency=low
+
+  * Update sql query
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.107
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Fri, 25 May 2012 15:00:00 +0900
+
+libmedia-service (0.1.106) unstable; urgency=low
+
+  * Fix a bug that doesn't finalize a statement
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.106
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 22 May 2012 20:00:00 +0900
+
+libmedia-service (0.1.105) unstable; urgency=low
+
+  * Change DRM apis
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.105
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 22 May 2012 18:00:00 +0900
+
+libmedia-service (0.1.104) unstable; urgency=low
+
+  * Enable new media-svc apis in plugin
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.104
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 21 May 2012 18:00:00 +0900
+
+libmedia-service (0.1.103) unstable; urgency=low
+
+  * Add refresh API
+  * Git : slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.103
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Wed, 16 May 2012 14:53:36 +0900
+
+libmedia-service (0.1.102) unstable; urgency=low
+
+  * Add a new api minfo_update_media_orientation
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.102
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 14 May 2012 18:00:00 +0900
+
+libmedia-service (0.1.101) unstable; urgency=low
+
+  * bug fix of stat
+  * Git : slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.101
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Fri, 16 Mar 2012 14:01:32 +0900
+
+libmedia-service (0.1.100) unstable; urgency=low
+
+  * add file_name field to support BADA
+  * Git : slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.100
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Tue, 13 Mar 2012 11:08:21 +0900
+
+libmedia-service (0.1.99) unstable; urgency=low
+
+  * Update spec file for OBS build
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.99
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Fri, 9 Mar 2012 18:00:00 +0900
+
+libmedia-service (0.1.98) unstable; urgency=low
+
+  * Rollback to enable to exctract thumbnail when bulk-insert
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.98
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 5 Mar 2012 14:00:00 +0900
+
+libmedia-service (0.1.97) unstable; urgency=low
+
+  * bug fix of memory free
+  * Git : slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.97
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Fri, 02 Mar 2012 17:42:33 +0900
+
+libmedia-service (0.1.96) unstable; urgency=low
+
+  * The api update_begin starts to call thumbnail_request_extract_all_thumbs
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.96
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 29 Feb 2012 18:00:00 +0900
+
+libmedia-service (0.1.95) unstable; urgency=low
+
+  * Reduce buffer size of stack
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.95
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 20 Feb 2011 20:00:00 +0900
+
+libmedia-service (0.1.94) unstable; urgency=low
+
+  * get Album info also when get list item.
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.94
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Fri, 17 Feb 2012 17:22:01 +0900
+
+libmedia-service (0.1.93) unstable; urgency=low
+
+  * Add a routine to extract thumbnail when adding visual items
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.93
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 15 Feb 2011 18:00:00 +0900
+
+libmedia-service (0.1.92) unstable; urgency=low
+
+  * code clean up.
+  * Update TC
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.92
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Fri, 10 Feb 2012 17:34:35 +0900
+
+libmedia-service (0.1.91) unstable; urgency=low
+
+  * Fix a bug
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.91
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 6 Feb 2011 18:00:00 +0900
+
+libmedia-service (0.1.90) unstable; urgency=low
+
+  * Enable plugin
+  * New api : minfo_get_all_item_count
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.90
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Fri, 3 Feb 2011 11:00:00 +0900
+
+libmedia-service (0.1.89) unstable; urgency=low
+
+  * Fix a bug to get visual media list
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.89
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 1 Feb 2011 11:00:00 +0900
+
+libmedia-service (0.1.88) unstable; urgency=low
+
+  * Change to latest source from rollback
+  * Add new api minfo_get_all_item_conut
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.88
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 30 Jan 2011 23:00:00 +0900
+
+libmedia-service (0.1.87) unstable; urgency=low
+
+  * Rollback to 0.1.85
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.87
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 30 Jan 2011 23:00:00 +0900
+
+libmedia-service (0.1.86) unstable; urgency=low
 
-  * Change that makes user managing db handle
   * Add DB field : size in visual_media, genre in video_meta
-  * Code cleanup and fix some bugs
-  * Git : pkgs/l/libmedia-service
-  * Tag : libmedia-service_0.2.0-3
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.86
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 30 Jan 2011 23:00:00 +0900
+
+libmedia-service (0.1.85) unstable; urgency=low
+
+  * Change that makes user managing db handle
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.85
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 18 Jan 2011 17:00:00 +0900
+
+libmedia-service (0.1.84) unstable; urgency=low
+
+  * Remove a dependancy of libmedia-thumbnail
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.84
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 5 Jan 2011 18:30:00 +0900
+
+libmedia-service (0.1.83) unstable; urgency=low
+
+  * Fix dependancy
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.83
 
- -- Hyunjun Ko <zzoon.ko@samsung.com>  Fri, 10 Feb 2012 17:30:00 +0900
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 4 Jan 2011 16:30:00 +0900
 
-libmedia-service (0.2.0-2) unstable; urgency=low
+libmedia-service (0.1.82) unstable; urgency=low
 
-  * Remove libmedia-thumbnail dependancy
-  * Git : pkgs/l/libmedia-service
-  * Tag : libmedia-service_0.2.0-2
+  * Remove md5 codes 
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.82
 
- -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 5 Jan 2012 18:30:00 +0900
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 3 Jan 2011 18:30:00 +0900
 
-libmedia-service (0.2.0-1) unstable; urgency=low
+libmedia-service (0.1.81) unstable; urgency=low
 
-  * Remove md5 codes
-  * Git : pkgs/l/libmedia-service
-  * Tag : libmedia-service_0.2.0-1
+  * Arrange MD5 algorithm opensource
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.81
 
- -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 3 Jan 2012 18:30:00 +0900
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 28 Dec 2011 18:30:00 +0900
 
-libmedia-service (0.2.0-0) unstable; urgency=low
+libmedia-service (0.1.80) unstable; urgency=low
 
-  * Initial Release
-  * Git : pkgs/l/libmedia-service
-  * Tag : libmedia-service_0.2.0-0
+  * some APIs are not deprecated.
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.80
 
  -- Haejeong Kim <backto.kim@samsung.com>  Wed, 07 Dec 2011 12:35:23 +0900
 
+libmedia-service (0.1.79) unstable; urgency=low
+
+  * code cleanup.
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-service
+  * Tag : libmedia-service_0.1.79
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Wed, 07 Dec 2011 11:00:14 +0900
+
+libmedia-service (0.1.78) unstable; urgency=low
+
+  * Change the name of this pkg from libmedia-info to libmedia-service
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-service_0.1.78
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Tue, 29 Nov 2011 18:30:00 +0900
+
+libmedia-info (0.1.77) unstable; urgency=low
+
+  * mark deprecated functions : mediainfo_register_file
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.77
+
+ -- Yong Yeon Kim <yy9875.kim@samsung.com>  Wed, 30 Nov 2011 16:33:07 +0900
+
+libmedia-info (0.1.76) unstable; urgency=low
+
+  * Fix a bug for deleting invalid items
+  * code clean up
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.76
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 29 Nov 2011 18:30:00 +0900
+
+libmedia-info (0.1.75) unstable; urgency=low
+
+  * code clean up.
+  * fix thumbnail bug when adding bulk insertion
+  * modify code to same folrder but different web_album_id can be added to DB 
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.75
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Thu, 24 Nov 2011 10:43:43 +0900
+
+libmedia-info (0.1.74) unstable; urgency=low
+
+  * code clean up. remove unused code and files.
+  * register busy_handler 
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.74
+
+ -- backto.kim <backto.kim@samsung.com>  Tue, 22 Nov 2011 17:47:39 +0900
+
+libmedia-info (0.1.73) unstable; urgency=low
+
+  * bug fix. disable album_id
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.73
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Wed, 16 Nov 2011 11:00:37 +0900
+
+libmedia-info (0.1.72) unstable; urgency=low
+
+  * modify insert_item to reduce db commit time.
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.72
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Fri, 11 Nov 2011 14:38:24 +0900
+
+libmedia-info (0.1.71) unstable; urgency=low
+
+  * Fix CQ defects
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.71
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 10 Nov 2011 14:30:00 +0900
+
+libmedia-info (0.1.70) unstable; urgency=low
+
+  * Fix prevents defects
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.70
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 7 Nov 2011 18:30:00 +0900
+
+libmedia-info (0.1.69) unstable; urgency=low
+
+  * sorting case insenstive
+  * bug fix of add folder info
+  * remove unused API
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.69
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Mon, 07 Nov 2011 16:45:49 +0900
+
+libmedia-info (0.1.68) unstable; urgency=low
+
+  * Fix a bug in mb_svc_get_media_id_by_http_url 
+  * The length of path buffer is changed
+  * Sorting with case independent
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.68
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 3 Nov 2011 18:30:00 +0900
+
+libmedia-info (0.1.67) unstable; urgency=low
+
+  * Fix a bug in video bookmark 
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.67
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 3 Nov 2011 10:30:00 +0900
+
+libmedia-info (0.1.66) unstable; urgency=low
+
+  * Apply UUID 
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.66
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 2 Nov 2011 19:30:00 +0900
+
+libmedia-info (0.1.65) unstable; urgency=low
+
+  * modify albumart image type. (png to proper img type)
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.65
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Mon, 24 Oct 2011 11:05:49 +0900
+
+libmedia-info (0.1.64) unstable; urgency=low
+
+  * add timeout to socket
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.64
+
+ -- Yong Yeon Kim <yy9875.kim@samsung.com>  Wed, 19 Oct 2011 16:48:55 +0900
+
+libmedia-info (0.1.63) unstable; urgency=low
+
+  * change way to IPC of register file from DBUS to UDP
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.63
+
+ -- Yong Yeon Kim <yy9875.kim@samsung.com>  Wed, 19 Oct 2011 11:18:13 +0900
+
+libmedia-info (0.1.62) unstable; urgency=low
+
+  * Fix a problem when moving items
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.62
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 12 Oct 2011 19:30:00 +0900
+
+libmedia-info (0.1.61) unstable; urgency=low
+
+  * Remove code to create thumbnail
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.61
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 12 Oct 2011 12:30:00 +0900
+
+libmedia-info (0.1.60) unstable; urgency=low
+
+  * Fix a critical bug when inserting items
+  * modify audio_svc_move_item to reduce db commit time
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.60
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 11 Oct 2011 18:30:00 +0900
+
+libmedia-info (0.1.59) unstable; urgency=low
+
+  * Fix some bugs and prevent defects
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.59
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 10 Oct 2011 17:30:00 +0900
+
+libmedia-info (0.1.58) unstable; urgency=low
+
+  * Fix some bugs
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.58
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 7 Aug 2011 12:30:00 +0900
+
+libmedia-info (0.1.57) unstable; urgency=low
+
+  * Fix the defect H0100134184
+  * New api minfo_update_image_meta_info_int and minfo_update_media_thumb
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.57
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 4 Aug 2011 15:30:00 +0900
+
+libmedia-info (0.1.56) unstable; urgency=low
+
+  * Disable SPLUSA feature
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.56
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Wed, 28 Sep 2011 10:59:39 +0900
+
+libmedia-info (0.1.55) unstable; urgency=low
+
+  * Change an option when opening files 
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.55
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 23 Aug 2011 17:00:00 +0900
+
+libmedia-info (0.1.54) unstable; urgency=low
+
+  * Fix a bug when querying a string including escape character
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.54
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 23 Aug 2011 17:00:00 +0900
+
+libmedia-info (0.1.53) unstable; urgency=low
+
+  * add code to get favourite value 
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.53
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Fri, 23 Sep 2011 10:17:49 +0900
+
+libmedia-info (0.1.52) unstable; urgency=low
+
+  * Fix minor bug when saving thumbnail of video
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.52
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 21 Aug 2011 12:00:00 +0900
+
+libmedia-info (0.1.51) unstable; urgency=low
+
+  * Fix defects when saving thumbnail of video
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.51
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 21 Aug 2011 12:00:00 +0900
+
+libmedia-info (0.1.50) unstable; urgency=low
+
+  * add favourite field in audio_media table 
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.50
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Tue, 20 Sep 2011 09:24:39 +0900
+
+libmedia-info (0.1.49) unstable; urgency=low
+
+  * Change not to resize if it's small jpeg when making thumbs
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.49
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 19 Aug 2011 12:00:00 +0900
+
+libmedia-info (0.1.48) unstable; urgency=low
+
+  * Fix a bug rotation in thumb
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.48
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 17 Aug 2011 17:00:00 +0900
+
+libmedia-info (0.1.47) unstable; urgency=low
+
+  * Fix a minor bug in audio_svc_list_by_search
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.47
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 16 Aug 2011 17:00:00 +0900
+
+libmedia-info (0.1.46) unstable; urgency=low
+
+  * Fix some bugs
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.46
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 15 Aug 2011 20:00:00 +0900
+
+libmedia-info (0.1.45) unstable; urgency=low
+
+  * Rotate thumbnails according to its orientation
+  * Improve the logic of handling exif info
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.45
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 15 Aug 2011 19:00:00 +0900
+
+libmedia-info (0.1.44) unstable; urgency=low
+
+  * Fix bugs when making thumb
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.44
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 15 Aug 2011 15:00:00 +0900
+
+libmedia-info (0.1.43) unstable; urgency=low
+
+  * Codes to decide if the DRM file is image or video
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.43
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 14 Aug 2011 19:00:00 +0900
+
+libmedia-info (0.1.42) unstable; urgency=low
+
+  * Fix a bug when writing thumb file
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.42
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 09 Aug 2011 11:00:00 +0900
+
+libmedia-info (0.1.41) unstable; urgency=low
+
+  * Remove gdk dependency in control file
+  * Check width and height when extracting thumb in exif
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.41
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 08 Aug 2011 15:00:00 +0900
+
+libmedia-info (0.1.40) unstable; urgency=low
+
+  * Remove gdk dependency
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.40
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 07 Aug 2011 18:00:00 +0900
+
+libmedia-info (0.1.39) unstable; urgency=low
+
+  * Update music mime and file register code 
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.39
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Wed, 07 Sep 2011 08:47:28 +0900
+
+libmedia-info (0.1.38) unstable; urgency=low
+
+  * Improve minfo_delete_invalid_media_records
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.38
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 05 Aug 2011 18:00:00 +0900
+
+libmedia-info (0.1.37) unstable; urgency=low
+
+  * DB schema changed.
+  * query for getting artist is changed. Since UX change 
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.37
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Mon, 05 Sep 2011 14:18:23 +0900
+
+libmedia-info (0.1.36) unstable; urgency=low
+
+  * Improve minfo_set_db_valid api
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.36
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 29 Aug 2011 15:00:00 +0900
+
+libmedia-info (0.1.35) unstable; urgency=low
+
+  * Add a busy handler to sqlite
+  * Add new api mediainfo_register_file 
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.35
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 24 Aug 2011 19:00:00 +0900
+
+libmedia-info (0.1.34) unstable; urgency=low
+
+  * Change the directory name from /mnt/mmc to /opt/storage/sdcard
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.34
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 17 Aug 2011 15:00:00 +0900
+
+libmedia-info (0.1.33) unstable; urgency=low
+
+  * Change the maximum of resolution to be able to get thumbnail to 3000x3000
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.33
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 4 Aug 2011 19:00:00 +0900
+
+libmedia-info (0.1.32) unstable; urgency=low
+
+  * Change the maximum of resolution to be able to get thumbnail
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.32
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 2 Aug 2011 11:00:00 +0900
+
+libmedia-info (0.1.31) unstable; urgency=low
+
+  * Make it atomic to manage db handlers
+  * Modify to make ecore evas
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.31
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Fri, 29 Jul 2011 17:00:00 +0900
+
+libmedia-info (0.1.30) unstable; urgency=low
+
+  * Add new api for search
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.30
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 28 Jul 2010 20:00:00 +0900
+
+libmedia-info (0.1.29) unstable; urgency=low
+
+  * Fix a bug of positioning when getting list 
+  * Fix defects from prevent and memory leak
+  * Modify the path of default thumbnail
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.29
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Fri, 22 Jul 2010 18:00:00 +0900
+
+libmedia-info (0.1.28) unstable; urgency=low
+
+  * Fix defects from prevent and memory leak
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.28
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 11 Jul 2010 18:00:00 +0900
+
+libmedia-info (0.1.27) unstable; urgency=low
+
+  * Enable to extract thumbnails using evas
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.27
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 5 Jul 2010 18:00:00 +0900
+
+libmedia-info (0.1.26) unstable; urgency=low
+
+  * Fix the crash in media server and CQ H0100128875
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.26
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Fri, 1 Jul 2010 18:00:00 +0900
+
+libmedia-info (0.1.25) unstable; urgency=low
+
+  * Fix the api minfo_update_cluster_name
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.25
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 29 Jun 2010 18:00:00 +0900
+
+libmedia-info (0.1.24) unstable; urgency=low
+
+  * Added new api minfo_add_web_media_with_type
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.24
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Fri, 17 Jun 2010 16:00:00 +0900
+
+libmedia-info (0.1.23) unstable; urgency=low
+
+  * Added codes to use transaction when writing DB
+  * Fixed a problem of web media and get_list of locked folder
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.23
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 13 Jun 2010 18:00:00 +0900
+
+libmedia-info (0.1.22) unstable; urgency=low
+
+  * Change the way to decide mime type 
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.22
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 13 Jun 2010 18:00:00 +0900
+
+libmedia-info (0.1.21) unstable; urgency=low
+
+  * Fix a problem of positioning in minfo_get_item_list
+  * Fix a problem of minfo_delete_media_id
+  * Prevent thumbnail extraction of high resolution jpeg files
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.21
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Fri, 10 Jun 2010 18:00:00 +0900
+
+libmedia-info (0.1.20) unstable; urgency=low
+
+  * Fix a problem of getting count apis
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.20
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 9 Jun 2010 12:00:00 +0900
+
+libmedia-info (0.1.19) unstable; urgency=low
+
+  * Add new apis - minfo_get_media_count_by_tagname, minfo_get_media_list_by_tagname_with_filter
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.19
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 8 Jun 2010 14:00:00 +0900
+
+libmedia-info (0.1.18) unstable; urgency=low
+
+  * Fix problems in minfo_update_cluster_name
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.18
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 2 Jun 2010 15:00:00 +0900
+
+libmedia-info (0.1.17) unstable; urgency=low
+
+  * Fix problems in minfo_get_media_list
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.17
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 31 May 2010 17:00:00 +0900
+
+libmedia-info (0.1.16) unstable; urgency=low
+
+  * Fix a crash in gallery
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.16
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 25 May 2010 17:00:00 +0900
+
+libmedia-info (0.1.15) unstable; urgency=low
+
+  * New codes to extract new meta info
+  * Changes in minfo_get_thumb_path according to new policy
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.15
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 25 May 2010 15:00:00 +0900
+
+libmedia-info (0.1.14) unstable; urgency=low
+
+  * Fix a bug in minfo_delete_media_id 
+  * Fix prevent defects
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.14
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 23 May 2010 16:00:00 +0900
+
+libmedia-info (0.1.13) unstable; urgency=low
+
+  * Fix myfiles problem
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.13
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 19 May 2010 19:00:00 +0900
+
+libmedia-info (0.1.12) unstable; urgency=low
+
+  * Call g_type_init
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.12
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 18 May 2010 12:00:00 +0900
+
+libmedia-info (0.1.11) unstable; urgency=low
+
+  * Control DB handles in each thread for audio-svc.
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.11
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 17 May 2010 15:00:00 +0900
+
+libmedia-info (0.1.10) unstable; urgency=low
+
+  * Control DB handles in each thread. 
+  * Change from sprintf to snprintf
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.10
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 16 May 2010 16:00:00 +0900
+
+libmedia-info (0.1.9) unstable; urgency=low
+
+  * Rollback media-svc APIs
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.9
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 11 May 2010 19:00:00 +0900
+
+libmedia-info (0.1.8) unstable; urgency=low
+
+  * remove media-svc APIs
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.8
+
+ -- Yong Yeon Kim <yy9875.kim@samsung.com>  Fri, 06 May 2011 18:26:36 +0900
+
+libmedia-info (0.1.7) unstable; urgency=low
+
+  * enable SPLUSA and modify TC
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.7
+
+ -- Yong Yeon Kim <yy9875.kim@samsung.com>  Fri, 06 May 2011 17:27:04 +0900
+
+libmedia-info (0.1.4) unstable; urgency=low
+
+  * enable SPLUSA and modify TC
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.4
+
+ -- Haejeong Kim <backto.kim@samsung.com>  Wed, 04 May 2011 08:59:32 +0900
+
+libmedia-info (0.1.3) unstable; urgency=low
+
+  * Modify parameter of audio_svc_delete_invalid_items
+  * Add new apis minfo_update_media_date, minfo_get_item_by_http_url
+  * Add new attributes for image and video meta structures 
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.3
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 2 May 2010 17:00:00 +0900
+
+libmedia-info (0.1.2) unstable; urgency=low
+
+  * Add new attributes for media tag structures.
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.2
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Mon, 2 May 2010 15:50:00 +0900
+
+libmedia-info (0.1.1) unstable; urgency=low
+
+  * Modification for review.
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.1
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Thu, 28 Apr 2010 15:50:00 +0900
+
+libmedia-info (0.1.0) unstable; urgency=low
+
+  * Initial Release.
+  * New DB schema for visual and audio media contents.
+  * Git : 165.213.180.234:slp/pkgs/l/libmedia-info
+  * Tag : libmedia-info_0.1.0
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Wed, 27 Apr 2010 15:50:00 +0900
index 36cdd7a..3ba3f19 100755 (executable)
@@ -9,7 +9,7 @@ Build-Depends: debhelper (>= 5), libglib2.0-dev,
                libsqlite3-dev, 
                libmm-fileinfo-dev, 
                libmm-utility-dev, 
-               drm-service-dev,
+               drm-client-dev,
                libexif-dev,
                libevas-dev,
                libecore-dev,
@@ -27,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, libmedia-thumbnail, 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-client-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 6056fe6..b861f7d 100755 (executable)
@@ -1258,7 +1258,7 @@ void test_audio_svc_list_by_search(MediaSvcHandle *db_handle)
                err = audio_svc_list_by_search(db_handle, audio_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);
+                       printf("Fail to get items : %d", err);
                        return err;
                }
                
@@ -3509,7 +3509,7 @@ void test_audio_svc_list_by_search(MediaSvcHandle *db_handle)
                err = audio_svc_list_by_search(db_handle, audio_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);
+                       printf("Fail to get items : %d", err);
                        return err;
                }
                
index 3ede38d..ed28a53 100755 (executable)
@@ -45,7 +45,7 @@
 
 #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_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_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_DATABASE_NO_RECORD            -108            /**< Item not found in DB */
 
 #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_SOCKET_RECEIVE_TIMEOUT                -205            /**< Socket time out */
 
 #define MEDIA_INFO_ERROR_INTERNAL                                              -998            /**< Internal error */
 #define MEDIA_INFO_ERROR_UNKNOWN                                       -999            /**< Unknown error */
index 79e60e5..2f202ec 100755 (executable)
 
 typedef void MediaSvcHandle;           /**< Handle */
 
+/**
+ * Type definition for storage type
+ */
+typedef enum{
+       MEDIA_SVC_STORAGE_INTERNAL,                     /**< Internal storage*/
+       MEDIA_SVC_STORAGE_EXTERNAL,                     /**< External storage*/
+       MEDIA_SVC_STORAGE_MAX,                          /**< Invalid storage*/
+}media_svc_storage_type_e;
+
+/**
+ * Type definition for content type
+ */
+typedef enum{
+       MEDIA_SVC_MEDIA_TYPE_IMAGE      = 0,    /**< Image Content*/
+       MEDIA_SVC_MEDIA_TYPE_VIDEO      = 1,    /**< Video Content*/
+       MEDIA_SVC_MEDIA_TYPE_SOUND      = 2,    /**< Sound Content like Ringtone*/
+       MEDIA_SVC_MEDIA_TYPE_MUSIC      = 3,    /**< Music Content like mp3*/
+       MEDIA_SVC_MEDIA_TYPE_OTHER      = 4,    /**< Invalid Content*/
+}media_svc_media_type_e;
+
 #endif /*_MEDIA_SVC_TYPES_H_*/
index 056bd91..01c17f8 100755 (executable)
@@ -52,14 +52,13 @@ extern "C" {
 /**
  *     media_svc_connect:
  *     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             handle [out]            Handle to access 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            media_svc_disconnect
- *     @pre            None.
- *     @post           call media_svc_connect to connect to the media database
+ *     @pre            None
+ *     @post           call media_svc_disconnect to disconnect media database.
  *     @remark The database name is "/opt/dbspace/.media.db".
  *     @par example
  *     @code
@@ -91,14 +90,13 @@ int media_svc_connect(MediaSvcHandle **handle);
 /**
  *     media_svc_disconnect:
  *     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             handle [out]            Handle to access database.
+ *  @param             handle [in]             Handle to access 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            media_svc_connect
- *     @pre            None.
- *     @post           call media_svc_disconnect to disconnect to the media database
+ *     @pre            call media_svc_connect to connect media database.
+ *     @post           None
  *     @remark The database name is "/opt/dbspace/.media.db".
  *     @par example
  *     @code
@@ -138,6 +136,92 @@ void disconnect_media_db()
 int media_svc_disconnect(MediaSvcHandle *handle);
 
 
+/**
+ *     media_svc_create_table:
+ *     Create table of media database and set Index and Triggers.
+ *
+ *  @param             handle [in]             Handle to access 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            None
+ *     @pre            call media_svc_connect to connect media database.
+ *     @post           call media_svc_disconnect to disconnect media database.
+ *     @remark The database name is "/opt/dbspace/.media.db".
+ *     @par example
+ *     @code
+
+#include <media-info.h>
+
+void create_media_db_table()
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       MediaSvcHandle* my_handle = NULL;
+
+       // connect to the media database
+       ret = media_svc_connect(&my_handle);
+
+       if (ret < 0)
+       {
+               printf("Fatal error to connect DB\n");
+               return;
+       }
+
+       ret = media_svc_create_table(my_handle);
+       if (ret < 0)
+       {
+               printf("Fatal error to create DB table\n");
+       }
+
+       ret = media_svc_disconnect(my_handle);
+       if (ret < 0)
+       {
+               printf("Fatal error to disconnect DB\n");
+       }
+
+       return;
+}
+
+ *     @endcode
+ */
+
+int media_svc_create_table(MediaSvcHandle *handle);
+
+int media_svc_check_item_exist_by_path(MediaSvcHandle *handle, const char *path);
+
+int media_svc_insert_folder(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path);
+
+int media_svc_insert_item_begin(MediaSvcHandle *handle, int data_cnt);
+
+int media_svc_insert_item_end(MediaSvcHandle *handle);
+
+int media_svc_insert_item_bulk(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, const char *mime_type, media_svc_media_type_e media_type);
+
+int media_svc_insert_item_immediately(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, const char *mime_type, media_svc_media_type_e media_type);
+
+int media_svc_move_item_begin(MediaSvcHandle *handle, int data_cnt);
+
+int media_svc_move_item_end(MediaSvcHandle *handle);
+
+int media_svc_move_item(MediaSvcHandle *handle, media_svc_storage_type_e src_storage, const char *src_path, media_svc_storage_type_e dest_storage, const char *dest_path);
+
+int media_svc_set_item_validity_begin(MediaSvcHandle *handle, int data_cnt);
+
+int media_svc_set_item_validity_end(MediaSvcHandle *handle);
+
+int media_svc_set_item_validity(MediaSvcHandle *handle, const char *path, int validity);
+
+int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *path);
+
+int media_svc_delete_all_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type);
+
+int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type);
+
+int media_svc_set_all_storage_items_validity(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, int validity);
+
+int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, media_svc_media_type_e media_type);
+
+int media_svc_rename_folder(MediaSvcHandle *handle, const char *src_path, const char *dst_path);
+
 /** @} */
 
 /**
index 4201920..2ae6d6f 100755 (executable)
@@ -182,6 +182,19 @@ typedef enum {
        MINFO_SEARCH_MAX = 0x00000008,                  /**< maximum */
 } minfo_search_field_t;
 
+
+typedef enum {
+    MINFO_ORIENT_NOT_AVAILABLE=0,
+    MINFO_ORIENT_NORMAL  =1,
+    MINFO_ORIENT_HFLIP   =2,
+    MINFO_ORIENT_ROT_180 =3,
+    MINFO_ORIENT_VFLIP   =4,
+    MINFO_ORIENT_TRANSPOSE   =5,
+    MINFO_ORIENT_ROT_90  =6,
+    MINFO_ORIENT_TRANSVERSE  =7,
+    MINFO_ORIENT_ROT_270 =8
+} minfo_exif_orientation_t;
+
 /**
 * @struct minfo_item_filter
 * This structure defines filter of minfo item.
index 8eb6f97..434ba1b 100755 (executable)
@@ -1157,9 +1157,44 @@ minfo_update_media_favorite(MediaSvcHandle *mb_svc_handle, const char *media_id,
  * @endcode
  */
 
-int  
+int
 minfo_update_media_date(MediaSvcHandle *mb_svc_handle, const char *media_id, time_t modified_date);
 
+/**
+ * minfo_update_media_orientation
+ * This function updates orientation of image file in 'image_meta' table. This function actually call the Sqlite3 UPDATE.
+ * In Gallery application or ug-imageviewer, user could want to set orientation of an image, 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      mb_svc_handle   [in]    the handle of DB
+ * @param      media_id                [in]    Unique id of the media file
+ * @param      orientation             [in]    orientation to modify, which is a type of int
+ * @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_orientation(MediaSvcHandle *mb_svc_handle)
+       {
+               int ret = -1;
+               const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+               minfo_exif_orientation_t orientation = MINFO_ORIENT_ROT_90;
+
+               //update an image's orientation
+               ret = minfo_update_media_orientation(mb_svc_handle, media_id, orientation);
+               if( ret < 0) {
+                       printf("minfo_update_media_orientation failed\n");
+                       return;
+               }
+       }
+ * @endcode
+ */
+int
+minfo_update_media_orientation(MediaSvcHandle *mb_svc_handle, const char *media_id, minfo_exif_orientation_t orientation);
 
 /**
  * minfo_add_cluster
index 6690c9f..eda18cf 100644 (file)
@@ -1,7 +1,8 @@
+#sbs-git:slp/pkgs/l/libmedia-service libmedia-service 0.1.101 9a5b1f60f91231fdd7bf8d0ba935602f03425400
 Name:       libmedia-service
 Summary:    Media information service library for multimedia applications.
-Version: 0.2.0
-Release:    6
+Version: 0.1.121
+Release:    1
 Group:      System/Libraries
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
@@ -32,7 +33,7 @@ BuildRequires:  pkgconfig(sqlite3)
 BuildRequires:  pkgconfig(db-util)
 BuildRequires:  pkgconfig(mm-fileinfo)
 BuildRequires:  pkgconfig(media-thumbnail)
-BuildRequires:  pkgconfig(drm-service)
+BuildRequires:  pkgconfig(drm-client)
 BuildRequires:  pkgconfig(aul)
 
 %description
@@ -50,9 +51,9 @@ Media information service library for multimedia applications. (development file
 %prep
 %setup -q 
 
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
 
 %build
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
 make %{?jobs:-j%jobs}
 
 %install
@@ -60,7 +61,6 @@ rm -rf %{buildroot}
 %make_install
 
 %post -p /sbin/ldconfig
-
 %postun -p /sbin/ldconfig
 
 %files
@@ -74,6 +74,9 @@ rm -rf %{buildroot}
 %{_libdir}/libmedia-svc-plugin.so
 %{_libdir}/libmedia-svc-plugin.so.1
 %{_libdir}/libmedia-svc-plugin.so.1.0.0
+%{_libdir}/libmedia-content-plugin.so
+%{_libdir}/libmedia-content-plugin.so.1
+%{_libdir}/libmedia-content-plugin.so.1.0.0
 
 %files devel
 %{_libdir}/pkgconfig/libmedia-service.pc
diff --git a/plugin/media-content-plugin.c b/plugin/media-content-plugin.c
new file mode 100755 (executable)
index 0000000..5f82226
--- /dev/null
@@ -0,0 +1,723 @@
+/*
+ * 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 STRING_VALID(str)      \
+       ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
+#define STORAGE_VALID(storage)\
+       (((storage == MEDIA_SVC_STORAGE_INTERNAL) || (storage == MEDIA_SVC_STORAGE_EXTERNAL)) ? TRUE : FALSE)
+
+
+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 MEDIA_SVC_MEDIA_TYPE_SOUND;
+       else if (category & MS_CATEGORY_MUSIC)  return MEDIA_SVC_MEDIA_TYPE_MUSIC;
+       else if (category & MS_CATEGORY_IMAGE)  return MEDIA_SVC_MEDIA_TYPE_IMAGE;
+       else if (category & MS_CATEGORY_VIDEO)  return MEDIA_SVC_MEDIA_TYPE_VIDEO;
+       else    return MEDIA_SVC_MEDIA_TYPE_OTHER;
+}
+
+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_type == MEDIA_INFO_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_type == MEDIA_INFO_ERROR_DATABASE_INTERNAL))
+               *err_msg = strdup("DB internal error");
+       else if((err_type == AUDIO_SVC_ERROR_INTERNAL) ||(err_type == MB_SVC_ERROR_INTERNAL) || (err_type == MEDIA_INFO_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)
+{
+       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;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+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 = media_svc_check_item_exist_by_path(handle, file_path);
+       if(ret == MEDIA_INFO_ERROR_NONE)
+               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 = media_svc_insert_item_begin(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 = media_svc_insert_item_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_media_type_e content_type = __get_content_type(file_path, mime_type);
+
+       ret = media_svc_insert_item_bulk(handle, storage_type, file_path, mime_type, content_type);
+       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_media_type_e content_type = __get_content_type(file_path, mime_type);
+
+       ret = media_svc_insert_item_immediately(handle, storage_type, file_path, mime_type, content_type);
+
+       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 = media_svc_move_item_begin(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 = media_svc_move_item_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;
+       }
+
+       ret = media_svc_move_item(handle, src_storage_type, src_path, dest_storage_type, dest_path);
+       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;
+       }
+
+       ret = media_svc_set_all_storage_items_validity(handle, storage_type, 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 = media_svc_set_item_validity_begin(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 = media_svc_set_item_validity_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;
+       }
+
+       ret = media_svc_set_item_validity(handle, file_path, validity);
+
+       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 = media_svc_check_item_exist_by_path(handle, file_path);
+       if(ret == 0) {
+               ret = media_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;
+       }
+
+       __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;
+       }
+
+       ret = media_svc_delete_all_items_in_storage(handle, storage_type);
+       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;
+       }
+
+       ret = media_svc_delete_invalid_items_in_storage(handle, storage_type);
+       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_STORAGE_INTERNAL, err_msg);
+       if(ret < 0)
+               return MEDIA_SVC_PLUGIN_ERROR;
+
+       ret = delete_all_items_in_storage(handle, MEDIA_SVC_STORAGE_EXTERNAL, err_msg);
+       if(ret < 0)
+               return MEDIA_SVC_PLUGIN_ERROR;
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int refresh_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_media_type_e content_type = __get_content_type(file_path, mime_type);
+
+       ret = media_svc_refresh_item(handle, storage_type, file_path, content_type);
+
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               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 4dc92a2..ae6beee 100755 (executable)
 #include "audio-svc.h"
 #include "visual-svc.h"
 
+//#define NEW_MEDIA_SVC
+
 #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)
+       (((storage == MEDIA_SVC_STORAGE_INTERNAL) || (storage == MEDIA_SVC_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,
@@ -203,12 +196,11 @@ static int __get_content_type(const char * file_path, const char * mime_type)
        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;
-
+       if (category & MS_CATEGORY_SOUND)               return MEDIA_SVC_MEDIA_TYPE_SOUND;
+       else if (category & MS_CATEGORY_MUSIC)  return MEDIA_SVC_MEDIA_TYPE_MUSIC;
+       else if (category & MS_CATEGORY_IMAGE)  return MEDIA_SVC_MEDIA_TYPE_IMAGE;
+       else if (category & MS_CATEGORY_VIDEO)  return MEDIA_SVC_MEDIA_TYPE_VIDEO;
+       else    return MEDIA_SVC_MEDIA_TYPE_OTHER;
 }
 
 static void __set_error_message(int err_type, char ** err_msg)
@@ -232,11 +224,11 @@ static void __set_error_message(int err_type, char ** err_msg)
                *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))
+       else if((err_type == AUDIO_SVC_ERROR_INVALID_PARAMETER) || (err_type == MB_SVC_ERROR_INVALID_PARAMETER) || (err_type == MEDIA_INFO_ERROR_INVALID_PARAMETER))
                *err_msg = strdup("invalid parameter");
-       else if((err_type == AUDIO_SVC_ERROR_DB_INTERNAL) ||(err_type == MB_SVC_ERROR_DB_INTERNAL))
+       else if((err_type == AUDIO_SVC_ERROR_DB_INTERNAL) ||(err_type == MB_SVC_ERROR_DB_INTERNAL) ||(err_type == MEDIA_INFO_ERROR_DATABASE_INTERNAL))
                *err_msg = strdup("DB internal error");
-       else if((err_type == AUDIO_SVC_ERROR_INTERNAL) || (err_type == MB_SVC_ERROR_INTERNAL))
+       else if((err_type == AUDIO_SVC_ERROR_INTERNAL) ||(err_type == MB_SVC_ERROR_INTERNAL) || (err_type == MEDIA_INFO_ERROR_INTERNAL))
                *err_msg = strdup("media service internal error");
        else
                *err_msg = strdup("error unknown");
@@ -259,13 +251,14 @@ int check_item(const char *file_path, const char * mime_type, char ** err_msg)
 
        content_type = __get_content_type(file_path, mime_type);
 
-       if(content_type == CONTENT_TYPE_MAX) {
+#ifndef NEW_MEDIA_SVC
+       if(content_type == MEDIA_SVC_MEDIA_TYPE_OTHER) {
                __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
-
+#endif
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
 int connect(void ** handle, char ** err_msg)
@@ -317,6 +310,7 @@ int check_item_exist(void* handle, const char *file_path, int storage_type, char
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
+#ifndef NEW_MEDIA_SVC
        ret = audio_svc_check_item_exist(handle, file_path);
        if(ret == 0)
                return MEDIA_SVC_PLUGIN_ERROR_NONE;     //exist
@@ -324,10 +318,25 @@ int check_item_exist(void* handle, const char *file_path, int storage_type, char
        ret = minfo_check_item_exist(handle, file_path);
        if(ret == 0)
                return MEDIA_SVC_PLUGIN_ERROR_NONE;     //exist
+#else
+       ret = audio_svc_check_item_exist(handle, file_path);
+       if(ret == 0) {
+               ret = media_svc_check_item_exist_by_path(handle, file_path);
+               if(ret == MEDIA_INFO_ERROR_NONE)
+                       return MEDIA_SVC_PLUGIN_ERROR_NONE;     //exist
+       }
+
+       ret = minfo_check_item_exist(handle, file_path);
+       if(ret == 0) {
+               ret = media_svc_check_item_exist_by_path(handle, file_path);
+               if(ret == MEDIA_INFO_ERROR_NONE)
+                       return MEDIA_SVC_PLUGIN_ERROR_NONE;     //exist
+       }
+#endif
 
        __set_error_message(ERR_CHECK_ITEM, err_msg);
-       return MEDIA_SVC_PLUGIN_ERROR;          //not exist
 
+       return MEDIA_SVC_PLUGIN_ERROR;          //not exist
 }
 
 int insert_item_begin(void * handle, int item_cnt, char ** err_msg)
@@ -351,6 +360,14 @@ int insert_item_begin(void * handle, int item_cnt, char ** err_msg)
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
+#ifdef NEW_MEDIA_SVC
+       ret = media_svc_insert_item_begin(handle, item_cnt);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+#endif
+
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
@@ -375,6 +392,14 @@ int insert_item_end(void * handle, char ** err_msg)
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
+#ifdef NEW_MEDIA_SVC
+       ret = media_svc_insert_item_end(handle);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+#endif
+
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
@@ -402,40 +427,44 @@ int insert_item(void * handle, const char *file_path, int storage_type, const ch
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       media_svc_content_type_e content_type = __get_content_type(file_path, mime_type);
+       media_svc_media_type_e content_type = __get_content_type(file_path, mime_type);
 
-       if(content_type == CONTENT_TYPE_SOUND || content_type == CONTENT_TYPE_MUSIC)    {
+       if(content_type == MEDIA_SVC_MEDIA_TYPE_SOUND || content_type == MEDIA_SVC_MEDIA_TYPE_MUSIC)    {
 
-               if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL) {
+               if(storage_type == MEDIA_SVC_STORAGE_INTERNAL) {
 
-                       if(content_type == CONTENT_TYPE_SOUND)
+                       if(content_type == MEDIA_SVC_MEDIA_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) {
+               } else if (storage_type == MEDIA_SVC_STORAGE_EXTERNAL) {
 
-                       if(content_type == CONTENT_TYPE_SOUND)
+                       if(content_type == MEDIA_SVC_MEDIA_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) {
+       } else if (content_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || content_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
 
-               if(content_type == CONTENT_TYPE_IMAGE)
+               if(content_type == MEDIA_SVC_MEDIA_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 {
-
+#ifndef NEW_MEDIA_SVC
                __set_error_message(ERR_NOT_MEDIAFILE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
-
+#endif
        }
 
+#ifdef NEW_MEDIA_SVC
+       ret = media_svc_insert_item_bulk(handle, storage_type, file_path, mime_type, content_type);
+#endif
+
        if(ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
@@ -468,39 +497,42 @@ int insert_item_immediately(void * handle, const char *file_path, int storage_ty
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       media_svc_content_type_e content_type = __get_content_type(file_path, mime_type);
+       media_svc_media_type_e content_type = __get_content_type(file_path, mime_type);
 
-       if(content_type == CONTENT_TYPE_SOUND || content_type == CONTENT_TYPE_MUSIC)    {
+       if(content_type == MEDIA_SVC_MEDIA_TYPE_SOUND || content_type == MEDIA_SVC_MEDIA_TYPE_MUSIC)    {
 
                if(storage_type == 0) {
 
-                       if(content_type == CONTENT_TYPE_SOUND)
+                       if(content_type == MEDIA_SVC_MEDIA_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)
+                       if(content_type == MEDIA_SVC_MEDIA_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) {
+       } else if (content_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || content_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
 
-               if(content_type == CONTENT_TYPE_IMAGE)
+               if(content_type == MEDIA_SVC_MEDIA_TYPE_IMAGE)
                        ret = minfo_add_media(handle, file_path, MINFO_ITEM_IMAGE);
                else
                        ret = minfo_add_media(handle, file_path, MINFO_ITEM_VIDEO);
 
        } else {
-
+#ifndef NEW_MEDIA_SVC
                __set_error_message(ERR_NOT_MEDIAFILE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
-
+#endif
        }
+#ifdef NEW_MEDIA_SVC
+       ret = media_svc_insert_item_immediately(handle, storage_type, file_path, mime_type, content_type);
+#endif
 
        if(ret < 0) {
                __set_error_message(ret, err_msg);
@@ -532,6 +564,14 @@ int move_item_begin(void * handle, int item_cnt, char ** err_msg)
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
+#ifdef NEW_MEDIA_SVC
+       ret = media_svc_move_item_begin(handle, item_cnt);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+#endif
+
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
@@ -556,6 +596,14 @@ int move_item_end(void * handle, char ** err_msg)
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
+#ifdef NEW_MEDIA_SVC
+       ret = media_svc_move_item_end(handle);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+#endif
+
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
@@ -583,35 +631,42 @@ int move_item(void * handle, const char *src_path, int src_storage_type, const c
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       media_svc_content_type_e content_type = __get_content_type(src_path, mime_type);
+       media_svc_media_type_e content_type = __get_content_type(src_path, mime_type);
 
-       if(content_type == CONTENT_TYPE_SOUND || content_type == CONTENT_TYPE_MUSIC)    {
+       if(content_type == MEDIA_SVC_MEDIA_TYPE_SOUND || content_type == MEDIA_SVC_MEDIA_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) {
+       } else if (content_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || content_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
 
-               if(content_type == CONTENT_TYPE_IMAGE)
+               if(content_type == MEDIA_SVC_MEDIA_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 {
-
+#ifndef NEW_MEDIA_SVC
                __set_error_message(ERR_NOT_MEDIAFILE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
+#endif
+       }
 
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
        }
 
+#ifdef NEW_MEDIA_SVC
+       ret = media_svc_move_item(handle, src_storage_type, src_path, dest_storage_type, dest_path);
        if(ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
+#endif
 
        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;
@@ -626,7 +681,7 @@ int set_all_storage_items_validity(void * handle, int storage_type, int validity
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL) {
+       if(storage_type == MEDIA_SVC_STORAGE_INTERNAL) {
                ret = audio_svc_set_db_valid(handle, AUDIO_SVC_STORAGE_PHONE, validity);
                if(ret < 0) {
                        __set_error_message(ret, err_msg);
@@ -639,7 +694,7 @@ int set_all_storage_items_validity(void * handle, int storage_type, int validity
                        return MEDIA_SVC_PLUGIN_ERROR;
                }
 
-       } else if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL) {
+       } else if(storage_type == MEDIA_SVC_STORAGE_EXTERNAL) {
 
                ret = audio_svc_set_db_valid(handle, AUDIO_SVC_STORAGE_MMC, validity);
                if(ret < 0) {
@@ -654,6 +709,14 @@ int set_all_storage_items_validity(void * handle, int storage_type, int validity
                }
        }
 
+#ifdef NEW_MEDIA_SVC
+       ret = media_svc_set_all_storage_items_validity(handle, storage_type, validity);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+#endif
+
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
@@ -678,6 +741,14 @@ int set_item_validity_begin(void * handle, int item_cnt, char ** err_msg)
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
+#ifdef NEW_MEDIA_SVC
+       ret = media_svc_set_item_validity_begin(handle, item_cnt);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+#endif
+
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
@@ -702,6 +773,14 @@ int set_item_validity_end(void * handle, char ** err_msg)
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
+#ifdef NEW_MEDIA_SVC
+       ret = media_svc_set_item_validity_end(handle);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+#endif
+
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
@@ -729,30 +808,39 @@ int set_item_validity(void * handle, const char *file_path, int storage_type, co
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       media_svc_content_type_e content_type = __get_content_type(file_path, mime_type);
+       media_svc_media_type_e content_type = __get_content_type(file_path, mime_type);
 
-       if(content_type == CONTENT_TYPE_SOUND || content_type == CONTENT_TYPE_MUSIC)    {
+       if(content_type == MEDIA_SVC_MEDIA_TYPE_SOUND || content_type == MEDIA_SVC_MEDIA_TYPE_MUSIC)    {
 
                ret = audio_svc_set_item_valid(handle, file_path, validity);
 
-       } else if (content_type == CONTENT_TYPE_IMAGE || content_type == CONTENT_TYPE_VIDEO) {
+       } else if (content_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || content_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
 
-                       if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL)
+                       if(storage_type == MEDIA_SVC_STORAGE_INTERNAL)
                                ret = minfo_set_item_valid(handle, MINFO_PHONE, file_path, validity);
-                       else if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL)
+                       else if(storage_type == MEDIA_SVC_STORAGE_EXTERNAL)
                                ret = minfo_set_item_valid(handle, MINFO_MMC, file_path, validity);
 
        } else {
-
+#ifndef NEW_MEDIA_SVC
                __set_error_message(ERR_NOT_MEDIAFILE, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
+#endif
+       }
 
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
        }
 
+#ifdef NEW_MEDIA_SVC
+       ret = media_svc_set_item_validity(handle, file_path, validity);
+
        if(ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
        }
+#endif
 
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
@@ -783,8 +871,9 @@ int delete_item(void * handle, const char *file_path, int storage_type, char **
                if(ret < 0) {
                        __set_error_message(ret, err_msg);
                        return MEDIA_SVC_PLUGIN_ERROR;
-               } else
-                       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+               }
+//             } else
+//                     return MEDIA_SVC_PLUGIN_ERROR_NONE;
        }
 
        ret = minfo_check_item_exist(handle, file_path);
@@ -795,9 +884,23 @@ int delete_item(void * handle, const char *file_path, int storage_type, char **
                        __set_error_message(ret, err_msg);
                        return MEDIA_SVC_PLUGIN_ERROR;
                }
+//             else
+//                     return MEDIA_SVC_PLUGIN_ERROR_NONE;
+       } 
+
+#ifdef NEW_MEDIA_SVC
+       ret = media_svc_check_item_exist_by_path(handle, file_path);
+       if(ret == 0) {
+               ret = media_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;
-       } 
+       }
+#endif
 
        __set_error_message(ERR_CHECK_ITEM, err_msg);   //not exist in DB so can't delete item.
        return MEDIA_SVC_PLUGIN_ERROR;
@@ -817,7 +920,7 @@ int delete_all_items_in_storage(void * handle, int storage_type, char ** err_msg
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL) {
+       if(storage_type == MEDIA_SVC_STORAGE_INTERNAL) {
 
                ret = audio_svc_delete_all(handle, AUDIO_SVC_STORAGE_PHONE);
                if(ret < 0) {
@@ -831,7 +934,7 @@ int delete_all_items_in_storage(void * handle, int storage_type, char ** err_msg
                        return MEDIA_SVC_PLUGIN_ERROR;
                }
 
-       } else if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL) {
+       } else if(storage_type == MEDIA_SVC_STORAGE_EXTERNAL) {
 
                ret = audio_svc_delete_all(handle,AUDIO_SVC_STORAGE_MMC);
                if(ret < 0) {
@@ -845,6 +948,14 @@ int delete_all_items_in_storage(void * handle, int storage_type, char ** err_msg
                }
        }
 
+#ifdef NEW_MEDIA_SVC
+       ret = media_svc_delete_all_items_in_storage(handle, storage_type);
+       if(ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+       }
+#endif
+
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
@@ -862,7 +973,7 @@ int delete_all_invalid_items_in_storage(void * handle, int storage_type, char **
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL) {
+       if(storage_type == MEDIA_SVC_STORAGE_INTERNAL) {
 
                ret =  audio_svc_delete_invalid_items(handle,AUDIO_SVC_STORAGE_PHONE);
                if(ret < 0) {
@@ -876,7 +987,7 @@ int delete_all_invalid_items_in_storage(void * handle, int storage_type, char **
                        return MEDIA_SVC_PLUGIN_ERROR;
                }
 
-       } else if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL) {
+       } else if(storage_type == MEDIA_SVC_STORAGE_EXTERNAL) {
 
                ret =  audio_svc_delete_invalid_items(handle,AUDIO_SVC_STORAGE_MMC);
                if(ret < 0) {
@@ -890,6 +1001,13 @@ int delete_all_invalid_items_in_storage(void * handle, int storage_type, char **
                        return MEDIA_SVC_PLUGIN_ERROR;
                }
        }
+#ifdef NEW_MEDIA_SVC
+       ret = media_svc_delete_invalid_items_in_storage(handle, storage_type);
+       if(ret < 0) {
+                       __set_error_message(ret, err_msg);
+                       return MEDIA_SVC_PLUGIN_ERROR;
+       }
+#endif
 
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
@@ -903,17 +1021,54 @@ int delete_all_items(void * handle, char ** err_msg)
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = delete_all_items_in_storage(handle, MEDIA_SVC_PLUGIN_STORAGE_INTERNAL, err_msg);
+       ret = delete_all_items_in_storage(handle, MEDIA_SVC_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);
+       ret = delete_all_items_in_storage(handle, MEDIA_SVC_STORAGE_EXTERNAL, err_msg);
        if(ret < 0)
                return MEDIA_SVC_PLUGIN_ERROR;
 
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
+int refresh_item(void * handle, const char *file_path, int storage_type, const char * mime_type, char ** err_msg)
+{
+#ifdef NEW_MEDIA_SVC
+       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_media_type_e content_type = __get_content_type(file_path, mime_type);
+
+       ret = media_svc_refresh_item(handle, storage_type, file_path, content_type);
+
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+#endif
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
 int update_begin(void)
 {
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
index 7f1539e..0609da7 100755 (executable)
@@ -35,7 +35,6 @@
 #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"
 
 
index e54a024..ec3cb99 100755 (executable)
@@ -42,8 +42,7 @@
 #include <dirent.h>
 #include <glib.h>
 #include <glib/gstdio.h>
-#include <drm-service-types.h>
-#include <drm-service.h>
+#include <drm_client.h>
 #include <mm_file.h>
 #include "audio-svc-debug.h"
 #include "audio-svc-error.h"
@@ -51,6 +50,7 @@
 #include "audio-svc.h"
 #include "audio-svc-types-priv.h"
 #include "media-svc-hash.h"
+#include "media-svc-util.h"
 
 #define AUDIO_SVC_PARENTAL_RATING_LEN          20
 #define AUDIO_SVC_FILE_EXT_LEN_MAX                             6                       /**<  Maximum file ext lenth*/
@@ -141,6 +141,7 @@ int _audio_svc_extract_metadata_audio(audio_svc_storage_type_e storage_type, con
        MMHandleType tag = 0;
        char *p = NULL;
        void *image = NULL;
+       int ret = 0;
        int size = -1;
        int extracted_field = AUDIO_SVC_EXTRACTED_FIELD_NONE;
        int mmf_error = -1;
@@ -157,10 +158,114 @@ int _audio_svc_extract_metadata_audio(audio_svc_storage_type_e storage_type, con
        _strncpy_safe(item->pathname, path, sizeof(item->pathname));
        item->storage_type = storage_type;
 
-       if (drm_svc_is_drm_file(item->pathname)) {
+       drm_bool_type_e drm_type;
+
+       ret = drm_is_drm_file(item->pathname, &drm_type);
+       if (ret < 0) {
+               audio_svc_error("drm_is_drm_file falied : %d", ret);
+               drm_type = DRM_FALSE;
+       }
+
+       if (drm_type) {
                bool invalid_file = FALSE;
+               drm_file_type_e drm_file_type;
+               drm_permission_type_e drm_perm_type = DRM_PERMISSION_TYPE_PLAY;
+               drm_content_info_s contentInfo;
+               drm_license_status_e license_status;
+               memset(&contentInfo, 0x00, sizeof(drm_content_info_s));
+
+               ret = drm_get_file_type(item->pathname, &drm_file_type);
+               if (ret < 0) {
+                       audio_svc_error("drm_get_file_type falied : %d", ret);
+                       drm_file_type = DRM_TYPE_UNDEFINED;
+                       invalid_file = TRUE;
+               }
+
+               ret = drm_get_content_info(item->pathname, &contentInfo);
+               if (ret != DRM_RETURN_SUCCESS) {
+                       audio_svc_error("drm_get_content_info() fails. : %d", ret);
+                       invalid_file = TRUE;
+               }
 
-               DRM_FILE_TYPE type = drm_svc_get_drm_type(item->pathname);
+               ret = drm_get_license_status(item->pathname, drm_perm_type, &license_status);
+               if (ret != DRM_RETURN_SUCCESS) {
+                       audio_svc_error("drm_get_license_status() fails. : %d", ret);
+                       invalid_file = TRUE;
+               }
+
+               if ((!invalid_file) && (license_status != DRM_LICENSE_STATUS_VALID)) {
+                       invalid_file = TRUE;
+                       if (drm_file_type == DRM_TYPE_OMA_V1) {
+
+                               if (strlen(contentInfo.title) > 0) {
+                                       _strncpy_safe(item->audio.title, contentInfo.title, sizeof(item->audio.title));
+                                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_TITLE;
+                               }
+
+                               if (strlen(contentInfo.description) > 0) {
+                                       _strncpy_safe(item->audio.description, contentInfo.description, sizeof(item->audio.description));
+                                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_DESC;
+                               }
+                       } else if (drm_file_type == DRM_TYPE_OMA_V2) {
+                               if (strlen(contentInfo.title) > 0) {
+                                       _strncpy_safe(item->audio.title, contentInfo.title, sizeof(item->audio.title));
+                                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_TITLE;
+                               }
+
+                               if (strlen(contentInfo.description) > 0) {
+                                       _strncpy_safe(item->audio.description, contentInfo.description, sizeof(item->audio.description));
+                                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_DESC;
+                               }
+
+                               if (strlen(contentInfo.copyright) > 0) {
+                                       _strncpy_safe(item->audio.copyright, contentInfo.copyright, sizeof(item->audio.copyright));
+                                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_COPYRIGHT;
+                               }
+                               if (strlen(contentInfo.author) > 0) {
+                                       _strncpy_safe(item->audio.author, contentInfo.author, sizeof(item->audio.author));
+                                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_AUTHOR;
+                               }
+                               if (strlen(contentInfo.author) > 0) {
+                                       _strncpy_safe(item->audio.artist, contentInfo.author, sizeof(item->audio.artist));
+                                       extracted_field |= AUDIO_SVC_EXTRACTED_FIELD_ARTIST;
+                               }
+
+                       }
+               }
+
+               if (invalid_file) {
+                       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));
+                                       SAFE_FREE(title);
+                               } else {
+                                       audio_svc_error("Can't extract title from filepath");
+                                       _strncpy_safe(item->audio.title, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.title));
+                               }
+                       }
+
+                       if (!(extracted_field & AUDIO_SVC_EXTRACTED_FIELD_DESC)) {
+                               _strncpy_safe(item->audio.description, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.description));
+                       }
+                       if (!(extracted_field & AUDIO_SVC_EXTRACTED_FIELD_AUTHOR)) {
+                               _strncpy_safe(item->audio.author, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.author));
+                       }
+                       if (!(extracted_field & AUDIO_SVC_EXTRACTED_FIELD_ARTIST)) {
+                               _strncpy_safe(item->audio.description, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.description));
+                       }
+                       if (!(extracted_field & AUDIO_SVC_EXTRACTED_FIELD_COPYRIGHT)) {
+                               _strncpy_safe(item->audio.copyright, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.copyright));
+                       }
+
+                       _strncpy_safe(item->audio.album, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.album));
+                       _strncpy_safe(item->audio.genre, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.genre));
+                       _strncpy_safe(item->audio.year, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.year));
+
+                       return AUDIO_SVC_ERROR_NONE;
+               }
+
+#if 0
 
                if (type == DRM_FILE_TYPE_OMA) {
                        drm_dcf_header_t header_info;
@@ -386,6 +491,7 @@ int _audio_svc_extract_metadata_audio(audio_svc_storage_type_e storage_type, con
                        
                        return AUDIO_SVC_ERROR_NONE;
                }
+#endif
        }
 
        mmf_error = mm_file_create_content_attrs(&content, item->pathname);
@@ -659,11 +765,55 @@ bool _audio_svc_possible_to_extract_title_from_file(const char *path)
        int size = 0;
        char *p = NULL;
        char *err_attr_name = NULL;
+       drm_bool_type_e drm_type;
+       drm_file_type_e drm_file_type;
+       drm_permission_type_e drm_perm_type = DRM_PERMISSION_TYPE_PLAY;
+       drm_license_status_e license_status;
+
+       err = drm_is_drm_file(path, &drm_type);
+       if (err < 0) {
+               audio_svc_error("drm_is_drm_file falied : %d", err);
+               drm_type = DRM_FALSE;
+       }
 
-       if (drm_svc_is_drm_file(path)) {
-               DRM_FILE_TYPE type = drm_svc_get_drm_type(path);
+       if (drm_type == DRM_TRUE) {
+               bool ret = FALSE;
+               err = drm_get_file_type(path, &drm_file_type);
+               if (err < 0) {
+                       audio_svc_error("drm_get_file_type falied : %d", err);
+                       drm_file_type = DRM_TYPE_UNDEFINED;
+               }
 
-               if (type == DRM_FILE_TYPE_OMA) {
+               if (drm_file_type == DRM_TYPE_OMA_V1) {
+                       err = drm_get_license_status(path, drm_perm_type, &license_status);
+                       if (err != DRM_RETURN_SUCCESS) {
+                               audio_svc_error("drm_get_license_status() fails. : %d", err);
+
+                               ret = FALSE;
+                       } else {
+                               if (license_status != DRM_LICENSE_STATUS_VALID) {
+                                       audio_svc_debug("no valid ro. can't extract meta data");
+                                       ret = FALSE;
+                               } else {
+                                       ret = TRUE;
+                               }
+                       }
+
+               } else if (drm_file_type == DRM_TYPE_OMA_V2) {
+
+                       drm_content_info_s contentInfo;
+                       memset(&contentInfo, 0x00, sizeof(drm_content_info_s));
+
+                       ret = drm_get_content_info(path, &contentInfo);
+                       if (err != DRM_RETURN_SUCCESS) {
+                               audio_svc_error("drm_get_content_info() fails. : %d", err);
+                               ret = FALSE;
+                       } else {
+                               ret = TRUE;
+                       }
+
+#if 0
+               if (drm_file_type == DRM_FILE_TYPE_OMA) {
                        drm_dcf_header_t header_info;
                        bool ret = FALSE;
                        memset(&header_info, 0, sizeof(drm_dcf_header_t));
@@ -696,15 +846,28 @@ bool _audio_svc_possible_to_extract_title_from_file(const char *path)
                                drm_svc_free_dcf_header_info(&header_info);
                                return ret;
                        }
-               } else if (type == DRM_FILE_TYPE_PLAYREADY) {
+#endif
+               } else if (drm_file_type == DRM_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");
+
+                       err = drm_get_license_status(path, drm_perm_type, &license_status);
+                       if (err != DRM_RETURN_SUCCESS) {
+                               audio_svc_error("drm_get_license_status() fails. : %d", ret);
+                                       ret = FALSE;
+                       } else {
+                               if (license_status != DRM_LICENSE_STATUS_VALID) {
+                                       audio_svc_debug("no valid ro. can't extract meta data");
+                                       ret = FALSE;
+                               } else {
+                                       ret = TRUE;
+                               }
                        }
                } else {
                        audio_svc_error("Not supported DRM type");
                        return FALSE;
                }
+
+               return ret;
        }
 
        err = mm_file_create_tag_attrs(&tag, path);
@@ -874,24 +1037,27 @@ bool _audio_svc_get_thumbnail_path(audio_svc_storage_type_e storage_type, char *
 
 int _audio_svc_get_drm_mime_type(const char *path, char *mime_type)
 {
-       drm_content_info_t contentInfo;
+       int ret = 0;
+       drm_content_info_s contentInfo;
+       char mimetype[AUDIO_SVC_METADATA_LEN_MAX] = {0,};
 
        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");
+       memset(&contentInfo, 0x00, sizeof(drm_content_info_s));
+
+       ret = drm_get_content_info(path, &contentInfo);
+       if (ret != DRM_RETURN_SUCCESS) {
+               audio_svc_error("drm_get_content_info() fails. : %d", ret);
                return AUDIO_SVC_ERROR_INVALID_MEDIA;
        }
+
+       audio_svc_debug("DRM mime type: %s", contentInfo.mime_type);
+
+       strncpy(mimetype, contentInfo.mime_type, sizeof(mimetype) - 1);
+       mimetype[sizeof(mimetype) - 1] = '\0';
        
        return AUDIO_SVC_ERROR_NONE;
 }
@@ -907,7 +1073,7 @@ char *_year_2_str(int year)
        }
        return ret;
 }
-
+#if 0
 void _strncpy_safe(char *x_dst, const char *x_src, int max_len)
 {
        if (!x_src || strlen(x_src) == 0) {
@@ -923,7 +1089,7 @@ void _strncpy_safe(char *x_dst, const char *x_src, int max_len)
     strncpy(x_dst, x_src, max_len-1);
        x_dst[max_len-1] = '\0';
 }
-
+#endif
 void _strlcat_safe(char *x_dst, char *x_src, int max_len)
 {
        if (!x_src || strlen(x_src) == 0) {
diff --git a/src/common/media-svc-album.c b/src/common/media-svc-album.c
new file mode 100755 (executable)
index 0000000..3c30aef
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * 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-album.h"
+#include "media-svc-error.h"
+#include "media-svc-debug.h"
+#include "media-svc-env.h"
+#include "media-svc-util.h"
+#include "media-svc-db-utils.h"
+
+int _media_svc_get_album_id(sqlite3 *handle, const char *album, const char *artist, int * album_id)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+       char *sql = NULL;
+
+       media_svc_retvm_if(album == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "album is NULL");
+
+       if(artist != NULL) {
+               sql = sqlite3_mprintf("SELECT album_id FROM %s WHERE name = '%q' AND artist = '%q';", MEDIA_SVC_DB_TABLE_ALBUM, album, artist);
+       } else {
+               sql = sqlite3_mprintf("SELECT album_id FROM %s WHERE name = '%q' AND artist IS NULL;", MEDIA_SVC_DB_TABLE_ALBUM, album, artist);
+       }
+
+       ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
+
+       if (ret != MEDIA_INFO_ERROR_NONE) {
+               if(ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+                       media_svc_debug("there is no album.");
+               }
+               else {
+                       media_svc_error("error when _media_svc_get_album_id. err = [%d]", ret);
+               }
+               return ret;
+       }
+
+       *album_id = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return ret;
+}
+
+int _media_svc_get_album_art_by_album_id(sqlite3 *handle, int album_id, char **album_art)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+       char *value = NULL;
+
+       char *sql = sqlite3_mprintf("SELECT album_art FROM %s WHERE album_id=%d", MEDIA_SVC_DB_TABLE_ALBUM, album_id);
+
+       ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
+
+       if (ret != MEDIA_INFO_ERROR_NONE) {
+               if(ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+                       media_svc_debug("there is no album_id.");
+               }
+               else {
+                       media_svc_error("error when _media_svc_get_folder_id_by_foldername. err = [%d]", ret);
+               }
+               return ret;
+       }
+
+       value = (char *)sqlite3_column_text(sql_stmt, 0);
+
+       if (STRING_VALID(value)) {
+               ret = __media_svc_malloc_and_strncpy(album_art, value);
+               if (ret < 0) {
+                       media_svc_error("__media_svc_malloc_and_strncpy failed: %d", ret);
+                       SQLITE3_FINALIZE(sql_stmt);
+                       return ret;
+               }
+       } else {
+               *album_art = NULL;
+       }
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_append_album(sqlite3 *handle, const char *album, const char *artist, const char *album_art, int * album_id)
+{
+       int err = -1;
+
+       char *sql = sqlite3_mprintf("INSERT INTO %s (name, artist, album_art, album_art) values (%Q, %Q, %Q, %Q); ",
+                                            MEDIA_SVC_DB_TABLE_ALBUM, album, artist, album_art, album_art);
+       err = _media_svc_sql_query(handle, sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               media_svc_error("failed to insert albums");
+               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+       }
+
+       *album_id = sqlite3_last_insert_rowid(handle);
+
+       return MEDIA_INFO_ERROR_NONE;
+}
diff --git a/src/common/media-svc-db-utils.c b/src/common/media-svc-db-utils.c
new file mode 100755 (executable)
index 0000000..c67a91f
--- /dev/null
@@ -0,0 +1,654 @@
+/*
+ * 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 <db-util.h>
+#include "media-svc-env.h"
+#include "media-svc-debug.h"
+#include "media-svc-error.h"
+#include "media-svc-db-utils.h"
+
+static int __media_svc_busy_handler(void *pData, int count);
+
+static int __media_svc_busy_handler(void *pData, int count)
+{
+       usleep(50000);
+
+       media_svc_debug("media_svc_busy_handler called : %d", count);
+
+       return 100 - count;
+}
+
+int _media_svc_connect_db_with_handle(sqlite3 **db_handle)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+
+       media_svc_debug_func();
+
+       /*Connect DB*/
+       ret = db_util_open(MEDIA_SVC_DB_NAME, db_handle, DB_UTIL_REGISTER_HOOK_METHOD);
+
+       if (SQLITE_OK != ret) {
+
+               media_svc_error("error when db open");
+               *db_handle = NULL;
+               return MEDIA_INFO_ERROR_DATABASE_CONNECT;
+       }
+
+       /*Register busy handler*/
+       ret = sqlite3_busy_handler(*db_handle, __media_svc_busy_handler, NULL);
+
+       if (SQLITE_OK != ret) {
+
+               if (*db_handle) {
+                       media_svc_error("[error when register busy handler] %s\n", sqlite3_errmsg(*db_handle));
+               }
+
+               db_util_close(*db_handle);
+               *db_handle = NULL;
+
+               return MEDIA_INFO_ERROR_DATABASE_CONNECT;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_disconnect_db_with_handle(sqlite3 *db_handle)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+
+       media_svc_debug_func();
+
+       ret = db_util_close(db_handle);
+
+       if (SQLITE_OK != ret) {
+               media_svc_error("error when db close");
+               media_svc_error("Error : %s", sqlite3_errmsg(db_handle));
+               db_handle = NULL;
+               return MEDIA_INFO_ERROR_DATABASE_DISCONNECT;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_create_media_table(sqlite3 *db_handle)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       char * sql = NULL;
+
+       media_svc_debug_func();
+
+       sql = sqlite3_mprintf("CREATE TABLE IF NOT EXISTS %s (\
+                               media_uuid                      TEXT PRIMARY KEY, \
+                               path                                    TEXT NOT NULL UNIQUE, \
+                               file_name                       TEXT NOT NULL, \
+                               media_type                      INTEGER,\
+                               mime_type                       TEXT, \
+                               size                                    INTEGER DEFAULT 0, \
+                               added_time                      INTEGER DEFAULT 0,\
+                               modified_time                   INTEGER DEFAULT 0, \
+                               folder_uuid                     TEXT NOT NULL, \
+                               thumbnail_path          TEXT, \
+                               title                                   TEXT, \
+                               album_id                                INTEGER DEFAULT 0, \
+                               album                           TEXT, \
+                               artist                          TEXT, \
+                               genre                           TEXT, \
+                               composer                        TEXT, \
+                               year                                    TEXT, \
+                               recorded_date           TEXT, \
+                               copyright                       TEXT, \
+                               track_num                       TEXT, \
+                               description                     TEXT, \
+                               bitrate                         INTEGER DEFAULT -1, \
+                               samplerate                      INTEGER DEFAULT -1, \
+                               channel                         INTEGER DEFAULT -1, \
+                               duration                                INTEGER DEFAULT -1, \
+                               longitude                       DOUBLE DEFAULT 0, \
+                               latitude                                DOUBLE DEFAULT 0, \
+                               altitude                                DOUBLE DEFAULT 0, \
+                               width                           INTEGER DEFAULT -1, \
+                               height                          INTEGER DEFAULT -1, \
+                               datetaken                       TEXT, \
+                               orientation                     INTEGER DEFAULT -1, \
+                               played_count                    INTEGER DEFAULT 0, \
+                               last_played_time                INTEGER DEFAULT 0, \
+                               last_played_position    INTEGER DEFAULT 0, \
+                               rating                          INTEGER DEFAULT 0, \
+                               favourite                               INTEGER DEFAULT 0, \
+                               author                          TEXT, \
+                               provider                                TEXT, \
+                               content_name            TEXT, \
+                               category                                TEXT, \
+                               location_tag                    TEXT, \
+                               age_rating                      TEXT, \
+                               keyword                         TEXT, \
+                               is_drm                          INTEGER DEFAULT 0, \
+                               storage_type                    INTEGER, \
+                               validity                                INTEGER DEFAULT 1, \
+                               unique(path, file_name) \
+                               );",
+                               MEDIA_SVC_DB_TABLE_MEDIA);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create db table (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       /* Create Index*/
+       sql = sqlite3_mprintf(" CREATE INDEX IF NOT EXISTS media_media_type_idx on %s (media_type); \
+                                               CREATE INDEX IF NOT EXISTS media_title_idx on %s (title); \
+                                               CREATE INDEX IF NOT EXISTS media_modified_time_idx on %s (modified_time); \
+                                               CREATE INDEX IF NOT EXISTS media_provider_idx on %s (provider); \
+                                               ",
+                                               MEDIA_SVC_DB_TABLE_MEDIA,
+                                               MEDIA_SVC_DB_TABLE_MEDIA,
+                                               MEDIA_SVC_DB_TABLE_MEDIA,
+                                               MEDIA_SVC_DB_TABLE_MEDIA);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create db table (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_create_folder_table(sqlite3 *db_handle)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       char * sql = NULL;
+
+       media_svc_debug_func();
+
+       sql = sqlite3_mprintf("CREATE TABLE IF NOT EXISTS %s (\
+                               folder_uuid             TEXT PRIMARY KEY, \
+                               path                            TEXT NOT NULL UNIQUE, \
+                               name                    TEXT NOT NULL, \
+                               modified_time           INTEGER DEFAULT 0, \
+                               storage_type            INTEGER, \
+                               unique(path, name) \
+                               );",
+                               MEDIA_SVC_DB_TABLE_FOLDER);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create db table (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       /* Create Trigger to remove folder which have no content from folder when media remove from media_table*/
+       sql = sqlite3_mprintf("CREATE TRIGGER IF NOT EXISTS folder_cleanup \
+                               DELETE ON %s BEGIN DELETE FROM %s \
+                               WHERE (SELECT count(*) FROM %s WHERE folder_uuid=old.folder_uuid)=1 AND folder_uuid=old.folder_uuid;END;",
+                               MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_FOLDER, MEDIA_SVC_DB_TABLE_MEDIA);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create trigger (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_create_playlist_table(sqlite3 *db_handle)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       char * sql = NULL;
+
+       media_svc_debug_func();
+
+       /*Create playlist table*/
+       sql = sqlite3_mprintf("CREATE TABLE IF NOT EXISTS %s (\
+                               playlist_id             INTEGER PRIMARY KEY AUTOINCREMENT, \
+                               name                    TEXT NOT NULL UNIQUE\
+                               );",
+                               MEDIA_SVC_DB_TABLE_PLAYLIST);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create db table (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       /*Create playlist_map table*/
+       sql = sqlite3_mprintf("CREATE TABLE IF NOT EXISTS %s (\
+                               _id                             INTEGER PRIMARY KEY AUTOINCREMENT, \
+                               playlist_id             INTEGER NOT NULL,\
+                               media_uuid              TEXT NOT NULL,\
+                               play_order              INTEGER NOT NULL\
+                               );",
+                               MEDIA_SVC_DB_TABLE_PLAYLIST_MAP);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create db table (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       /* Create Trigger to remove media from playlist_map when media remove from media_table*/
+       sql = sqlite3_mprintf("CREATE TRIGGER IF NOT EXISTS playlist_map_cleanup \
+                               DELETE ON %s BEGIN DELETE FROM %s WHERE media_uuid=old.media_uuid;END;",
+                               MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_PLAYLIST_MAP);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create trigger (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       /* Create Trigger to remove media from playlist_map when playlist removed from playlist table*/
+       sql = sqlite3_mprintf("CREATE TRIGGER IF NOT EXISTS playlist_map_cleanup_1 \
+                               DELETE ON %s BEGIN DELETE FROM %s WHERE playlist_id=old.playlist_id;END;",
+                               MEDIA_SVC_DB_TABLE_PLAYLIST, MEDIA_SVC_DB_TABLE_PLAYLIST_MAP);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create trigger (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_create_album_table(sqlite3 *db_handle)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       char * sql = NULL;
+
+       media_svc_debug_func();
+
+       sql = sqlite3_mprintf("CREATE TABLE IF NOT EXISTS %s (\
+                               album_id                        INTEGER PRIMARY KEY AUTOINCREMENT, \
+                               name                    TEXT NOT NULL,\
+                               artist                  TEXT, \
+                               album_art               TEXT, \
+                               unique(name, artist) \
+                               );",
+                               MEDIA_SVC_DB_TABLE_ALBUM);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create db table (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       /* Create Trigger to remove album when media remove from media_table*/
+       sql = sqlite3_mprintf("CREATE TRIGGER IF NOT EXISTS album_cleanup \
+                               DELETE ON %s BEGIN DELETE FROM %s \
+                               WHERE (SELECT count(*) FROM %s WHERE album_id=old.album_id)=1 AND album_id=old.album_id;END;",
+                               MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_ALBUM, MEDIA_SVC_DB_TABLE_MEDIA);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create trigger (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_create_tag_table(sqlite3 *db_handle)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       char * sql = NULL;
+
+       media_svc_debug_func();
+
+       /*Create tag table*/
+       sql = sqlite3_mprintf("CREATE TABLE IF NOT EXISTS %s (\
+                               tag_id          INTEGER PRIMARY KEY AUTOINCREMENT, \
+                               name            TEXT NOT NULL UNIQUE\
+                               );",
+                               MEDIA_SVC_DB_TABLE_TAG);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create db table (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       /*Create tag_map table*/
+       sql = sqlite3_mprintf("CREATE TABLE IF NOT EXISTS %s (\
+                               _id                             INTEGER PRIMARY KEY AUTOINCREMENT, \
+                               tag_id                  INTEGER NOT NULL,\
+                               media_uuid              TEXT NOT NULL,\
+                               unique(tag_id, media_uuid) \
+                               );",
+                               MEDIA_SVC_DB_TABLE_TAG_MAP);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create db table (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       /* Create Trigger to remove media from tag_map when media remove from media_table*/
+       sql = sqlite3_mprintf("CREATE TRIGGER IF NOT EXISTS tag_map_cleanup \
+                               DELETE ON %s BEGIN DELETE FROM %s WHERE media_uuid=old.media_uuid;END;",
+                               MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_TAG_MAP);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create trigger (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       /* Create Trigger to remove media from tag_map when tag removed from tag table*/
+       sql = sqlite3_mprintf("CREATE TRIGGER IF NOT EXISTS tag_map_cleanup_1 \
+                               DELETE ON %s BEGIN DELETE FROM %s WHERE tag_id=old.tag_id;END;",
+                               MEDIA_SVC_DB_TABLE_TAG, MEDIA_SVC_DB_TABLE_TAG_MAP);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create trigger (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_create_bookmark_table(sqlite3 *db_handle)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       char * sql = NULL;
+
+       media_svc_debug_func();
+
+       sql = sqlite3_mprintf("CREATE TABLE IF NOT EXISTS %s (\
+                               bookmark_id             INTEGER PRIMARY KEY AUTOINCREMENT, \
+                               media_uuid              TEXT NOT NULL,\
+                               marked_time             INTEGER DEFAULT 0, \
+                               thumbnail_path  TEXT, \
+                               unique(media_uuid, marked_time) \
+                               );",
+                               MEDIA_SVC_DB_TABLE_BOOKMARK);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create db table (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       /* Create Trigger to remove media from tag_map when media remove from media_table*/
+       sql = sqlite3_mprintf("CREATE TRIGGER IF NOT EXISTS bookmark_cleanup \
+                               DELETE ON %s BEGIN DELETE FROM %s WHERE media_uuid=old.media_uuid;END;",
+                               MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_BOOKMARK);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create trigger (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_create_custom_table(sqlite3 *db_handle)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       char * sql = NULL;
+
+       media_svc_debug_func();
+
+       sql = sqlite3_mprintf("CREATE TABLE IF NOT EXISTS %s (\
+                               _id                             INTEGER PRIMARY KEY AUTOINCREMENT, \
+                               media_uuid              TEXT, \
+                               media_type              INTEGER,\
+                               author                  TEXT, \
+                               provider                        TEXT, \
+                               content_name    TEXT, \
+                               category                        TEXT, \
+                               location_tag            TEXT, \
+                               age_rating              TEXT \
+                               );",
+                               MEDIA_SVC_DB_TABLE_CUSTOM);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create db table (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       /* Create Trigger to remove media from tag_map when media remove from media_table*/
+       sql = sqlite3_mprintf("CREATE TRIGGER IF NOT EXISTS custom_cleanup \
+                               DELETE ON %s BEGIN DELETE FROM %s WHERE media_uuid=old.media_uuid;END;",
+                               MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_CUSTOM);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create trigger (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       /* Create Index*/
+       sql = sqlite3_mprintf("CREATE INDEX IF NOT EXISTS custom_provider_idx on %s (provider); \
+                                               ",
+                                               MEDIA_SVC_DB_TABLE_CUSTOM);
+
+       media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+
+       ret = _media_svc_sql_query(db_handle, sql);
+       sqlite3_free(sql);
+       if (ret != SQLITE_OK) {
+               media_svc_error("It failed to create db table (%d)", ret);
+               return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_sql_query(sqlite3 *db_handle, const char *sql_str)
+{
+       int err = -1;
+       char *zErrMsg = NULL;
+
+       media_svc_debug("SQL = [%s]", sql_str);
+
+       media_svc_retvm_if(sql_str == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "sql_str is NULL");
+
+       err = sqlite3_exec(db_handle, sql_str, NULL, NULL, &zErrMsg);
+
+       if (SQLITE_OK != err) {
+               media_svc_error("failed to execute [%s], err[%d]", zErrMsg, err);
+       } else {
+               media_svc_debug("query success");
+       }
+
+       if (zErrMsg)
+               sqlite3_free (zErrMsg);
+
+       return err;
+}
+
+int _media_svc_sql_prepare_to_step(sqlite3 *handle, const char *sql_str, sqlite3_stmt** stmt)
+{
+       int err = -1;
+
+       media_svc_debug("[SQL query] : %s", sql_str);
+
+       err = sqlite3_prepare_v2(handle, sql_str, -1, stmt, NULL);
+       sqlite3_free((char *)sql_str);
+
+       if (err != SQLITE_OK) {
+               media_svc_error ("prepare error [%s]", sqlite3_errmsg(handle));
+               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+       }
+
+       err = sqlite3_step(*stmt);
+       if (err != SQLITE_ROW) {
+               media_svc_error("Item not found. end of row [%s]", sqlite3_errmsg(handle));
+               SQLITE3_FINALIZE(*stmt);
+               return MEDIA_INFO_ERROR_DATABASE_NO_RECORD;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_sql_begin_trans(sqlite3 *handle)
+{
+       char *err_msg = NULL;
+
+       media_svc_debug("========_media_svc_sql_begin_trans");
+
+       if (SQLITE_OK != sqlite3_exec(handle, "BEGIN IMMEDIATE;", NULL, NULL, &err_msg)) {
+               media_svc_error("Error:failed to begin transaction: error=%s", err_msg);
+               sqlite3_free(err_msg);
+               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+       }
+
+       sqlite3_free(err_msg);
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_sql_end_trans(sqlite3 *handle)
+{
+       char *err_msg = NULL;
+
+       media_svc_debug("========_media_svc_sql_end_trans");
+
+       if (SQLITE_OK != sqlite3_exec(handle, "COMMIT;", NULL, NULL, &err_msg)) {
+               media_svc_error("Error:failed to end transaction: error=%s", err_msg);
+               sqlite3_free(err_msg);
+               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+       }
+
+       sqlite3_free(err_msg);
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_sql_rollback_trans(sqlite3 *handle)
+{
+       char *err_msg = NULL;
+
+       media_svc_debug("========_media_svc_sql_rollback_trans");
+
+       if (SQLITE_OK != sqlite3_exec(handle, "ROLLBACK;", NULL, NULL, &err_msg)) {
+               media_svc_error("Error:failed to rollback transaction: error=%s", err_msg);
+               sqlite3_free(err_msg);
+               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+       }
+
+       sqlite3_free(err_msg);
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_sql_query_list(sqlite3 *handle, GList **query_list)
+{
+       int i = 0;
+       int length = g_list_length(*query_list);
+       int err = -1;
+       char *sql = NULL;
+
+       media_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 = _media_svc_sql_query(handle, sql);
+
+                       if (err != SQLITE_OK) {
+                               media_svc_error("A query failed in batch");
+                       }
+                       sqlite3_free(sql);
+                       sql = NULL;
+               }
+       }
+
+       _media_svc_sql_query_release(query_list);
+
+       return MEDIA_INFO_ERROR_NONE;
+
+}
+
+void _media_svc_sql_query_add(GList **query_list, char **query)
+{
+       *query_list = g_list_append( *query_list, *query);
+}
+
+void _media_svc_sql_query_release(GList **query_list)
+{
+       if (*query_list) {
+               media_svc_debug("_svc_sql_query_release");
+               g_list_free(*query_list);
+               *query_list = NULL;
+       }
+}
+
index 8cd23d3..53617c6 100755 (executable)
@@ -92,7 +92,7 @@ void mediainfo_print_debug_time(char *time_string)
            (double)(time.tv_sec * 1000000 + time.tv_usec -
                     g_time_usec) / CLOCKS_PER_SEC;
 
-       mediainfo_dbg("time [%s] : %f \n", time_string, totaltime);
+       media_svc_debug("time [%s] : %f \n", time_string, totaltime);
 #endif
 }
 
@@ -105,7 +105,7 @@ mediainfo_print_debug_time_ex(long start, long end, const char *func_name,
 
        totaltime = (double)(end - start) / CLOCKS_PER_SEC;
 
-       mediainfo_dbg("time [%s: %s] : %f \n", func_name, time_string,
+       media_svc_debug("time [%s: %s] : %f \n", func_name, time_string,
                      totaltime);
 #endif
 }
diff --git a/src/common/media-svc-media-folder.c b/src/common/media-svc-media-folder.c
new file mode 100755 (executable)
index 0000000..2a1678a
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * 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 <glib/gstdio.h>
+#include "media-svc-media-folder.h"
+#include "media-svc-error.h"
+#include "media-svc-debug.h"
+#include "media-svc-env.h"
+#include "media-svc-util.h"
+#include "media-svc-db-utils.h"
+
+extern __thread GList *g_media_svc_move_item_query_list;
+
+int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *folder_name, char *folder_id)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       char *sql = sqlite3_mprintf("SELECT folder_uuid FROM %s WHERE path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, folder_name);
+
+       ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
+
+       if (ret != MEDIA_INFO_ERROR_NONE) {
+               if(ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+                       media_svc_debug("there is no folder.");
+               }
+               else {
+                       media_svc_error("error when _media_svc_get_folder_id_by_foldername. err = [%d]", ret);
+               }
+               return ret;
+       }
+
+       _strncpy_safe(folder_id, (const char *)sqlite3_column_text(sql_stmt, 0), MEDIA_SVC_UUID_SIZE+1);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return ret;
+}
+
+int _media_svc_append_folder(sqlite3 *handle, media_svc_storage_type_e storage_type,
+                                   const char *folder_id, const char *path_name, const char *folder_name, int modified_date)
+{
+       int err = -1;
+
+       char *sql = sqlite3_mprintf("INSERT INTO %s (folder_uuid, path, name, storage_type, modified_time) values (%Q, %Q, %Q, '%d', '%d'); ",
+                                            MEDIA_SVC_DB_TABLE_FOLDER, folder_id, path_name, folder_name, storage_type, modified_date);
+       err = _media_svc_sql_query(handle, sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               media_svc_error("failed to insert folder");
+               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_update_folder_modified_time_by_folder_uuid(sqlite3 *handle, const char *folder_uuid, const char *folder_path, bool stack_query)
+{
+       int err = -1;
+       int modified_time = 0;
+
+       modified_time = _media_svc_get_file_time(folder_path);
+
+       char *sql = sqlite3_mprintf("UPDATE %s SET modified_time=%d WHERE folder_uuid=%Q;", MEDIA_SVC_DB_TABLE_FOLDER, modified_time, folder_uuid);
+
+       if(!stack_query) {
+               err = _media_svc_sql_query(handle, sql);
+               sqlite3_free(sql);
+               if (err != SQLITE_OK) {
+                       media_svc_error("failed to update folder");
+                       return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+               }
+       } else {
+               _media_svc_sql_query_add(&g_media_svc_move_item_query_list, &sql);
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *path, media_svc_storage_type_e storage_type, char *folder_id)
+{
+       char *path_name = NULL;
+       int ret = MEDIA_INFO_ERROR_NONE;
+
+       path_name = g_path_get_dirname(path);
+
+       ret = _media_svc_get_folder_id_by_foldername(handle, path_name, folder_id);
+
+       if(ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+               char *folder_name = NULL;
+               int folder_modified_date = 0;
+               char *folder_uuid = _media_info_generate_uuid();
+               if(folder_uuid == NULL ) {
+                       media_svc_error("Invalid UUID");
+                       SAFE_FREE(path_name);
+                       return MEDIA_INFO_ERROR_INTERNAL;
+               }
+
+               folder_name = g_path_get_basename(path_name);
+               folder_modified_date = _media_svc_get_file_time(path_name);
+
+               ret = _media_svc_append_folder(handle, storage_type, folder_uuid, path_name, folder_name, folder_modified_date);
+               SAFE_FREE(folder_name);
+               _strncpy_safe(folder_id, folder_uuid, MEDIA_SVC_UUID_SIZE+1);
+       }
+
+       SAFE_FREE(path_name);
+
+       return ret;
+}
+
+int _media_svc_update_folder_table(sqlite3 *handle)
+{
+       int err = -1;
+       char *sql = NULL;
+
+       sql = sqlite3_mprintf("DELETE FROM %s WHERE folder_uuid IN (SELECT folder_uuid FROM %s WHERE folder_uuid NOT IN (SELECT folder_uuid FROM %s))",
+            MEDIA_SVC_DB_TABLE_FOLDER, MEDIA_SVC_DB_TABLE_FOLDER, MEDIA_SVC_DB_TABLE_MEDIA);
+
+       err = _media_svc_sql_query(handle, sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               media_svc_error("failed to delete folder item");
+               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
diff --git a/src/common/media-svc-media.c b/src/common/media-svc-media.c
new file mode 100755 (executable)
index 0000000..401373f
--- /dev/null
@@ -0,0 +1,502 @@
+/*
+ * 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-svc-media.h"
+#include "media-svc-media-folder.h"
+#include "media-svc-error.h"
+#include "media-svc-debug.h"
+#include "media-svc-util.h"
+#include "media-svc-db-utils.h"
+
+typedef struct{
+       char thumbnail_path[MEDIA_SVC_PATHNAME_SIZE];
+}media_svc_thumbnailpath_s;
+
+static __thread GList *g_media_svc_item_validity_query_list = NULL;
+static __thread GList *g_media_svc_insert_item_query_list = NULL;
+__thread GList *g_media_svc_move_item_query_list = NULL;
+
+static int __media_svc_count_invalid_records_with_thumbnail(sqlite3 *handle, media_svc_storage_type_e storage_type, int *count);
+static int __media_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, media_svc_storage_type_e storage_type,
+                                                       int count, media_svc_thumbnailpath_s * thumb_path);
+
+static int __media_svc_count_invalid_records_with_thumbnail(sqlite3 *handle, media_svc_storage_type_e storage_type, int *count)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+       char *sql = sqlite3_mprintf("SELECT count(*) FROM %s WHERE validity=0 AND storage_type=%d AND thumbnail_path IS NOT NULL",
+                                       MEDIA_SVC_DB_TABLE_MEDIA, storage_type);
+
+       ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
+
+       if (ret != MEDIA_INFO_ERROR_NONE) {
+               media_svc_error("error when __media_svc_count_invalid_records_with_thumbnail. err = [%d]", ret);
+               return ret;
+       }
+
+       *count = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return MEDIA_INFO_ERROR_NONE;
+
+}
+
+static int __media_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, media_svc_storage_type_e storage_type,
+                                                       int count, media_svc_thumbnailpath_s * thumb_path)
+{
+       int err = -1;
+       int idx = 0;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       char *sql = sqlite3_mprintf("select thumbnail_path from %s WHERE validity=0 AND storage_type=%d AND thumbnail_path IS NOT NULL",
+                                       MEDIA_SVC_DB_TABLE_MEDIA, storage_type);
+
+       media_svc_debug("[SQL query] : %s", sql);
+
+       err = sqlite3_prepare_v2(handle, sql, -1, &sql_stmt, NULL);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               media_svc_error("prepare error [%s]", sqlite3_errmsg(handle));
+               return MEDIA_INFO_ERROR_DATABASE_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]));
+               media_svc_debug("thumb_path[%d]=[%s]", idx, thumb_path[idx].thumbnail_path);
+               idx++;
+       }
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_count_record_with_path(sqlite3 *handle, const char *path, int *count)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       char *sql = sqlite3_mprintf("SELECT count(*) FROM %s WHERE path='%q'", MEDIA_SVC_DB_TABLE_MEDIA, path);
+
+       ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
+
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       *count = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_insert_item_with_data(sqlite3 *handle, media_svc_content_info_s *content_info, bool stack_query)
+{
+       int err = -1;
+
+       char * db_fields = "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, folder_uuid, \
+                                       thumbnail_path, title, album_id, album, artist, genre, composer, year, recorded_date, copyright, track_num, description,\
+                                       bitrate, samplerate, channel, duration, longitude, latitude, altitude, width, height, datetaken, orientation,\
+                                       rating, is_drm, storage_type";
+
+       char *sql = sqlite3_mprintf("INSERT INTO %s (%s) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %d, %Q, \
+                                                                                                       %Q, %Q, %d, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, \
+                                                                                                       %d, %d, %d, %d, %f, %f, %f, %d, %d, %Q, %d, \
+                                                                                                       %d, %d, %d);",
+               MEDIA_SVC_DB_TABLE_MEDIA, db_fields,
+               content_info->media_uuid,
+               content_info->path,
+               content_info->file_name,
+               content_info->media_type,
+               content_info->mime_type,
+               content_info->size,
+               content_info->added_time,
+               content_info->modified_time,
+               content_info->folder_uuid,
+               content_info->thumbnail_path,           //
+               content_info->media_meta.title,
+               content_info->album_id,
+               content_info->media_meta.album,
+               content_info->media_meta.artist,
+               content_info->media_meta.genre,
+               content_info->media_meta.composer,
+               content_info->media_meta.year,
+               content_info->media_meta.recorded_date,
+               content_info->media_meta.copyright,
+               content_info->media_meta.track_num,
+               content_info->media_meta.description,   //
+               content_info->media_meta.bitrate,
+               content_info->media_meta.samplerate,
+               content_info->media_meta.channel,
+               content_info->media_meta.duration,
+               content_info->media_meta.longitude,
+               content_info->media_meta.latitude,
+               content_info->media_meta.altitude,
+               content_info->media_meta.width,
+               content_info->media_meta.height,
+               content_info->media_meta.datetaken,
+               content_info->media_meta.orientation,
+               content_info->media_meta.rating,
+               content_info->is_drm,
+               content_info->storage_type);
+
+       media_svc_debug("query : %s", sql);
+
+       if(!stack_query) {
+               err = _media_svc_sql_query(handle, sql);
+               sqlite3_free(sql);
+               if (err != SQLITE_OK) {
+                       media_svc_error("failed to insert item");
+
+                       return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+               }
+       } else {
+               _media_svc_sql_query_add(&g_media_svc_insert_item_query_list, &sql);
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_update_item_with_data(sqlite3 *handle, media_svc_content_info_s *content_info)
+{
+       int err = -1;
+
+       char *sql = sqlite3_mprintf("UPDATE %s SET \
+               size=%lld, modified_time=%d, thumbnail_path=%Q, title=%Q, album_id=%d, album=%Q, artist=%Q, genre=%Q, \
+               composer=%Q, year=%Q, recorded_date=%Q, copyright=%Q, track_num=%Q, description=%Q, \
+               bitrate=%d, samplerate=%d, channel=%d, duration=%d, longitude=%f, latitude=%f, altitude=%f, width=%d, height=%d, datetaken=%Q, \
+                                                                                                       orientation=%d WHERE path=%Q",
+               MEDIA_SVC_DB_TABLE_MEDIA,
+               content_info->size,
+               content_info->modified_time,
+               content_info->thumbnail_path,
+               content_info->media_meta.title,
+               content_info->album_id,
+               content_info->media_meta.album,
+               content_info->media_meta.artist,
+               content_info->media_meta.genre,
+               content_info->media_meta.composer,
+               content_info->media_meta.year,
+               content_info->media_meta.recorded_date,
+               content_info->media_meta.copyright,
+               content_info->media_meta.track_num,
+               content_info->media_meta.description,
+               content_info->media_meta.bitrate,
+               content_info->media_meta.samplerate,
+               content_info->media_meta.channel,
+               content_info->media_meta.duration,
+               content_info->media_meta.longitude,
+               content_info->media_meta.latitude,
+               content_info->media_meta.altitude,
+               content_info->media_meta.width,
+               content_info->media_meta.height,
+               content_info->media_meta.datetaken,
+               content_info->media_meta.orientation,
+               content_info->path
+               );
+
+       media_svc_debug("query : %s", sql);
+
+       err = _media_svc_sql_query(handle, sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               media_svc_error("failed to update item");
+
+               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+int _media_svc_get_thumbnail_path_by_path(sqlite3 *handle, const char *path, char *thumbnail_path)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       char *sql = sqlite3_mprintf("SELECT thumbnail_path FROM %s WHERE path='%q'", MEDIA_SVC_DB_TABLE_MEDIA, path);
+
+       ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
+
+       if (ret != MEDIA_INFO_ERROR_NONE) {
+               if(ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+                       media_svc_debug("there is no thumbnail.");
+               }
+               else {
+                       media_svc_error("error when _media_svc_get_thumbnail_path_by_path. err = [%d]", ret);
+               }
+               return ret;
+       }
+
+       _strncpy_safe(thumbnail_path, (const char *)sqlite3_column_text(sql_stmt, 0), MEDIA_SVC_PATHNAME_SIZE);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_get_media_type_by_path(sqlite3 *handle, const char *path, int *media_type)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       char *sql = sqlite3_mprintf("SELECT media_type FROM %s WHERE path='%q'", MEDIA_SVC_DB_TABLE_MEDIA, path);
+
+       ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
+
+       if (ret != MEDIA_INFO_ERROR_NONE) {
+               media_svc_error("error when _media_svc_get_media_type_by_path. err = [%d]", ret);
+               return ret;
+       }
+
+       *media_type = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_delete_item_by_path(sqlite3 *handle, const char *path)
+{
+       int err = -1;
+       char *sql = sqlite3_mprintf("DELETE FROM %s WHERE validity=1 AND path='%q'", MEDIA_SVC_DB_TABLE_MEDIA, path);
+
+       err = _media_svc_sql_query(handle, sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               media_svc_error("It failed to delete item (%d)", err);
+               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_truncate_table(sqlite3 *handle, media_svc_storage_type_e storage_type)
+{
+       int err = -1;
+       char *sql = sqlite3_mprintf("DELETE FROM %s WHERE storage_type=%d", MEDIA_SVC_DB_TABLE_MEDIA, storage_type);
+
+       err = _media_svc_sql_query(handle, sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               media_svc_error("It failed to truncate table (%d)", err);
+               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+
+}
+
+int _media_svc_delete_invalid_items(sqlite3 *handle, media_svc_storage_type_e storage_type)
+{
+       int idx = 0;
+       media_svc_thumbnailpath_s *thumbpath_record = NULL;
+       int err = -1;
+       int invalid_count = 0;
+       int ret = MEDIA_INFO_ERROR_NONE;
+
+       ret = __media_svc_count_invalid_records_with_thumbnail(handle, storage_type, &invalid_count);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       media_svc_debug("invalid count: %d\n", invalid_count);
+
+       if (invalid_count > 0) {
+               thumbpath_record = (media_svc_thumbnailpath_s *)calloc( invalid_count, sizeof(media_svc_thumbnailpath_s));
+               if (thumbpath_record == NULL) {
+                       media_svc_error("fail to memory allocation");
+                       return MEDIA_INFO_ERROR_OUT_OF_MEMORY;
+               }
+
+               ret = __media_svc_get_invalid_records_with_thumbnail(handle, storage_type, invalid_count, thumbpath_record);
+               if (ret != MEDIA_INFO_ERROR_NONE) {
+                       media_svc_error("error when get thumbnail record");
+                       SAFE_FREE(thumbpath_record);
+                       return ret;
+               }
+       } else {
+               media_svc_debug("There is no item with thumbnail");
+       }
+
+       char *sql = sqlite3_mprintf("DELETE FROM %s WHERE validity = 0 AND storage_type=%d", MEDIA_SVC_DB_TABLE_MEDIA, storage_type);
+       err = _media_svc_sql_query(handle, sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               media_svc_error("To delete invalid items is failed(%d)", err);
+               SAFE_FREE(thumbpath_record);
+               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+       }
+
+       /*Delete thumbnails*/
+       for (idx = 0; idx < invalid_count; idx++) {
+               if (strlen(thumbpath_record[idx].thumbnail_path) > 0) {
+                       if (_media_svc_remove_file(thumbpath_record[idx].thumbnail_path) == FALSE) {
+                               media_svc_error("fail to remove thumbnail file.");
+                               SAFE_FREE(thumbpath_record);
+                               return MEDIA_INFO_ERROR_INTERNAL;
+                       }
+               }
+       }
+
+       SAFE_FREE(thumbpath_record);
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_update_item_validity(sqlite3 *handle, const char *path, int validity, bool stack_query)
+{
+       int err = -1;
+
+       char *sql = sqlite3_mprintf("UPDATE %s SET validity=%d WHERE path= '%q'", MEDIA_SVC_DB_TABLE_MEDIA, validity, path);
+
+       if(!stack_query) {
+               err = _media_svc_sql_query(handle, sql);
+               sqlite3_free(sql);
+               if (err != SQLITE_OK) {
+                       media_svc_error("To update item as valid is failed(%d)", err);
+                       return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+               }
+       } else {
+               _media_svc_sql_query_add(&g_media_svc_item_validity_query_list, &sql);
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_update_thumbnail_path(sqlite3 *handle, const char *path, const char *thumb_path)
+{
+       int err = -1;
+
+       char *sql = sqlite3_mprintf("UPDATE %s SET thumbnail_path=%Q WHERE path= %Q", MEDIA_SVC_DB_TABLE_MEDIA, thumb_path, path);
+
+       err = _media_svc_sql_query(handle, sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               media_svc_error("To update thumb path failed(%d)", err);
+               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_update_valid_of_music_records(sqlite3 *handle, media_svc_storage_type_e storage_type, int validity)
+{
+       int err = -1;
+       char *sql = sqlite3_mprintf("UPDATE %s SET validity=%d WHERE storage_type=%d", MEDIA_SVC_DB_TABLE_MEDIA, validity, storage_type);
+       err = _media_svc_sql_query(handle, sql);
+       sqlite3_free(sql);
+       if (err != SQLITE_OK) {
+               media_svc_error("To update item as valid is failed(%d)", err);
+               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_update_item_by_path(sqlite3 *handle, const char *src_path, media_svc_storage_type_e dest_storage, const char *dest_path,
+                               const char *file_name, int modified_time, const char *folder_uuid, const char *thumb_path, bool stack_query)
+{
+       /* update path, filename, modified_time, folder_uuid, thumbnail_path, */
+       /* played_count, last_played_time, last_played_position, favourite, storaget_type*/
+
+       int err = -1;
+       char *sql = NULL;
+
+       if(thumb_path != NULL) {
+               sql = sqlite3_mprintf("UPDATE %s SET \
+                                       path=%Q, file_name=%Q, modified_time=%d, folder_uuid=%Q, thumbnail_path=%Q, storage_type=%d, \
+                                       played_count=0, last_played_time=0, last_played_position=0, favourite=0 \
+                                       WHERE path=%Q",
+                                       MEDIA_SVC_DB_TABLE_MEDIA, dest_path, file_name, modified_time, folder_uuid, thumb_path, dest_storage, src_path);
+       } else {
+               sql = sqlite3_mprintf("UPDATE %s SET \
+                                       path=%Q, file_name=%Q, modified_time=%d, folder_uuid=%Q, storage_type=%d, \
+                                       played_count=0, last_played_time=0, last_played_position=0, favourite=0 \
+                                       WHERE path=%Q",
+                                       MEDIA_SVC_DB_TABLE_MEDIA, dest_path, file_name, modified_time, folder_uuid, dest_storage, src_path);
+       }
+
+       if(!stack_query) {
+               err = _media_svc_sql_query(handle, sql);
+               sqlite3_free(sql);
+               if (err != SQLITE_OK) {
+                       media_svc_error("It failed to update metadata (%d)", err);
+                       return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+               }
+       } else {
+               _media_svc_sql_query_add(&g_media_svc_move_item_query_list, &sql);
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_list_query_do(sqlite3 *handle, media_svc_query_type_e query_type)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+
+       ret = _media_svc_sql_begin_trans(handle);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       if (query_type == MEDIA_SVC_QUERY_SET_ITEM_VALIDITY)
+               ret = _media_svc_sql_query_list(handle, &g_media_svc_item_validity_query_list);
+       else if (query_type == MEDIA_SVC_QUERY_MOVE_ITEM)
+               ret = _media_svc_sql_query_list(handle, &g_media_svc_move_item_query_list);
+       else if (query_type == MEDIA_SVC_QUERY_INSERT_ITEM)
+               ret = _media_svc_sql_query_list(handle, &g_media_svc_insert_item_query_list);
+       else
+               ret = MEDIA_INFO_ERROR_INVALID_PARAMETER;
+
+       if (ret != MEDIA_INFO_ERROR_NONE) {
+               media_svc_error("_media_svc_list_query_do failed. start rollback");
+               _media_svc_sql_rollback_trans(handle);
+               return ret;
+       }
+
+       ret = _media_svc_sql_end_trans(handle);
+       if (ret != MEDIA_INFO_ERROR_NONE) {
+               media_svc_error("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+               _media_svc_sql_rollback_trans(handle);
+               return ret;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_get_media_id_by_path(sqlite3 *handle, const char *path, char *media_uuid, int max_length)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+       char *sql = sqlite3_mprintf("SELECT media_uuid FROM %s WHERE validity=1 AND path='%q'",
+                                       MEDIA_SVC_DB_TABLE_MEDIA, path);
+
+       ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
+
+       if (ret != MEDIA_INFO_ERROR_NONE) {
+               media_svc_error("error when __media_svc_count_invalid_records_with_thumbnail. err = [%d]", ret);
+               return ret;
+       }
+
+       strncpy(media_uuid, (const char*)sqlite3_column_text(sql_stmt, 0), max_length);
+       media_uuid[max_length - 1] = '\0';
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return MEDIA_INFO_ERROR_NONE;
+
+}
index c159313..cc56645 100755 (executable)
  *
  */
 
-#include "uuid.h"
+#include <unistd.h>
 #include <stdlib.h>
+#include <time.h>
+#include <string.h>
+#include <sys/vfs.h>
+#include <glib/gstdio.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <dirent.h>
+#include <ctype.h>
+#include <errno.h>
+#include <drm_client.h>
+#include <mm_file.h>
+#include <mm_error.h>
+#include <libexif/exif-data.h>
+#include <media-thumbnail.h>
+#include "uuid.h"
+#include "media-svc-util.h"
+#include "media-svc-error.h"
+#include "media-svc-debug.h"
+#include "media-svc-env.h"
+#include "media-svc-hash.h"
+#include "media-svc-album.h"
+
+
+#define MEDIA_SVC_FILE_EXT_LEN_MAX                             6                       /**<  Maximum file ext lenth*/
+
+typedef enum {
+       MEDIA_SVC_EXTRACTED_FIELD_NONE                  = 0x00000001,
+       MEDIA_SVC_EXTRACTED_FIELD_TITLE                         = MEDIA_SVC_EXTRACTED_FIELD_NONE << 1,
+       MEDIA_SVC_EXTRACTED_FIELD_DESC                  = MEDIA_SVC_EXTRACTED_FIELD_NONE << 2,
+       MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT             = MEDIA_SVC_EXTRACTED_FIELD_NONE << 3,
+       MEDIA_SVC_EXTRACTED_FIELD_AUTHOR                = MEDIA_SVC_EXTRACTED_FIELD_NONE << 4,
+       MEDIA_SVC_EXTRACTED_FIELD_ARTIST                        = MEDIA_SVC_EXTRACTED_FIELD_NONE << 5,
+       MEDIA_SVC_EXTRACTED_FIELD_GENRE                 = MEDIA_SVC_EXTRACTED_FIELD_NONE << 6,
+       MEDIA_SVC_EXTRACTED_FIELD_ALBUM                 = MEDIA_SVC_EXTRACTED_FIELD_NONE << 7,
+       MEDIA_SVC_EXTRACTED_FIELD_TRACKNUM              = MEDIA_SVC_EXTRACTED_FIELD_NONE << 8,
+       MEDIA_SVC_EXTRACTED_FIELD_YEAR                  = MEDIA_SVC_EXTRACTED_FIELD_NONE << 9,
+       MEDIA_SVC_EXTRACTED_FIELD_CATEGORY              = MEDIA_SVC_EXTRACTED_FIELD_NONE << 10,
+} media_svc_extracted_field_e;
+
+#if 0
+static char *__year_2_str(int year);
+
+static char *__year_2_str(int year)
+{
+       static char ret[MEDIA_SVC_METADATA_LEN_MAX];
+
+       if (year == -1 || year == 0) {
+               _strncpy_safe(ret, MEDIA_SVC_TAG_UNKNOWN, MEDIA_SVC_METADATA_LEN_MAX);
+       } else {
+               snprintf(ret, MEDIA_SVC_METADATA_LEN_MAX - 1, "%d", year);
+       }
+       return ret;
+}
+#endif
 
 char *_media_info_generate_uuid(void)
 {
@@ -30,10 +84,193 @@ char *_media_info_generate_uuid(void)
        uuid_generate(uuid_value);
        uuid_unparse(uuid_value, uuid_unparsed);
 
-       //mediainfo_dbg("UUID : %s", uuid_unparsed);
+       //media_svc_debug("UUID : %s", uuid_unparsed);
        return uuid_unparsed;
 }
 
+void _strncpy_safe(char *x_dst, const char *x_src, int max_len)
+{
+       if (!x_src || strlen(x_src) == 0) {
+               media_svc_error("x_src is NULL");
+               return;
+       }
+
+       if (max_len < 1) {
+               media_svc_error("length is Wrong");
+               return;
+       }
+
+    strncpy(x_dst, x_src, max_len-1);
+       x_dst[max_len-1] = '\0';
+}
+
+int __media_svc_malloc_and_strncpy(char **dst, const char *src)
+{
+       int len = 0;
+
+       if (!STRING_VALID(src)) {
+               media_svc_error("invalid src");
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+
+       if (*dst) {
+               SAFE_FREE(*dst);
+       }
+
+       len = strlen(src) + 1;
+       *dst = malloc(len);
+
+       if (*dst == NULL) {
+               media_svc_error("malloc failed");
+               return MEDIA_INFO_ERROR_INTERNAL;
+       }
+
+       strncpy(*dst, src, len);
+       char *p = *dst;
+       p[len - 1] = '\0';
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+static void __media_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;
+       }
+}
+
+static int __media_svc_get_exif_info(ExifData *ed,
+                                                                               char *buf,
+                                                                               int *i_value,
+                                                                               double *d_value,
+                                                                               int ifdtype,
+                                                                               long tagtype)
+{
+       ExifEntry *entry;
+       ExifIfd ifd;
+       ExifTag tag;
+
+       if (ed == NULL) {
+               return -1;
+       }
+
+       ifd = ifdtype;
+       tag = tagtype;
+
+       entry = exif_data_get_entry(ed, tag);
+       if (entry) {
+               /* Get the contents of the tag in human-readable form */
+               if (tag == EXIF_TAG_ORIENTATION ||
+                               tag == EXIF_TAG_PIXEL_X_DIMENSION ||
+                               tag == EXIF_TAG_PIXEL_Y_DIMENSION) {
+
+                       if (i_value == NULL) {
+                               media_svc_error("i_value is NULL");
+                               return -1;
+                       }
+
+                       ExifByteOrder mByteOrder = exif_data_get_byte_order(ed);
+                       short exif_value = exif_get_short(entry->data, mByteOrder);
+                       media_svc_debug("%s : %d", exif_tag_get_name_in_ifd(tag,ifd), exif_value);
+                       *i_value = (int)exif_value;
+
+               } else if (tag == EXIF_TAG_GPS_LATITUDE || tag == EXIF_TAG_GPS_LONGITUDE) {
+
+                       if (d_value == NULL) {
+                               media_svc_error("d_value is NULL");
+                               return -1;
+                       }
+
+                       /* Get the contents of the tag in human-readable form */
+                       char gps_buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = { '\0' };
+                       exif_entry_get_value(entry, gps_buf, sizeof(gps_buf));
+                       gps_buf[strlen(gps_buf)] = '\0';
+
+                       media_svc_debug("%s: %s\n", exif_tag_get_name_in_ifd(tag, ifd), gps_buf);
+
+                       double tmp_arr[3] = { 0.0, 0.0, 0.0 };
+                       int count = 0;
+
+                       __media_svc_split_to_double(gps_buf, tmp_arr, &count);
+                       if (count != 3) {
+                               media_svc_error("Value is invalid");
+                               return -1;
+                       }
+
+                       *d_value = tmp_arr[0] + tmp_arr[1] / 60 + tmp_arr[2] / 3600;
+                       media_svc_debug("GPS value is %f", *d_value);
+               } else {
+
+                       if (buf == NULL) {
+                               media_svc_error("buf is NULL");
+                               return -1;
+                       }
+
+                       exif_entry_get_value(entry, buf, MEDIA_SVC_METADATA_LEN_MAX);
+                       buf[strlen(buf)] = '\0';
+
+                       if (*buf) {
+                               media_svc_debug("%s: %s\n", exif_tag_get_name_in_ifd(tag, ifd), buf);
+                       }
+               }
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+unsigned int _media_svc_get_current_time(void)
+{
+       struct timeval  t;
+       unsigned int tval = 0;
+       gettimeofday(&t, NULL);
+
+       tval = t.tv_sec*1000000L + t.tv_usec;
+
+       return tval/1000;
+}
+
 int _media_svc_check_escape_char(char ch)
 {
        int i;
@@ -53,7 +290,7 @@ 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;
@@ -71,7 +308,1495 @@ char *_media_svc_escape_str(char *input, int len)
        }
 
        result[j] = '\0';
-       
+
        return result;
 }
 
+int _media_svc_rename_file( const char *old_name, const char *new_name)
+{
+       if((old_name == NULL) || (new_name == NULL))
+       {
+               media_svc_error("invalid file name");
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+
+       if (rename(old_name, new_name) < 0) {
+               media_svc_error("file rename is failed. errno : %s", strerror(errno));
+               return MEDIA_INFO_ERROR_INTERNAL;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+bool _media_svc_remove_file(const char *path)
+{
+       int result = -1;
+
+       result = remove(path);
+       if (result == 0) {
+               media_svc_debug("success to remove file");
+               return TRUE;
+       } else {
+               media_svc_error("fail to remove file result errno = %s", strerror(errno));
+               return FALSE;
+       }
+}
+
+int _media_svc_remove_all_files_in_dir(const char *dir_path)
+{
+       struct dirent *entry = NULL;
+       struct stat st;
+       char filename[MEDIA_SVC_PATHNAME_SIZE] = {0};
+       DIR *dir = NULL;
+
+       dir = opendir(dir_path);
+       if (dir == NULL) {
+               media_svc_error("%s is not exist", dir_path);
+               return MEDIA_INFO_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) {
+                       media_svc_error("failed to remove : %s", filename);
+                       closedir(dir);
+                       return MEDIA_INFO_ERROR_INTERNAL;
+               }
+       }
+
+       closedir(dir);
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+char *_media_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;
+
+       media_svc_debug("title tag doesn't exist, so get from file path");
+
+       if (!path) {
+               media_svc_error("path is NULL");
+               return NULL;
+       }
+
+       filename = g_path_get_basename(path);
+       if ((filename == NULL) || (strlen(filename) < 1)) {
+               media_svc_error("wrong file name");
+               SAFE_FREE(filename);
+               return NULL;
+       }
+
+       filename_len = strlen(filename);
+
+       ext = g_strrstr(filename, ".");
+       if (!ext) {
+               media_svc_error("there is no file extention");
+               return filename;
+       }
+
+       new_title_len = filename_len - strlen(ext);
+       if (new_title_len < 1) {
+               media_svc_error("title length is zero");
+               SAFE_FREE(filename);
+               return NULL;
+       }
+
+       title = g_strndup(filename, new_title_len < MEDIA_SVC_PATHNAME_SIZE ? new_title_len : MEDIA_SVC_PATHNAME_SIZE-1);
+
+       SAFE_FREE(filename);
+
+       media_svc_debug("extract title is [%s]", title);
+
+       return title;
+}
+
+int _media_svc_save_image(void *image, int size, char *image_path)
+{
+       media_svc_debug("start save image, path: %s", image_path);
+       if (!image) {
+               media_svc_error("invalid image..");
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+
+       struct statfs fs;
+       if (-1 == statfs(MEDIA_SVC_THUMB_PATH_PREFIX, &fs)) {
+               media_svc_error("error in statfs");
+               return MEDIA_INFO_ERROR_INTERNAL;
+       }
+
+       long bsize_kbytes = fs.f_bsize >> 10;
+
+       if ((bsize_kbytes * fs.f_bavail) < 1024) {
+               media_svc_error("not enought space...");
+               return MEDIA_INFO_ERROR_INTERNAL;
+       }
+
+       FILE *fp = NULL;
+       int nwrite = -1;
+       if (image != NULL && size > 0) {
+               fp = fopen(image_path, "w");
+
+               if (fp == NULL) {
+                       media_svc_error("failed to open file");
+                       return MEDIA_INFO_ERROR_INTERNAL;
+               }
+               media_svc_debug("image size = [%d]",  size);
+
+               nwrite = fwrite(image, 1, size, fp);
+               if (nwrite != size) {
+                       media_svc_error("failed to write thumbnail");
+                       fclose(fp);
+                       return MEDIA_INFO_ERROR_INTERNAL;
+               }
+               fclose(fp);
+       }
+
+       media_svc_debug("save thumbnail success!!");
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+bool _media_svc_get_thumbnail_path(media_svc_storage_type_e storage_type, char *thumb_path, const char *pathname, const char *img_format)
+{
+       char savename[MEDIA_SVC_PATHNAME_SIZE] = {0};
+       char file_ext[MEDIA_SVC_FILE_EXT_LEN_MAX + 1] = {0};
+       char *thumb_dir = NULL;
+       char hash[255 + 1];
+       char *thumbfile_ext = NULL;
+
+       thumb_dir = (storage_type == MEDIA_SVC_STORAGE_INTERNAL) ? MEDIA_SVC_THUMB_INTERNAL_PATH : MEDIA_SVC_THUMB_EXTERNAL_PATH;
+
+       memset(file_ext, 0, sizeof(file_ext));
+       if (!_media_svc_get_file_ext(pathname, file_ext)) {
+               media_svc_error("get file ext fail");
+               return FALSE;
+       }
+
+       int err = -1;
+       err = mb_svc_generate_hash_code(pathname, hash, sizeof(hash));
+       if (err < 0) {
+               media_svc_error("mb_svc_generate_hash_code failed : %d", err);
+               return FALSE;
+       }
+
+       media_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 {
+               media_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, MEDIA_SVC_PATHNAME_SIZE);
+       media_svc_debug("thumb_path is [%s]", thumb_path);
+
+       return TRUE;
+}
+
+bool _media_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], MEDIA_SVC_FILE_EXT_LEN_MAX);
+                       return true;
+               }
+
+               if (file_path[i] == '/') {
+                       return false;
+               }
+       }
+       return false;
+}
+
+int _media_svc_get_file_time(const char *full_path)
+{
+       struct stat statbuf;
+       int fd = 0;
+
+       memset(&statbuf, 0, sizeof(struct stat));
+       fd = stat(full_path, &statbuf);
+       if (fd == -1) {
+                media_svc_debug("stat(%s) fails.", full_path);
+                return MEDIA_INFO_ERROR_INTERNAL;
+        }
+
+        return statbuf.st_mtime;
+}
+
+int _media_svc_set_media_info(media_svc_content_info_s *content_info, media_svc_storage_type_e storage_type,
+                         const char *path, const char *mime_type, media_svc_media_type_e media_type, bool refresh)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       char * media_uuid = NULL;
+       char * file_name = NULL;
+       struct stat st;
+       drm_bool_type_e drm_type;
+
+       ret = __media_svc_malloc_and_strncpy(&content_info->path, path);
+       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+       memset(&st, 0, sizeof(struct stat));
+       if (stat(path, &st) == 0) {
+               content_info->modified_time = st.st_mtime;
+               content_info->size = st.st_size;
+               media_svc_debug("Modified time : %d", content_info->modified_time);
+               media_svc_debug("Size : %lld", content_info->size);
+       } else {
+               media_svc_error("stat failed : %s", strerror(errno));
+       }
+
+       /* refresh is TRUE when file modified. so only modified_time and size are changed*/
+       if(refresh) {
+               media_svc_debug("refresh");
+               return MEDIA_INFO_ERROR_NONE;
+       }
+
+       content_info->media_type = media_type;
+       content_info->storage_type = storage_type;
+       time(&content_info->added_time);
+
+       media_uuid = _media_info_generate_uuid();
+       media_svc_retvm_if(media_uuid == NULL, MEDIA_INFO_ERROR_INTERNAL, "Invalid UUID");
+
+       ret = __media_svc_malloc_and_strncpy(&content_info->media_uuid, media_uuid);
+       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+       ret = __media_svc_malloc_and_strncpy(&content_info->mime_type, mime_type);
+       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+       file_name = g_path_get_basename(path);
+       ret = __media_svc_malloc_and_strncpy(&content_info->file_name, file_name);
+       SAFE_FREE(file_name);
+       media_svc_retv_del_if(ret < 0, ret, content_info);
+       //_strncpy_safe(content_info->file_name, file_name, sizeof(content_info->file_name));
+
+       ret = drm_is_drm_file(content_info->path, &drm_type);
+       if (ret < 0) {
+               media_svc_error("drm_is_drm_file falied : %d", ret);
+               drm_type = DRM_FALSE;
+       }
+
+       content_info->is_drm = drm_type;
+
+       content_info->played_count = 0;
+       content_info->last_played_time= 0;
+       content_info->last_played_position= 0;
+       content_info->favourate= 0;
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info, media_svc_media_type_e media_type)
+{
+       media_svc_debug_func();
+
+       if (content_info == NULL || media_type != MEDIA_SVC_MEDIA_TYPE_IMAGE) {
+               media_svc_error("content_info == NULL || media_type != MEDIA_SVC_MEDIA_TYPE_IMAGE");
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+
+       char buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = { '\0' };
+       char description_buf[MEDIA_SVC_METADATA_DESCRIPTION_MAX + 1] = { '\0' };
+       memset(buf, 0x00, sizeof(buf));
+       memset(description_buf, 0x00, sizeof(description_buf));
+
+       int ret = MEDIA_INFO_ERROR_NONE;
+       double value = 0.0;
+       int orient_value = 0;
+       int exif_width = 0;
+       int exif_height = 0;
+       ExifData *ed = NULL;
+
+       char *path = content_info->path;
+       if (path == NULL) {
+               media_svc_error("path is NULL");
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+
+       /* Load an ExifData object from an EXIF file */
+       ed = exif_data_new_from_file(path);
+
+       if (!ed) {
+               media_svc_debug("There is no exif data in [ %s ]", path);
+       }
+
+       if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_GPS_LATITUDE_REF) == MEDIA_INFO_ERROR_NONE) {
+               if (strlen(buf) != 0) {
+                       if (__media_svc_get_exif_info(ed, NULL, NULL, &value, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE) == MEDIA_INFO_ERROR_NONE) {
+
+                               if (strcmp(buf, "S") == 0) {
+                                       value = -1 * value;
+                               }
+
+                               content_info->media_meta.latitude = value;
+                       } else {
+                               content_info->media_meta.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
+                               media_svc_debug("Use default gps value");
+                       }
+               } else {
+                       content_info->media_meta.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
+                       media_svc_debug("Use default gps value");
+               }
+       } else {
+               content_info->media_meta.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
+               media_svc_debug("Use default gps value");
+       }
+
+       memset(buf, 0x00, sizeof(buf));
+
+       if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_GPS_LONGITUDE_REF) == MEDIA_INFO_ERROR_NONE) {
+               if (strlen(buf) != 0) {
+                       if (__media_svc_get_exif_info(ed, NULL, NULL, &value, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE) == MEDIA_INFO_ERROR_NONE) {
+                               if (strcmp(buf, "W") == 0) {
+                                       value = -1 * value;
+                               }
+                               content_info->media_meta.longitude = value;
+                       } else {
+                               content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
+                               media_svc_debug("Use default gps value");
+                       }
+               } else {
+                       content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
+                       media_svc_debug("Use default gps value");
+               }
+       } else {
+               content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
+               media_svc_debug("Use default gps value");
+       }
+
+       memset(buf, 0x00, sizeof(buf));
+
+       if (__media_svc_get_exif_info(ed, description_buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_IMAGE_DESCRIPTION) == MEDIA_INFO_ERROR_NONE) {
+               if (strlen(description_buf) == 0) {
+                       media_svc_debug("Use 'No description'");
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, "No description");
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+               } else {
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, description_buf);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+               }
+       } else {
+               media_svc_debug("Use 'No description'");
+               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, "No description");
+               media_svc_retv_del_if(ret < 0, ret, content_info);
+       }
+
+       memset(buf, 0x00, sizeof(buf));
+
+       if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_DATE_TIME) == MEDIA_INFO_ERROR_NONE) {
+               if (strlen(buf) == 0) {
+                       media_svc_debug("time  is NULL");
+               } else {
+                       media_svc_debug("time  is %s", buf);
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.datetaken, buf);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+               }
+       } else {
+               media_svc_debug("time  is NULL");
+       }
+
+       /* Get orientation value from exif. */
+       if (__media_svc_get_exif_info(ed, NULL, &orient_value, NULL, EXIF_IFD_0, EXIF_TAG_ORIENTATION) == MEDIA_INFO_ERROR_NONE) {
+               if (orient_value >= NOT_AVAILABLE && orient_value <= ROT_270) {
+                       content_info->media_meta.orientation = orient_value;
+               } else {
+                       content_info->media_meta.orientation = 0;
+               }
+       } else {
+               content_info->media_meta.orientation = 0;
+       }
+
+       /* Get width value from exif. */
+       if (__media_svc_get_exif_info(ed, NULL, &exif_width, NULL, EXIF_IFD_EXIF, EXIF_TAG_PIXEL_X_DIMENSION) == MEDIA_INFO_ERROR_NONE) {
+               if (exif_width > 0) {
+                       content_info->media_meta.width = exif_width;
+               } else {
+                       content_info->media_meta.width = 0;
+               }
+       } else {
+               content_info->media_meta.width = 0;
+       }
+
+       /* Get height value from exif. */
+       if (__media_svc_get_exif_info(ed, NULL, &exif_height, NULL, EXIF_IFD_EXIF, EXIF_TAG_PIXEL_Y_DIMENSION) == MEDIA_INFO_ERROR_NONE) {
+               if (exif_height > 0) {
+                       content_info->media_meta.height = exif_height;
+               } else {
+                       content_info->media_meta.height = 0;
+               }
+       } else {
+               content_info->media_meta.height = 0;
+       }
+
+       if (ed != NULL) exif_data_unref(ed);
+
+       /* Extracting thumbnail */
+       char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
+       int width = 0;
+       int height = 0;
+
+       ret = thumbnail_request_from_db_with_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height);
+       if (ret < 0) {
+               media_svc_error("thumbnail_request_from_db failed: %d", ret);
+       } else {
+               media_svc_debug("thumbnail_request_from_db success: %s", thumb_path);
+       }
+
+       content_info->media_meta.width = width;
+       content_info->media_meta.height = height;
+       ret = __media_svc_malloc_and_strncpy(&content_info->thumbnail_path, thumb_path);
+       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, media_svc_media_type_e media_type)
+{
+       MMHandleType content = 0;
+       MMHandleType tag = 0;
+       char *p = NULL;
+       void *image = NULL;
+       int size = -1;
+       int extracted_field = MEDIA_SVC_EXTRACTED_FIELD_NONE;
+       int mmf_error = -1;
+       bool thumb_extracted_from_drm = FALSE;
+       char *err_attr_name = NULL;
+       char *title = NULL;
+       bool extract_thumbnail = FALSE;
+       bool append_album = FALSE;
+       int album_id = 0;
+       double gps_value = 0.0;
+       int ret = MEDIA_INFO_ERROR_NONE;
+       drm_bool_type_e drm_type;
+       char *path = content_info->path;
+
+       ret = drm_is_drm_file(path, &drm_type);
+       if (ret < 0) {
+               media_svc_error("drm_is_drm_file falied : %d", ret);
+               drm_type = DRM_FALSE;
+       }
+
+       /*To do - code for DRM content*/
+       if (drm_type) {
+               bool invalid_file = FALSE;
+               drm_file_type_e drm_file_type;
+               drm_permission_type_e drm_perm_type = DRM_PERMISSION_TYPE_PLAY;
+               drm_content_info_s contentInfo;
+               drm_license_status_e license_status;
+               memset(&contentInfo, 0x00, sizeof(drm_content_info_s));
+
+               ret = drm_get_file_type(path, &drm_file_type);
+               if (ret < 0) {
+                       media_svc_error("drm_get_file_type falied : %d", ret);
+                       drm_file_type = DRM_TYPE_UNDEFINED;
+                       invalid_file = TRUE;
+               }
+
+               ret = drm_get_content_info(path, &contentInfo);
+               if (ret != DRM_RETURN_SUCCESS) {
+                       media_svc_error("drm_get_content_info() fails. : %d", ret);
+                       invalid_file = TRUE;
+               }
+
+               ret = drm_get_license_status(path, drm_perm_type, &license_status);
+               if (ret != DRM_RETURN_SUCCESS) {
+                       media_svc_error("drm_get_license_status() fails. : %d", ret);
+                       invalid_file = TRUE;
+               }
+
+               if ((!invalid_file) && (license_status != DRM_LICENSE_STATUS_VALID)) {
+                       invalid_file = TRUE;
+                       if (drm_file_type == DRM_TYPE_OMA_V1) {
+
+                               if (strlen(contentInfo.title) > 0) {
+                                        __media_svc_malloc_and_strncpy(&content_info->media_meta.title, contentInfo.title);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE;
+                               }
+
+                               if (strlen(contentInfo.description) > 0) {
+                                        __media_svc_malloc_and_strncpy(&content_info->media_meta.description, contentInfo.description);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_DESC;
+                               }
+                       } else if (drm_file_type == DRM_TYPE_OMA_V2) {
+                               if (strlen(contentInfo.title) > 0) {
+                                        __media_svc_malloc_and_strncpy(&content_info->media_meta.title, contentInfo.title);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE;
+                               }
+
+                               if (strlen(contentInfo.description) > 0) {
+                                        __media_svc_malloc_and_strncpy(&content_info->media_meta.description, contentInfo.description);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_DESC;
+                               }
+
+                               if (strlen(contentInfo.copyright) > 0) {
+                                        __media_svc_malloc_and_strncpy(&content_info->media_meta.copyright, contentInfo.copyright);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT;
+                               }
+
+                               if (strlen(contentInfo.author) > 0) {
+                                        __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, contentInfo.author);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                                        __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, contentInfo.author);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
+                                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_ARTIST;
+                               }
+                       }
+               }
+
+               if (invalid_file) {
+                       if (!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) {
+                               title = _media_svc_get_title_from_filepath(path);
+                               if (title) {
+                                       __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
+                                       SAFE_FREE(title);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                               } else {
+                                       media_svc_error("Can't extract title from filepath");
+                                       __media_svc_malloc_and_strncpy(&content_info->media_meta.title, MEDIA_SVC_TAG_UNKNOWN);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                               }
+                       }
+
+                       if (!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_DESC)) {
+                               __media_svc_malloc_and_strncpy(&content_info->media_meta.description, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                       }
+                       if (!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_AUTHOR)) {
+                               __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                       }
+                       if (!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ARTIST)) {
+                               __media_svc_malloc_and_strncpy(&content_info->media_meta.description, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                       }
+                       if (!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT)) {
+                               __media_svc_malloc_and_strncpy(&content_info->media_meta.copyright, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                       }
+
+                       __media_svc_malloc_and_strncpy(&content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                       __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                       __media_svc_malloc_and_strncpy(&content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                       return MEDIA_INFO_ERROR_NONE;
+               }
+       }
+
+#if 0
+       if (drm_svc_is_drm_file(content_info->path)) {
+               bool invalid_file = FALSE;
+
+               DRM_FILE_TYPE type = drm_svc_get_drm_type(content_info->path);
+
+               if (type == DRM_FILE_TYPE_OMA) {
+                       drm_dcf_header_t header_info;
+                       memset(&header_info, 0, sizeof(drm_dcf_header_t));
+                       media_svc_debug("drm type is OMA");
+
+                       if (drm_svc_get_dcf_header_info(content_info->path, &header_info) != DRM_RESULT_SUCCESS) {
+                               media_svc_debug("cannot get dcf header info. just get the title");
+                               title = _media_svc_get_title_from_filepath(content_info->path);
+                               if (title) {
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
+                                       SAFE_FREE(title);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                                       //_strncpy_safe(content_info->media_meta.title, title, sizeof(content_info->media_meta.title));
+                               } else {
+                                       media_svc_error("Can't extract title from filepath");
+                                       return MEDIA_INFO_ERROR_INTERNAL;
+                               }
+
+/*
+                               _strncpy_safe(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.album));
+                               _strncpy_safe(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.artist));
+                               _strncpy_safe(content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.genre));
+                               _strncpy_safe(content_info->media_meta.author, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.author));
+                               _strncpy_safe(content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.year));
+*/
+
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                               return MEDIA_INFO_ERROR_NONE;
+                       }
+
+                       if (drm_svc_has_valid_ro(content_info->path, DRM_PERMISSION_PLAY) != DRM_RESULT_SUCCESS) {
+                               media_svc_debug("no valid ro. can't extract meta data");
+                               invalid_file = TRUE;
+                       }
+
+                       if (header_info.version == DRM_OMA_DRMV1_RIGHTS) {
+                               media_svc_debug("DRM V1");
+                               if (invalid_file) {
+
+                                       if (strlen(header_info.headerUnion.headerV1.contentName) > 0) {
+
+                                               //_strncpy_safe(content_info->media_meta.title, header_info.headerUnion.headerV1.contentName, sizeof(content_info->media_meta.title));
+                                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, header_info.headerUnion.headerV1.contentName);
+                                               media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                                               extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE;
+                                               media_svc_debug("extract title from DCF");
+                                       }
+
+                                       if (strlen(header_info.headerUnion.headerV1.contentDescription) > 0) {
+                                               //_strncpy_safe(content_info->media_meta.description, header_info.headerUnion.headerV1.contentDescription, sizeof(content_info->media_meta.description));
+                                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, header_info.headerUnion.headerV1.contentDescription);
+                                               media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                                               extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_DESC;
+                                               media_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;
+
+                               media_svc_debug("DRM V2");
+
+                               if (drm_svc_get_user_data_box_info(content_info->path, DRM_UDTA_TITLE, &metadata) == DRM_RESULT_SUCCESS) {
+                                       //_strncpy_safe(content_info->media_meta.title, metadata.subBox.title.str, sizeof(content_info->media_meta.title));
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, metadata.subBox.title.str);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE;
+                                       media_svc_debug("extract title from odf");
+                               }
+
+                               if (drm_svc_get_user_data_box_info(content_info->path, DRM_UDTA_DESCRIPTION, &metadata) == DRM_RESULT_SUCCESS) {
+                                       //_strncpy_safe(content_info->media_meta.description, metadata.subBox.desc.str, sizeof(content_info->media_meta.description));
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, metadata.subBox.desc.str);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_DESC;
+                               }
+
+                               if (drm_svc_get_user_data_box_info(content_info->path, DRM_UDTA_COPYRIGHT, &metadata) == DRM_RESULT_SUCCESS) {
+                                       //_strncpy_safe(content_info->media_meta.copyright, metadata.subBox.copyright.str, sizeof(content_info->media_meta.copyright));
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.copyright, metadata.subBox.copyright.str);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT;
+                               }
+
+                               if (drm_svc_get_user_data_box_info(content_info->path, DRM_UDTA_AUTHOR, &metadata) == DRM_RESULT_SUCCESS) {
+                                       //_strncpy_safe(content_info->media_meta.composer, metadata.subBox.author.str, sizeof(content_info->media_meta.composer));
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, metadata.subBox.author.str);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
+                               }
+
+                               if (drm_svc_get_user_data_box_info(content_info->path, DRM_UDTA_PERFORMER, &metadata) == DRM_RESULT_SUCCESS) {
+                                       //_strncpy_safe(content_info->media_meta.artist, metadata.subBox.performer.str, sizeof(content_info->media_meta.artist));
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, metadata.subBox.performer.str);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_ARTIST;
+                               }
+
+                               if (drm_svc_get_user_data_box_info(content_info->path, DRM_UDTA_GENRE, &metadata) == DRM_RESULT_SUCCESS) {
+                                       //_strncpy_safe(content_info->media_meta.genre, metadata.subBox.genre.str, sizeof(content_info->media_meta.genre));
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, metadata.subBox.genre.str);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                                       media_svc_debug("genre : %s", content_info->media_meta.genre);
+                                       if ((strcasecmp("Ringtone", metadata.subBox.genre.str) == 0) | (strcasecmp("Alert tone", metadata.subBox.genre.str) == 0)) {
+                                               content_info->media_type = MEDIA_SVC_MEDIA_TYPE_SOUND;
+                                       }
+                                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_GENRE;
+                               }
+
+                               if (drm_svc_get_user_data_box_info(content_info->path, DRM_UDTA_ALBUM, &metadata) == DRM_RESULT_SUCCESS) {
+                                       //_strncpy_safe(content_info->media_meta.album, metadata.subBox.album.albumTitle, sizeof(content_info->media_meta.album));
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, metadata.subBox.album.albumTitle);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_ALBUM;
+
+                                       char track_num[MEDIA_SVC_METADATA_LEN_MAX] = {0,};
+                                       snprintf(track_num, sizeof(track_num), "%d", metadata.subBox.album.trackNum);
+
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.track_num, track_num);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                                       //snprintf(content_info->media_meta.track_num, MEDIA_SVC_METADATA_LEN_MAX, "%d", metadata.subBox.album.trackNum);
+                               }
+
+                               if (drm_svc_get_user_data_box_info(content_info->path, DRM_UDTA_RECODINGYEAR, &metadata) == DRM_RESULT_SUCCESS) {
+                                       //_strncpy_safe(content_info->media_meta.year, __year_2_str(metadata.subBox.recodingYear.recodingYear), sizeof(content_info->media_meta.year));
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, __year_2_str(metadata.subBox.recodingYear.recodingYear));
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_YEAR;
+                               }
+
+                               if (drm_svc_get_index_of_relative_contents(content_info->path, DRM_CONTENTS_INDEX_ALBUMJACKET, &type_index) == DRM_RESULT_SUCCESS) {
+                                       char thumb_path[MEDIA_SVC_PATHNAME_SIZE+1] = {0};
+
+                                       if (drm_svc_make_multipart_drm_full_path(content_info->path, type_index, MEDIA_SVC_PATHNAME_SIZE, thumb_path) == DRM_TRUE) {
+
+                                               DRM_FILE_HANDLE hFile = DRM_HANDLE_NULL;
+
+                                               media_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.
+                                                       media_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, content_info);
+                                                               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 {
+                               media_svc_debug("unsupported drm format");
+                               drm_svc_free_dcf_header_info(&header_info);
+                               title = _media_svc_get_title_from_filepath(content_info->path);
+                               if (title) {
+                                       //_strncpy_safe(content_info->media_meta.title, title, sizeof(content_info->media_meta.title));
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
+                                       SAFE_FREE(title);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                               } else {
+                                       media_svc_error("Can't extract title from filepath");
+                                       return MEDIA_INFO_ERROR_INTERNAL;
+                               }
+
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+/*
+                               _strncpy_safe(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.album));
+                               _strncpy_safe(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.artist));
+                               _strncpy_safe(content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.genre));
+                               _strncpy_safe(content_info->media_meta.composer, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.composer));
+                               _strncpy_safe(content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.year));
+*/
+                               return MEDIA_INFO_ERROR_NONE;
+                       }
+
+                       if (invalid_file == TRUE) {
+                               if (!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) {
+                                       title = _media_svc_get_title_from_filepath(content_info->path);
+                                       if (title) {
+                                               //_strncpy_safe(content_info->media_meta.title, title, sizeof(content_info->media_meta.title));
+                                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
+                                               SAFE_FREE(title);
+                                               media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                                               extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE;
+                                       } else {
+                                               media_svc_error("Can't extract title from filepath");
+                                               drm_svc_free_dcf_header_info(&header_info);
+                                               return MEDIA_INFO_ERROR_INTERNAL;
+                                       }
+
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, MEDIA_SVC_TAG_UNKNOWN);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+/*
+                                       _strncpy_safe(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.album));
+                                       _strncpy_safe(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.artist));
+                                       _strncpy_safe(content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.genre));
+                                       _strncpy_safe(content_info->media_meta.composer, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.composer));
+                                       _strncpy_safe(content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.year));
+*/
+                               }
+
+                               drm_svc_free_dcf_header_info(&header_info);
+                               return MEDIA_INFO_ERROR_NONE;
+                       }
+               } else if (type == DRM_FILE_TYPE_PLAYREADY) {
+                       media_svc_debug("drm type is PLAYREADY");
+                       if (drm_svc_has_valid_ro(content_info->path, DRM_PERMISSION_PLAY) != DRM_RESULT_SUCCESS) {
+                               media_svc_debug("no valid ro. can't extract meta data");
+                               title = _media_svc_get_title_from_filepath(content_info->path);
+                               if (title) {
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
+                                       SAFE_FREE(title);
+                                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                                       //_strncpy_safe(content_info->media_meta.title, title, sizeof(content_info->media_meta.title));
+                               } else {
+                                       media_svc_error("Can't extract title from filepath");
+                                       return MEDIA_INFO_ERROR_INTERNAL;
+                               }
+
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+/*
+                               _strncpy_safe(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.album));
+                               _strncpy_safe(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.artist));
+                               _strncpy_safe(content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.genre));
+                               _strncpy_safe(content_info->media_meta.composer, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.composer));
+                               _strncpy_safe(content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.year));
+*/
+
+                               return MEDIA_INFO_ERROR_NONE;
+                       }
+               } else {
+                       media_svc_error("Not supported DRM type");
+                       title = _media_svc_get_title_from_filepath(content_info->path);
+                       if (title) {
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
+                               SAFE_FREE(title);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                               //_strncpy_safe(content_info->media_meta.title, title, sizeof(content_info->media_meta.title));
+                       } else {
+                               media_svc_error("Can't extract title from filepath");
+                               return MEDIA_INFO_ERROR_INTERNAL;
+                       }
+
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, MEDIA_SVC_TAG_UNKNOWN);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+/*
+                       _strncpy_safe(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.album));
+                       _strncpy_safe(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.artist));
+                       _strncpy_safe(content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.genre));
+                       _strncpy_safe(content_info->media_meta.author, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.author));
+                       _strncpy_safe(content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.year));
+*/
+                       return MEDIA_INFO_ERROR_NONE;
+               }
+       }
+#endif
+       /*Get Content attribute ===========*/
+       mmf_error = mm_file_create_content_attrs(&content, content_info->path);
+       if (mmf_error == MM_ERROR_NONE) {
+               /*Common attribute*/
+               mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_DURATION, &content_info->media_meta.duration, NULL);
+               if (mmf_error != 0) {
+                       SAFE_FREE(err_attr_name);
+                       media_svc_debug("fail to get duration attr - err(%x)", mmf_error);
+               } else {
+                       media_svc_debug("duration : %d", content_info->media_meta.duration);
+               }
+
+               /*Sound/Music attribute*/
+               if((media_type == MEDIA_SVC_MEDIA_TYPE_SOUND) || (media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC)) {
+
+                       mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_BITRATE, &content_info->media_meta.bitrate, NULL);
+                       if (mmf_error != 0) {
+                               SAFE_FREE(err_attr_name);
+                               media_svc_debug("fail to get audio bitrate attr - err(%x)", mmf_error);
+                       } else {
+                               media_svc_debug("bit rate : %d", content_info->media_meta.bitrate);
+                       }
+
+                       mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_SAMPLERATE, &content_info->media_meta.samplerate, NULL);
+                       if (mmf_error != 0) {
+                               SAFE_FREE(err_attr_name);
+                               media_svc_debug("fail to get sample rate attr - err(%x)", mmf_error);
+                       } else {
+                               media_svc_debug("sample rate : %d", content_info->media_meta.samplerate);
+                       }
+
+                       mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_CHANNELS, &content_info->media_meta.channel, NULL);
+                       if (mmf_error != 0) {
+                               SAFE_FREE(err_attr_name);
+                               media_svc_debug("fail to get audio channels attr - err(%x)", mmf_error);
+                       } else {
+                               media_svc_debug("channel : %d", content_info->media_meta.channel);
+                       }
+               }else if(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)      {       /*Video attribute*/
+
+                       mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_VIDEO_WIDTH, &content_info->media_meta.width, NULL);
+                       if (mmf_error != 0) {
+                               SAFE_FREE(err_attr_name);
+                               media_svc_debug("fail to get video width attr - err(%x)", mmf_error);
+                       } else {
+                               media_svc_debug("width : %d", content_info->media_meta.width);
+                       }
+
+                       mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_VIDEO_HEIGHT, &content_info->media_meta.height, NULL);
+                       if (mmf_error != 0) {
+                               SAFE_FREE(err_attr_name);
+                               media_svc_debug("fail to get video height attr - err(%x)", mmf_error);
+                       } else {
+                               media_svc_debug("height : %d", content_info->media_meta.height);
+                       }
+
+               } else {
+                       media_svc_error("Not support type");
+                       return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+               }
+
+               mmf_error = mm_file_destroy_content_attrs(content);
+               if (mmf_error != 0) {
+                       media_svc_debug("fail to free content attr - err(%x)", mmf_error);
+               }
+       } else {
+               media_svc_error("error in mm_file_create_content_attrs [%d]", mmf_error);
+       }
+
+       /*Get Content Tag attribute ===========*/
+       mmf_error = mm_file_create_tag_attrs(&tag, content_info->path);
+
+       if (mmf_error == MM_ERROR_NONE) {
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM, &p, &size, NULL);
+               if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ALBUM)) && mmf_error == 0 && size > 0) {
+                       //_strncpy_safe(content_info->media_meta.album, p, sizeof(content_info->media_meta.album));
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, p);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                       media_svc_debug("album[%d] : %s", size, content_info->media_meta.album);
+               } else {
+                       SAFE_FREE(err_attr_name);
+                       media_svc_debug("album - unknown");
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                       //_strncpy_safe(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.album));
+               }
+
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTIST, &p, &size, NULL);
+               if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ARTIST)) && mmf_error == 0 && size > 0) {
+                       //_strncpy_safe(content_info->media_meta.artist, p, sizeof(content_info->media_meta.artist));
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, p);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                       media_svc_debug("artist[%d] : %s", size, content_info->media_meta.artist);
+               } else {
+                       SAFE_FREE(err_attr_name);
+                       media_svc_debug("artist - unknown");
+                       //_strncpy_safe(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.artist));
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+               }
+
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_GENRE, &p, &size, NULL);
+               if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_GENRE)) && mmf_error == 0 && size > 0) {
+                       //_strncpy_safe(content_info->media_meta.genre, p, sizeof(content_info->media_meta.genre));
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, p);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                       media_svc_debug("genre : %s", content_info->media_meta.genre);
+                       if ((strcasecmp("Ringtone", p) == 0) | (strcasecmp("Alert tone", p) == 0)) {
+                               content_info->media_type = MEDIA_SVC_MEDIA_TYPE_SOUND;
+                       }
+               } else {
+                       SAFE_FREE(err_attr_name);
+                       media_svc_debug("genre - unknown");
+                       //_strncpy_safe(content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.genre));
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+               }
+
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TITLE, &p, &size, NULL);
+               if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) && mmf_error == 0 && size > 0 &&     (!isspace(*p))) {
+                       //_strncpy_safe(content_info->media_meta.title, p, sizeof(content_info->media_meta.title));
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE;
+                       media_svc_debug("extract title from content : %s", content_info->media_meta.title);
+                       media_svc_debug("^^^^^^^^^^^^^^^ path = %s, title = %s, size = %d ^^^^^^^^^^^^^^", content_info->path, content_info->media_meta.title, size);
+               } else {
+                       SAFE_FREE(err_attr_name);
+                       title = _media_svc_get_title_from_filepath(content_info->path);
+                       if (title) {
+                               //_strncpy_safe(content_info->media_meta.title, title, sizeof(content_info->media_meta.title));
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
+                               SAFE_FREE(title);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                       } else {
+                               media_svc_error("Can't extract title from filepath");
+                               return MEDIA_INFO_ERROR_INTERNAL;
+                       }
+               }
+
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DESCRIPTION, &p, &size, NULL);
+               if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_DESC)) && mmf_error == 0 && size > 0) {
+                       //_strncpy_safe(content_info->media_meta.description, p, sizeof(content_info->media_meta.description));
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, p);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                       media_svc_debug("desc : %s", content_info->media_meta.description);
+               } else {
+                       SAFE_FREE(err_attr_name);
+                       //content_info->media_meta.description = strdup("");
+               }
+
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_AUTHOR, &p, &size, NULL);
+               if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_AUTHOR)) && mmf_error == 0 && size > 0) {
+                       //_strncpy_safe(content_info->media_meta.composer, p, sizeof(content_info->media_meta.composer));
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, p);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
+                       media_svc_debug("extract composer from content : %s", content_info->media_meta.composer);
+               } else {
+                       media_svc_debug("composer - unknown");
+                       SAFE_FREE(err_attr_name);
+                       //_strncpy_safe(content_info->media_meta.composer, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.composer));
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, MEDIA_SVC_TAG_UNKNOWN);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+               }
+
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TRACK_NUM, &p, &size, NULL);
+               if (mmf_error == 0 && size > 0) {
+                       //_strncpy_safe(content_info->media_meta.track_num, p, sizeof(content_info->media_meta.track_num));
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.track_num, p);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+               } else {
+                       SAFE_FREE(err_attr_name);
+                       //_strncpy_safe(content_info->media_meta.track_num, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.track_num));
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.track_num, MEDIA_SVC_TAG_UNKNOWN);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+               }
+               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DATE, &p, &size, NULL);
+               if (!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_YEAR)) {
+                       if (mmf_error == 0 && size > 0) {
+                               //_strncpy_safe(content_info->media_meta.year, p, sizeof(content_info->media_meta.year));
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, p);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                       } else {
+                               SAFE_FREE(err_attr_name);
+                               //_strncpy_safe(content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.year));
+                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                       }
+               } 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) {
+                       content_info->media_meta.rating = atoi(p);
+               } else {
+                       SAFE_FREE(err_attr_name);
+                       content_info->media_meta.rating = 0;
+               }
+
+               /*Initialize album_id to 0. below code will set the album_id*/
+               content_info->album_id = album_id;
+
+               /* extract thumbnail image */
+               if(strncmp(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN))) {
+                       if(strncmp(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN))) {
+
+                               ret = _media_svc_get_album_id(handle, content_info->media_meta.album, content_info->media_meta.artist, &album_id);
+
+                               if (ret != MEDIA_INFO_ERROR_NONE) {
+                                       if (ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+                                               media_svc_debug("album does not exist. So start to make album art");
+                                               extract_thumbnail = TRUE;
+                                               append_album = TRUE;
+                                       } else
+                                               return ret;
+                               } else {
+                                       media_svc_debug("album already exists. don't need to make album art");
+                                       content_info->album_id = album_id;
+                                       ret = _media_svc_get_album_art_by_album_id(handle, album_id, &content_info->thumbnail_path);
+                                       media_svc_debug("content_info->thumbnail_path[%s]", content_info->thumbnail_path);
+                                       media_svc_retv_del_if((ret != MEDIA_INFO_ERROR_NONE) && (ret != MEDIA_INFO_ERROR_DATABASE_NO_RECORD), ret, content_info);
+                                       extract_thumbnail = FALSE;
+                                       append_album = FALSE;
+                               }
+                       } else {
+                               ret = _media_svc_get_album_id(handle, content_info->media_meta.album, content_info->media_meta.artist, &album_id);
+
+                               if (ret != MEDIA_INFO_ERROR_NONE) {
+
+                                       if (ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+                                               media_svc_debug("Unknown artist album does not exist.");
+                                               extract_thumbnail = TRUE;
+                                               append_album = TRUE;
+                                       }
+                                       else
+                                               return ret;
+                               } else {
+                                       media_svc_debug("Unknown artist album already exists.");
+
+                                       content_info->album_id = album_id;
+                                       extract_thumbnail = TRUE;
+                                       append_album = FALSE;
+                               }
+                       }
+               } else {
+                       extract_thumbnail = TRUE;
+                       append_album = FALSE;
+               }
+
+               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) {
+                               media_svc_debug("fail to get tag artwork - err(%x)", mmf_error);
+                               SAFE_FREE(err_attr_name);
+                       } else {
+                               media_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) {
+                               media_svc_debug("fail to get artwork size - err(%x)", mmf_error);
+                               SAFE_FREE(err_attr_name);
+                       } else {
+                               media_svc_debug("artwork size2 [%d]", size);
+                       }
+                       if (image != NULL && size > 0) {
+                               bool ret = FALSE;
+                               int result = MEDIA_INFO_ERROR_NONE;
+                               char thumb_path[MEDIA_SVC_PATHNAME_SIZE] = "\0";
+                               int artwork_mime_size = -1;
+
+                               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 = _media_svc_get_thumbnail_path(content_info->storage_type, thumb_path, content_info->path, p);
+                                       if (ret == FALSE) {
+                                               media_svc_error("fail to get thumb path..");
+                                               mmf_error = mm_file_destroy_tag_attrs(tag);
+                                               if (mmf_error != 0) {
+                                                       media_svc_error("fail to free tag attr - err(%x)", mmf_error);
+                                               }
+                                               return MEDIA_INFO_ERROR_INTERNAL;
+                                       }
+                               } else {
+                                       SAFE_FREE(err_attr_name);
+                               }
+
+                               if (!strlen(thumb_path)) {
+                                       media_svc_error("fail to get thumb path..");
+                                       mmf_error = mm_file_destroy_tag_attrs(tag);
+                                       if (mmf_error != 0) {
+                                               media_svc_error("fail to free tag attr - err(%x)", mmf_error);
+                                       }
+                                       return MEDIA_INFO_ERROR_INTERNAL;
+                               }
+
+                               result = _media_svc_save_image(image, size, thumb_path);
+                               if (result != MEDIA_INFO_ERROR_NONE) {
+                                       mmf_error = mm_file_destroy_tag_attrs(tag);
+                                       if (mmf_error != 0) {
+                                               media_svc_error("fail to free tag attr - err(%x)", mmf_error);
+                                       }
+                                       return result;
+                               }
+
+                               //_strncpy_safe(content_info->thumbnail_path, thumb_path, sizeof(content_info->thumbnail_path));
+                               ret = __media_svc_malloc_and_strncpy(&content_info->thumbnail_path, thumb_path);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+                       }
+               }
+
+               if(append_album == TRUE) {
+
+                       if(strncmp(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN)))
+                               ret = _media_svc_append_album(handle, content_info->media_meta.album, content_info->media_meta.artist, content_info->thumbnail_path, &album_id);
+                       else
+                               ret = _media_svc_append_album(handle, content_info->media_meta.album, content_info->media_meta.artist, NULL, &album_id);
+
+                       content_info->album_id = album_id;
+               }
+
+               if(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
+                       mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_LONGITUDE, &gps_value, NULL);
+                       if (mmf_error == 0) {
+                               if (gps_value == 0.0)
+                                       content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
+                               else
+                                       content_info->media_meta.longitude = gps_value;
+                       } else {
+                               SAFE_FREE(err_attr_name);
+                               content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
+                       }
+
+                       mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_LATIDUE, &gps_value, NULL);
+                       if (mmf_error == 0) {
+                               if (gps_value == 0.0)
+                                       content_info->media_meta.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
+                               else
+                                       content_info->media_meta.latitude = gps_value;
+                       } else {
+                               SAFE_FREE(err_attr_name);
+                               content_info->media_meta.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
+                       }
+
+                       mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALTIDUE, &gps_value, NULL);
+                       if (mmf_error == 0) {
+                               if (gps_value == 0.0)
+                                       content_info->media_meta.altitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
+                               else
+                                       content_info->media_meta.altitude = gps_value;
+                       } else {
+                               SAFE_FREE(err_attr_name);
+                               content_info->media_meta.altitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
+                       }
+
+                       if ((!thumb_extracted_from_drm) && (extract_thumbnail == TRUE))
+                       {
+                               /* Extracting thumbnail */
+                               char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
+                               int width = 0;
+                               int height = 0;
+
+                               ret = thumbnail_request_from_db_with_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height);
+                               if (ret < 0) {
+                                       media_svc_error("thumbnail_request_from_db failed: %d", ret);
+                               } else {
+                                       media_svc_debug("thumbnail_request_from_db success: %s", thumb_path);
+                               }
+
+                               ret = __media_svc_malloc_and_strncpy(&content_info->thumbnail_path, thumb_path);
+                               media_svc_retv_del_if(ret < 0, ret, content_info);
+
+                               if (content_info->media_meta.width <= 0) content_info->media_meta.width = width;
+                               if (content_info->media_meta.height <= 0) content_info->media_meta.height = height;
+                       }
+               }
+
+               mmf_error = mm_file_destroy_tag_attrs(tag);
+               if (mmf_error != 0) {
+                       media_svc_error("fail to free tag attr - err(%x)", mmf_error);
+               }
+       }       else {
+               char *title = NULL;
+               media_svc_error("no tag information");
+
+               title = _media_svc_get_title_from_filepath(content_info->path);
+               if (title) {
+                       //_strncpy_safe(content_info->media_meta.title, title, sizeof(content_info->media_meta.title));
+                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
+                       SAFE_FREE(title);
+                       media_svc_retv_del_if(ret < 0, ret, content_info);
+               } else {
+                       media_svc_error("Can't extract title from filepath");
+                       return MEDIA_INFO_ERROR_INTERNAL;
+               }
+
+               /* in case of file size 0, MMFW Can't parsting tag info but add it to Music DB. */
+               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN);
+               media_svc_retv_del_if(ret < 0, ret, content_info);
+               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN);
+               media_svc_retv_del_if(ret < 0, ret, content_info);
+               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN);
+               media_svc_retv_del_if(ret < 0, ret, content_info);
+               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, MEDIA_SVC_TAG_UNKNOWN);
+               media_svc_retv_del_if(ret < 0, ret, content_info);
+               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN);
+               media_svc_retv_del_if(ret < 0, ret, content_info);
+/*
+               _strncpy_safe(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.album));
+               _strncpy_safe(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.artist));
+               _strncpy_safe(content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.genre));
+               _strncpy_safe(content_info->media_meta.composer, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.composer));
+               _strncpy_safe(content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN, sizeof(content_info->media_meta.year));
+*/
+               content_info->album_id = album_id;
+               content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
+               content_info->media_meta.latitude= MEDIA_SVC_DEFAULT_GPS_VALUE;
+               content_info->media_meta.altitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+void _media_svc_destroy_content_info(media_svc_content_info_s *content_info)
+{
+       media_svc_retm_if(content_info == NULL, "content info is NULL");
+
+       /* Delete media_svc_content_info_s */
+       if (content_info->media_uuid) {
+               SAFE_FREE(content_info->media_uuid);
+       }
+       if (content_info->path) {
+               SAFE_FREE(content_info->path);
+       }
+       if (content_info->file_name) {
+               SAFE_FREE(content_info->file_name);
+       }
+       if (content_info->mime_type) {
+               SAFE_FREE(content_info->mime_type);
+       }
+       if (content_info->folder_uuid) {
+               SAFE_FREE(content_info->folder_uuid);
+       }
+       if (content_info->thumbnail_path) {
+               SAFE_FREE(content_info->thumbnail_path);
+       }
+
+       /* Delete media_svc_content_meta_s */
+       if (content_info->media_meta.title) {
+               SAFE_FREE(content_info->media_meta.title);
+       }
+       if (content_info->media_meta.album) {
+               SAFE_FREE(content_info->media_meta.album);
+       }
+       if (content_info->media_meta.artist) {
+               SAFE_FREE(content_info->media_meta.artist);
+       }
+       if (content_info->media_meta.genre) {
+               SAFE_FREE(content_info->media_meta.genre);
+       }
+       if (content_info->media_meta.composer) {
+               SAFE_FREE(content_info->media_meta.composer);
+       }
+       if (content_info->media_meta.year) {
+               SAFE_FREE(content_info->media_meta.year);
+       }
+       if (content_info->media_meta.recorded_date) {
+               SAFE_FREE(content_info->media_meta.recorded_date);
+       }
+       if (content_info->media_meta.copyright) {
+               SAFE_FREE(content_info->media_meta.copyright);
+       }
+       if (content_info->media_meta.track_num) {
+               SAFE_FREE(content_info->media_meta.track_num);
+       }
+       if (content_info->media_meta.description) {
+               SAFE_FREE(content_info->media_meta.description);
+       }
+       if (content_info->media_meta.datetaken) {
+               SAFE_FREE(content_info->media_meta.datetaken);
+       }
+
+       return;
+}
+
+int _media_svc_get_store_type_by_path(const char *path, media_svc_storage_type_e *storage_type)
+{
+       if(path != NULL && strlen(path) > 0)
+       {
+               if(strncmp(path, MEDIA_SVC_PATH_PHONE, strlen(MEDIA_SVC_PATH_PHONE)) == 0)
+               {
+                       *storage_type = MEDIA_SVC_STORAGE_INTERNAL;
+               }
+               else if(strncmp (path, MEDIA_SVC_PATH_MMC, strlen(MEDIA_SVC_PATH_MMC)) == 0)
+               {
+                       *storage_type = MEDIA_SVC_STORAGE_EXTERNAL;
+               }
+       }
+       else
+       {
+               media_svc_error("INVALID parameter");
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+char *_media_svc_replace_path(char *s, const char *olds, const char *news)
+{
+  char *result, *sr;
+  size_t i, count = 0;
+  size_t oldlen = strlen(olds); if (oldlen < 1) return s;
+  size_t newlen = strlen(news);
+
+  if (newlen != oldlen) {
+    for (i = 0; s[i] != '\0';) {
+      if (memcmp(&s[i], olds, oldlen) == 0) count++, i += oldlen;
+      else i++;
+    }   
+  } else i = strlen(s);
+
+
+  result = (char *) calloc(1, i + 1 + count * (newlen - oldlen));
+  if (result == NULL) return NULL;
+
+  sr = result;
+  while (*s) {
+    if (memcmp(s, olds, oldlen) == 0) {
+      memcpy(sr, news, newlen);
+      sr += newlen;
+      s  += oldlen;
+    } else *sr++ = *s++;
+  }
+
+  *sr = '\0';
+
+  return result;
+}
+
index db75ebd..7597df4 100755 (executable)
  *
  */
 
-#include <unistd.h>
-#include <sqlite3.h>
-#include <db-util.h>
+#include <string.h>
 #include "media-svc.h"
-#include "media-svc-error.h"
+#include "media-svc-media.h"
 #include "media-svc-debug.h"
-#include "media-svc-env.h"
+#include "media-svc-util.h"
+#include "media-svc-db-utils.h"
+#include "media-svc-media-folder.h"
+#include "media-svc-album.h"
 
 
-static int __media_svc_busy_handler(void *pData, int count);
-static int __media_svc_connect_db_with_handle(sqlite3 **db_handle);
-static int __media_svc_disconnect_db_with_handle(sqlite3 *db_handle);
+static __thread int g_media_svc_item_validity_data_cnt = 1;
+static __thread int g_media_svc_item_validity_cur_data_cnt = 0;
 
-static int __media_svc_busy_handler(void *pData, int count)
+static __thread int g_media_svc_move_item_data_cnt = 1;
+static __thread int g_media_svc_move_item_cur_data_cnt = 0;
+
+static __thread int g_media_svc_insert_item_data_cnt = 1;
+static __thread int g_media_svc_insert_item_cur_data_cnt = 0;
+
+int media_svc_connect(MediaSvcHandle **handle)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3 * db_handle = NULL;
+
+       media_svc_debug_func();
+
+       ret = _media_svc_connect_db_with_handle(&db_handle);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       *handle = db_handle;
+       return MEDIA_INFO_ERROR_NONE;
+
+}
+
+int media_svc_disconnect(MediaSvcHandle *handle)
+{
+       sqlite3 * db_handle = (sqlite3 *)handle;
+
+       media_svc_debug_func();
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+
+       return _media_svc_disconnect_db_with_handle(db_handle);
+}
+
+int media_svc_create_table(MediaSvcHandle *handle)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+
+       media_svc_debug_func();
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+
+       /*create media table*/
+       ret = _media_svc_create_media_table(handle);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       /*create folder table*/
+       ret = _media_svc_create_folder_table(handle);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       /*create playlist table*/
+       ret = _media_svc_create_playlist_table(handle);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       /* create album table*/
+       ret = _media_svc_create_album_table(handle);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       /*create tag table*/
+       ret = _media_svc_create_tag_table(handle);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       /*create bookmark table*/
+       ret = _media_svc_create_bookmark_table(handle);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+#if 0  /*unify media and custom table*/
+       /*create custom table*/
+       ret = _media_svc_create_custom_table(handle);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+#endif
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int media_svc_check_item_exist_by_path(MediaSvcHandle *handle, const char *path)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+       int count = -1;
+
+       media_svc_debug_func();
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+       media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "Path is NULL");
+
+       ret = _media_svc_count_record_with_path(db_handle, path, &count);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       if(count > 0) {
+               media_svc_debug("item is exist in database");
+               return MEDIA_INFO_ERROR_NONE;
+       } else {
+               media_svc_debug("item is not exist in database");
+               return MEDIA_INFO_ERROR_DATABASE_NO_RECORD;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int media_svc_insert_item_begin(MediaSvcHandle *handle, int data_cnt)
+{
+       sqlite3 * db_handle = (sqlite3 *)handle;
+
+       media_svc_debug("Transaction data count : [%d]", data_cnt);
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+       media_svc_retvm_if(data_cnt < 1, MEDIA_INFO_ERROR_INVALID_PARAMETER, "data_cnt shuld be bigger than 1");
+
+       g_media_svc_insert_item_data_cnt  = data_cnt;
+       g_media_svc_insert_item_cur_data_cnt  = 0;
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int media_svc_insert_item_end(MediaSvcHandle *handle)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+
+       media_svc_debug_func();
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+
+       if (g_media_svc_insert_item_cur_data_cnt  > 0) {
+
+               ret = _media_svc_list_query_do(db_handle, MEDIA_SVC_QUERY_INSERT_ITEM);
+       }
+
+       g_media_svc_insert_item_data_cnt  = 1;
+       g_media_svc_insert_item_cur_data_cnt  = 0;
+
+       return ret;
+}
+
+int media_svc_insert_item_bulk(MediaSvcHandle *handle, media_svc_storage_type_e storage_type,
+                         const char *path, const char *mime_type, media_svc_media_type_e media_type)
 {
-       usleep(50000);
-       mediainfo_dbg("mb_svc_busy_handler called : %d\n", count);
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+       char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,};
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+       media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "path is NULL");
+       media_svc_retvm_if(!STRING_VALID(mime_type), MEDIA_INFO_ERROR_INVALID_PARAMETER, "mime_type is NULL");
+
+       if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)) {
+               media_svc_error("storage type is incorrect[%d]", storage_type);
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+
+       if ((media_type < MEDIA_SVC_MEDIA_TYPE_IMAGE) || (media_type > MEDIA_SVC_MEDIA_TYPE_OTHER)) {
+               media_svc_error("invalid media_type condition[%d]", media_type);
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+
+       media_svc_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, media_type);
+
+       media_svc_content_info_s content_info;
+       memset(&content_info, 0, sizeof(media_svc_content_info_s));
+
+       /*Set media info*/
+       ret = _media_svc_set_media_info(&content_info, storage_type, path, mime_type, media_type, FALSE);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       if(media_type == MEDIA_SVC_MEDIA_TYPE_OTHER) {
+               /*Do nothing.*/
+       } else if(media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) {
+               ret = _media_svc_extract_image_metadata(&content_info, media_type);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+       } else {
+               ret = _media_svc_extract_media_metadata(handle, &content_info, media_type);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+       }
+
+       /*Set or Get folder id*/
+       ret = _media_svc_get_and_append_folder_id_by_path(handle, path, storage_type, folder_uuid);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
 
-       return 100 - count;
+       ret = __media_svc_malloc_and_strncpy(&content_info.folder_uuid, folder_uuid);
+       media_svc_retv_del_if(ret < 0, ret, &content_info);
+
+       if (g_media_svc_insert_item_data_cnt == 1) {
+
+               ret = _media_svc_insert_item_with_data(db_handle, &content_info, FALSE);
+               media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, &content_info);
+
+       } else if(g_media_svc_insert_item_cur_data_cnt  < (g_media_svc_insert_item_data_cnt  - 1)) {
+
+               ret = _media_svc_insert_item_with_data(db_handle, &content_info, TRUE);
+               media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, &content_info);
+
+               g_media_svc_insert_item_cur_data_cnt ++;
+
+       } else if (g_media_svc_insert_item_cur_data_cnt  == (g_media_svc_insert_item_data_cnt  - 1)) {
+
+               ret = _media_svc_insert_item_with_data(db_handle, &content_info, TRUE);
+               media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, &content_info);
+
+               ret = _media_svc_list_query_do(db_handle, MEDIA_SVC_QUERY_INSERT_ITEM);
+               media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, &content_info);
+
+               g_media_svc_insert_item_cur_data_cnt = 0;
+
+       } else {
+               media_svc_debug("Error in media_svc_insert_item_bulk");
+               _media_svc_destroy_content_info(&content_info);
+               return MEDIA_INFO_ERROR_INTERNAL;
+       }
+
+       _media_svc_destroy_content_info(&content_info);
+
+       return MEDIA_INFO_ERROR_NONE;
 }
 
-static int __media_svc_connect_db_with_handle(sqlite3 **db_handle)
+int media_svc_insert_item_immediately(MediaSvcHandle *handle, media_svc_storage_type_e storage_type,
+                         const char *path, const char *mime_type, media_svc_media_type_e media_type)
 {
-       mediainfo_dbg("");
-       int err = -1;
-       err = db_util_open(MEDIA_INFO_DATABASE_NAME, db_handle,
-                        DB_UTIL_REGISTER_HOOK_METHOD);
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+       char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,};
+
+       media_svc_debug_func();
 
-       if (SQLITE_OK != err) {
-               *db_handle = NULL;
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+       media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "path is NULL");
+       media_svc_retvm_if(!STRING_VALID(mime_type), MEDIA_INFO_ERROR_INVALID_PARAMETER, "mime_type is NULL");
 
-               return MEDIA_INFO_ERROR_DATABASE_CONNECT;
+       if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)) {
+               media_svc_error("storage type is incorrect[%d]", storage_type);
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
        }
 
-       /*Register busy handler*/
-       err = sqlite3_busy_handler(*db_handle, __media_svc_busy_handler, NULL);
-       if (SQLITE_OK != err) {
-               if (*db_handle) mediainfo_dbg("[sqlite] %s\n", sqlite3_errmsg(*db_handle));
+       if ((media_type < MEDIA_SVC_MEDIA_TYPE_IMAGE) || (media_type > MEDIA_SVC_MEDIA_TYPE_OTHER)) {
+               media_svc_error("invalid media_type condition[%d]", media_type);
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+
+       media_svc_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, media_type);
+
+       media_svc_content_info_s content_info;
+       memset(&content_info, 0, sizeof(media_svc_content_info_s));
 
-               db_util_close(*db_handle);
-               *db_handle = NULL;
+       /*Set media info*/
+       ret = _media_svc_set_media_info(&content_info, storage_type, path, mime_type, media_type, FALSE);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
 
-               return MEDIA_INFO_ERROR_DATABASE_CONNECT;
+       if(media_type == MEDIA_SVC_MEDIA_TYPE_OTHER) {
+               /*Do nothing.*/
+       } else if(media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) {
+               ret = _media_svc_extract_image_metadata(&content_info, media_type);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+       } else {
+               ret = _media_svc_extract_media_metadata(handle, &content_info, media_type);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
        }
 
+       /*Set or Get folder id*/
+       ret = _media_svc_get_and_append_folder_id_by_path(handle, path, storage_type, folder_uuid);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       ret = __media_svc_malloc_and_strncpy(&content_info.folder_uuid, folder_uuid);
+       media_svc_retv_del_if(ret < 0, ret, &content_info);
+
+       ret = _media_svc_insert_item_with_data(db_handle, &content_info, FALSE);
+       media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, &content_info);
+
+       _media_svc_destroy_content_info(&content_info);
        return MEDIA_INFO_ERROR_NONE;
 }
 
-static int __media_svc_disconnect_db_with_handle(sqlite3 *db_handle)
+int media_svc_insert_folder(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path)
 {
-       mediainfo_dbg("");
-       int err = -1;
-       err = db_util_close(db_handle);
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+
+       media_svc_debug_func();
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+       media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "path is NULL");
+
+       if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)) {
+               media_svc_error("storage type is incorrect[%d]", storage_type);
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+
+       media_svc_debug("storage[%d], path[%s]", storage_type, path);
 
-       if (SQLITE_OK != err) {
-               db_handle = NULL;
+       /*Get folder info*/
+       char *folder_name = NULL;
+       int folder_modified_date = 0;
+       char *folder_uuid = _media_info_generate_uuid();
+       if(folder_uuid == NULL ) {
+               media_svc_error("Invalid UUID");
+               return MEDIA_INFO_ERROR_INTERNAL;
+       }
+
+       folder_name = g_path_get_basename(path);
+       folder_modified_date = _media_svc_get_file_time(path);
+
+       ret = _media_svc_append_folder(handle, storage_type, folder_uuid, path, folder_name, folder_modified_date);
+       SAFE_FREE(folder_name);
 
-               return MEDIA_INFO_ERROR_DATABASE_DISCONNECT;
+       if (ret < MEDIA_INFO_ERROR_NONE) {
+               media_svc_error("_media_svc_append_folder error [%d]", ret);
+               return ret;
        }
 
        return MEDIA_INFO_ERROR_NONE;
 }
 
-int media_svc_connect(MediaSvcHandle **handle)
+int media_svc_move_item_begin(MediaSvcHandle *handle, int data_cnt)
 {
-       int ret = -1;
-       sqlite3 * db_handle = NULL;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+
+       media_svc_debug("Transaction data count : [%d]", data_cnt);
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+       media_svc_retvm_if(data_cnt < 1, MEDIA_INFO_ERROR_INVALID_PARAMETER, "data_cnt shuld be bigger than 1");
+
+       g_media_svc_move_item_data_cnt  = data_cnt;
+       g_media_svc_move_item_cur_data_cnt  = 0;
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int media_svc_move_item_end(MediaSvcHandle *handle)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+
+       media_svc_debug_func();
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+
+       if (g_media_svc_move_item_cur_data_cnt  > 0) {
+
+               ret = _media_svc_list_query_do(db_handle, MEDIA_SVC_QUERY_MOVE_ITEM);
+       }
+
+       /*clean up old folder path*/
+       ret = _media_svc_update_folder_table(handle);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       g_media_svc_move_item_data_cnt  = 1;
+       g_media_svc_move_item_cur_data_cnt  = 0;
+
+       return ret;
+}
+
+int media_svc_move_item(MediaSvcHandle *handle, media_svc_storage_type_e src_storage, const char *src_path,
+                       media_svc_storage_type_e dest_storage, const char *dest_path)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+       char *file_name = NULL;
+       char *folder_path = NULL;
+       int modified_time = 0;
+       char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,};
+       char old_thumb_path[MEDIA_SVC_PATHNAME_SIZE] = {0,};
+       char new_thumb_path[MEDIA_SVC_PATHNAME_SIZE] = {0,};
+       int media_type = -1;
+
+       media_svc_debug_func();
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+       media_svc_retvm_if(!STRING_VALID(src_path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "src_path is NULL");
+       media_svc_retvm_if(!STRING_VALID(dest_path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "dest_path is NULL");
+
+       if ((src_storage != MEDIA_SVC_STORAGE_INTERNAL) && (src_storage != MEDIA_SVC_STORAGE_EXTERNAL)) {
+               media_svc_error("src_storage type is incorrect[%d]", src_storage);
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+       if ((dest_storage != MEDIA_SVC_STORAGE_INTERNAL) && (dest_storage != MEDIA_SVC_STORAGE_EXTERNAL)) {
+               media_svc_error("dest_storage type is incorrect[%d]", dest_storage);
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+
+       /*check and update folder*/
+       ret = _media_svc_get_and_append_folder_id_by_path(handle, dest_path, dest_storage, folder_uuid);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       /*get filename*/
+       file_name = g_path_get_basename(dest_path);
+
+       /*get modified_time*/
+       modified_time = _media_svc_get_file_time(dest_path);
+
+       /*get thumbnail_path to update. only for Imgae and Video items. Audio share album_art(thumbnail)*/
+       ret = _media_svc_get_media_type_by_path(handle, src_path, &media_type);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       if((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) ||(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) {
+               /*get old thumbnail_path*/
+               ret = _media_svc_get_thumbnail_path_by_path(handle, src_path, old_thumb_path);
+               media_svc_retv_if((ret != MEDIA_INFO_ERROR_NONE) && (ret != MEDIA_INFO_ERROR_DATABASE_NO_RECORD), ret);
+
+               _media_svc_get_thumbnail_path(dest_storage, new_thumb_path, dest_path, THUMB_EXT);
+       }
+
+       if (g_media_svc_move_item_data_cnt == 1) {
+
+               /*update item*/
+               if((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) ||(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) {
+                       ret = _media_svc_update_item_by_path(handle, src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, new_thumb_path, FALSE);
+               } else {
+                       ret = _media_svc_update_item_by_path(handle, src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, NULL, FALSE);
+               }
+               SAFE_FREE(file_name);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+               /*update folder modified_time*/
+               folder_path = g_path_get_dirname(dest_path);
+               ret = _media_svc_update_folder_modified_time_by_folder_uuid(handle, folder_uuid, folder_path, FALSE);
+               SAFE_FREE(folder_path);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+               ret = _media_svc_update_folder_table(handle);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       } else if (g_media_svc_move_item_cur_data_cnt  < (g_media_svc_move_item_data_cnt  - 1)) {
+
+               /*update item*/
+               if((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) ||(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) {
+                       ret = _media_svc_update_item_by_path(handle, src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, new_thumb_path, TRUE);
+               } else {
+                       ret = _media_svc_update_item_by_path(handle, src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, NULL, TRUE);
+               }
+               SAFE_FREE(file_name);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+               /*update folder modified_time*/
+               folder_path = g_path_get_dirname(dest_path);
+               ret = _media_svc_update_folder_modified_time_by_folder_uuid(handle, folder_uuid, folder_path, TRUE);
+               SAFE_FREE(folder_path);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+               g_media_svc_move_item_cur_data_cnt ++;
+
+       } else if (g_media_svc_move_item_cur_data_cnt  == (g_media_svc_move_item_data_cnt  - 1)) {
+
+               /*update item*/
+               if((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) ||(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) {
+                       ret = _media_svc_update_item_by_path(handle, src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, new_thumb_path, TRUE);
+               } else {
+                       ret = _media_svc_update_item_by_path(handle, src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, NULL, TRUE);
+               }
+               SAFE_FREE(file_name);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+               /*update folder modified_time*/
+               folder_path = g_path_get_dirname(dest_path);
+               ret = _media_svc_update_folder_modified_time_by_folder_uuid(handle, folder_uuid, folder_path, TRUE);
+               SAFE_FREE(folder_path);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
 
-       ret = __media_svc_connect_db_with_handle(&db_handle);
+               /*update db*/
+               ret = _media_svc_list_query_do(db_handle, MEDIA_SVC_QUERY_MOVE_ITEM);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+               g_media_svc_move_item_cur_data_cnt = 0;
 
-       if ( ret < 0) {
-               return -1;
        } else {
-               *handle = db_handle;
-               return 0;
+               media_svc_error("Error in media_svc_move_item");
+               return MEDIA_INFO_ERROR_INTERNAL;
+       }
+
+       /*rename thumbnail file*/
+       if((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) ||(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) {
+               if(strlen(old_thumb_path) > 0) {
+                       ret = _media_svc_rename_file(old_thumb_path,new_thumb_path);
+                       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+               }
        }
+
+       return MEDIA_INFO_ERROR_NONE;
 }
 
-int media_svc_disconnect(MediaSvcHandle *handle)
+int media_svc_set_item_validity_begin(MediaSvcHandle *handle, int data_cnt)
+{
+       sqlite3 * db_handle = (sqlite3 *)handle;
+
+       media_svc_debug("Transaction data count : [%d]", data_cnt);
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+       media_svc_retvm_if(data_cnt < 1, MEDIA_INFO_ERROR_INVALID_PARAMETER, "data_cnt shuld be bigger than 1");
+
+       g_media_svc_item_validity_data_cnt  = data_cnt;
+       g_media_svc_item_validity_cur_data_cnt  = 0;
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int media_svc_set_item_validity_end(MediaSvcHandle *handle)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+
+       media_svc_debug_func();
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+
+       if (g_media_svc_item_validity_cur_data_cnt  > 0) {
+
+               ret = _media_svc_list_query_do(db_handle, MEDIA_SVC_QUERY_SET_ITEM_VALIDITY);
+       }
+
+       g_media_svc_item_validity_data_cnt  = 1;
+       g_media_svc_item_validity_cur_data_cnt  = 0;
+
+       return ret;
+}
+
+int media_svc_set_item_validity(MediaSvcHandle *handle, const char *path, int validity)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+
+       media_svc_debug_func();
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+       media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "path is NULL");
+
+       media_svc_debug("path=[%s], validity=[%d]", path, validity);
+
+       if (g_media_svc_item_validity_data_cnt  == 1) {
+
+               return _media_svc_update_item_validity(db_handle, path, validity, FALSE);
+
+       } else if (g_media_svc_item_validity_cur_data_cnt  < (g_media_svc_item_validity_data_cnt  - 1)) {
+
+               ret = _media_svc_update_item_validity(db_handle, path, validity, TRUE);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+               g_media_svc_item_validity_cur_data_cnt ++;
+
+       } else if (g_media_svc_item_validity_cur_data_cnt  == (g_media_svc_item_validity_data_cnt  - 1)) {
+
+               ret = _media_svc_update_item_validity(db_handle, path, validity, TRUE);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+               ret = _media_svc_list_query_do(db_handle, MEDIA_SVC_QUERY_SET_ITEM_VALIDITY);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+               g_media_svc_item_validity_cur_data_cnt  = 0;
+
+       } else {
+
+               media_svc_error("Error in media_svc_set_item_validity");
+               return MEDIA_INFO_ERROR_INTERNAL;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *path)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+       char thumb_path[MEDIA_SVC_PATHNAME_SIZE] = {0,};
+
+       media_svc_debug_func();
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+       media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "path is NULL");
+
+       /*Get thumbnail path to delete*/
+       ret = _media_svc_get_thumbnail_path_by_path(db_handle, path, thumb_path);
+       media_svc_retv_if((ret != MEDIA_INFO_ERROR_NONE) && (ret != MEDIA_INFO_ERROR_DATABASE_NO_RECORD), ret);
+
+       /*Delete item*/
+       ret = _media_svc_delete_item_by_path(db_handle, path);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       /*Delete thumbnail*/
+       if (strlen(thumb_path) > 0) {
+               if (_media_svc_remove_file(thumb_path) == FALSE) {
+                       media_svc_error("fail to remove thumbnail file.");
+                       return MEDIA_INFO_ERROR_INTERNAL;
+               }
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int media_svc_delete_all_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+       char * dirpath = NULL;
+
+       media_svc_debug_func();
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+
+       if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)) {
+               media_svc_error("storage type is incorrect[%d]", storage_type);
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _media_svc_truncate_table(db_handle, storage_type);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       dirpath = (storage_type == MEDIA_SVC_STORAGE_INTERNAL) ? MEDIA_SVC_THUMB_INTERNAL_PATH : MEDIA_SVC_THUMB_EXTERNAL_PATH;
+
+       /* remove thumbnails */
+       media_svc_debug("dirpath [%s]", dirpath);
+       ret = _media_svc_remove_all_files_in_dir(dirpath);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+
+       media_svc_debug_func();
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+
+       if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)) {
+               media_svc_error("storage type is incorrect[%d]", storage_type);
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+
+       /*Delete from DB and remove thumbnail files*/
+       ret = _media_svc_delete_invalid_items(db_handle, storage_type);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int media_svc_set_all_storage_items_validity(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, int validity)
+{
+       sqlite3 * db_handle = (sqlite3 *)handle;
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+
+       if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)) {
+               media_svc_error("storage type is incorrect[%d]", storage_type);
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+
+       return _media_svc_update_valid_of_music_records(db_handle, storage_type, validity);
+}
+
+int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type,
+                         const char *path, media_svc_media_type_e media_type)
+{
+       int ret = MEDIA_INFO_ERROR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+
+       media_svc_debug_func();
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+       media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "path is NULL");
+
+       if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)) {
+               media_svc_error("storage type is incorrect[%d]", storage_type);
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+
+       if ((media_type < MEDIA_SVC_MEDIA_TYPE_IMAGE) || (media_type > MEDIA_SVC_MEDIA_TYPE_OTHER)) {
+               media_svc_error("invalid media_type condition[%d]", media_type);
+               return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+       }
+
+       media_svc_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, media_type);
+
+       media_svc_content_info_s content_info;
+       memset(&content_info, 0, sizeof(media_svc_content_info_s));
+
+       /*Set media info*/
+       ret = _media_svc_set_media_info(&content_info, storage_type, path, NULL, media_type, TRUE);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       /* Initialize thumbnail information to remake thumbnail. */
+       char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1];
+       ret = _media_svc_get_thumbnail_path_by_path(handle, path, thumb_path);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       if (g_file_test(thumb_path, G_FILE_TEST_EXISTS)) {
+               ret = _media_svc_remove_file(thumb_path);
+               media_svc_retv_if(ret != TRUE, ret);
+       }
+
+       ret = _media_svc_update_thumbnail_path(handle, path, NULL);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       if(media_type == MEDIA_SVC_MEDIA_TYPE_OTHER) {
+               /*Do nothing.*/
+       } else if(media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) {
+               ret = _media_svc_extract_image_metadata(&content_info, media_type);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+       } else {
+               ret = _media_svc_extract_media_metadata(handle, &content_info, media_type);
+               media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+       }
+
+       ret = _media_svc_update_item_with_data(db_handle, &content_info);
+       media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, &content_info);
+
+       _media_svc_destroy_content_info(&content_info);
+
+       return MEDIA_INFO_ERROR_NONE;
+}
+
+int media_svc_rename_folder(MediaSvcHandle *handle, const char *src_path, const char *dst_path)
 {
        sqlite3 * db_handle = (sqlite3 *)handle;
+       int ret = MEDIA_INFO_ERROR_NONE;
+
+       media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+       media_svc_retvm_if(src_path == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "src_path is NULL");
+       media_svc_retvm_if(dst_path == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "dst_path is NULL");
+
+       media_svc_debug("Src path : %s,  Dst Path : %s", src_path, dst_path);
+
+       ret = _media_svc_sql_begin_trans(handle);
+       media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+
+       /* Update all folder record's path, which are matched by old parent path */
+       char *update_folder_path_sql = NULL;
+       char src_path_slash[MEDIA_SVC_PATHNAME_SIZE + 1];
+       char dst_path_slash[MEDIA_SVC_PATHNAME_SIZE + 1];
 
-       return __media_svc_disconnect_db_with_handle(db_handle);
+       snprintf(src_path_slash, sizeof(src_path_slash), "%s/", src_path);
+       snprintf(dst_path_slash, sizeof(dst_path_slash), "%s/", dst_path);
+
+       update_folder_path_sql = sqlite3_mprintf("UPDATE folder SET path = REPLACE( path, '%q', '%q');", src_path_slash, dst_path_slash);
+
+       ret = _media_svc_sql_query(handle, update_folder_path_sql);
+       sqlite3_free(update_folder_path_sql);
+
+       if (ret != SQLITE_OK) {
+               media_svc_error("failed to update folder path");
+               _media_svc_sql_rollback_trans(handle);
+
+               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+       }
+
+       /* Update all folder record's modified date, which are changed above */
+       char *update_folder_modified_time_sql = NULL;
+       time_t date;
+       time(&date);
+
+       update_folder_modified_time_sql = sqlite3_mprintf("UPDATE folder SET modified_time = %d where path like '%q';", date, dst_path);
+
+       ret = _media_svc_sql_query(handle, update_folder_modified_time_sql);
+       sqlite3_free(update_folder_modified_time_sql);
+
+       if (ret != SQLITE_OK) {
+               media_svc_error("failed to update folder modified time");
+               _media_svc_sql_rollback_trans(handle);
+
+               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+       }
+
+       /* Update all items */
+       char *select_all_sql = NULL;
+       sqlite3_stmt *sql_stmt = NULL;
+       char dst_child_path[MEDIA_SVC_PATHNAME_SIZE + 1];
+
+       snprintf(dst_child_path, sizeof(dst_child_path), "%s/%%", dst_path);
+
+       select_all_sql = sqlite3_mprintf("SELECT media_uuid, path, thumbnail_path, media_type from media where folder_uuid IN ( SELECT folder_uuid FROM folder where path='%q' or path like '%q');", dst_path, dst_child_path);
+
+       media_svc_debug("[SQL query] : %s", select_all_sql);
+
+       ret = sqlite3_prepare_v2(handle, select_all_sql, -1, &sql_stmt, NULL);
+       sqlite3_free((char *)select_all_sql);
+
+       if (ret != SQLITE_OK) {
+               media_svc_error ("prepare error [%s]", sqlite3_errmsg(handle));
+               _media_svc_sql_rollback_trans(handle);
+               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+       }
+
+       while (1) {
+               ret = sqlite3_step(sql_stmt);
+               if (ret != SQLITE_ROW) {
+                       media_svc_debug("end of iteration");
+                       break;
+               }
+
+               char media_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0,};
+               char media_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0,};
+               char media_thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0,};
+               char media_new_thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0,};
+               int media_type;
+               bool no_thumb = FALSE;
+
+               if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 0))) {
+                       strncpy(media_uuid,     (const char *)sqlite3_column_text(sql_stmt, 0), sizeof(media_uuid));
+               } else {
+                       media_svc_error("media UUID is NULL");
+                       return MEDIA_INFO_ERROR_DATABASE_INVALID;
+               }
+
+               if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 1))) {
+                       strncpy(media_path,     (const char *)sqlite3_column_text(sql_stmt, 1), sizeof(media_path));
+               } else {
+                       media_svc_error("media path is NULL");
+                       return MEDIA_INFO_ERROR_DATABASE_INVALID;
+               }
+
+               if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 2))) {
+                       strncpy(media_thumb_path,       (const char *)sqlite3_column_text(sql_stmt, 2), sizeof(media_thumb_path));
+               } else {
+                       media_svc_debug("media thumb path doesn't exist in DB");
+                       no_thumb = TRUE;
+               }
+
+               media_type = sqlite3_column_int(sql_stmt, 3);
+
+               /* Update path, thumbnail path of this item */
+               char *replaced_path = NULL;
+               replaced_path = _media_svc_replace_path(media_path, src_path, dst_path);
+               if (replaced_path == NULL) {
+                       media_svc_error("_media_svc_replace_path failed");
+                       SQLITE3_FINALIZE(sql_stmt);
+                       _media_svc_sql_rollback_trans(handle);
+                       return MEDIA_INFO_ERROR_INTERNAL;
+               }
+
+               media_svc_debug("New media path : %s", replaced_path);
+               media_svc_storage_type_e storage_type;
+
+               if (!no_thumb) {
+                       ret = _media_svc_get_store_type_by_path(replaced_path, &storage_type);
+                       if (ret < 0) {
+                               media_svc_error("_media_svc_get_store_type_by_path failed : %d", ret);
+                               SAFE_FREE(replaced_path);
+                               _media_svc_sql_rollback_trans(handle);
+                               return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+                       }
+
+                       ret = _media_svc_get_thumbnail_path(storage_type, media_new_thumb_path, replaced_path, THUMB_EXT);
+                       if (ret < 0) {
+                               media_svc_error("_media_svc_get_thumbnail_path failed : %d", ret);
+                               SAFE_FREE(replaced_path);
+                               SQLITE3_FINALIZE(sql_stmt);
+                               _media_svc_sql_rollback_trans(handle);
+                               return MEDIA_INFO_ERROR_INTERNAL;
+                       }
+
+                       media_svc_debug("New media thumbnail path : %s", media_new_thumb_path);
+               }
+
+               char *update_item_sql = NULL;
+
+               if (no_thumb) {
+                       update_item_sql = sqlite3_mprintf("UPDATE media SET path='%q' WHERE media_uuid='%q'", replaced_path, media_uuid);
+               } else {
+                       if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
+                               update_item_sql = sqlite3_mprintf("UPDATE media SET path='%q', thumbnail_path='%q' WHERE media_uuid='%q'", replaced_path, media_new_thumb_path, media_uuid);
+                       } else {
+                               update_item_sql = sqlite3_mprintf("UPDATE media SET path='%q', thumbnail_path='%q' WHERE media_uuid='%q'", replaced_path, media_thumb_path, media_uuid);
+                       }
+               }
+
+               ret = _media_svc_sql_query(handle, update_item_sql);
+               sqlite3_free(update_item_sql);
+               SAFE_FREE(replaced_path);
+
+               if (ret != SQLITE_OK) {
+                       media_svc_error("failed to update item");
+                       SQLITE3_FINALIZE(sql_stmt);
+                       _media_svc_sql_rollback_trans(handle);
+       
+                       return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+               }
+
+               /* Rename thumbnail file of file system */
+               if ((!no_thumb) && (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) {
+                       ret = _media_svc_rename_file(media_thumb_path, media_new_thumb_path);
+                       if (ret < 0) {
+                               media_svc_error("_media_svc_rename_file failed : %d", ret);
+                               SQLITE3_FINALIZE(sql_stmt);
+                               _media_svc_sql_rollback_trans(handle);
+       
+                               return MEDIA_INFO_ERROR_INTERNAL;
+                       }
+               }
+       }
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       ret = _media_svc_sql_end_trans(handle);
+       if (ret != MEDIA_INFO_ERROR_NONE) {
+               media_svc_error("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+               _media_svc_sql_rollback_trans(handle);
+               return ret;
+       }
+
+       return MEDIA_INFO_ERROR_NONE;
 }
 
index a9cb62b..50c0fc3 100755 (executable)
@@ -55,7 +55,7 @@
        ((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 _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
diff --git a/src/include/common/media-svc-album.h b/src/include/common/media-svc-album.h
new file mode 100755 (executable)
index 0000000..09fe97b
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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_SVC_ALBUM_H_
+#define _MEDIA_SVC_ALBUM_H_
+
+#include <sqlite3.h>
+
+int _media_svc_get_album_id(sqlite3 *handle, const char *album, const char *artist, int * album_id);
+int _media_svc_get_album_art_by_album_id(sqlite3 *handle, int album_id, char **album_art);
+int _media_svc_append_album(sqlite3 *handle, const char *album, const char *artist, const char *album_art, int * album_id);
+
+
+#endif /*_MEDIA_SVC_ALBUM_H_*/
diff --git a/src/include/common/media-svc-db-utils.h b/src/include/common/media-svc-db-utils.h
new file mode 100755 (executable)
index 0000000..5e2a6df
--- /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 _MEDIA_SVC_DB_UTILS_H_
+#define _MEDIA_SVC_DB_UTILS_H_
+
+#include <sqlite3.h>
+#include <glib.h>
+
+#define SQLITE3_FINALIZE(x)       if(x  != NULL) {sqlite3_finalize(x);}
+
+int _media_svc_connect_db_with_handle(sqlite3 **db_handle);
+int _media_svc_disconnect_db_with_handle(sqlite3 *db_handle);
+int _media_svc_create_media_table(sqlite3 *db_handle);
+int _media_svc_create_folder_table(sqlite3 *db_handle);
+int _media_svc_create_playlist_table(sqlite3 *db_handle);
+int _media_svc_create_album_table(sqlite3 *db_handle);
+int _media_svc_create_tag_table(sqlite3 *db_handle);
+int _media_svc_create_bookmark_table(sqlite3 *db_handle);
+int _media_svc_create_custom_table(sqlite3 *db_handle);
+int _media_svc_sql_query(sqlite3 *db_handle, const char *sql_str);
+int _media_svc_sql_prepare_to_step(sqlite3 *handle, const char *sql_str, sqlite3_stmt** stmt);
+int _media_svc_sql_begin_trans(sqlite3 *handle);
+int _media_svc_sql_end_trans(sqlite3 *handle);
+int _media_svc_sql_rollback_trans(sqlite3 *handle);
+int _media_svc_sql_query_list(sqlite3 *handle, GList **query_list);
+void _media_svc_sql_query_add(GList **query_list, char **query);
+void _media_svc_sql_query_release(GList **query_list);
+
+#endif /*_MEDIA_SVC_DB_UTILS_H_*/
index 41763b9..e9c6187 100755 (executable)
 
 #define LOG_TAG "Media-Service"
 
-#define mediainfo_dbg(fmt, arg...)      LOGD("[%s : %d] [%s] " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##arg)
+#define media_svc_debug(fmt, arg...) do { \
+                       LOGD("[%s-%d]\n"fmt"", __FUNCTION__, __LINE__,##arg);     \
+               } while (0)
+
+#define media_svc_error(fmt, arg...) do { \
+                       LOGE("%s-%d]\n"fmt"", __FUNCTION__, __LINE__,##arg);     \
+               } while (0)
+
+#define media_svc_debug_func() do { \
+                       LOGD("[%s-%d]\n", __FUNCTION__, __LINE__);     \
+               } while (0)
+
+#define media_svc_retm_if(expr, fmt, arg...) do { \
+                       if(expr) { \
+                               LOGE("[%s-%d]\n"fmt"", __FUNCTION__, __LINE__,##arg);   \
+                               return; \
+                       } \
+               } while (0)
+#define media_svc_retv_if(expr, val) do { \
+                       if(expr) { \
+                               LOGE("[%s-%d]\n", __FUNCTION__, __LINE__);     \
+                               return (val); \
+                       } \
+               } while (0)
+#define media_svc_retvm_if(expr, val, fmt, arg...) do { \
+                       if(expr) { \
+                               LOGE("[%s-%d]\n"fmt"", __FUNCTION__, __LINE__,##arg);   \
+                               return (val); \
+                       } \
+               } while (0)
+
+#define media_svc_retv_del_if(expr, val, p_str) do { \
+                       if(expr) { \
+                               LOGE("[%s-%d]\n", __FUNCTION__, __LINE__);     \
+                               _media_svc_destroy_content_info(p_str);        \
+                               return (val); \
+                       } \
+               } while (0)
 
 #ifdef _USE_LOG_FILE_
 void mediainfo_init_file_debug();
index 665d27a..a8d03db 100755 (executable)
 #ifndef _MEDIA_SVC_ENV_H_
 #define _MEDIA_SVC_ENV_H_
 
+#include <time.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#define MEDIA_INFO_DATABASE_NAME "/opt/dbspace/.media.db"
+/**
+ * DB information
+ */
+
+#define MEDIA_SVC_DB_NAME                                              "/opt/dbspace/.media.db"                /**<  media db name*/
+
+/**
+ * DB table information
+ */
+
+#define MEDIA_SVC_DB_TABLE_MEDIA                                       "media"                         /**<  media table*/
+#define MEDIA_SVC_DB_TABLE_FOLDER                                      "folder"                                /**<  media_folder table*/
+#define MEDIA_SVC_DB_TABLE_PLAYLIST                            "playlist"                              /**<  playlist table*/
+#define MEDIA_SVC_DB_TABLE_PLAYLIST_MAP                        "playlist_map"                  /**<  playlist_map table*/
+#define MEDIA_SVC_DB_TABLE_ALBUM                                       "album"                         /**<  album table*/
+#define MEDIA_SVC_DB_TABLE_TAG                                 "tag"                           /**<  tag table*/
+#define MEDIA_SVC_DB_TABLE_TAG_MAP                             "tag_map"                       /**<  tag_map table*/
+#define MEDIA_SVC_DB_TABLE_BOOKMARK                            "bookmark"                      /**<  bookmark table*/
+#define MEDIA_SVC_DB_TABLE_CUSTOM                              "custom"                                /**<  custom table*/
+
+
+#define MEDIA_SVC_METADATA_LEN_MAX                     128                                             /**<  Length of metadata*/
+#define MEDIA_SVC_METADATA_DESCRIPTION_MAX     512                                             /**<  Length of description*/
+#define MEDIA_SVC_PATHNAME_SIZE                                4096                                    /**<  Length of Path name. */
+#define MEDIA_SVC_UUID_SIZE                                            36                                              /**< Length of UUID*/
+
+#define MEDIA_SVC_TAG_UNKNOWN                          "Unknown"
+#define MEDIA_SVC_MEDIA_PATH                                   "/opt/data/file-manager-service"                        /**<  Media path*/
+#define MEDIA_SVC_THUMB_PATH_PREFIX                    MEDIA_SVC_MEDIA_PATH"/.thumb"                   /**< Thumbnail path prefix*/
+#define MEDIA_SVC_THUMB_INTERNAL_PATH          MEDIA_SVC_THUMB_PATH_PREFIX"/phone"     /**<  Phone thumbnail path*/
+#define MEDIA_SVC_THUMB_EXTERNAL_PATH          MEDIA_SVC_THUMB_PATH_PREFIX"/mmc"               /**<  MMC thumbnail path*/
+
+#define MEDIA_SVC_DEFAULT_GPS_VALUE                    1000.00                 /**<  Default GPS Value*/
+#define THUMB_EXT      "jpg"
+
+#define MEDIA_SVC_PATH_PHONE                           "/opt/media"
+#define MEDIA_SVC_PATH_MMC                                     "/opt/storage/sdcard"
+
+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
+};
+
+#if 0
+/**
+ * Media meta data information
+ */
+typedef struct {
+       char            title[MEDIA_SVC_METADATA_LEN_MAX];                              /**< track title*/
+       char            album[MEDIA_SVC_METADATA_LEN_MAX];                      /**< album name*/
+       char            artist[MEDIA_SVC_METADATA_LEN_MAX];                     /**< artist name*/
+       char            genre[MEDIA_SVC_METADATA_LEN_MAX];                      /**< genre of track*/
+       char            author[MEDIA_SVC_METADATA_LEN_MAX];                     /**< author name*/
+       char            year[MEDIA_SVC_METADATA_LEN_MAX];                               /**< author name*/
+       char            recorded_date[MEDIA_SVC_METADATA_LEN_MAX];              /**< recorded date*/
+       char            copyright[MEDIA_SVC_METADATA_LEN_MAX];                  /**< copyright*/
+       char            track_num[MEDIA_SVC_METADATA_LEN_MAX];          /**< track number*/
+       char            description[MEDIA_SVC_METADATA_DESCRIPTION_MAX];        /**< description*/
+       int             bitrate;                                                                                        /**< bitrate*/
+       int             samplerate;                                                                             /**< samplerate*/
+       int             channel;                                                                                        /**< channel*/
+       int             duration;                                                                               /**< duration*/
+       float           longitude;                                                                              /**< longitude*/
+       float           latitude;                                                                                       /**< latitude*/
+       float           altitude;                                                                                       /**< altitude*/
+       int             width;                                                                                  /**< width*/
+       int             height;                                                                                 /**< height*/
+       char            datetaken[MEDIA_SVC_METADATA_LEN_MAX];          /**< datetaken*/
+       char            timetaken[MEDIA_SVC_METADATA_LEN_MAX];          /**< timetaken*/
+       int             orientation;                                                                            /**< orientation*/
+       int             rating;                                                                                 /**< user defined rating */
+} media_svc_content_meta_s;
+
+
+/**
+ * Media data information
+ */
+typedef struct {
+       char            media_uuid[MEDIA_SVC_UUID_SIZE+1];                      /**< Unique ID of item */
+       char            path[MEDIA_SVC_PATHNAME_SIZE];                          /**< Full path and file name of media file */
+       char            file_name[MEDIA_SVC_PATHNAME_SIZE];                     /**< Full path and file name of media file */
+       int             media_type;                                                                     /**< Type of media file : internal/external */
+       char            mime_type[MEDIA_SVC_PATHNAME_SIZE];                     /**< Full path and file name of media file */
+       int             size;
+       int             added_time;                                                                     /**< added time */
+       int             modified_time;                                                          /**< modified time */
+       char            folder_uuid[MEDIA_SVC_UUID_SIZE+1];                     /**< Unique ID of folder */
+       int             album_id;                                                                       /**< Unique ID of album */
+       char            thumbnail_path[MEDIA_SVC_PATHNAME_SIZE];                /**< Thumbnail image file path */
+       int             played_count;                                                           /**< played count */
+       int             last_played_time;                                                                       /**< last played time */
+       int             last_played_position;
+       int             favourate;                                                                      /**< favourate. o or 1 */
+       int             hiding;                                                                         /**< hiding. o or 1 */
+       int             is_drm;                                                                         /**< is_drm. o or 1 */
+       int             storage_type;                                                                   /**< Storage of media file : internal/external */
+       media_svc_content_meta_s                media_meta;                                     /**< meta data structure for audio files */
+} media_svc_content_info_s;
+#else
+/**
+ * Media meta data information
+ */
+typedef struct {
+       char    *       title;                          /**< track title*/
+       char    *       album;                          /**< album name*/
+       char    *       artist;                         /**< artist name*/
+       char    *       genre;                          /**< genre of track*/
+       char    *       composer;                       /**< composer name*/
+       char    *       year;                           /**< year*/
+       char    *       recorded_date;          /**< recorded date*/
+       char    *       copyright;                      /**< copyright*/
+       char    *       track_num;                      /**< track number*/
+       char    *       description;                    /**< description*/
+       int             bitrate;                                /**< bitrate*/
+       int             samplerate;                     /**< samplerate*/
+       int             channel;                                /**< channel*/
+       int             duration;                       /**< duration*/
+       float           longitude;                      /**< longitude*/
+       float           latitude;                               /**< latitude*/
+       float           altitude;                               /**< altitude*/
+       int             width;                          /**< width*/
+       int             height;                         /**< height*/
+       char    *       datetaken;                      /**< datetaken*/
+       int             orientation;                    /**< orientation*/
+       int             rating;                         /**< user defined rating */
+} media_svc_content_meta_s;
+
+
+/**
+ * Media data information
+ */
+typedef struct {
+       char    *       media_uuid;                                     /**< Unique ID of item */
+       char    *       path;                                           /**< Full path and file name of media file */
+       char    *       file_name;                                      /**< Full path and file name of media file */
+       int             media_type;                                     /**< Type of media file : internal/external */
+       char    *       mime_type;                                      /**< Full path and file name of media file */
+       unsigned long long      size;                                                   /**< size */
+       time_t  added_time;                                     /**< added time, time_t */
+       time_t  modified_time;                          /**< modified time, time_t */
+       char    *       folder_uuid;                                    /**< Unique ID of folder */
+       int             album_id;                                       /**< Unique ID of album */
+       char    *       thumbnail_path;                         /**< Thumbnail image file path */
+       int             played_count;                           /**< played count */
+       int             last_played_time;                               /**< last played time */
+       int             last_played_position;                   /**< last played position */
+       int             favourate;                                      /**< favourate. o or 1 */
+       int             is_drm;                                         /**< is_drm. o or 1 */
+       int             storage_type;                                   /**< Storage of media file : internal/external */
+       media_svc_content_meta_s        media_meta;     /**< meta data structure for audio files */
+} media_svc_content_info_s;
+#endif
+
+typedef enum{
+       MEDIA_SVC_QUERY_INSERT_ITEM,
+       MEDIA_SVC_QUERY_SET_ITEM_VALIDITY,
+       MEDIA_SVC_QUERY_MOVE_ITEM,
+} media_svc_query_type_e;
 
 #ifdef __cplusplus
 }
diff --git a/src/include/common/media-svc-media-folder.h b/src/include/common/media-svc-media-folder.h
new file mode 100755 (executable)
index 0000000..3b9897a
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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_SVC_MEDIA_FOLDER_H_
+#define _MEDIA_SVC_MEDIA_FOLDER_H_
+
+#include <sqlite3.h>
+#include <stdbool.h>
+#include "media-svc-types.h"
+
+int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *folder_name, char *folder_id);
+int _media_svc_append_folder(sqlite3 *handle, media_svc_storage_type_e storage_type, const char *folder_id, const char *path_name, const char *folder_name, int modified_date);
+int _media_svc_update_folder_modified_time_by_folder_uuid(sqlite3 *handle, const char *folder_uuid, const char *folder_path, bool stack_query);
+int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *path, media_svc_storage_type_e storage_type, char *folder_id);
+int _media_svc_update_folder_table(sqlite3 *handle);
+
+#endif /*_MEDIA_SVC_MEDIA_FOLDER_H_*/
diff --git a/src/include/common/media-svc-media.h b/src/include/common/media-svc-media.h
new file mode 100755 (executable)
index 0000000..4944304
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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_SVC_MEDIA_H_
+#define _MEDIA_SVC_MEDIA_H_
+
+#include <sqlite3.h>
+#include <stdbool.h>
+#include "media-svc-types.h"
+#include "media-svc-env.h"
+
+int _media_svc_count_record_with_path(sqlite3 *handle, const char *path, int *count);
+int _media_svc_insert_item_with_data(sqlite3 *handle, media_svc_content_info_s *content_info, bool stack_query);
+int _media_svc_update_item_with_data(sqlite3 *handle, media_svc_content_info_s *content_info);
+int _media_svc_get_thumbnail_path_by_path(sqlite3 *handle, const char *path, char *thumbnail_path);
+int _media_svc_get_media_type_by_path(sqlite3 *handle, const char *path, int *media_type);
+int _media_svc_delete_item_by_path(sqlite3 *handle, const char *path);
+int _media_svc_truncate_table(sqlite3 *handle, media_svc_storage_type_e storage_type);
+int _media_svc_delete_invalid_items(sqlite3 *handle, media_svc_storage_type_e storage_type);
+int _media_svc_update_valid_of_music_records(sqlite3 *handle, media_svc_storage_type_e storage_type, int validity);
+int _media_svc_update_item_validity(sqlite3 *handle, const char *path, int validity, bool stack_query);
+int _media_svc_update_item_by_path(sqlite3 *handle, const char *src_path, media_svc_storage_type_e dest_storage, const char *dest_path, const char *file_name, int modified_time, const char *folder_uuid, const char *thumb_path, bool stack_query);
+int _media_svc_list_query_do(sqlite3 *handle, media_svc_query_type_e query_type);
+int _media_svc_get_media_id_by_path(sqlite3 *handle, const char *path, char *media_uuid, int max_length);
+int _media_svc_update_thumbnail_path(sqlite3 *handle, const char *path, const char *thumb_path);
+
+#endif /*_MEDIA_SVC_MEDIA_H_*/
index 4d46d2f..62b3345 100755 (executable)
 #ifndef _MEDIA_SVC_UTIL_H_
 #define _MEDIA_SVC_UTIL_H_
 
+#include <string.h>
+#include <stdbool.h>
+#include <sqlite3.h>
+#include "media-svc-types.h"
+#include "media-svc-env.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+#ifndef FALSE
+#define FALSE  0
+#endif
+#ifndef TRUE
+#define TRUE   1
+#endif
+
+#define SAFE_FREE(src)      { if(src) {free(src); src = NULL;}}
+#define STRING_VALID(str)      \
+       ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
+
 char *_media_info_generate_uuid(void);
 char *_media_svc_escape_str(char *input, int len);
+void _strncpy_safe(char *x_dst, const char *x_src, int max_len);
+unsigned int _media_svc_get_current_time(void);
+int _media_svc_rename_file( const char *old_name, const char *new_name);
+bool _media_svc_remove_file(const char *path);
+int _media_svc_remove_all_files_in_dir(const char *dir_path);
+char *_media_svc_get_title_from_filepath (const char *path);
+int _media_svc_save_image(void *image, int size, char *image_path);
+bool _media_svc_get_thumbnail_path(media_svc_storage_type_e storage_type, char *thumb_path, const char *pathname, const char *img_format);
+bool _media_svc_get_file_ext(const char *file_path, char *file_ext);
+int _media_svc_get_file_time(const char *full_path);
+int _media_svc_set_media_info(media_svc_content_info_s *content_info, media_svc_storage_type_e storage_type, const char *path, const char *mime_type, media_svc_media_type_e media_type, bool refresh);
+int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info, media_svc_media_type_e media_type);
+int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, media_svc_media_type_e media_type);
+int __media_svc_malloc_and_strncpy(char **dst, const char *src);
+void _media_svc_destroy_content_info(media_svc_content_info_s *content_info);
+int _media_svc_get_store_type_by_path(const char *path, media_svc_storage_type_e *storage_type);
+char *_media_svc_replace_path(char *s, const char *olds, const char *news);
 
 #ifdef __cplusplus
 }
similarity index 99%
rename from src/include/visual/media-svc-db-util.h
rename to src/include/visual/visual-svc-db-util.h
index c65415c..ae58ec5 100755 (executable)
@@ -22,7 +22,7 @@
 /** 
  * This file defines synchronize apis for phone explorer.
  *
- * @file               media-svc-db-util.h
+ * @file               visual-svc-db-util.h
  * @author             Hyunjun Ko <zzoon.ko@samsung.com>
  * @version    1.0
  * @brief      This file defines in-house apis for media service.
@@ -120,6 +120,7 @@ extern "C" {
 #define MB_SVC_UPDATE_MEDIA_THUMB_PATH   "UPDATE %s SET thumbnail_path = '%q' WHERE visual_uuid = '%s';"
 #define MB_SVC_UPDATE_MEDIA_FAVORITE_BY_ID   "UPDATE %s SET rating = %d WHERE visual_uuid = '%s';"
 #define MB_SVC_UPDATE_MEDIA_DATE_BY_ID   "UPDATE %s SET modified_date = %d WHERE visual_uuid = '%s';"
+#define MB_SVC_UPDATE_MEDIA_ORIENTATION_BY_ID   "UPDATE %s SET orientation = %d WHERE visual_uuid = '%s';"
 #define MB_SVC_UPDATE_FOLDER_ALBUM_STATUS   "UPDATE %s SET lock_status = ? WHERE folder_uuid = ?;"
 #define MB_SVC_UPDATE_MEDIA_VALID_BY_UUID   "UPDATE %s SET valid = %d WHERE visual_uuid = '%s';"
 #define MB_SVC_UPDATE_FOLDER_VALID_BY_UUID   "UPDATE %s SET valid = %d WHERE folder_uuid = '%s';"
similarity index 99%
rename from src/include/visual/media-svc-db.h
rename to src/include/visual/visual-svc-db.h
index 118f2ba..6c6715b 100755 (executable)
@@ -22,7 +22,7 @@
 /** 
  * This file defines synchronize apis for phone explorer.
  *
- * @file               media-svc-db.h
+ * @file               visual-svc-db.h
  * @author             Hyunjun Ko <zzoon.ko@samsung.com>
  * @version    1.0
  * @brief      This file defines in-house apis for media service.
@@ -593,6 +593,9 @@ int
 mb_svc_set_media_records_as_valid(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type, int valid);
 
 int
+mb_svc_update_orientation_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, int orientation);
+
+int
 mb_svc_update_album_lock_status(MediaSvcHandle *mb_svc_handle, const char *folder_id, int lock, minfo_store_type storage_type );
 
 int
@@ -604,6 +607,8 @@ mb_svc_update_record_folder_path(MediaSvcHandle *mb_svc_handle, char* old_path,
 int
 mb_svc_update_folder_modified_date(MediaSvcHandle *mb_svc_handle, char* path, int date);
 
+void mb_svc_init_last_updated_folder_uuid();
+
 int
 mb_svc_set_folder_as_valid_sql_add(const char *folder_id, int valid);
 
index 61933ea..e7f0737 100755 (executable)
@@ -30,7 +30,7 @@
 
 /**
 * @ingroup MEDIA-SVC
-* @defgroup    MEDIA_SVC_UTIL error code table
+* @defgroup    VISUAL_SVC_UTIL error code table
 * @{
 */
 
index 35dd9d0..ee64f1c 100644 (file)
  *
  */
 #include "media-img-codec-osal.h"
+#include "visual-svc-debug.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include <drm-service.h>
+#include <drm_client.h>
 
 void *IfegMemAlloc(unsigned int size)
 {
@@ -58,74 +59,23 @@ 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;
-       }
+       return NULL;
 }
 
 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);
-       }
+       return 0;
 }
 
 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;
 }
 
@@ -148,11 +98,5 @@ BOOL DrmGetFileAttributes(const char *szPathName, FmFileAttribute * pFileAttr)
 
 BOOL DrmCloseFile(HFile hFile)
 {
-       if (!_is_real_drm) {
-               fclose(hFile);
-       } else {
-               drm_svc_close_file((DRM_FILE_HANDLE) hFile);
-       }
-
        return TRUE;
 }
index 0da6aff..3e9f61f 100755 (executable)
@@ -20,7 +20,7 @@
  */
 #include <glib.h>
 #include <glib-object.h>
-#include <drm-service.h>
+#include <drm_client.h>
 #include <dirent.h>
 #include <sys/types.h>
 #include <string.h>
 #include "media-svc-debug.h"
 #include "media-svc-api.h"
 #include "media-svc-thumb.h"
-#include "media-svc-db-util.h"
+#include "visual-svc-db-util.h"
 #include "visual-svc-debug.h"
 #include "visual-svc-util.h"
-#include "media-svc-db.h"
+#include "visual-svc-db.h"
 #include "media-svc-util.h"
 #include "media-svc-types.h"
 #include "visual-svc-error.h"
@@ -224,7 +224,15 @@ mb_svc_insert_file_batch(MediaSvcHandle *mb_svc_handle, const char *file_full_pa
            ("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);
+
+       drm_bool_type_e drm_type;
+       ret = drm_is_drm_file(file_full_path, &drm_type);
+       if (ret < 0) {
+               mb_svc_debug("drm_is_drm_file falied : %d", ret);
+               drm_type = DRM_FALSE;
+       }
+
+       is_drm = (drm_type == DRM_TRUE);
 
        ret = _mb_svc_thumb_generate_hash_name(file_full_path,
                                                                                media_record.thumbnail_path,
@@ -428,7 +436,15 @@ mb_svc_insert_file(MediaSvcHandle *mb_svc_handle, const char *file_full_path, mi
            ("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);
+
+       drm_bool_type_e drm_type;
+       ret = drm_is_drm_file(file_full_path, &drm_type);
+       if (ret < 0) {
+               mb_svc_debug("drm_is_drm_file falied : %d", ret);
+               drm_type = DRM_FALSE;
+       }
+
+       is_drm = (drm_type == 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 */
index ac25b30..be70df9 100755 (executable)
@@ -47,7 +47,7 @@
 #include <mm_file.h>
 #include <mm_util_imgp.h>
 #include <mm_util_jpeg.h>
-#include <drm-service.h>
+#include <drm_client.h>
 #include <Evas.h>
 #include <Ecore_Evas.h>
 #include <string.h>
@@ -329,39 +329,6 @@ 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;
 }
 
@@ -2491,7 +2458,15 @@ mb_svc_image_create_thumb(const char *file_full_path, char *thumb_hash_path,
        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);
+
+       drm_bool_type_e drm_type;
+       err = drm_is_drm_file(file_full_path, &drm_type);
+       if (err < 0) {
+               mb_svc_debug("drm_is_drm_file falied : %d", err);
+               drm_type = DRM_FALSE;
+       }
+
+       thumb_info.is_drm = (drm_type == DRM_TRUE);
 
        err =
            __mb_svc_thumb_save(thumb, thumb_info, max_thumb_length,
@@ -2572,7 +2547,16 @@ mb_svc_image_create_thumb_new(const char *file_full_path, char *thumb_hash_path,
        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);
+
+       drm_bool_type_e drm_type;
+       err = drm_is_drm_file(file_full_path, &drm_type);
+       if (err < 0) {
+               mb_svc_debug("drm_is_drm_file falied : %d", err);
+               drm_type = DRM_FALSE;
+       }
+
+       thumb_info.is_drm = (drm_type == DRM_TRUE);
+
 
        err = __mb_svc_thumb_save_new(thumb, thumb_info, max_thumb_length);
        if (err < 0) {
@@ -2991,7 +2975,15 @@ mb_svc_video_create_thumb(const char *file_full_path, char *thumb_hash_path,
                return MB_SVC_ERROR_INVALID_PARAMETER;
        }
 
-       thumb_info.is_drm = (drm_svc_is_drm_file(file_full_path) == DRM_TRUE);
+       drm_bool_type_e drm_type;
+       err = drm_is_drm_file(file_full_path, &drm_type);
+       if (err < 0) {
+               mb_svc_debug("drm_is_drm_file falied : %d", err);
+               drm_type = DRM_FALSE;
+       }
+
+       thumb_info.is_drm = (drm_type == DRM_TRUE);
+
        err = mm_file_create_content_attrs(&content, file_full_path);
 
        if (err < 0) {
index c5096ac..f457086 100755 (executable)
@@ -24,7 +24,7 @@
 #include "visual-svc-types.h"
 #include "visual-svc.h"
 #include "visual-svc-error.h"
-#include "media-svc-db.h"
+#include "visual-svc-db.h"
 #include "media-svc-api.h"
 #include "visual-svc-util.h"
 #include "media-svc-thumb.h"
@@ -35,7 +35,7 @@
 #include "minfo-meta.h"
 #include "minfo-bookmark.h"
 #include "minfo-streaming.h"
-#include "media-svc-db-util.h"
+#include "visual-svc-db-util.h"
 
 static __thread int g_trans_valid_cnt = 1;
 static __thread int g_cur_trans_valid_cnt = 0;
@@ -1955,6 +1955,37 @@ int minfo_update_media_date(MediaSvcHandle *mb_svc_handle, const char *media_id,
        return MB_SVC_ERROR_NONE;
 }
 
+int minfo_update_media_orientation(MediaSvcHandle *mb_svc_handle, const char *media_id, minfo_exif_orientation_t orientation)
+{
+       int ret = -1;
+
+       if (mb_svc_handle == NULL) {
+               mb_svc_debug("media service handle is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (media_id == NULL) {
+               mb_svc_debug("media_id is NULL");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       if((orientation < MINFO_ORIENT_NOT_AVAILABLE) || (orientation > MINFO_ORIENT_ROT_270)) {
+               mb_svc_debug("invalid orientation value");
+               return MB_SVC_ERROR_INVALID_PARAMETER;
+       }
+
+       mb_svc_debug("minfo_update_media_orientation: %s", media_id);
+       mb_svc_debug("minfo_update_media_orientation: %d", orientation);
+
+       ret = mb_svc_update_orientation_by_id(mb_svc_handle, media_id, orientation);
+       if (ret < 0) {
+               mb_svc_debug("mb_svc_update_orientation_by_id failed\n");
+               return ret;
+       }
+
+       return MB_SVC_ERROR_NONE;
+}
+
 EXPORT_API int minfo_cp_media(MediaSvcHandle *mb_svc_handle, const char *src_media_id, const char *dst_cluster_id)
 {
        int ret = -1;
@@ -3040,6 +3071,7 @@ minfo_set_item_valid_end(MediaSvcHandle *mb_svc_handle)
                }
        }
 
+       mb_svc_init_last_updated_folder_uuid();
        g_cur_trans_valid_cnt = 0;
        g_trans_valid_cnt = 1;
 
similarity index 99%
rename from src/visual/media-svc-db-util.c
rename to src/visual/visual-svc-db-util.c
index 06ca930..420dfa6 100755 (executable)
@@ -26,7 +26,7 @@
 #include <sqlite3.h>
 #include "media-svc-util.h"
 #include "visual-svc-util.h"
-#include "media-svc-db-util.h"
+#include "visual-svc-db-util.h"
 #include "visual-svc-debug.h"
 #include "visual-svc-error.h"
 
similarity index 98%
rename from src/visual/media-svc-db.c
rename to src/visual/visual-svc-db.c
index 7d5073c..deca56c 100755 (executable)
@@ -24,9 +24,9 @@
 #include <sys/stat.h>
 #include "media-svc-env.h"
 #include "media-svc-util.h"
-#include "media-svc-db.h"
+#include "visual-svc-db.h"
 #include "visual-svc-debug.h"
-#include "media-svc-db-util.h"
+#include "visual-svc-db-util.h"
 #include "visual-svc-util.h"
 #include "media-svc-api.h"
 #include "media-svc-structures.h"
@@ -388,6 +388,14 @@ static int __mb_svc_delete_record_by_uuid(MediaSvcHandle *mb_svc_handle, const c
 static int __mb_svc_db_get_next_id(MediaSvcHandle *mb_svc_handle, int table_id);
 
 
+void mb_svc_init_last_updated_folder_uuid()
+{
+       /* Initialize g_last_updated_folder_uuid */
+       memset(g_last_updated_folder_uuid, 0x00, sizeof(g_last_updated_folder_uuid));
+
+       return;
+}
+
 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);
@@ -2197,6 +2205,30 @@ int mb_svc_update_date_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id
        return 0;
 }
 
+int mb_svc_update_orientation_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, int orientation)
+{
+       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_IMAGE_META].table_name);
+
+       snprintf(query_string, sizeof(query_string),
+                MB_SVC_UPDATE_MEDIA_ORIENTATION_BY_ID, table_name, orientation, media_id);
+       err = mb_svc_query_sql(mb_svc_handle, 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("");
index 904e313..c936f80 100755 (executable)
@@ -27,7 +27,7 @@
 
 #include <vconf.h>
 #include <vconf-keys.h>
-#include <drm-service.h>
+#include <drm_client.h>
 #include <string.h>
 #include <aul/aul.h>
 #include <sys/stat.h>
@@ -269,27 +269,43 @@ bool _mb_svc_glist_free(GList **glist, bool is_free_element)
 int _mb_svc_get_file_type(const char *file_full_path)
 {
        int ret = 0;
+       drm_bool_type_e drm_type;
+       drm_file_type_e drm_file_type;
        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) {
+       ret = drm_is_drm_file(file_full_path, &drm_type);
+       if (ret < 0) {
+               mb_svc_debug("drm_is_drm_file falied : %d", ret);
+               drm_type = DRM_FALSE;
+       }
+
+       if (drm_type == DRM_TRUE) {
+               drm_file_type = DRM_TYPE_UNDEFINED;
+
+               ret = drm_get_file_type(file_full_path, &drm_file_type);
+               if (ret < 0) {
+                       mb_svc_debug("drm_get_file_type falied : %d", ret);
+                       return MINFO_ITEM_NONE;
+               }
+
+               if (drm_file_type == DRM_TYPE_UNDEFINED) {
                        return MINFO_ITEM_NONE;
                } 
                else {
-                       drm_content_info_t contentInfo = { 0 };
+                       drm_content_info_s contentInfo;
+                       memset(&contentInfo, 0x00, sizeof(drm_content_info_s));
 
-                       ret = drm_svc_get_content_info(file_full_path, &contentInfo);
-                       if (ret != DRM_RESULT_SUCCESS) {
-                               mb_svc_debug("drm_svc_get_content_info() fails. ");
+                       ret = drm_get_content_info(file_full_path, &contentInfo);
+                       if (ret != DRM_RETURN_SUCCESS) {
+                               mb_svc_debug("drm_get_content_info() fails. : %d", ret);
                                return MINFO_ITEM_NONE;
                        }
+                       mb_svc_debug("DRM mime type: %s", contentInfo.mime_type);
 
-                       strncpy(mimetype, contentInfo.contentType, sizeof(mimetype));
+                       strncpy(mimetype, contentInfo.mime_type, sizeof(mimetype));
                }
        } else {
                /* get content type and mime type from file. */
index fb92639..94e3a27 100644 (file)
@@ -8,7 +8,7 @@ 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
+       $(CC) -c $(SRCS) -I../../include -L../../cmake_build_tmp `pkg-config $(LIBS) --cflags --libs` -g
 clean :
        rm $(TARGET)
        rm $(OBJS)
index 2503ee5..ee52cd9 100755 (executable)
@@ -33,6 +33,7 @@ int (*svc_check_item)                 (const char *file_path, const char * mime_type, char **
 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 (*svc_insert_item_immediately)     (void* handle, const char *file_path, int storage_type, const char * mime_type, char ** err_msg);
 
 int __load_functions()
 {
@@ -47,10 +48,12 @@ int __load_functions()
        svc_connect                     = dlsym (funcHandle, "connect");
        svc_disconnect          = dlsym (funcHandle, "disconnect");
        svc_check_item_exist    = dlsym (funcHandle, "check_item_exist");
+       svc_insert_item_immediately     = dlsym (funcHandle, "insert_item_immediately");
 
        if ( !svc_check_item ||
                 !svc_connect ||
                 !svc_disconnect ||
+                !svc_insert_item_immediately ||
                 !svc_check_item_exist) {
                fprintf(stderr,"error: %s\n", dlerror());
                return -1;
@@ -76,11 +79,15 @@ int main()
        int ret = 0;
        MediaSvcHandle * db_handle = NULL;
        char * err_msg = NULL;
+       char path[1024] = {0,};
+       char type[1024] = {0,};
 
        ret = __load_functions();
        if(ret < 0) {
                msg_print(__LINE__, "__load_functions error");
                return -1;
+       } else {
+               msg_print(__LINE__, "__load_functions success");
        }
 
        //check_item ================================================
@@ -94,6 +101,8 @@ int main()
                }
                __unload_functions();
                return -1;
+       } else {
+               msg_print(__LINE__, "svc_check_item success");
        }
 
        //db open ==================================================
@@ -107,10 +116,26 @@ int main()
                }
                __unload_functions();
                return -1;
+       } else {
+               msg_print(__LINE__, "svc_connect success");
        }
 
+#if 1
+       ret = media_svc_create_table(db_handle);
+       if (ret < 0) {
+               msg_print(__LINE__, "table already exists");
+       } else {
+               msg_print(__LINE__, "table create success");
+       }
+#endif
+
+       while (1) {
+
+       printf("Enter path and mimetype ( ex. /opt/media/a.jpg image ) : ");
+       scanf("%s %s", path, type);
+
        //check_item_exist ============================================
-       ret = svc_check_item_exist(db_handle, "/opt/media/Music/Over the horizon.mp3", 0, &err_msg);
+       ret = svc_check_item_exist(db_handle, path, 0, &err_msg);
        if(ret < 0) {
                msg_print(__LINE__, "svc_check_item_exist error");
                if(err_msg != NULL) {
@@ -118,8 +143,33 @@ int main()
                        free(err_msg);
                        err_msg = NULL;
                }
-               __unload_functions();
-               return -1;
+               //__unload_functions();
+               //return -1;
+       } else {
+               msg_print(__LINE__, "svc_check_item_exist success");
+       }
+
+       // svc_check_item_exist ============================================
+       ret = svc_insert_item_immediately(db_handle, path, 0, type, &err_msg);
+       if(ret < 0) {
+               msg_print(__LINE__, "svc_insert_item_immediately error");
+               if(err_msg != NULL) {
+                       printf("err_msg[%s]\n", err_msg);
+                       free(err_msg);
+                       err_msg = NULL;
+               }
+               //__unload_functions();
+               //return -1;
+       } else {
+               msg_print(__LINE__, "svc_insert_item_immediately success");
+       }
+       } // End of While
+
+       ret = media_svc_insert_folder(db_handle, 0,  path);
+       if(ret < 0) {
+               msg_print(__LINE__, "media_svc_insert_folder error ");
+       } else {
+               msg_print(__LINE__, "media_svc_insert_folder success");
        }
 
        //db close ==================================================
@@ -133,6 +183,8 @@ int main()
                }
                __unload_functions();
                return -1;
+       } else {
+               msg_print(__LINE__, "svc_disconnect success");
        }
 
        __unload_functions();
index 0e934b2..754393c 100755 (executable)
@@ -95,10 +95,10 @@ int main(int argc, char *argv[])
        MediaSvcHandle *handle = NULL;
        err = media_svc_connect(&handle);
        if(err < 0) {
-               mediainfo_dbg("media_svc_connect fails");
+               media_svc_debug("media_svc_connect fails");
        }
 
-       mediainfo_dbg("media_svc_connect succeeds");
+       media_svc_debug("media_svc_connect succeeds");
 
        test_case = atoi(argv[1]);
 
@@ -107,7 +107,7 @@ int main(int argc, char *argv[])
                        test_connect_disconn();
                        break;
                case 1: 
-                       audio_svc_create_table(handle);
+                       media_svc_create_table(handle);
                        break;
                
                case 2: 
@@ -780,7 +780,7 @@ int main(int argc, char *argv[])
                err = audio_svc_list_by_search(handle, a_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);
+                       media_svc_debug("Fail to get items : %d", err);
                        return err;
                }
                
@@ -841,7 +841,7 @@ int main(int argc, char *argv[])
 
        err = media_svc_disconnect(handle);
        if(err < 0) {
-               mediainfo_dbg("media_svc_disconnect fails");
+               media_svc_debug("media_svc_disconnect fails");
        }
 
        printf("End of Test\n");
@@ -855,7 +855,7 @@ void *do_newjob()
        MediaSvcHandle *handle = NULL;
        err = media_svc_connect(&handle);
        if(err < 0) {
-               mediainfo_dbg("media_svc_connect fails");
+               media_svc_debug("media_svc_connect fails");
        }
 
        const char *media_id = "2b0a4efe-c3cb-cb62-fe12-3f4f7aef4ab9";
@@ -870,7 +870,7 @@ void *do_newjob()
        printf("Calling media_svc_disconnect in do_newjob \n");
        err = media_svc_disconnect(handle);
        if(err < 0) {
-               mediainfo_dbg("media_svc_disconnect fails");
+               media_svc_debug("media_svc_disconnect fails");
                return NULL;
        }
 
@@ -882,25 +882,25 @@ void *do_newjob()
 
 void test_connect_disconn()
 {
-       mediainfo_dbg("");
+       media_svc_debug("");
        int err = -1;
        MediaSvcHandle *handle = NULL;
        err = media_svc_connect(&handle);
        if( err < 0 ) {
-               mediainfo_dbg("Error");
+               media_svc_debug("Error");
                return;
-       } else { mediainfo_dbg("success"); }
+       } else { media_svc_debug("success"); }
 
-       if(handle == NULL) mediainfo_dbg("NULL!!!!!");
+       if(handle == NULL) media_svc_debug("NULL!!!!!");
        test_query((sqlite3 *)handle);
 
        err = media_svc_disconnect(handle);
        if( err < 0 ) {
-               mediainfo_dbg("Error");
+               media_svc_debug("Error");
                return;
        }
 
-       mediainfo_dbg("test_connect_disconn success");
+       media_svc_debug("test_connect_disconn success");
 
        return;
 }
@@ -913,7 +913,7 @@ int test_query(sqlite3* handle)
        memset(query_string, 0, sizeof(query_string) );
 
        if( handle == NULL ) {
-               mediainfo_dbg( "handle is NULL" );
+               media_svc_debug( "handle is NULL" );
                return -1;
        }
 
@@ -923,25 +923,25 @@ int test_query(sqlite3* handle)
 
        if (SQLITE_OK != err) 
        {
-                mediainfo_dbg ("prepare error [%s]\n", sqlite3_errmsg(handle));
-                mediainfo_dbg ("query string is %s\n", query_string);
+                media_svc_debug ("prepare error [%s]\n", sqlite3_errmsg(handle));
+                media_svc_debug ("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);
+                media_svc_debug ("end of row [%s]\n", sqlite3_errmsg(handle));
+                media_svc_debug ("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));
+       media_svc_debug("ID: %d", sqlite3_column_int (stmt, 0));
+       media_svc_debug("Display name: %s", (const char*)sqlite3_column_text (stmt, 2));
 
        if(err < 0)
        {
-               mediainfo_dbg ("mb-svc load data failed");
+               media_svc_debug ("mb-svc load data failed");
                sqlite3_finalize(stmt);
                return -1;
        }