Removed Code related to local db 08/50408/4
authorShubham Kumar <shubham.srib@samsung.com>
Wed, 28 Oct 2015 10:36:19 +0000 (16:06 +0530)
committerShubham Kumar <shubham.srib@samsung.com>
Wed, 28 Oct 2015 10:58:47 +0000 (16:28 +0530)
Change-Id: Id4d958e76dde2afb07af2df2d53e6ad18966a8eb
Signed-off-by: Shubham Kumar <shubham.srib@samsung.com>
CMakeLists.txt
service/CMakeLists.txt [deleted file]
service/include/mp-service-debug.h [deleted file]
service/include/mp-service-square.h [deleted file]
service/include/music-service.h [deleted file]
service/src/mp-service-main.c [deleted file]
service/src/mp-service-square.c [deleted file]
src/common/include/mp-db-client.h [deleted file]
src/common/mp-db-client.c [deleted file]
src/include/music.h
src/view/mp-player-view.c

index a6ae067047d36025c5fb3a4c42638884f88604e3..8b02aa3a62fa533640953e68035a04049098d3ce 100755 (executable)
@@ -93,7 +93,6 @@ SET(COMMON_SRCS
        src/core/mp-language-mgr.c
        src/core/mp-playlist-mgr.c
        src/core/mp-view-mgr.c
-#      src/core/mp-cloud.c
        src/core/mp-floating-widget-mgr.c
        src/core/mp-watch-dog.c
        src/common/mp-common.c
@@ -107,12 +106,7 @@ SET(COMMON_SRCS
        src/common/mp-app.c
        src/common/mp-media-info.c
        src/common/mp-ta.c
-#      src/common/mp-recommend.c
-#      src/common/mp-albumart.c
-       src/common/mp-db-client.c
        src/common/mp-file-util.c
-#      src/view/mp-lyric-view.c
-#      src/view/mp-mw-lyric-view.c
        src/widget/mp-lyric.c
        src/widget/mp-search.c
        src/widget/mp-smart-event-box.c
@@ -139,12 +133,10 @@ SET(COMMON_SRCS
        src/view/mp-search-view.c
        src/view/mp-set-as-view.c
        src/view/mp-now-playing-list-view.c
-#      src/view/mp-square-playlist-view.c
        src/view/mp-list-view.c
        src/view/mp-view.c
        src/view/mp-edit-view.c
        src/view/mp-genre-detail-view.c
-#      src/view/mp-square-layout.c
 
        src/widget/mp-list.c
        src/widget/mp-track-list.c
@@ -157,26 +149,15 @@ SET(COMMON_SRCS
        src/widget/mp-artist-detail-list.c
        src/widget/mp-folder-list.c
        src/widget/mp-now-playing-list.c
-#      src/widget/mp-square-list.c
 
 
 #START_PUBLIC_REMOVED_STRING
-#      src/core/mp-wifidirect-mgr.c
-#      src/core/mp-music-view-mgr.c
-#      src/core/mp-s-beam.c
-#      src/core/mp-context.c
-#      src/core/mp-voice-control-mgr.c
-#      src/core/mp-crypto.c
        src/core/mp-collect-color-sort.c
        src/core/mp-collect-color.c
        src/view/mp-setting-view.c
        src/view/mp-detail-view.c
-#      src/view/mp-album-booklet-view.c
-#      src/view/mp-artist-booklet-view.c
        src/widget/mp-mini-player.c
        src/widget/mp-notification.c
-#      src/view/mp-square-view-new.c
-#      src/view/mp-make-offline-view.c
        src/widget/mp-notification.c
 #END_START_PUBLIC_REMOVED_STRING
 )
@@ -191,11 +172,8 @@ SET(COMMON_INCLUDE
        src/view/include
        src/widget/include
 #START_PUBLIC_REMOVED_STRING
-#      src/dali/include
        src/dmc-player/include
        src/setting/src/include
-       #src/rich_info/src/include
-       #src/rich_info/src/core/include
        src/lib/include
 #END_START_PUBLIC_REMOVED_STRING
 )
diff --git a/service/CMakeLists.txt b/service/CMakeLists.txt
deleted file mode 100644 (file)
index 8fd7765..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(music-player-service C)
-
-#LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
-#LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/server)
-
-SET(DAEMON music-player-service)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(music-player-app_control_pkgs REQUIRED
-       capi-appfw-service-application
-       dlog
-       elementary
-       storage
-)
-
-FOREACH(flag ${music-player-app_control_pkgs_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-INCLUDE_DIRECTORIES(
-    ${CMAKE_CURRENT_SOURCE_DIR}/include
-    ${CMAKE_SOURCE_DIR}/src/common/include
-)
-
-SET(SRCS
-    ${CMAKE_CURRENT_SOURCE_DIR}/src/mp-service-main.c
-    ${CMAKE_CURRENT_SOURCE_DIR}/src/mp-service-square.c
-    ${CMAKE_SOURCE_DIR}/src/common/mp-media-info.c
-)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-SET(music-player-app_control_pkgs_LDFLAGS "${pkgs_LDFLAGS} ${music-player-app_control_pkgs_LDFLAGS}")
-
-ADD_EXECUTABLE(${DAEMON} ${SRCS})
-SET_TARGET_PROPERTIES(${DAEMON} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS})
-TARGET_LINK_LIBRARIES(${DAEMON} ${music-player-app_control_pkgs_LDFLAGS})
-
-TARGET_LINK_LIBRARIES(${DAEMON} -L${CMAKE_SOURCE_DIR}/src/lib -l_MusicSquare_TIZEN)
-
-
-INSTALL(TARGETS ${DAEMON} DESTINATION ${BINDIR})
-
diff --git a/service/include/mp-service-debug.h b/service/include/mp-service-debug.h
deleted file mode 100644 (file)
index c26920b..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/* 
-* Copyright (c) 2000-2015 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 __MP_APP_CONTROL_DEBUG_H__
-#define __MP_APP_CONTROL_DEBUG_H__
-
-
-#include <stdio.h>
-#include <unistd.h>
-#include "assert.h"
-#include <linux/unistd.h>
-#include "mp-file-util.h"
-
-//#ifdef MP_DEBUG_MODE
-#define ENABLE_CHECK_START_END_FUNCTION        //101219 aramie.kim support enter leave debug message
-//#endif
-
-#define LOG_COLOR_RESET    "\033[0m"
-#define LOG_COLOR_RED      "\033[31m"
-#define LOG_COLOR_YELLOW   "\033[33m"
-#define LOG_COLOR_GREEN        "\033[32m"
-#define LOG_COLOR_BLUE         "\033[36m"
-#define LOG_COLOR_PURPLE   "\033[35m"
-
-
-#define ENABLE_LOG_SYSTEM
-
-#ifdef ENABLE_LOG_SYSTEM
-
-#define USE_DLOG_SYSTEM
-
-#define gettid() syscall(__NR_gettid)
-
-#define DATA_DIR       DATA_PREFIX"/data"
-
-#ifdef USE_DLOG_SYSTEM
-#include <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif //LOG_TAG
-
-#define LOG_TAG "SVC_MUSIC_PLAYER"
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#define DEBUG_TRACE(fmt, arg...)       LOGD_IF(TRUE, "[TID:%d]   "fmt"\n", gettid(), ##arg)
-#define INFO_TRACE(fmt, arg...)        LOGI_IF(TRUE, "[TID:%d]   "fmt"\n", gettid(), ##arg)
-#define WARN_TRACE(fmt, arg...)        LOGW_IF(TRUE, "[TID:%d]   "fmt"\n", gettid(), ##arg)
-#define ERROR_TRACE(fmt, arg...)       LOGW_IF(TRUE, "[TID:%d]   "fmt"\n", gettid(), ##arg)
-#define mp_debug_temp(fmt, arg...)     LOGD_IF(TRUE, "[TID:%d]   "fmt"\n", gettid(), ##arg)
-
-#define SECURE_DEBUG(fmt, args...)     SECURE_LOGD("[T:%d] " fmt, gettid(), ##args)
-#define SECURE_INFO(fmt, args...)      SECURE_LOGI("[T:%d] " fmt, gettid(), ##args)
-#define SECURE_ERROR(fmt, args...)     SECURE_LOGD("[T:%d] " fmt, gettid(), ##args)
-
-
-#else // use USE_DLOG_SYSTEM
-
-#define DEBUG_TRACE(fmt, arg...) do{fprintf(stderr, "[%s : %s-%d]\t - \n", __FILE__, __func__, __LINE__);\
-           fprintf (stderr, __VA_ARGS__);}while(0)
-#define INFO_TRACE(fmt, arg...) do{fprintf(stderr, "[%s : %s-%d]\t - \n", __FILE__, __func__, __LINE__);\
-           fprintf (stderr, __VA_ARGS__);}while(0)
-#define WARN_TRACE(fmt, arg...) do{fprintf(stderr, "[%s : %s-%d]\t - \n", __FILE__, __func__, __LINE__);\
-           fprintf (stderr, __VA_ARGS__);}while(0)
-#define ERROR_TRACE(fmt, arg...) do{fprintf(stderr, "[%s : %s-%d]\t - \n", __FILE__, __func__, __LINE__);\
-           fprintf (stderr, __VA_ARGS__);}while(0)
-#define mp_debug_temp(fmt, arg...) do{fprintf(stderr, "[%s : %s-%d]\t - \n", __FILE__, __func__, __LINE__);\
-           fprintf (stderr, __VA_ARGS__);}while(0)
-#endif //USE_DLOG_SYSTEM
-
-#define DEBUG_TRACE_FUNC() DEBUG_TRACE("")
-
-#else //ENABLE_LOG_SYSTEM
-#define mp_debug(fmt, arg...)
-#define DEBUG_TRACE(fmt, arg...)
-#define INFO_TRACE(fmt, arg...)
-#define WARN_TRACE(fmt, arg...)
-#define ERROR_TRACE(fmt, arg...)
-#define mp_debug_temp(fmt, arg...)
-#endif //ENABLE_LOG_SYSTEM
-
-#ifdef ENABLE_CHECK_START_END_FUNCTION
-#define startfunc              DEBUG_TRACE("+-  START -------------------------");
-#define endfunc                DEBUG_TRACE("+-  END  --------------------------");
-#define exceptionfunc  ERROR_TRACE("#################################      CRITICAL ERROR   #####################################");
-#else
-#define startfunc
-#define endfunc
-#define exceptionfunc
-#endif
-
-#define mp_debug(fmt, arg...)                  LOGD_IF(TRUE,  LOG_COLOR_GREEN"[TID:%d]   "fmt""LOG_COLOR_RESET, gettid(), ##arg)
-#define mp_error(fmt, arg...)                  LOGW_IF(TRUE,  LOG_COLOR_RED"[TID:%d]# ERROR   CHECK  #   "fmt""LOG_COLOR_RESET, gettid(), ##arg)
-
-#define TIMER_TRACE(fmt, arg...)       do { if (mp_file_exists("/tmp/mp_show_timer_log")) LOGD_IF(TRUE,  LOG_COLOR_PURPLE"[TID:%d]   "fmt""LOG_COLOR_RESET, gettid(), ##arg); } while (0)
-
-#undef FREE
-#define FREE(ptr) free(ptr); ptr = NULL;
-
-#undef SAFE_FREE
-#define SAFE_FREE(x)       if(x) {free(x); x = NULL;}
-
-#undef IF_FREE
-#define IF_FREE(ptr) if (ptr) {free(ptr); ptr = NULL;}
-
-#define mp_ret_if(expr) do { \
-       if(expr) { \
-               DEBUG_TRACE("");\
-               return; \
-       } \
-} while (0)
-#define mp_retv_if(expr, val) do { \
-       if(expr) { \
-               DEBUG_TRACE("");\
-               return (val); \
-       } \
-} while (0)
-
-#define mp_retm_if(expr, fmt, arg...) do { \
-       if(expr) { \
-               DEBUG_TRACE(fmt, ##arg); \
-               return; \
-       } \
-} while (0)
-
-#define mp_retvm_if(expr, val, fmt, arg...) do { \
-       if(expr) { \
-               DEBUG_TRACE(fmt, ##arg); \
-               return (val); \
-       } \
-} while (0)
-
-#define MP_CHECK_EXCEP(expr) do { \
-       if(!(expr)) { \
-               ERROR_TRACE("CRITICAL ERROR ########################################## CHECK BELOW ITEM");\
-               goto mp_exception;\
-       } \
-} while (0)
-
-#define MP_CHECK_VAL(expr, val)                mp_retvm_if(!(expr),val,"INVALID PARM RETURN val:0x%x", val)
-#define MP_CHECK_NULL(expr)            mp_retvm_if(!(expr),NULL,"INVALID PARM RETURN NULL")
-#define MP_CHECK_FALSE(expr)           mp_retvm_if(!(expr),FALSE,"INVALID PARM RETURN FALSE")
-#define MP_CHECK_CANCEL(expr)          mp_retvm_if(!(expr), ECORE_CALLBACK_CANCEL, "INVALID PARAM RETURN")
-#define MP_CHECK(expr)                                 mp_retm_if(!(expr),"INVALID PARAM RETURN")
-
-#define mp_assert(expr) do { \
-       if(!(expr)) { \
-               ERROR_TRACE("CRITICAL ERROR ########################################## CHECK BELOW ITEM");\
-               assert(FALSE); \
-       } \
-} while (0)
-
-
-
-#endif // __MP_APP_CONTROL_DEBUG_H__
-
diff --git a/service/include/mp-service-square.h b/service/include/mp-service-square.h
deleted file mode 100755 (executable)
index 2e958b7..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* 
-* Copyright (c) 2000-2015 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 __MP_APP_CONTROL_SQUARE_H_
-#define __MP_APP_CONTROL_SQUARE_H_
-
-#include "mp-service-debug.h"
-
-mp_square_mgr_t *mp_app_control_square_mgr_create(void);
-bool mp_app_control_square_mgr_destory(mp_square_mgr_t *square_mgr);
-int mp_app_control_square_mgr_update(mp_square_mgr_t *square_mgr);
-int mp_app_control_square_mgr_update_diff_only(mp_square_mgr_t *square_mgr);
-int mp_app_control_square_mgr_reset(mp_square_mgr_t *square_mgr);
-int mp_app_control_square_mgr_records_count_get(mp_square_mgr_t *square_mgr, int *count);
-
-#endif /* __MP_SQUARE_MGR_H_ */
diff --git a/service/include/music-service.h b/service/include/music-service.h
deleted file mode 100755 (executable)
index 0ce5f09..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/* 
-* Copyright (c) 2000-2015 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 __DEF_music_app_control_H_
-#define __DEF_music_app_control_H_
-
-struct appdata
-{
-        mp_square_mgr_t  *square_mgr;
-};
-
-
-
-#endif /* __DEF_music_app_control_H_ */
diff --git a/service/src/mp-service-main.c b/service/src/mp-service-main.c
deleted file mode 100644 (file)
index f33e219..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/* 
-* Copyright (c) 2000-2015 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 <stdbool.h>
-#include <service_app.h>
-
-#include "music-service.h"
-#include "mp-service-square.h"
-#include "mp-service-debug.h"
-
-struct appdata *g_ad;
-
-static bool
-_app_control_app_create(void *data)
-{
-       startfunc;
-
-       struct appdata *ad = data;
-       g_ad = (struct appdata *)data;
-       MP_CHECK_VAL(ad, EINA_FALSE);
-
-       ad->square_mgr = mp_app_control_square_mgr_create();
-       MP_CHECK_FALSE(ad->square_mgr);
-
-       return true;
-}
-
-
-static void
-_app_control_app_terminate(void *data)
-{
-       startfunc;
-
-       struct appdata *ad = data;
-       MP_CHECK(ad);
-
-       mp_app_control_square_mgr_destory(ad->square_mgr);
-}
-
-
-static void
-app_control_app_control(app_control_h app_control, void *data)
-{
-       startfunc;
-
-       struct appdata *ad = data;
-       MP_CHECK(ad);
-
-       int ret = mp_app_control_square_mgr_update_diff_only(ad->square_mgr);
-
-       if (ret != 0) {
-               ERROR_TRACE("square mgr update diff error");
-       }
-}
-
-
-int
-main(int argc, char *argv[])
-{
-       startfunc;
-
-       struct appdata ad;
-       service_app_event_callback_s ops;
-
-       memset(&ops, 0x0, sizeof(service_app_event_callback_s));
-       ops.create = _app_control_app_create;
-       ops.terminate = _app_control_app_terminate;
-       ops..app_control = app_control_app_control;
-       ops.low_memory = NULL;
-       ops.low_battery = NULL;
-
-       memset(&ad, 0x0, sizeof(struct appdata));
-
-       return service_app_main(argc, argv, &ops, &ad);
-}
-
diff --git a/service/src/mp-service-square.c b/service/src/mp-service-square.c
deleted file mode 100755 (executable)
index 0af3d21..0000000
+++ /dev/null
@@ -1,1431 +0,0 @@
-/* 
-* Copyright (c) 2000-2015 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 <util-func.h>
-#include "mp-media-info.h"
-#include "mp-service-square.h"
-/*#include "mp-file-tag-info.h" */
-#include <dlfcn.h>
-#include "mp-file-util.h"
-
-#define MP_SQUARE_ARM_LIB_PATH 
-       "/usr/apps/org.tizen.music-player/lib/lib_MusicSquare_TIZEN.so"
-#define MP_SQUARE_I386_LIB_PATH 
-       "/usr/apps/org.tizen.music-player/lib/libMusicSquare_Tizen_SL.so"
-
-#define MP_SQUARE_DB_NAME DATA_DIR"/.music_square.db"
-#define MP_SQUARE_DB_TABLE_NAME "music_square"
-
-/* query string */
-#define MP_SQUARE_DB_TABLE_EXIST_QUERY_STRING  
-       "select name from sqlite_master WHERE name='%q';"
-#define MP_SQUARE_DB_DELETE_TABLE_QUERY_STRING  "DELETE FROM %q ;"
-#define MP_SQUARE_DB_DROP_TABLE_QUERY_STRING  "DROP TABLE %q ;"
-
-#define MP_SQUARE_DB_TABLE_RECORD_INSERT "INSERT INTO music_square (path, \
-       "score_excite, score_cheerful, score_violent, year, title) VALUES \
-       "('%q', %f, %f, %f, %d, '%q');"
-
-#define MP_SQUARE_DB_TABLE_RECORD_COUNT_ALL 
-       "select count(*) FROM music_square;"
-
-#define MP_SQUARE_DB_RAND_MAX 5
-#define MP_SQUARE_DB_QUERY_STR_LEN_MAX 512
-#define MP_SQUARE_DB_FILE_PATH_LEN_MAX 512
-
-#define SQL_SAFE_FREE(sql_string)
-               if (sql_string) sqlite3_free(sql_string)
-
-typedef struct {
-       int id;
-       char path[MP_SQUARE_MUSIC_FILE_PATH_LEN_MAX+1]; /* music path */
-       mp_square_position_t pos_mood;
-       mp_square_position_t pos_year;
-       mp_square_position_t pos_added;
-       mp_square_position_t pos_time;
-       char title[MP_SQUARE_MUSIC_FILE_PATH_LEN_MAX+1]; /* music title */
-       int year;
-       time_t added_time;
-       time_t played_time;
-       double scores[3];
-} mp_square_record_t;
-
-static int _mp_app_control_square_mgr_db_sql_query(mp_square_mgr_t 
-       *square_mgr, const char *sql_str);
-static int _mp_app_control_square_mgr_db_table_create(mp_square_mgr_t 
-       *square_mgrconst, const char *table_name);
-static int _mp_app_control_square_mgr_db_table_exist(mp_square_mgr_t 
-       *square_mgrconst, const char *table_name);
-static int _mp_app_control_square_mgr_db_table_drop(mp_square_mgr_t 
-       *square_mgrconst, const char *table_name);
-static int _mp_app_control_square_mgr_db_clear(mp_square_mgr_t *square_mgr);
-static int _mp_app_control_square_mgr_db_busy_handler(void *pData, int count);
-static int _mp_app_control_square_mgr_db_disconnect(sqlite3 *handle);
-static int _mp_app_control_square_mgr_db_connect(sqlite3 **handle);
-static int _mp_app_control_square_mgr_db_table_record_insert(
-       mp_square_mgr_t *square_mgr, mp_square_record_t *record);
-static int _mp_app_control_square_mgr_db_table_media_append(
-       mp_square_mgr_t *square_mgrconst);
-static int _mp_app_control_square_mgr_MpWitchMoodEngineInit(
-       mp_square_mgr_t *square_mgr);
-static double* _mp_app_control_square_mgr_MpWitchMoodEngineEXE(
-       mp_square_mgr_t *square_mgr, const char *path);
-static int _mp_app_control_square_mgr_MpWitchMoodEngineRelease
-       (mp_square_mgr_t *square_mgr);
-
-int WitchMoodEngineInit(void)
-{
-}
-int WitchMoodEngineRelease(void)
-{
-}
-double *WitchMoodEngineEXE(const char *path)
-{
-}
-
-static int _mp_app_control_square_mgr_MpWitchMoodEngineInit(
-               mp_square_mgr_t *square_mgr)
-{
-       DEBUG_TRACE_FUNC();
-       int ret = WitchMoodEngineInit();
-       return ret;
-}
-
-static double* _mp_app_control_square_mgr_MpWitchMoodEngineEXE(
-       mp_square_mgr_t *square_mgr, const char *path)
-{
-       /* DEBUG_TRACE_FUNC(); */
-       return WitchMoodEngineEXE((char *)path);
-}
-
-static int _mp_app_control_square_mgr_MpWitchMoodEngineRelease
-       (mp_square_mgr_t *square_mgr)
-{
-       DEBUG_TRACE_FUNC();
-       return WitchMoodEngineRelease();
-}
-
-static int _mp_app_control_square_mgr_db_sql_query(mp_square_mgr_t *square_mgr
-       , const char *sql_str)
-{
-       /* DEBUG_TRACE_FUNC(); */
-       MP_CHECK_VAL(square_mgr, -1);
-       MP_CHECK_VAL(square_mgr->sqlite_handle, -1);
-       MP_CHECK_VAL(sql_str, -1);
-
-       int err = -1;
-       char *zErrMsg = NULL;
-
-       /* mp_debug("SQL = [%s]", sql_str); */
-
-       err = sqlite3_exec(square_mgr->sqlite_handle, sql_str, NULL, 
-               NULL, &zErrMsg);
-
-       if (SQLITE_OK != err) {
-               mp_error("failed to execute [%s], err[%d]", zErrMsg, err);
-       }
-
-       if (zErrMsg)
-               sqlite3_free(zErrMsg);
-
-       return err;
-}
-
-static int _mp_app_control_square_mgr_db_table_create(mp_square_mgr_t 
-               *square_mgr, const char *table_name)
-{
-       DEBUG_TRACE_FUNC();
-
-       MP_CHECK_VAL(square_mgr, -1);
-       MP_CHECK_VAL(square_mgr->sqlite_handle, -1);
-       MP_CHECK_VAL(table_name, -1);
-
-       int err = -1;
-       MP_CHECK_VAL(table_name, MP_SQUARE_DB_ERROR_INVALID_PARAMETER);
-
-       char *sql = sqlite3_mprintf("create table if not exists %s (\
-                       _id
-                               INTEGER PRIMARY KEY AUTOINCREMENT,\
-                       path                    TEXT NOT NULL,\
-                       pos_mood                INTEGER,\
-                       pos_year                INTEGER,\
-                       pos_added               INTEGER,\
-                       pos_time                INTEGER,\
-                       score_excite    DOUBLE,\
-                       score_cheerful  DOUBLE,\
-                       score_violent   DOUBLE,\
-                       year                    INTEGER,\
-                       title                   TEXT NOT NULL\
-                       );"
-                       , table_name);
-       err = _mp_app_control_square_mgr_db_sql_query(square_mgr, sql);
-       sqlite3_free(sql);
-       if (err != SQLITE_OK) {
-               mp_error("It failed to create square table (%d)", err);
-               if (err == MP_SQUARE_DB_ERROR_CONNECT) {
-                       return err;
-               }
-               return MP_SQUARE_DB_ERROR_INTERNAL;
-       }
-
-       return MP_SQUARE_DB_ERROR_NONE;
-}
-
-static int _mp_app_control_square_mgr_db_table_exist(
-       mp_square_mgr_t *square_mgr, const char *table_name)
-{
-       DEBUG_TRACE_FUNC();
-
-       MP_CHECK_VAL(square_mgr, -1);
-       MP_CHECK_VAL(square_mgr->sqlite_handle, -1);
-       MP_CHECK_VAL(table_name, -1);
-
-       int ret = -1;
-       char szTableName[MP_SQUARE_DB_FILE_PATH_LEN_MAX + 1] = { '0', };
-       char *pszTempName = NULL;
-       sqlite3_stmt *pstStmt_pb = NULL;
-       int len = 0;
-
-       sqlite3 *handle = square_mgr->sqlite_handle;
-       MP_CHECK_VAL(handle, MP_SQUARE_DB_ERROR_INTERNAL);
-
-       char *szQuery = sqlite3_mprintf(MP_SQUARE_DB_TABLE_EXIST_QUERY_STRING, 
-               table_name);
-       MP_CHECK_VAL(szQuery, MP_SQUARE_DB_ERROR_INTERNAL);
-       len = strlen(szQuery);
-       ret =
-           sqlite3_prepare_v2(handle, szQuery, len, &pstStmt_pb,
-                              NULL);
-       SQL_SAFE_FREE(szQuery);
-       if (SQLITE_OK != ret) {
-               mp_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
-               mp_debug("query string is %s\n", szQuery);
-               return MP_SQUARE_DB_ERROR_INTERNAL;
-       }
-
-       ret = sqlite3_step(pstStmt_pb);
-       if (SQLITE_ROW != ret) {
-               mp_debug("end of row [%s]\n", sqlite3_errmsg(handle));
-               mp_debug("query string is %s\n", szQuery);
-               sqlite3_finalize(pstStmt_pb);
-               return MP_SQUARE_DB_ERROR_INTERNAL;
-       }
-
-       pszTempName = (char *)sqlite3_column_text(pstStmt_pb, 0);
-       if (NULL != pszTempName) {
-               len = strlen(szQuery);
-               strncpy(szTableName, pszTempName, len);
-       }
-       sqlite3_finalize(pstStmt_pb);
-
-       ret = !(strcmp(table_name, szTableName));
-
-       return ret;
-}
-
-static int _mp_app_control_square_mgr_db_table_drop(mp_square_mgr_t 
-       *square_mgr, const char *table_name)
-{
-       DEBUG_TRACE_FUNC();
-
-       MP_CHECK_VAL(square_mgr, -1);
-       MP_CHECK_VAL(square_mgr->sqlite_handle, -1);
-       MP_CHECK_VAL(table_name, -1);
-
-       int err;
-
-       mp_debug("_table_drop--enter\n");
-
-       err = _mp_app_control_square_mgr_db_table_exist(square_mgr, table_name);
-       if (err > 0) {
-               char *query_string = sqlite3_mprintf(
-                       MP_SQUARE_DB_DROP_TABLE_QUERY_STRING, table_name);
-               MP_CHECK_VAL(query_string, MP_SQUARE_NORMAL_ERROR);
-               err = _mp_app_control_square_mgr_db_sql_query(
-                       square_mgr, query_string);
-               SQL_SAFE_FREE(query_string);
-               if (err < 0) {
-                       mp_debug("truncate table failed\n");
-                       mp_debug("query string is %s\n",
-                               query_string);
-
-                       return MP_SQUARE_DB_ERROR_INTERNAL;
-               }
-       }
-
-       mp_debug("_table_drop--leave\n");
-       return MP_SQUARE_DB_ERROR_NONE;
-}
-
-static int _mp_app_control_square_mgr_db_clear(mp_square_mgr_t *square_mgr)
-{
-       DEBUG_TRACE_FUNC();
-
-       int ret = 0;
-
-       ret = _mp_app_control_square_mgr_db_table_drop(square_mgr, 
-               MP_SQUARE_DB_TABLE_NAME);
-
-       return ret;
-}
-
-static int _mp_app_control_square_mgr_db_busy_handler(void *pData, int count)
-{
-       DEBUG_TRACE_FUNC();
-
-       usleep(50000);
-
-       mp_debug("_square_db_busy_handler called : %d\n", count);
-
-       return 100 - count;
-}
-
-static int _mp_app_control_square_mgr_db_disconnect(sqlite3 *handle)
-{
-       DEBUG_TRACE_FUNC();
-
-       /* disconnect from database-server */
-       if (handle == NULL)
-               return 0;
-
-       int ret = 0;
-
-       ret = sqlite3_close(handle);
-
-       if (SQLITE_OK != ret) {
-               mp_debug("can not disconnect database\n");
-               mp_debug("[sqlite] %s\n", sqlite3_errmsg(handle));
-
-               return MP_SQUARE_DB_ERROR_DISCONNECT;
-       }
-       handle = NULL;
-
-       mp_debug("Disconnected successfully\n");
-       return 0;
-}
-
-static int _mp_app_control_square_mgr_db_connect(sqlite3 **handle)
-{
-       DEBUG_TRACE_FUNC();
-
-       if (handle == NULL) {
-               mp_debug("Invalid input parameter error");
-               return MP_SQUARE_DB_ERROR_INVALID_PARAMETER;
-       }
-
-       int ret = 0;
-       ret = sqlite3_open(MP_SQUARE_DB_NAME, handle);
-
-       if (SQLITE_OK != ret) {
-               mp_debug("can not connect to db-server\n");
-               if (*handle)
-                       mp_debug("[sqlite] %s\n", sqlite3_errmsg(*handle));
-               *handle = NULL;
-
-               return MP_SQUARE_DB_ERROR_CONNECT;
-       }
-
-       /* Register Busy handler */
-       ret = sqlite3_busy_handler(*handle, 
-               _mp_app_control_square_mgr_db_busy_handler, NULL);
-       if (SQLITE_OK != ret) {
-               mp_debug("Fail to register busy handler\n");
-               if (*handle)
-                       mp_debug("[sqlite] %s\n", sqlite3_errmsg(*handle));
-
-               sqlite3_close(*handle);
-               if (SQLITE_OK != ret) {
-                       mp_debug("can not disconnect database\n");
-                       return MP_SQUARE_DB_ERROR_DISCONNECT;
-               }
-               *handle = NULL;
-
-               return MP_SQUARE_DB_ERROR_CONNECT;
-       }
-
-       mp_debug("connected to db-server\n");
-
-       return 0;
-}
-
-static int _mp_app_control_square_mgr_db_table_record_insert(mp_square_mgr_t 
-               *square_mgr, mp_square_record_t *record)
-{
-       DEBUG_TRACE_FUNC();
-
-       MP_CHECK_VAL(square_mgr, -1);
-       MP_CHECK_VAL(square_mgr->sqlite_handle, -1);
-       MP_CHECK_VAL(record, -1);
-
-       if (record == NULL) {
-               ERROR_TRACE("record pointer is null");
-               return MP_SQUARE_DB_ERROR_INVALID_PARAMETER;
-       }
-
-       int err = -1;
-       char *query_string = NULL;
-
-       query_string =
-               sqlite3_mprintf(MP_SQUARE_DB_TABLE_RECORD_INSERT,
-                       record->path,
-                       record->scores[0],
-                       record->scores[1],
-                       record->scores[2],
-                       record->year,
-                       record->title);
-
-       SECURE_DEBUG("[%s]", query_string);
-
-       err = _mp_app_control_square_mgr_db_sql_query(square_mgr, query_string);
-       sqlite3_free(query_string);
-
-       if (err < 0) {
-               mp_debug("Inserting record failed\n");
-               mp_debug("query string is %s\n", query_string);
-               return MP_SQUARE_DB_ERROR_INTERNAL;
-       }
-
-       return err;
-}
-
-static gint _mp_app_control_square_mgr_record_excite_score_sort_func(
-       gconstpointer a, gconstpointer b)
-{
-       if (!a || !b)
-               return 1;
-
-       mp_square_record_t *a_record = (mp_square_record_t *)a;
-       mp_square_record_t *b_record = (mp_square_record_t *)b;
-
-       return (gint)((b_record->scores[0] - a_record->scores[0]) * 100);
-}
-
-
-static int _mp_app_control_square_mgr_db_load(mp_square_mgr_t *square_mgr)
-{
-       startfunc;
-
-       MP_CHECK_VAL(square_mgr, -1);
-       MP_CHECK_VAL(square_mgr->sqlite_handle, -1);
-
-       int err = -1;
-
-       int count = 0;
-       err = mp_app_control_square_mgr_records_count_get(square_mgr, &count);
-       MP_CHECK_VAL(count, -1);
-       DEBUG_TRACE("record count = %d", count);
-
-       sqlite3 *handle = square_mgr->sqlite_handle;
-       sqlite3_stmt *stmt = NULL;
-
-       const char *q_string = 
-               "SELECT _id, score_excite, score_cheerful, score_violent, \
-               year FROM music_square";
-       err = sqlite3_prepare_v2(handle, q_string, 
-               strlen(q_string), &stmt, NULL);
-       if (SQLITE_OK != err) {
-               mp_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
-               mp_debug("query string is %s\n", q_string);
-               return MP_SQUARE_DB_ERROR_INTERNAL;
-       }
-
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
-               mp_square_record_t *record = calloc(1, 
-                       sizeof(mp_square_record_t));
-               record->id = (int)sqlite3_column_int(stmt, 0);
-               record->scores[0] = (double)sqlite3_column_double(stmt, 1);
-               record->scores[1] = (double)sqlite3_column_double(stmt, 2);
-               record->scores[2] = (double)sqlite3_column_double(stmt, 3);
-               record->year = (int)sqlite3_column_int(stmt, 4);
-
-               DEBUG_TRACE("[%d] %f, %f, %f, %d", record->id, record->
-                       scores[0], record->scores[1], record->scores[2], 
-                       record->year);
-               square_mgr->base_list = g_list_insert_sorted(square_mgr->
-                       base_list, record, _mp_app_control_square_mgr_record_
-                       excite_score_sort_func);
-       }
-
-       sqlite3_finalize(stmt);
-       endfunc;
-       return 0;
-}
-
-static inline int _get_cell_num(int *cell, int index)
-{
-       int i = 0;
-       int j = 0;
-       while (i < 5) {
-               j += cell[i];
-               /* DEBUG_TRACE("i = %d, j= %d index = %d", i, j, index); */
-               if (j > index)
-                       return i;
-
-               ++i;
-       }
-
-       return 0;
-}
-
-static int _mp_app_control_square_mgr_db_update(mp_square_mgr_t *square_mgr)
-{
-       startfunc;
-
-       MP_CHECK_VAL(square_mgr, -1);
-       MP_CHECK_VAL(square_mgr->sqlite_handle, -1);
-       MP_CHECK_VAL(square_mgr->base_list, -1);
-
-       GList *list = square_mgr->base_list;
-
-       int ret = 0;
-       ret = _mp_app_control_square_mgr_db_sql_query(square_mgr, "BEGIN");
-       if (ret) {
-               mp_error("transaction BEGIN failed");
-               return ret;
-       }
-
-       int cell[MP_SQUARE_CELL_MAX][MP_SQUARE_CELL_MAX];
-       int i = 0;
-       int j = 0;
-       for (i = 0; i < MP_SQUARE_CELL_MAX; i++) {
-               int total = g_list_length(square_mgr->mood_x[i]);
-               int item_per_cell = total / MP_SQUARE_CELL_MAX;
-               int remain = total % MP_SQUARE_CELL_MAX;
-
-               for (j = 0; j < MP_SQUARE_CELL_MAX; j++) {
-                       cell[i][j] = item_per_cell;
-                       if (j < remain)
-                               cell[i][j]++;
-
-                       /* DEBUG_TRACE("sell[%d][%d] = [%d]", i, j, 
-                                       cell[i][j]); */
-               }
-       }
-
-       for (i = 0; i < g_list_length(list) ; i++) {
-               mp_square_record_t *record = g_list_nth_data(list, i);
-               int y = record->pos_mood.y;
-               record->pos_mood.y = y + 1;
-               record->pos_mood.x = _get_cell_num(cell[y], 
-                       g_list_index(square_mgr->mood_x[y], record)) + 1;
-
-               record->pos_year.y = y + 1;
-               record->pos_year.x = _get_cell_num(cell[y], g_list_index(
-                       square_mgr->year_x[y], record)) + 1;
-
-               char *query = sqlite3_mprintf(
-               "UPDATE music_square SET pos_mood=%d, pos_year=%d WHERE _id=%d"
-               , record->pos_mood, record->pos_year, record->id);
-               DEBUG_TRACE("MOOD[%d, %d] => %f", record->pos_mood.x, 
-                       record->pos_mood.y, record->scores[0]);
-               DEBUG_TRACE("YEAR[%d, %d] => %d", record->pos_mood.x, 
-                       record->pos_mood.y, record->year);
-               ret = _mp_app_control_square_mgr_db_sql_query
-                       (square_mgr, query);
-               SQL_SAFE_FREE(query);
-               if (ret) {
-                       mp_error("Inserting record failed");
-                       _mp_app_control_square_mgr_db_sql_query
-                               (square_mgr, "ROLLBACK");
-                       return ret;
-               }
-       }
-
-       ret = _mp_app_control_square_mgr_db_sql_query(square_mgr, "COMMIT");
-       if (ret) {
-               mp_error("transaction COMMIT failed");
-               return ret;
-       }
-
-       endfunc;
-       return 0;
-}
-
-static int _mp_app_control_square_mgr_db_update_track_less_than_25
-       (mp_square_mgr_t *square_mgr)
-{
-       startfunc;
-
-       MP_CHECK_VAL(square_mgr, -1);
-       MP_CHECK_VAL(square_mgr->sqlite_handle, -1);
-       MP_CHECK_VAL(square_mgr->base_list, -1);
-
-       GList *list = square_mgr->base_list;
-
-       int ret = 0;
-       ret = _mp_app_control_square_mgr_db_sql_query(square_mgr, "BEGIN");
-       if (ret) {
-               mp_error("transaction BEGIN failed");
-               return ret;
-       }
-
-       int i = 0;
-
-       for (i = 0; i < g_list_length(list) ; i++) {
-               mp_square_record_t *record = g_list_nth_data(list, i);
-               record->pos_mood.y = MP_SQUARE_CELL_MAX - i%MP_SQUARE_CELL_MAX;
-               record->pos_mood.x = MP_SQUARE_CELL_MAX - 
-                       (int)(i/MP_SQUARE_CELL_MAX);
-
-               record->pos_year.y = MP_SQUARE_CELL_MAX - i%MP_SQUARE_CELL_MAX;
-               record->pos_year.x = MP_SQUARE_CELL_MAX - 
-                       (int)(i/MP_SQUARE_CELL_MAX);
-
-               char *query = sqlite3_mprintf(
-               "UPDATE music_square SET pos_mood=%d, pos_year=%d WHERE _id=%d"
-               , record->pos_mood, record->pos_year, record->id);
-               DEBUG_TRACE("MOOD[%d, %d] => %f", record->pos_mood.x, 
-                       record->pos_mood.y, record->scores[0]);
-               DEBUG_TRACE("YEAR[%d, %d] => %d", record->pos_mood.x, 
-                       record->pos_mood.y, record->year);
-               ret = _mp_app_control_square_mgr_db_sql_query(
-                       square_mgr, query);
-               SQL_SAFE_FREE(query);
-               if (ret) {
-                       mp_error("Inserting record failed");
-                       _mp_app_control_square_mgr_db_sql_query(
-                               square_mgr, "ROLLBACK");
-                       return ret;
-               }
-       }
-
-       ret = _mp_app_control_square_mgr_db_sql_query(square_mgr, "COMMIT");
-       if (ret) {
-               mp_error("transaction COMMIT failed");
-               return ret;
-       }
-
-       endfunc;
-       return 0;
-}
-
-static gint _mp_app_control_square_mgr_mood_sort_func(gconstpointer a, 
-               gconstpointer b)
-{
-       if (!a || !b)
-               return 1;
-
-       mp_square_record_t *a_record = (mp_square_record_t *)a;
-       mp_square_record_t *b_record = (mp_square_record_t *)b;
-
-       double a_mood = a_record->scores[1] - a_record->scores[2];
-       double b_mood = b_record->scores[1] - b_record->scores[2];
-
-       return (gint)((b_mood - a_mood) * 100);
-}
-
-static gint _mp_app_control_square_mgr_year_sort_func(gconstpointer a, 
-               gconstpointer b)
-{
-       if (!a || !b)
-               return 1;
-
-       mp_square_record_t *a_record = (mp_square_record_t *)a;
-       mp_square_record_t *b_record = (mp_square_record_t *)b;
-
-       return (a_record->year - b_record->year);
-}
-
-static void
-_mp_app_control_square_mgr_position_recalculate(mp_square_mgr_t *square_mgr)
-{
-       MP_CHECK(square_mgr);
-       GList *list = square_mgr->base_list;
-       MP_CHECK(list);
-
-       int total_count = g_list_length(list);
-
-       int i = 0;
-       int item_per_cell = total_count / MP_SQUARE_CELL_MAX;
-       int current_item_count = 0;
-       int remain = total_count % MP_SQUARE_CELL_MAX;
-
-       int cell = 0;
-       for (i = 0; i < total_count; i++) {
-               mp_square_record_t *record = g_list_nth_data(list, i);
-               record->pos_mood.y = cell;
-
-               square_mgr->mood_x[cell] = g_list_insert_sorted(
-                       square_mgr->mood_x[cell], record, 
-                       _mp_app_control_square_mgr_mood_sort_func);
-               square_mgr->year_x[cell] = g_list_insert_sorted(
-                       square_mgr->year_x[cell], record, 
-                       _mp_app_control_square_mgr_year_sort_func);
-               ++current_item_count;
-
-               if (current_item_count == item_per_cell) {
-                       if (remain > 0) {
-                               ++i;
-                               record = g_list_nth_data(list, i);
-                               record->pos_mood.y = cell;
-                               square_mgr->mood_x[cell] = g_list_insert_sorted
-                               (square_mgr->mood_x[cell], record, 
-                               _mp_app_control_square_mgr_mood_sort_func);
-                               square_mgr->year_x[cell] = g_list_insert_sorted
-                               (square_mgr->year_x[cell], record, 
-                               _mp_app_control_square_mgr_year_sort_func);
-                               --remain;
-                       }
-
-                       ++cell;
-                       current_item_count = 0;
-               }
-       }
-}
-
-static void _mp_app_control_square_mgr_db_table_records_update(
-               mp_square_mgr_t *square_mgr)
-{
-       startfunc;
-       MP_CHECK(square_mgr);
-
-       int i = 0;
-
-       /* load all data from DB */
-       _mp_app_control_square_mgr_db_load(square_mgr);
-       MP_CHECK(square_mgr->base_list);
-
-       if (square_mgr->media_count >= 25) {
-               /* recalculate pos */
-               _mp_app_control_square_mgr_position_recalculate(square_mgr);
-
-               /* update db */
-               _mp_app_control_square_mgr_db_update(square_mgr);
-
-               /* free list data */
-               for (i = 0; i < MP_SQUARE_CELL_MAX; i++) {
-                       if (square_mgr->mood_x[i]) {
-                               g_list_free(square_mgr->mood_x[i]);
-                               square_mgr->mood_x[i] = NULL;
-                       }
-
-                       if (square_mgr->year_x[i]) {
-                               g_list_free(square_mgr->year_x[i]);
-                               square_mgr->year_x[i] = NULL;
-                       }
-               }
-       } else {
-               _mp_app_control_square_mgr_db_update_track_less_than_25(
-                       square_mgr);
-       }
-
-       for (i = 0; i < g_list_length(square_mgr->base_list); i++) {
-               mp_square_record_t *record = g_list_nth_data(square_mgr->
-                       base_list, i);
-               IF_FREE(record);
-       }
-
-       g_list_free(square_mgr->base_list);
-       square_mgr->base_list = NULL;
-
-
-
-       endfunc;
-}
-
-static void _mp_app_control_square_mgr_db_table_records_append_timer_cb
-       (void *data)
-{
-       DEBUG_TRACE_FUNC();
-
-       TIMER_TRACE();
-       mp_square_mgr_t *square_mgr = data;
-       MP_CHECK(square_mgr);
-
-       int index = square_mgr->current_index;
-       int count = square_mgr->media_count;
-       bool exit_flag = true;
-
-       ERROR_TRACE("COUNT:%d", count);
-       while (exit_flag) {
-               ERROR_TRACE("go");
-               if (square_mgr->current_index < count && square_mgr->
-                               total_count && !square_mgr->terminal_status) {
-                       ERROR_TRACE("id: %d", square_mgr->current_index);
-                       mp_square_record_t *record = (mp_square_record_t *)
-                               square_mgr->record;
-                       MP_CHECK(record);
-
-                       if (square_mgr->added_media_array[square_mgr->
-                                       current_index] == false) {
-                               /* mp_debug("index=%d,count=%d\n", 
-                                               index, count); */
-                               char *path = NULL;
-                               char *title = NULL;
-                               char *fid = NULL;
-                               char *year = NULL;
-                               time_t added_time;
-                               memset(&added_time, 0, sizeof(time_t));
-                               time_t played_time;
-                               memset(&played_time, 0, sizeof(time_t));
-
-                               mp_media_info_h audio_handle = NULL;
-                               audio_handle = mp_media_info_list_nth_item(
-                                       square_mgr->svc_handle, 
-                                       square_mgr->current_index);
-                               mp_media_info_get_file_path(audio_handle, 
-                                       &path);
-                               MP_CHECK(path);
-
-                               mp_media_info_get_title(audio_handle, &title);
-                               mp_media_info_get_media_id(audio_handle, &fid);
-                               mp_media_info_get_year(audio_handle, &year);
-                               mp_media_info_get_added_time(audio_handle, 
-                                       &added_time);
-                               mp_media_info_get_played_time(audio_handle, 
-                                       &played_time);
-                               DEBUG_TRACE("year=%s", year);
-                               /* DEBUG_TRACE("added_time=%ld", added_time);
-                               DEBUG_TRACE("played_time=%ld", played_time);
-                               DEBUG_TRACE("path=%s", path); */
-
-                               if (path != NULL)
-                                       strncpy(record[square_mgr->record_
-                                               count].path, path, sizeof(
-                                               record[square_mgr->record_
-                                               count].path)-1);
-                               if (title != NULL)
-                                       strncpy(record[square_mgr->record_
-                                               count].title, title, sizeof(
-                                               record[square_mgr->record_
-                                               count].title)-1);
-                               if (year != NULL)
-                                       /* strncpy(record[square_mgr->record_
-                                               count].year, year, sizeof(
-                                               record[square_mgr->record_
-                                               count].year)-1); */
-                                       record[square_mgr->record_count].year 
-                                               = atoi(year);
-                               record[square_mgr->record_count].added_time = 
-                                       added_time;
-                               record[square_mgr->record_count].added_time = 
-                                       played_time;
-
-                               double *scores = NULL;
-                               struct stat s_stat;
-                               int result = stat(path, &s_stat);
-                               if (result == -1) {
-                                       ERROR_TRACE("stat:error=%d", result);
-                               }
-
-                               if (mp_file_exists(path) && result != -1 && 
-                                               s_stat.st_size > 0) {
-                                       scores = _mp_app_control_square_mgr_
-                                               MpWitchMoodEngineEXE(
-                                               square_mgr, path);
-                                       /* mp_debug("scores=%p", scores); */
-                                       if (scores) {
-                                               /* mp_debug("scores[0]=%lf,
-                                                               scores[1]=%lf,
-                                                               scores[2]=%lf"
-                                                               , scores[0], 
-                                                               scores[1], 
-                                                               scores[2]); */
-                                               record[square_mgr->record_
-                                                       count].scores[0] = 
-                                                       scores[0];
-                                               record[square_mgr->record_
-                                                       count].scores[1] = 
-                                                       scores[1];
-                                               record[square_mgr->record
-                                                       _count].scores[2] = 
-                                                       scores[2];
-                                       }
-                               }
-
-                               _mp_app_control_square_mgr_db_table_record_
-                                       insert(square_mgr, 
-                                       &record[square_mgr->record_count]);
-                               square_mgr->record_count++;
-                       }
-                       square_mgr->current_index++;
-               } else {
-                       ERROR_TRACE("else");
-                       square_mgr->terminal_status = false;
-                       IF_FREE(square_mgr->record);
-
-                       square_mgr->current_index = -1;
-                       square_mgr->record_count = -1;
-                       square_mgr->total_count = -1;
-
-                       if (square_mgr->svc_handle)
-                               mp_media_info_list_destroy
-                                       (square_mgr->svc_handle);
-                       square_mgr->svc_handle = NULL;
-
-                       SAFE_FREE(square_mgr->added_media_array);
-
-               /* release music square engine */
-                       _mp_app_control_square_mgr_
-                               MpWitchMoodEngineRelease(square_mgr);
-
-               /* update db */
-                       _mp_app_control_square_mgr_db_table_records_update
-                               (square_mgr);
-
-                       /* update square list 
-                       _mp_app_control_square_mgr_list_destroy(square_mgr);
-                       _mp_app_control_square_mgr_list_create(square_mgr); */
-
-                       exit_flag = false;
-
-                       }
-               }
-
-       }
-
-static int _mp_app_control_square_mgr_db_table_media_append
-       (mp_square_mgr_t *square_mgr)
-{
-       DEBUG_TRACE_FUNC();
-
-       MP_CHECK_VAL(square_mgr, -1);
-       MP_CHECK_VAL(square_mgr->svc_handle, -1);
-
-       int ret = 0;
-       int count = 0;
-       int index = 0;
-
-       if (_mp_app_control_square_mgr_db_table_exist(square_mgr, 
-                       MP_SQUARE_DB_TABLE_NAME) != 1) {
-               if (_mp_app_control_square_mgr_db_table_create(square_mgr, 
-                               MP_SQUARE_DB_TABLE_NAME) != 
-                                       MP_SQUARE_DB_ERROR_NONE)
-                       return -1;
-       }
-
-       while (index < square_mgr->media_count) {
-               if (square_mgr->added_media_array[index] == false)
-                       ++count;
-
-               ++index;
-       }
-       WARN_TRACE("Not added media count = %d", count);
-
-       mp_square_record_t *record = calloc(count, sizeof(mp_square_record_t));
-       MP_CHECK_VAL(record, -1);
-       IF_FREE(square_mgr->record);
-       square_mgr->record = record;
-
-       square_mgr->total_count = count;
-       square_mgr->record_count = 0;
-       square_mgr->current_index = 0;
-
-       if (square_mgr->total_count == 0) {
-               IF_FREE(square_mgr->record);
-       } else {
-               /* init music square engine */
-               ret = _mp_app_control_square_mgr_MpWitchMoodEngineInit
-                       (square_mgr);
-       }
-
-       ERROR_TRACE("Add timer");
-       _mp_app_control_square_mgr_db_table_records_append_timer_cb(square_mgr);
-       /* square_mgr->create_record_timer = ecore_timer_add(0.005, 
-               _mp_app_control_square_mgr_db_table_records_append_timer_cb, 
-               square_mgr);*/
-
-       return ret;
-}
-
-int _mp_app_control_square_mgr_db_table_records_list_get(
-                       mp_square_mgr_t *square_mgr,
-                       const char *q_string,
-                       GList **list_records)
-{
-       DEBUG_TRACE_FUNC();
-
-       MP_CHECK_VAL(square_mgr, -1);
-       MP_CHECK_VAL(square_mgr->sqlite_handle, -1);
-       MP_CHECK_VAL(list_records, -1);
-       MP_CHECK_VAL(q_string, -1);
-
-       sqlite3 *handle = square_mgr->sqlite_handle;
-       sqlite3_stmt *stmt = NULL;
-       int err = -1;
-
-       err =
-           sqlite3_prepare_v2(handle, q_string, strlen(q_string), &stmt, NULL);
-       if (SQLITE_OK != err) {
-               mp_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
-               mp_debug("query string is %s\n", q_string);
-               return MP_SQUARE_DB_ERROR_INTERNAL;
-       }
-
-       int i = 0;
-       int position = 0;
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
-               mp_square_item_t *item = calloc(1, sizeof(mp_square_item_t));
-
-               char *path = (char *)sqlite3_column_text(stmt, 0);
-               mp_debug("====path=%s====", path);
-               if (!mp_check_file_exist(path)) {
-                       IF_FREE(item);
-                       continue;
-               }
-               if (path != NULL)
-                       strncpy(item->path, path, 
-       MP_SQUARE_MUSIC_FILE_PATH_LEN_MAX);
-
-               position = sqlite3_column_int(stmt, 1);
-               item->pos.x = position&0xFF;
-               item->pos.y = position>>8;
-
-               *list_records = g_list_append(*list_records, item);
-/*
-               char *title = (char*)sqlite3_column_text(stmt, 2);
-               mp_debug("====title=%s====", title);
-*/
-               i++;
-       }
-
-       sqlite3_finalize(stmt);
-
-       return 0;
-}
-
-
-
-int mp_app_control_square_mgr_records_count_get(mp_square_mgr_t *square_mgr, 
-       int *count)
-{
-       /* DEBUG_TRACE_FUNC();*/
-
-       MP_CHECK_VAL(square_mgr, -1);
-       MP_CHECK_VAL(square_mgr->sqlite_handle, -1);
-
-       sqlite3 *handle = square_mgr->sqlite_handle;
-       sqlite3_stmt *stmt = NULL;
-
-       int err = -1;
-       char query[MP_SQUARE_DB_QUERY_STR_LEN_MAX] = {0};
-
-       snprintf(query, sizeof(query), MP_SQUARE_DB_TABLE_RECORD_COUNT_ALL);
-
-       err = sqlite3_prepare_v2(handle, query, -1, &stmt, NULL);
-       if (err != SQLITE_OK) {
-               mp_error("prepare error [%s]", sqlite3_errmsg(handle));
-               return MP_SQUARE_DB_ERROR_INTERNAL;
-       }
-
-       /* mp_debug("[SQL query] : %s", query);*/
-
-       err = sqlite3_step(stmt);
-       if (err != SQLITE_ROW) {
-               mp_error("end of row [%s]", sqlite3_errmsg(handle));
-               sqlite3_finalize(stmt);
-               return MP_SQUARE_DB_ERROR_INTERNAL;
-       }
-       *count = sqlite3_column_int(stmt, 0);
-
-       sqlite3_finalize(stmt);
-
-       return MP_SQUARE_DB_ERROR_NONE;
-}
-
-int mp_app_control_square_mgr_reset(mp_square_mgr_t *square_mgr)
-{
-       DEBUG_TRACE_FUNC();
-
-       MP_CHECK_FALSE(square_mgr);
-       MP_CHECK_FALSE(square_mgr->sqlite_handle);
-
-       int ret = 0;
-
-       /* clear square db */
-       ret = _mp_app_control_square_mgr_db_clear(square_mgr);
-       if (ret != MP_SQUARE_DB_ERROR_NONE) {
-               return ret;
-       }
-
-       return 0;
-}
-
-int mp_app_control_square_mgr_update(mp_square_mgr_t *square_mgr)
-{
-       DEBUG_TRACE_FUNC();
-
-       MP_CHECK_FALSE(square_mgr);
-       MP_CHECK_FALSE(square_mgr->sqlite_handle);
-
-       int ret = 0;
-
-       /* update square db */
-       ret = _mp_app_control_square_mgr_db_clear(square_mgr);
-       if (ret != MP_SQUARE_DB_ERROR_NONE) {
-               return ret;
-       }
-
-       ret = _mp_app_control_square_mgr_db_table_create
-               (square_mgr, MP_SQUARE_DB_TABLE_NAME);
-       if (ret != MP_SQUARE_DB_ERROR_NONE) {
-               return ret;
-       }
-
-       int count = 0;
-       ret = mp_media_info_list_count(MP_TRACK_ALL, 
-               NULL, NULL, NULL, 0, &count);
-       MP_CHECK_VAL(ret == 0, -1);
-       MP_CHECK_VAL(count > 0, -1);
-       mp_debug("track_count: %d", count);
-
-       if (square_mgr->svc_handle)
-               mp_media_info_list_destroy(square_mgr->svc_handle);
-       square_mgr->svc_handle = NULL;
-       ret = mp_media_info_list_create(&square_mgr->svc_handle, MP_TRACK_ALL, 
-               NULL, NULL, NULL, 0, 0, count);
-       MP_CHECK_VAL(ret == 0, -1);
-
-       square_mgr->media_count = count;
-       SAFE_FREE(square_mgr->added_media_array);
-       square_mgr->added_media_array = calloc(count, sizeof(bool));
-       mp_assert(square_mgr->added_media_array);
-
-       ret = _mp_app_control_square_mgr_db_table_media_append(square_mgr);
-
-       return ret;
-}
-
-static int
-_mp_app_control_square_mgr_find_path_from_media_list(mp_media_list_h media_list
-       , int count, bool *added_media_array, const char *finding_path)
-{
-       MP_CHECK_VAL(media_list, -1);
-       MP_CHECK_VAL(count > 0, -1);
-       MP_CHECK_VAL(added_media_array, -1);
-       MP_CHECK_VAL(finding_path, -1);
-
-       int index = 0;
-       mp_media_info_h media = NULL;
-       char *path = NULL;
-       while (index < count) {
-               if (added_media_array[index] == false) {
-                       media = mp_media_info_list_nth_item(media_list, index);
-                       if (media) {
-                               mp_media_info_get_file_path(media, &path);
-                               if (!g_strcmp0(path, finding_path)) {
-                                       /*mp_debug("index of [%s] is [%d]", 
-                                       path, index);*/
-                                       return index;
-                               }
-                       }
-               }
-
-               ++index;
-       }
-
-       return -1;
-}
-
-static void
-_mp_app_control_square_mgr_compare_list(mp_square_mgr_t *square_mgr, 
-       GList *path_list, bool *record_check_list)
-{
-       startfunc;
-       MP_CHECK(square_mgr);
-
-       mp_media_list_h media_list = square_mgr->svc_handle;
-       MP_CHECK(media_list);
-
-       bool *added_media_array = square_mgr->added_media_array;
-       MP_CHECK(added_media_array);
-
-       int media_count = square_mgr->media_count;
-       MP_CHECK(media_count > 0);
-
-       MP_CHECK(path_list);
-       MP_CHECK(record_check_list);
-
-       int record_index = 0;
-       int media_index = -1;
-       int record_count = g_list_length(path_list);
-       while (record_index < record_count) {
-               char *path = g_list_nth_data(path_list, record_index);
-               if (path) {
-                       media_index = _mp_app_control_square_mgr_find_path_from
-                               _media_list(media_list, media_count, 
-                                       added_media_array, path);
-                       if (media_index >= 0) {
-                               added_media_array[media_index] = true;
-                               record_check_list[record_index] = true;
-                       }
-               }
-
-               ++record_index;
-       }
-}
-
-static void
-_mp_app_control_square_mgr_remove_record_from_square_db(mp_square_mgr_t 
-       *square_mgr, GList *path_list, bool *exist_path_list_array)
-{
-       startfunc;
-       MP_CHECK(square_mgr);
-       MP_CHECK(path_list);
-       MP_CHECK(exist_path_list_array);
-
-       int index = 0;
-       int record_count = g_list_length(path_list);
-       int max_rec = (record_count > 20) ? 20 : record_count;
-
-       while (index < record_count) {
-               int  loop_cnt = 0;
-               char *where = NULL;
-               char *path = NULL;
-               while (loop_cnt < max_rec && index < record_count) {
-                       if (exist_path_list_array[index] == false) {
-                               path = g_list_nth_data(path_list, index);
-                               if (path && strlen(path)) {
-                                       mp_debug("remove path : %s, index %d", 
-                                               path, index);
-                                       char *cond = sqlite3_mprintf(
-                                               "path=\'%q\'", path);
-                                       if (where) {
-                                               char *old = where;
-                                               where = sqlite3_mprintf(
-                                                       "%s OR %s", 
-                                                       old, cond);
-                                               sqlite3_free(cond);
-                                               sqlite3_free(old);
-                                       } else {
-                                               where = cond;
-                                       }
-                                       loop_cnt++;
-                               }
-                       }
-
-                       ++index;
-
-               }
-
-               if (where == NULL) {
-                       mp_debug("no remove record");
-                       return;
-               }
-
-               char *query_string = sqlite3_mprintf(
-                       "DELETE FROM music_square WHERE ( %s )", where);
-               sqlite3_free(where);
-               mp_debug("Query : %s", query_string);
-               _mp_app_control_square_mgr_db_sql_query(square_mgr, 
-                       query_string);
-               sqlite3_free(query_string);
-       }
-       endfunc;
-}
-
-int _mp_app_control_square_mgr_db_table_path_list_get(
-       mp_square_mgr_t *square_mgr, GList **path_list)
-{
-       startfunc;
-
-       MP_CHECK_VAL(square_mgr, -1);
-       MP_CHECK_VAL(square_mgr->sqlite_handle, -1);
-       MP_CHECK_VAL(path_list, -1);
-
-       sqlite3 *handle = square_mgr->sqlite_handle;
-       sqlite3_stmt *stmt = NULL;
-       int err = -1;
-
-       const char *q_string = "SELECT path FROM music_square";
-       err = sqlite3_prepare_v2
-       (handle, q_string, strlen(q_string), &stmt, NULL);
-       if (SQLITE_OK != err) {
-               mp_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
-               mp_debug("query string is %s\n", q_string);
-               return MP_SQUARE_DB_ERROR_INTERNAL;
-       }
-
-       int i = 0;
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
-               char *path = (char *)sqlite3_column_text(stmt, 0);
-               if (path) {
-                       mp_debug("[path : %s]", path);
-                       *path_list = g_list_append(*path_list, g_strdup(path));
-               }
-               i++;
-       }
-
-       sqlite3_finalize(stmt);
-       endfunc;
-       return 0;
-}
-
-
-int mp_app_control_square_mgr_update_diff_only(mp_square_mgr_t *square_mgr)
-{
-       DEBUG_TRACE_FUNC();
-
-       MP_CHECK_FALSE(square_mgr);
-       MP_CHECK_FALSE(square_mgr->sqlite_handle);
-
-       int ret = 0;
-
-       ret = mp_media_info_connect();
-       MP_CHECK_VAL(ret == 0, -1);
-
-       GList *path_list = NULL;
-       int path_count = 0;
-       bool *exist_path_list_array = NULL;
-
-       if (_mp_app_control_square_mgr_db_table_exist
-                       (square_mgr, MP_SQUARE_DB_TABLE_NAME) != 1) {
-               if (_mp_app_control_square_mgr_db_table_create
-                               (square_mgr, MP_SQUARE_DB_TABLE_NAME) != 
-                                       MP_SQUARE_DB_ERROR_NONE) {
-                       ret = -1;
-                       goto exception;
-               }
-       }
-
-       if (square_mgr->svc_handle) {
-               mp_media_info_list_destroy(square_mgr->svc_handle);
-               square_mgr->svc_handle = NULL;
-       }
-       SAFE_FREE(square_mgr->added_media_array);
-       square_mgr->media_count = 0;
-
-       /* get media list */
-       ret = mp_media_info_list_count(
-       MP_TRACK_ALL, NULL, NULL, NULL, 0, &square_mgr->media_count);
-       MP_CHECK_VAL(ret == 0, -1);
-
-       mp_debug("track_count: %d", square_mgr->media_count);
-       if (square_mgr->media_count > 0) {
-               square_mgr->added_media_array = 
-       calloc(square_mgr->media_count, sizeof(bool));
-               mp_assert(square_mgr->added_media_array);
-
-               ret = mp_media_info_list_create(&square_mgr->svc_handle, 
-       MP_TRACK_ALL, NULL, NULL, NULL, 0, 0, square_mgr->media_count);
-               if (ret != 0) {
-                       mp_error("mp_media_info_list_create().. [0x%x]", ret);
-                       goto exception;
-               }
-       } else {
-               _mp_app_control_square_mgr_db_clear(square_mgr);
-               return -1;
-       }
-
-       /* get list from Square DB */
-       if (_mp_app_control_square_mgr_db_table_path_list_get
-       (square_mgr, &path_list) != 0) {
-               mp_error(
-       "_mp_app_control_square_mgr_db_table_records_list_get()");
-               ret = -1;
-               goto exception;
-       }
-
-       path_count = g_list_length(path_list);
-       mp_debug("square DB count = %d", path_count);
-       if (path_count > 0) {
-               exist_path_list_array = calloc(path_count, sizeof(bool));
-               mp_assert(exist_path_list_array);
-       }
-
-       /* compare */
-       _mp_app_control_square_mgr_compare_list(square_mgr, 
-       path_list, exist_path_list_array);
-
-       /* remove records from Sqaure DB */
-       _mp_app_control_square_mgr_remove_record_from_square_db(square_mgr, 
-       path_list, exist_path_list_array);
-       SAFE_FREE(exist_path_list_array);
-       GList *temp = path_list;
-       while (temp) {
-               char *path = temp->data;
-               SAFE_FREE(path);
-               temp = temp->next;
-       }
-       g_list_free(path_list);
-       path_list = NULL;
-
-       /* append new media to Sqaure DB */
-       ret = _mp_app_control_square_mgr_db_table_media_append(square_mgr);
-       if (ret != 0) {
-               mp_error(
-       "_mp_app_control_square_mgr_db_table_media_append() ... [0x%x]", ret);
-               goto exception;
-       }
-
-       mp_media_info_disconnect();
-
-       return 0;
-
-exception:
-       if (square_mgr->svc_handle) {
-               mp_media_info_list_destroy(square_mgr->svc_handle);
-               square_mgr->svc_handle = NULL;
-       }
-       square_mgr->media_count = 0;
-       SAFE_FREE(square_mgr->added_media_array);
-       SAFE_FREE(exist_path_list_array);
-
-       return ret;
-}
-
-bool mp_app_control_square_mgr_destory(mp_square_mgr_t *square_mgr)
-{
-       DEBUG_TRACE_FUNC();
-
-       MP_CHECK_FALSE(square_mgr);
-       MP_CHECK_FALSE(square_mgr->sqlite_handle);
-
-       if (square_mgr->svc_handle) {
-               mp_media_info_list_destroy(square_mgr->svc_handle);
-               square_mgr->svc_handle = NULL;
-       }
-       SAFE_FREE(square_mgr->added_media_array);
-
-       /* disconnect db */
-       if (square_mgr->sqlite_handle != NULL)
-               _mp_app_control_square_mgr_db_disconnect(
-       square_mgr->sqlite_handle);
-
-       /* free square mgr */
-       free(square_mgr);
-       square_mgr = NULL;
-
-       return true;
-}
-
-mp_square_mgr_t *mp_app_control_square_mgr_create(void)
-{
-       startfunc;
-       DEBUG_TRACE_FUNC();
-
-       mp_square_mgr_t *square_mgr = NULL;
-       square_mgr = calloc(1, sizeof(mp_square_mgr_t));
-       MP_CHECK_NULL(square_mgr);
-       square_mgr->record_count = -1;
-       square_mgr->total_count = -1;
-
-       int ret = 0;
-
-       ret = _mp_app_control_square_mgr_db_connect(&square_mgr->sqlite_handle);
-
-       if (ret == 0) {
-               if (_mp_app_control_square_mgr_db_table_exist(square_mgr, 
-       MP_SQUARE_DB_TABLE_NAME) != 1) {
-                       ERROR_TRACE("Db not exist");
-               }
-       }
-
-       return square_mgr;
-}
-
diff --git a/src/common/include/mp-db-client.h b/src/common/include/mp-db-client.h
deleted file mode 100755 (executable)
index e5a16dc..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* 
-* Copyright (c) 2000-2015 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 __MP_DB_CLIENT_H__
-#define __MP_DB_CLIENT_H__
-
-#include <glib.h>
-#include <sqlite3.h>
-#include "mp-square-mgr.h"
-
-typedef struct
-{
-       struct appdata *ad;
-
-       sqlite3 *sqlite_handle;
-
-        GList *path_list;
-
-} mp_dbc_mgr_t;
-
-
-bool mp_db_client_get_mood_by_path(mp_dbc_mgr_t *dbc_mgr, int *mood, char *path);
-int mp_db_client_get_paths_by_mood(mp_dbc_mgr_t *dbc_mgr, int mood);
-int mp_db_client_mgr_create(struct appdata *ad);
-bool mp_db_client_mgr_destory(mp_dbc_mgr_t *dbc_mgr);
-
-#endif
-
diff --git a/src/common/mp-db-client.c b/src/common/mp-db-client.c
deleted file mode 100755 (executable)
index c5ea547..0000000
+++ /dev/null
@@ -1,290 +0,0 @@
-/* 
-* Copyright (c) 2000-2015 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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. 
-* 
-*/
-
-#ifdef GBSBUILD
-#include <util-func.h>
-#endif
-#include <dlfcn.h>
-#include "music.h"
-#include "mp-util.h"
-#include "mp-db-client.h"
-
-#define SQL_SAFE_FREE(sql_string)\
-if (sql_string) {\
-        sqlite3_free(sql_string);\
-        sql_string = NULL;\
-}
-
-#define MP_SQUARE_ARM_LIB_PATH DATA_PREFIX"/lib/lib_MusicSquare_TIZEN.so"
-#define MP_SQUARE_I386_LIB_PATH DATA_PREFIX"/lib/libMusicSquare_Tizen_SL.so"
-
-#define MP_SQUARE_DB_NAME DATA_DIR"/.music_square.db"
-#define MP_SQUARE_DB_TABLE_NAME "music_square"
-
-#define MP_SQUARE_DB_RAND_MAX 5
-#define MP_SQUARE_DB_QUERY_STR_LEN_MAX 512
-#define MP_SQUARE_DB_FILE_PATH_LEN_MAX 512
-
-/* query string */
-#define MP_SQUARE_DB_TABLE_EXIST_QUERY_STRING  "select name from sqlite_master WHERE name='%q';"
-#define MP_SQUARE_DB_DELETE_TABLE_QUERY_STRING  "DELETE FROM %q ;"
-#define MP_SQUARE_DB_DROP_TABLE_QUERY_STRING  "DROP TABLE %q ;"
-
-static int _mp_db_client_disconnect(sqlite3 *handle)
-{
-       startfunc;
-
-       /* disconnect from database-server */
-       if (handle == NULL)
-               return 0;
-
-       int ret = 0;
-
-       ret = sqlite3_close(handle);
-
-       if (SQLITE_OK != ret) {
-               mp_debug("can not disconnect database\n");
-               mp_debug("[sqlite] %s\n", sqlite3_errmsg(handle));
-
-               return MP_SQUARE_DB_ERROR_DISCONNECT;
-       }
-       handle = NULL;
-
-       mp_debug("Disconnected successfully\n");
-       return 0;
-}
-
-static int _mp_db_client_busy_handler(void *pData, int count)
-{
-       startfunc;
-
-       sleep(1);
-
-       mp_debug("_square_db_busy_handler called : %d\n", count);
-
-       return 100 - count;
-}
-
-static int _mp_db_client_connect(sqlite3 **handle)
-{
-       startfunc;
-
-       if (handle == NULL) {
-               mp_debug("Invalid input parameter error");
-               return MP_SQUARE_DB_ERROR_INVALID_PARAMETER;
-       }
-
-       int ret = 0;
-       ret = sqlite3_open(MP_SQUARE_DB_NAME, handle);
-
-       if (SQLITE_OK != ret) {
-               mp_debug("can not connect to db-server\n");
-               if (*handle)
-                       mp_debug("[sqlite] %s\n", sqlite3_errmsg(*handle));
-               *handle = NULL;
-
-               return MP_SQUARE_DB_ERROR_CONNECT;
-       }
-
-       /* Register Busy handler */
-       MP_CHECK_VAL(*handle, -1);
-       ret = sqlite3_busy_handler(*handle, _mp_db_client_busy_handler, NULL);
-       if (SQLITE_OK != ret) {
-               mp_debug("Fail to register busy handler\n");
-               if (*handle)
-                       mp_debug("[sqlite] %s\n", sqlite3_errmsg(*handle));
-
-               sqlite3_close(*handle);
-               *handle = NULL;
-
-               return MP_SQUARE_DB_ERROR_CONNECT;
-       }
-
-       mp_debug("connected to db-server\n");
-
-       return 0;
-}
-
-static int _mp_db_client_table_exist(mp_dbc_mgr_t *dbc_mgr, const char *table_name)
-{
-       startfunc;
-
-       MP_CHECK_VAL(dbc_mgr, -1);
-       MP_CHECK_VAL(dbc_mgr->sqlite_handle, -1);
-       MP_CHECK_VAL(table_name, -1);
-
-       int ret = -1;
-       char szTableName[MP_SQUARE_DB_FILE_PATH_LEN_MAX + 1] = { '0', };
-       char *pszTempName = NULL;
-       sqlite3_stmt *pstStmt_pb = NULL;
-       int len = 0;
-
-       sqlite3 *handle = dbc_mgr->sqlite_handle;
-       MP_CHECK_VAL(handle, MP_SQUARE_DB_ERROR_INTERNAL);
-
-       char *szQuery = sqlite3_mprintf(MP_SQUARE_DB_TABLE_EXIST_QUERY_STRING, table_name);
-       MP_CHECK_VAL(szQuery, MP_SQUARE_DB_ERROR_INTERNAL);
-       len = strlen(szQuery);
-       ret =
-           sqlite3_prepare_v2(handle, szQuery, len, &pstStmt_pb,
-                              NULL);
-       if (SQLITE_OK != ret) {
-               mp_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
-                SQL_SAFE_FREE(szQuery);
-               return MP_SQUARE_DB_ERROR_INTERNAL;
-       }
-
-       ret = sqlite3_step(pstStmt_pb);
-       if (SQLITE_ROW != ret) {
-               mp_debug("end of row [%s]\n", sqlite3_errmsg(handle));
-               sqlite3_finalize(pstStmt_pb);
-                SQL_SAFE_FREE(szQuery);
-               return MP_SQUARE_DB_ERROR_INTERNAL;
-       }
-
-       pszTempName = (char *)sqlite3_column_text(pstStmt_pb, 0);
-       if (NULL != pszTempName) {
-               len = strlen(szQuery);
-               strncpy(szTableName, pszTempName, len);
-       }
-       sqlite3_finalize(pstStmt_pb);
-
-       ret = !(strcmp(table_name, szTableName));
-
-       SQL_SAFE_FREE(szQuery);
-
-       return ret;
-}
-
-
-bool mp_db_client_get_mood_by_path(mp_dbc_mgr_t *dbc_mgr, int *mood, char *path)
-{
-       MP_CHECK_FALSE(dbc_mgr);
-       MP_CHECK_FALSE(dbc_mgr->sqlite_handle);
-       MP_CHECK_FALSE(path);
-
-       bool ret = false;
-
-       char *query = g_strdup_printf("SELECT %s FROM music_square WHERE path=\"%s\"", "pos_mood", path);
-       MP_CHECK_FALSE(query);
-
-       sqlite3_stmt *stmt = NULL;
-       int err = sqlite3_prepare_v2(dbc_mgr->sqlite_handle, query, strlen(query), &stmt, NULL);
-       if (SQLITE_OK != err) {
-               mp_debug("prepare error [%s]\n", sqlite3_errmsg(dbc_mgr->sqlite_handle));
-               mp_debug("query string is %s\n", query);
-
-               SAFE_FREE(query);
-               return false;
-       }
-
-       if (sqlite3_step(stmt) == SQLITE_ROW) {
-               *mood = sqlite3_column_int(stmt, 0);
-               DEBUG_TRACE("mood: %d   path: %s", *mood, path);
-               ret = true;
-       }
-       sqlite3_finalize(stmt);
-
-       SAFE_FREE(query);
-       return ret;
-}
-
-int mp_db_client_get_paths_by_mood(mp_dbc_mgr_t *dbc_mgr, int mood)
-{
-        startfunc;
-
-       MP_CHECK_FALSE(dbc_mgr);
-       MP_CHECK_FALSE(dbc_mgr->sqlite_handle);
-
-       bool ret = false;
-
-        dbc_mgr->path_list = NULL;
-
-       char *query = g_strdup_printf("SELECT %s FROM music_square WHERE pos_mood=\"%d\"", "path", mood);
-       MP_CHECK_FALSE(query);
-
-       sqlite3_stmt *stmt = NULL;
-       int err = sqlite3_prepare_v2(dbc_mgr->sqlite_handle, query, strlen(query), &stmt, NULL);
-       if (SQLITE_OK != err) {
-               mp_debug("prepare error [%s]\n", sqlite3_errmsg(dbc_mgr->sqlite_handle));
-               mp_debug("query string is %s\n", query);
-
-               SAFE_FREE(query);
-               return false;
-       }
-
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
-               char *path = (char*)sqlite3_column_text(stmt, 0);
-                dbc_mgr->path_list = g_list_append(dbc_mgr->path_list, g_strdup(path));
-               ret = true;
-       }
-       sqlite3_finalize(stmt);
-
-       SAFE_FREE(query);
-
-
-       return ret;
-}
-
-
-int mp_db_client_mgr_create(struct appdata *ad)
-{
-        startfunc;
-
-       MP_CHECK_VAL(ad, -1);
-       //MP_CHECK_VAL(!ad->dbc_mgr, -1);
-
-       mp_dbc_mgr_t *dbc_mgr = NULL;
-        dbc_mgr = calloc(1, sizeof(mp_dbc_mgr_t));
-       MP_CHECK_VAL(dbc_mgr, -1);
-
-        ad->dbc_mgr = dbc_mgr;
-       //ad->dbc_mgr->ad = ad;
-
-       int ret = 0;
-       ret = _mp_db_client_connect(&(ad->dbc_mgr->sqlite_handle));
-
-       if (ret == 0) {
-               if (_mp_db_client_table_exist(ad->dbc_mgr, MP_SQUARE_DB_TABLE_NAME) != 1) {
-                        ERROR_TRACE("table not exsit");
-               }
-       }
-
-       return ret;
-}
-
-bool mp_db_client_mgr_destory(mp_dbc_mgr_t *dbc_mgr)
-{
-       DEBUG_TRACE_FUNC();
-
-       MP_CHECK_FALSE(dbc_mgr);
-       MP_CHECK_FALSE(dbc_mgr->sqlite_handle);
-
-       /* disconnect db */
-       if (dbc_mgr->sqlite_handle != NULL)
-               _mp_db_client_disconnect(dbc_mgr->sqlite_handle);
-
-        //g_list_free(dbc_mgr->path_list);
-
-       /* free square mgr */
-       free(dbc_mgr);
-       dbc_mgr = NULL;
-
-       return true;
-}
-
-
index da83ae6e4272e08b12ffaad4df79764d7000f006..2fb88f1f5dc14a1d82d7a011dfde7632f7ceeafc 100755 (executable)
@@ -51,7 +51,6 @@
 
 #include "mp-lyric.h"
 #include "mp-widget.h"
-#include "mp-db-client.h"
 
 #include "mp-view-mgr.h"
 #include "mp-popup.h"
@@ -444,7 +443,6 @@ struct appdata
        bool desktop_mode;
 #endif
 
-        mp_dbc_mgr_t *dbc_mgr;
 
        Evas_Object *more_btn_popup;
        mp_more_button_type_e more_btn_type;
index a50594e55350a0fc8a41ef566cfc1fb730509978..1b68c147a13dad5f5372475cf8f1a98d3ce5d805 100755 (executable)
@@ -39,7 +39,6 @@
 #include "mp-edit-callback.h"
 #include "mp-setting-ctrl.h"
 #include "mp-edit-view.h"
-#include "mp-db-client.h"
 #include "mp-playlist-detail-view.h"
 #include <runtime_info.h>
 #ifndef MP_SOUND_PLAYER