Update scanner process 96/48996/1 accepted/tizen/mobile/20151005.055537 accepted/tizen/tv/20151005.055553 accepted/tizen/wearable/20151005.055604 submit/tizen/20151005.042745
authorMinje Ahn <minje.ahn@samsung.com>
Mon, 5 Oct 2015 02:16:05 +0000 (11:16 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Mon, 5 Oct 2015 02:16:05 +0000 (11:16 +0900)
Change-Id: I2c5316629b5da779b04a3faaa7263ed0e915e69c
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
14 files changed:
CMakeLists.txt
include/media-svc.h
packaging/libmedia-service.spec
plugin/media-content-plugin.c
src/common/media-svc-db-utils.c
src/common/media-svc-media-folder.c
src/common/media-svc-media.c
src/common/media-svc-noti.c
src/common/media-svc-util.c
src/common/media-svc.c
src/include/common/media-svc-env.h
src/include/common/media-svc-media-folder.h
src/include/common/media-svc-noti.h
src/include/common/media-svc-util.h

index 2a1cf6a..1cc5acb 100755 (executable)
@@ -55,7 +55,7 @@ EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
 
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 dlog sqlite3 db-util libexif mm-common mm-fileinfo media-thumbnail libmedia-utils aul uuid vconf)
+pkg_check_modules(pkgs REQUIRED glib-2.0 dlog sqlite3 db-util libexif mm-common mm-fileinfo media-thumbnail libmedia-utils aul uuid vconf iniparser)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 5a77ecf..372e3b2 100755 (executable)
@@ -42,10 +42,6 @@ int media_svc_insert_item_begin(MediaSvcHandle *handle, int with_noti, int data_
 int media_svc_insert_item_end(MediaSvcHandle *handle, uid_t uid);
 int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, int is_burst, uid_t uid);
 int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid);
-#if 0
-int media_svc_move_item_begin(MediaSvcHandle *handle, int data_cnt);
-int media_svc_move_item_end(MediaSvcHandle *handle, uid_t uid);
-#endif
 int media_svc_move_item(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e src_storage, const char *src_path, media_svc_storage_type_e dest_storage, const char *dest_path, uid_t uid);
 int media_svc_set_item_validity_begin(MediaSvcHandle *handle, int data_cnt);
 int media_svc_set_item_validity_end(MediaSvcHandle *handle, uid_t uid);
@@ -61,12 +57,12 @@ int media_svc_rename_folder(MediaSvcHandle *handle, const char *storage_id, cons
 int media_svc_request_update_db(const char *db_query, uid_t uid);
 int media_svc_get_storage_type(const char *path, media_svc_storage_type_e *storage_type, uid_t uid);
 int media_svc_get_file_info(MediaSvcHandle *handle, const char *storage_id, const char *path, time_t *modified_time, unsigned long long *size);
-int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *storage_id, const char *dir_path);
+int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *storage_id, const char *dir_path, const char *folder_id, media_item_update_type_e update_type, int pid);
 int media_svc_count_invalid_items_in_folder(MediaSvcHandle *handle, const char *storage_id, const char *folder_path, int *count);
 int media_svc_check_db_upgrade(MediaSvcHandle *handle, bool *need_full_scan, uid_t uid);
 int media_svc_check_db_corrupt(MediaSvcHandle *handle);
 int media_svc_get_folder_list(MediaSvcHandle *handle, char *start_path, char ***folder_list, time_t **modified_time_list, int **item_num_list, int *count);
-int media_svc_update_folder_time(MediaSvcHandle *handle, const char *folder_path, uid_t uid);
+int media_svc_update_folder_time(MediaSvcHandle *handle, const char *storage_id, const char *folder_path, uid_t uid);
 int media_svc_publish_noti(MediaSvcHandle *handle, media_item_type_e update_item, media_item_update_type_e update_type, const char *path, media_type_e media_type, const char *uuid, const char *mime_type);
 int media_svc_get_pinyin(MediaSvcHandle *handle, const char *src_str, char **pinyin_str);
 int media_svc_check_pinyin_support(bool *support);
@@ -97,6 +93,12 @@ int media_svc_insert_item_pass2(MediaSvcHandle *handle, const char *storage_id,
 int media_svc_insert_folder_begin(MediaSvcHandle *handle, int data_cnt);
 int media_svc_insert_folder_end(MediaSvcHandle *handle, uid_t uid);
 
+int media_svc_delete_invalid_folder_by_path(MediaSvcHandle *handle, const char *storage_id, const char *folder_path, uid_t uid, int *delete_count);
+int media_svc_check_folder_exist_by_path(MediaSvcHandle *handle, const char *storage_id, const char *folder_path);
+int media_svc_check_subfolder_by_path(MediaSvcHandle *handle, const char *storage_id, const char *folder_path, int *count);
+int media_svc_get_folder_id(MediaSvcHandle *handle, const char *storage_id, const char *path, char *folder_id);
+
+
 #ifdef __cplusplus
 }
 #endif
index 3c5b9c2..6195d1e 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmedia-service
 Summary:    Media information service library for multimedia applications
-Version: 0.2.53
+Version: 0.2.54
 Release:    3
 Group:      System/Libraries
 License:    Apache-2.0 and public domain
@@ -23,6 +23,7 @@ BuildRequires:  pkgconfig(media-thumbnail)
 BuildRequires:  pkgconfig(libmedia-utils)
 BuildRequires:  pkgconfig(uuid)
 BuildRequires:  pkgconfig(libtzplatform-config)
+BuildRequires:  pkgconfig(iniparser)
 
 %description
 Media information service library for multimedia applications.
index a31d457..a3ba0b8 100755 (executable)
@@ -498,7 +498,7 @@ int update_end(const char *start_path, uid_t uid)
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int send_dir_update_noti(void *handle, const char *storage_id, const char *dir_path, char **err_msg)
+int send_dir_update_noti(void *handle, const char *storage_id, const char *dir_path, const char *folder_id, int update_type, int pid, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
@@ -507,7 +507,7 @@ int send_dir_update_noti(void *handle, const char *storage_id, const char *dir_p
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = media_svc_send_dir_update_noti(handle, storage_id, dir_path);
+       ret = media_svc_send_dir_update_noti(handle, storage_id, dir_path, folder_id, (media_item_update_type_e)update_type, pid);
        if (ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
@@ -602,7 +602,7 @@ int get_folder_list(void *handle, const char *storage_id, char *start_path, char
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int update_folder_time(void *handle, char *folder_path, uid_t uid, char **err_msg)
+int update_folder_time(void *handle, const char *storage_id, char *folder_path, uid_t uid, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
@@ -616,7 +616,7 @@ int update_folder_time(void *handle, char *folder_path, uid_t uid, char **err_ms
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = media_svc_update_folder_time(handle, folder_path, uid);
+       ret = media_svc_update_folder_time(handle, storage_id, folder_path, uid);
        if (ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
@@ -679,7 +679,7 @@ int check_storage(void * handle, const char *storage_id, const char *storage_nam
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int insert_storage(void * handle, const char *storage_id, int storage_type, const char *storage_name, const char *storage_path, uid_t uid, char **err_msg)
+int insert_storage(void *handle, const char *storage_id, int storage_type, const char *storage_name, const char *storage_path, uid_t uid, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
@@ -697,7 +697,7 @@ int insert_storage(void * handle, const char *storage_id, int storage_type, cons
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int update_storage(void * handle, const char *storage_id, const char *storage_path, uid_t uid, char **err_msg)
+int update_storage(void *handle, const char *storage_id, const char *storage_path, uid_t uid, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
@@ -808,7 +808,7 @@ int get_storage_scan_status(void * handle, const char *storage_id, int *status,
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int set_storage_scan_status(void * handle, const char *storage_id, int status, uid_t uid, char **err_msg)
+int set_storage_scan_status(void *handle, const char *storage_id, int status, uid_t uid, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
        media_svc_scan_status_type_e storage_status = status;
@@ -827,7 +827,7 @@ int set_storage_scan_status(void * handle, const char *storage_id, int status, u
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int get_storage_list(void * handle, char ***storage_list, char ***storage_id_list,int **scan_status_list, int *count, char **err_msg)
+int get_storage_list(void *handle, char ***storage_list, char ***storage_id_list,int **scan_status_list, int *count, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
@@ -978,7 +978,7 @@ int insert_folder_begin(void * handle, int item_cnt, char **err_msg)
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int insert_folder_end(void * handle, uid_t uid, char **err_msg)
+int insert_folder_end(void *handle, uid_t uid, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
@@ -1059,3 +1059,81 @@ int set_folder_validity(void * handle, const char *storage_id, const char* start
 
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
+
+int delete_invalid_folder_by_path(void * handle, const char *storage_id, const char *folder_path, uid_t uid, int *delete_count, 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_delete_invalid_folder_by_path(handle, storage_id, folder_path, uid, delete_count);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int check_folder_exist(void * handle, const char *storage_id, const char *folder_path, 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_check_folder_exist_by_path(handle, storage_id, folder_path);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int count_subfolder(void * handle, const char *storage_id, const char *folder_path, int *count, char **err_msg)
+{
+       int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
+       int cnt = 0;
+
+       if(handle == NULL) {
+               __set_error_message(ERR_HANDLE, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       ret = media_svc_check_subfolder_by_path(handle, storage_id, folder_path, &cnt);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       *count = cnt;
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+int get_folder_id(void * handle, const char *storage_id, const char *path, char *folder_id, 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_get_folder_id(handle, storage_id, path, folder_id);
+       if(ret < 0) {
+               __set_error_message(ret, err_msg);
+               return MEDIA_SVC_PLUGIN_ERROR;
+       }
+
+       return MEDIA_SVC_PLUGIN_ERROR_NONE;
+}
+
+
+
index f35574f..a5aae27 100755 (executable)
@@ -581,7 +581,7 @@ int _media_svc_init_table_query(const char *event_table_name)
        ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_uuid", MEDIA_SVC_DB_TYPE_TEXT, "PRIMARY KEY", USER_V2, NULL, false, false, true);
        ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "path", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL UNIQUE", USER_V2, NULL, true, false, true);
        ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "file_name", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL", USER_V2, "media_file_name_idx", true, false, true);
-       ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_type", MEDIA_SVC_DB_TYPE_INT, NULL, USER_V2, "media_media_type_idx", false, false, true);
+       ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_type", MEDIA_SVC_DB_TYPE_INT, NULL, USER_V2, NULL, false, false, true);
        ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "mime_type", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true);
        ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "size", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true);
        ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "added_time", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true);
index 4a3f634..f5e596c 100755 (executable)
 extern __thread GList *g_media_svc_move_item_query_list;
 static __thread GList *g_media_svc_insert_folder_query_list;
 
-static int __media_svc_is_root_path(const char *folder_path, bool *is_root)
+static int __media_svc_is_root_path(const char *folder_path, bool *is_root, uid_t uid)
 {
        media_svc_retvm_if(!STRING_VALID(folder_path), MS_MEDIA_ERR_INVALID_PARAMETER, "folder_path is NULL");
 
        *is_root = FALSE;
 
-       if (strcmp(folder_path, MEDIA_ROOT_PATH_INTERNAL) == 0 ||
+       if (strcmp(folder_path, _media_svc_get_path(uid)) == 0 ||
                strcmp(folder_path, MEDIA_ROOT_PATH_SDCARD) == 0 ||
                strcmp(folder_path, MEDIA_ROOT_PATH_CLOUD) == 0) {
-               media_svc_debug("ROOT PATH [%d]", folder_path);
+               media_svc_debug("ROOT PATH [%s]", folder_path);
                *is_root = TRUE;
        }
 
@@ -106,7 +106,7 @@ int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_
        if(!STRING_VALID(parent_folder_uuid)) {
                bool is_root = FALSE;
 
-               ret = __media_svc_is_root_path(folder_name, &is_root);
+               ret = __media_svc_is_root_path(folder_name, &is_root, uid);
                if (is_root)
                        return MS_MEDIA_ERR_NONE;
 
@@ -246,7 +246,6 @@ static int __media_svc_get_and_append_parent_folder(sqlite3 *handle, const char
                        dir_path = strndup(path, next_pos);
                        next_pos++;
                } else {
-                       media_svc_error("End Path");
                        dir_path = strndup(path, strlen(path));
                        folder_search_end = TRUE;
                        media_svc_error("[No-Error] End Path [%s]", dir_path);
@@ -259,8 +258,6 @@ static int __media_svc_get_and_append_parent_folder(sqlite3 *handle, const char
 
                ret = _media_svc_get_folder_id_by_foldername(handle, storage_id, dir_path, parent_folder_uuid, uid);
                if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
-                       media_svc_error("NOT EXIST dir path : %s", dir_path);
-
                        folder_uuid = _media_info_generate_uuid();
                        if (folder_uuid == NULL) {
                                media_svc_error("Invalid UUID");
@@ -273,6 +270,7 @@ static int __media_svc_get_and_append_parent_folder(sqlite3 *handle, const char
                                media_svc_error("__media_svc_append_folder is failed");
                        }
 
+                       media_svc_error("[No-Error] New Appended folder path [%s], folder_uuid [%s], parent_folder_uuid [%s]", dir_path, folder_uuid, parent_folder_uuid);
                        _strncpy_safe(parent_folder_uuid, folder_uuid, MEDIA_SVC_UUID_SIZE + 1);
                } else {
                        media_svc_error("EXIST dir path : %s\n", dir_path);
@@ -306,14 +304,14 @@ int _media_svc_get_and_append_folder(sqlite3 *handle, const char *storage_id, co
 
 int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, uid_t uid)
 {
-       char *path_name = NULL;
+       char *dir_path = NULL;
        int ret = MS_MEDIA_ERR_NONE;
 
-       path_name = g_path_get_dirname(path);
+       dir_path = g_path_get_dirname(path);
 
-       ret =  _media_svc_get_and_append_folder(handle, storage_id, path_name, storage_type, folder_id, uid);
+       ret =  _media_svc_get_and_append_folder(handle, storage_id, dir_path, storage_type, folder_id, uid);
 
-       SAFE_FREE(path_name);
+       SAFE_FREE(dir_path);
 
        return ret;
 }
@@ -464,12 +462,12 @@ ERROR:
        return ret;
 }
 
-int _media_svc_get_folder_info_by_foldername(sqlite3 *handle, const char *folder_name, char *folder_id, time_t *modified_time)
+int _media_svc_get_folder_info_by_foldername(sqlite3 *handle, const char *storage_id, const char *folder_name, char *folder_id, time_t *modified_time)
 {
        int ret = MS_MEDIA_ERR_NONE;
        sqlite3_stmt *sql_stmt = NULL;
 
-       char *sql = sqlite3_mprintf("SELECT folder_uuid, modified_time FROM %s WHERE path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, folder_name);
+       char *sql = sqlite3_mprintf("SELECT folder_uuid, modified_time FROM %s WHERE (storage_uuid = '%q' AND path = '%q');", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, folder_name);
 
        ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
 
@@ -507,7 +505,7 @@ int _media_svc_get_and_append_folder_id_by_folder_path(sqlite3 *handle, const ch
                bool is_root = FALSE;
                bool is_parent_root = FALSE;
 
-               ret = __media_svc_is_root_path(path_name, &is_root);
+               ret = __media_svc_is_root_path(path_name, &is_root, uid);
                ret = __media_svc_parent_is_ext_root_path(path_name, &is_parent_root);
 
                char parent_folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0, };
@@ -582,17 +580,19 @@ int _media_svc_delete_invalid_folder(sqlite3 *handle, const char *storage_id, ui
 int _media_svc_set_folder_validity(sqlite3 *handle, const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
-       char start_path_id[MEDIA_SVC_UUID_SIZE+1] = {0,};
        char *sql = NULL;
+       char start_path_id[MEDIA_SVC_UUID_SIZE+1] = {0,};
 
        if (is_recursive) {
-               sql = sqlite3_mprintf("UPDATE '%s' SET validity = %d WHERE storage_uuid = '%q' AND path LIKE '%q%%'", MEDIA_SVC_DB_TABLE_FOLDER, validity, storage_id, start_path);
-       } else {
                ret = _media_svc_get_folder_id_by_foldername(handle, storage_id, start_path, start_path_id, uid);
                media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "_media_svc_get_folder_id_by_foldername fail");
                media_svc_retvm_if(!STRING_VALID(start_path_id), MS_MEDIA_ERR_INVALID_PARAMETER, "start_path_id is NULL");
 
-               sql = sqlite3_mprintf("UPDATE '%s' SET validity = %d WHERE storage_uuid = '%q' AND parent_folder_uuid = '%q'", MEDIA_SVC_DB_TABLE_FOLDER, validity, storage_id, start_path_id);
+               sql = sqlite3_mprintf("UPDATE '%s' SET validity = %d WHERE storage_uuid = '%q' AND (parent_folder_uuid = '%q' OR folder_uuid ='%q')",
+                                               MEDIA_SVC_DB_TABLE_FOLDER, validity, storage_id, start_path_id, start_path_id);
+       } else {
+               sql = sqlite3_mprintf("UPDATE '%s' SET validity = %d WHERE storage_uuid = '%q' AND path = '%q'",
+                                               MEDIA_SVC_DB_TABLE_FOLDER, validity, storage_id, start_path);
        }
 
        ret = _media_svc_sql_query(handle, sql, uid);
@@ -620,3 +620,96 @@ GList ** _media_svc_get_folder_list_ptr(void)
        return &g_media_svc_insert_folder_query_list;
 }
 
+int _media_svc_delete_invalid_folder_by_path(sqlite3 *handle, const char *storage_id, const char *folder_path, uid_t uid, int *delete_count)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       char *sql = NULL;
+       int del_count = 0;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       if (folder_path == NULL)
+               return MS_MEDIA_ERR_INVALID_PARAMETER;
+
+       /*check the number of the deleted folder*/
+       sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE (storage_uuid = '%q' AND validity = 0 AND PATH LIKE '%q/%%')", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, folder_path);
+
+       ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
+       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+
+       del_count = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+       sql = NULL;
+
+       /*delete invalid folder*/
+       sql = sqlite3_mprintf("DELETE FROM '%s' WHERE (storage_uuid = '%q' AND validity = 0 AND PATH LIKE '%q%%')", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, folder_path);
+       ret = _media_svc_sql_query(handle, sql, uid);
+
+       sqlite3_free(sql);
+
+       *delete_count = del_count;
+
+       return ret;
+}
+
+int _media_svc_count_folder_with_path(sqlite3 *handle,  const char *storage_id, const char *path, int *count)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       char *sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE (storage_uuid='%q' AND path='%q')", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, path);
+
+       ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
+
+       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+
+       *count = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return MS_MEDIA_ERR_NONE;
+}
+
+int _media_svc_count_subfolder_with_path(sqlite3 *handle,  const char *storage_id, const char *path, int *count)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+
+       char *sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE (storage_uuid='%q' AND path LIKE'%q/%%')", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, path);
+
+       ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
+
+       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+
+       *count = sqlite3_column_int(sql_stmt, 0);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return MS_MEDIA_ERR_NONE;
+}
+
+int _media_svc_get_folder_uuid(sqlite3 *handle, const char *storage_id, const char *path, char *folder_id)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+       char *sql = NULL;
+
+       sql = sqlite3_mprintf("SELECT folder_uuid FROM '%s' WHERE (storage_uuid='%q' AND path='%q')", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, path);
+
+       ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
+
+       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+
+       _strncpy_safe(folder_id, (const char *)sqlite3_column_text(sql_stmt, 0), MEDIA_SVC_UUID_SIZE+1);
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       if(!STRING_VALID(folder_id))
+       {
+               media_svc_error("Not found valid storage id [%s]", path);
+               ret = MS_MEDIA_ERR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
index f9c133a..5e2066d 100755 (executable)
@@ -214,6 +214,7 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me
 {
        int ret = MS_MEDIA_ERR_NONE;
        char *burst_id = NULL;
+       int ini_val = _media_svc_get_ini_value();
 
        const 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, album_artist, genre, composer, year, recorded_date, copyright, track_num, description, \
@@ -239,24 +240,25 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me
                }
 
                /* Get thumbnail for burst shot */
-               char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
-               int width = 0;
-               int height = 0;
-
-               ret = _media_svc_request_thumbnail_with_origin_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height, uid);
-               if (ret == MS_MEDIA_ERR_NONE) {
-
-                       ret = __media_svc_malloc_and_strncpy(&(content_info->thumbnail_path), thumb_path);
-                       if (ret != MS_MEDIA_ERR_NONE) {
-                               content_info->thumbnail_path = NULL;
+               if(ini_val == 1) {
+                       char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
+                       int width = 0;
+                       int height = 0;
+
+                       ret = _media_svc_request_thumbnail_with_origin_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height, uid);
+                       if (ret == MS_MEDIA_ERR_NONE) {
+                               ret = __media_svc_malloc_and_strncpy(&(content_info->thumbnail_path), thumb_path);
+                               if (ret != MS_MEDIA_ERR_NONE) {
+                                       content_info->thumbnail_path = NULL;
+                               }
                        }
-               }
 
-               if (content_info->media_meta.width <= 0)
-                       content_info->media_meta.width = width;
+                       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;
+                       if (content_info->media_meta.height <= 0)
+                               content_info->media_meta.height = height;
+               }
        }
 
        /*Update Pinyin If Support Pinyin*/
index 405406c..914c07e 100755 (executable)
@@ -74,6 +74,74 @@ int _media_svc_publish_noti(media_item_type_e update_item,
        return ret;
 }
 
+int _media_svc_publish_dir_noti(media_item_type_e update_item,
+                                                       media_item_update_type_e update_type,
+                                                       const char *path,
+                                                       media_type_e media_type,
+                                                       const char *uuid,
+                                                       const char *mime_type,
+                                                       int pid
+)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+
+       if(STRING_VALID(path))
+       {
+               ret = media_db_update_send(pid, update_item, update_type, (char *)path, (char *)uuid, media_type, (char *)mime_type);
+               if(ret != MS_MEDIA_ERR_NONE)
+               {
+                       media_svc_error("Send noti failed : %d [%s]", ret, path);
+                       ret = MS_MEDIA_ERR_SEND_NOTI_FAIL;
+               }
+               else
+               {
+                       media_svc_debug("Send noti success [%d][%d]", update_item, update_type);
+               }
+       }
+       else
+       {
+               media_svc_debug("invalid path");
+               ret = MS_MEDIA_ERR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+
+int _media_svc_publish_dir_noti_v2(media_item_type_e update_item,
+                                                       media_item_update_type_e update_type,
+                                                       const char *path,
+                                                       media_type_e media_type,
+                                                       const char *uuid,
+                                                       const char *mime_type,
+                                                       int pid
+)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+
+       if(STRING_VALID(path))
+       {
+               ret = media_db_update_send_internal(pid, update_item, update_type, (char *)path, (char *)uuid, media_type, (char *)mime_type);
+               if(ret != MS_MEDIA_ERR_NONE)
+               {
+                       media_svc_error("Send noti failed : %d [%s]", ret, path);
+                       ret = MS_MEDIA_ERR_SEND_NOTI_FAIL;
+               }
+               else
+               {
+                       media_svc_debug("Send noti success [%d][%d]", update_item, update_type);
+               }
+       }
+       else
+       {
+               media_svc_debug("invalid path");
+               ret = MS_MEDIA_ERR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+
 void _media_svc_set_noti_from_pid(int pid)
 {
        g_noti_from_pid = pid;
index 08459e7..945c30b 100755 (executable)
 #define _3GP_FILE ".3gp"
 #define _MP4_FILE ".mp4"
 #define _ASF_FILE ".asf"
+#define MEDIA_SVC_INI_GET_INT(dict, key, value, default) \
+       do { \
+               value = iniparser_getint(dict, key, default); \
+               media_svc_debug("get %s = %d", key, value); \
+       } while(0)
+#define MEDIA_SVC_INI_DEFAULT_PATH "/usr/etc/media_content_config.ini"
+
+static int g_ini_value = -1;
 
 typedef struct {
        char content_type[15];
@@ -862,10 +870,10 @@ static char *_media_svc_get_thumb_path(uid_t uid)
 int _media_svc_get_thumbnail_path(media_svc_storage_type_e storage_type, char *thumb_path, const char *pathname, const char *img_format, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
-       char savename[MEDIA_SVC_PATHNAME_SIZE] = {0};
-       char file_ext[MEDIA_SVC_FILE_EXT_LEN_MAX + 1] = {0};
+       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 hash[255 + 1] = {0, };
        char *thumbfile_ext = NULL;
 
        thumb_dir = (storage_type == MEDIA_SVC_STORAGE_INTERNAL) ? _media_svc_get_thumb_internal_path(uid) : _media_svc_get_thumb_external_path(uid);
@@ -2109,6 +2117,25 @@ bool _media_svc_check_pinyin_support(void)
        return TRUE;
 }
 
+int _media_svc_get_ini_value()
+{
+       if(g_ini_value == -1) {
+               dictionary *dict = NULL;
+
+               dict = iniparser_load(MEDIA_SVC_INI_DEFAULT_PATH);
+               if(!dict) {
+                       media_svc_error("%s load failed", MEDIA_SVC_INI_DEFAULT_PATH);
+                       return -1;
+               }
+
+               MEDIA_SVC_INI_GET_INT(dict, "media-content-config:thumbnail_activation",g_ini_value, 0);
+               iniparser_freedict(dict);
+       }
+       media_svc_debug("Thumb-server activation level = %d", g_ini_value);
+
+       return g_ini_value;
+}
+
 char* _media_svc_get_title_from_path(const char *path)
 {
        char *filename = NULL;
index 5328aa2..c8dc4e5 100755 (executable)
@@ -372,6 +372,7 @@ int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storag
        sqlite3 *db_handle = (sqlite3 *)handle;
        char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, };
        media_svc_media_type_e media_type;
+       int ini_val = _media_svc_get_ini_value();
 
        media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
        media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
@@ -405,22 +406,24 @@ int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storag
        media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
 #if 1
        /* Extracting thumbnail */
-       if (content_info.thumbnail_path == NULL) {
-               if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
-                       char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
-                       int width = 0;
-                       int height = 0;
-
-                       ret = _media_svc_request_thumbnail_with_origin_size(content_info.path, thumb_path, sizeof(thumb_path), &width, &height, uid);
-                       if (ret == MS_MEDIA_ERR_NONE) {
-                               ret = __media_svc_malloc_and_strncpy(&(content_info.thumbnail_path), thumb_path);
-                       }
+       if (ini_val == 1) {
+               if (content_info.thumbnail_path == NULL) {
+                       if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
+                               char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
+                               int width = 0;
+                               int height = 0;
+
+                               ret = _media_svc_request_thumbnail_with_origin_size(content_info.path, thumb_path, sizeof(thumb_path), &width, &height, uid);
+                               if (ret == MS_MEDIA_ERR_NONE) {
+                                       ret = __media_svc_malloc_and_strncpy(&(content_info.thumbnail_path), thumb_path);
+                               }
 
-                       if (content_info.media_meta.width <= 0)
-                               content_info.media_meta.width = width;
+                               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;
+                               if (content_info.media_meta.height <= 0)
+                                       content_info.media_meta.height = height;
+                       }
                }
        }
 #endif
@@ -438,48 +441,6 @@ int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storag
        return ret;
 }
 
-#if 0
-int media_svc_move_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, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
-       media_svc_retvm_if(data_cnt < 1, MS_MEDIA_ERR_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 MS_MEDIA_ERR_NONE;
-}
-
-int media_svc_move_item_end(MediaSvcHandle *handle, uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       sqlite3 *db_handle = (sqlite3 *)handle;
-
-       media_svc_debug_fenter();
-
-       media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_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, uid);
-       }
-
-       /*clean up old folder path*/
-       //need to check it. but media_svc_move_item_end API not used.
-       ret = _media_svc_update_folder_table(db_handle, DEFAULT_MEDIA_SVC_STORAGE_ID, uid);
-       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
-       g_media_svc_move_item_data_cnt  = 1;
-       g_media_svc_move_item_cur_data_cnt  = 0;
-
-       return ret;
-}
-#endif
-
 int media_svc_move_item(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e src_storage, const char *src_path,
                        media_svc_storage_type_e dest_storage, const char *dest_path, uid_t uid)
 {
@@ -874,6 +835,7 @@ int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media
        int ret = MS_MEDIA_ERR_NONE;
        sqlite3 *db_handle = (sqlite3 *)handle;
        media_svc_media_type_e media_type;
+       int ini_val = _media_svc_get_ini_value();
 
        media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
        media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
@@ -890,24 +852,26 @@ int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media
        }
 
        /* Initialize thumbnail information to remake thumbnail. */
-       char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1];
-       ret = _media_svc_get_thumbnail_path_by_path(db_handle, storage_id, path, thumb_path);
-       if (ret != MS_MEDIA_ERR_NONE) {
-               _media_svc_destroy_content_info(&content_info);
-               return ret;
-       }
-
-       if (g_file_test(thumb_path, G_FILE_TEST_EXISTS) && (strncmp(thumb_path, MEDIA_SVC_THUMB_DEFAULT_PATH, sizeof(MEDIA_SVC_THUMB_DEFAULT_PATH)) != 0)) {
-               ret = _media_svc_remove_file(thumb_path);
+       if(ini_val == 1) {
+               char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1];
+               ret = _media_svc_get_thumbnail_path_by_path(db_handle, storage_id, path, thumb_path);
                if (ret != MS_MEDIA_ERR_NONE) {
-                       media_svc_error("_media_svc_remove_file failed : %s", thumb_path);
+                       _media_svc_destroy_content_info(&content_info);
+                       return ret;
                }
-       }
 
-       ret = _media_svc_update_thumbnail_path(db_handle,  storage_id, path, NULL, uid);
-       if (ret != MS_MEDIA_ERR_NONE) {
-               _media_svc_destroy_content_info(&content_info);
-               return ret;
+               if (g_file_test(thumb_path, G_FILE_TEST_EXISTS) && (strncmp(thumb_path, MEDIA_SVC_THUMB_DEFAULT_PATH, sizeof(MEDIA_SVC_THUMB_DEFAULT_PATH)) != 0)) {
+                       ret = _media_svc_remove_file(thumb_path);
+                       if (ret != MS_MEDIA_ERR_NONE) {
+                               media_svc_error("_media_svc_remove_file failed : %s", thumb_path);
+                       }
+               }
+
+               ret = _media_svc_update_thumbnail_path(db_handle,  storage_id, path, NULL, uid);
+               if (ret != MS_MEDIA_ERR_NONE) {
+                       _media_svc_destroy_content_info(&content_info);
+                       return ret;
+               }
        }
 
        /* Get notification info */
@@ -936,22 +900,24 @@ int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media
        }
 #if 1
        /* Extracting thumbnail */
-       if (content_info.thumbnail_path == NULL) {
-               if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
-                       char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
-                       int width = 0;
-                       int height = 0;
-
-                       ret = _media_svc_request_thumbnail_with_origin_size(content_info.path, thumb_path, sizeof(thumb_path), &width, &height, uid);
-                       if (ret == MS_MEDIA_ERR_NONE) {
-                               ret = __media_svc_malloc_and_strncpy(&(content_info.thumbnail_path), thumb_path);
-                       }
+       if(ini_val == 1) {
+               if (content_info.thumbnail_path == NULL) {
+                       if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
+                               char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
+                               int width = 0;
+                               int height = 0;
+
+                               ret = _media_svc_request_thumbnail_with_origin_size(content_info.path, thumb_path, sizeof(thumb_path), &width, &height, uid);
+                               if (ret == MS_MEDIA_ERR_NONE) {
+                                       ret = __media_svc_malloc_and_strncpy(&(content_info.thumbnail_path), thumb_path);
+                               }
 
-                       if (content_info.media_meta.width <= 0)
-                               content_info.media_meta.width = width;
+                               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;
+                               if (content_info.media_meta.height <= 0)
+                                       content_info.media_meta.height = height;
+                       }
                }
        }
 
@@ -1163,10 +1129,11 @@ int media_svc_request_update_db(const char *db_query, uid_t uid)
        return _media_svc_sql_query(NULL, db_query, uid);
 }
 
-int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *storage_id, const char *dir_path)
+int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *storage_id, const char *dir_path, const char *folder_id, media_item_update_type_e update_type, int pid)
 {
        int ret = MS_MEDIA_ERR_NONE;
        sqlite3 *db_handle = (sqlite3 *)handle;
+       char *uuid = NULL;
 
        media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
        media_svc_retvm_if(!STRING_VALID(dir_path), MS_MEDIA_ERR_INVALID_PARAMETER, "dir_path is NULL");
@@ -1176,7 +1143,14 @@ int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *storage_i
        ret = _media_svc_get_noti_info(db_handle, storage_id, dir_path, MS_MEDIA_ITEM_DIRECTORY, &noti_item);
        media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
 
-       ret = _media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, dir_path, -1, noti_item->media_uuid, NULL);
+       if (folder_id != NULL) {
+               uuid = folder_id;
+       } else {
+               uuid = noti_item->media_uuid;
+       }
+
+       ret = _media_svc_publish_dir_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, dir_path, -1, noti_item->media_uuid, NULL, pid);
+       ret = _media_svc_publish_dir_noti_v2(MS_MEDIA_ITEM_DIRECTORY, update_type, dir_path, -1, uuid, NULL, pid);
        _media_svc_destroy_noti_item(noti_item);
 
        return ret;
@@ -1230,7 +1204,7 @@ int media_svc_get_folder_list(MediaSvcHandle *handle, char *start_path, char ***
        return _media_svc_get_all_folders(db_handle, start_path, folder_list, modified_time_list, item_num_list, count);
 }
 
-int media_svc_update_folder_time(MediaSvcHandle *handle, const char *folder_path, uid_t uid)
+int media_svc_update_folder_time(MediaSvcHandle *handle, const char *storage_id, const char *folder_path, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
        sqlite3 *db_handle = (sqlite3 *)handle;
@@ -1240,7 +1214,7 @@ int media_svc_update_folder_time(MediaSvcHandle *handle, const char *folder_path
 
        media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
 
-       ret = _media_svc_get_folder_info_by_foldername(db_handle, folder_path, folder_uuid, &sto_time);
+       ret = _media_svc_get_folder_info_by_foldername(db_handle, storage_id, folder_path, folder_uuid, &sto_time);
        if (ret == MS_MEDIA_ERR_NONE) {
                if (sto_time != cur_time) {
                        ret = _media_svc_update_folder_modified_time_by_folder_uuid(db_handle, folder_uuid, folder_path, FALSE, uid);
@@ -1285,7 +1259,6 @@ int media_svc_update_item_end(MediaSvcHandle *handle, uid_t uid)
        return ret;
 }
 
-
 int media_svc_update_item_meta(MediaSvcHandle *handle, const char *file_path, int storage_type, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
@@ -2149,3 +2122,79 @@ int media_svc_insert_item_pass2(MediaSvcHandle *handle, const char *storage_id,
 
        return MS_MEDIA_ERR_NONE;
 }
+
+int media_svc_delete_invalid_folder_by_path(MediaSvcHandle *handle, const char *storage_id, const char *folder_path, uid_t uid, int *delete_count)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+
+       media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+
+       ret = _media_svc_delete_invalid_folder_by_path(db_handle, storage_id, folder_path, uid, delete_count);
+
+       return ret;
+}
+
+int media_svc_check_folder_exist_by_path(MediaSvcHandle *handle, const char *storage_id, const char *folder_path)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+       int count = -1;
+
+       media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+       media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
+       media_svc_retvm_if(!STRING_VALID(folder_path), MS_MEDIA_ERR_INVALID_PARAMETER, "Path is NULL");
+
+       ret = _media_svc_count_folder_with_path(db_handle,  storage_id, folder_path, &count);
+       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+
+       if(count > 0) {
+               media_svc_debug("item is exist in database");
+               return MS_MEDIA_ERR_NONE;
+       } else {
+               media_svc_debug("item is not exist in database");
+               return MS_MEDIA_ERR_DB_NO_RECORD;
+       }
+
+       return MS_MEDIA_ERR_NONE;
+}
+
+int media_svc_check_subfolder_by_path(MediaSvcHandle *handle, const char *storage_id, const char *folder_path, int *count)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+       int cnt = -1;
+
+       media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+       media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
+       media_svc_retvm_if(!STRING_VALID(folder_path), MS_MEDIA_ERR_INVALID_PARAMETER, "Path is NULL");
+
+       *count = 0;
+       ret = _media_svc_count_subfolder_with_path(db_handle,  storage_id, folder_path, &cnt);
+       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+       *count = cnt;
+
+       if(cnt > 0) {
+               media_svc_debug("item is exist in database");
+               return MS_MEDIA_ERR_NONE;
+       } else {
+               media_svc_debug("item is not exist in database");
+               return MS_MEDIA_ERR_DB_NO_RECORD;
+       }
+
+       return MS_MEDIA_ERR_NONE;
+}
+
+int media_svc_get_folder_id(MediaSvcHandle *handle, const char *storage_id, const char *path, char *folder_id)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       sqlite3 * db_handle = (sqlite3 *)handle;
+
+       media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+       media_svc_retvm_if(path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
+
+       ret = _media_svc_get_folder_uuid(db_handle, storage_id, path, folder_id);
+
+       return ret;
+}
+
index a58abcd..a514c3e 100755 (executable)
@@ -54,7 +54,7 @@ extern "C" {
  * Table Name
  */
 #define MEDIA_SVC_DB_TABLE_MEDIA                               "media"                         /**<  media table*/
-#define MEDIA_SVC_DB_TABLE_FOLDER                              "folder"                                /**<  media_folder 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*/
index f092a8a..8290431 100755 (executable)
@@ -33,9 +33,15 @@ int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *sto
 int _media_svc_update_folder_table(sqlite3 *handle, const char *storage_id, uid_t uid);
 int _media_svc_get_all_folders(sqlite3 *handle, char *start_path, char ***folder_list, time_t **modified_time_list, int **item_num_list, int *count);
 int _media_svc_get_and_append_folder_id_by_folder_path(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, bool stack_query, uid_t uid);
-int _media_svc_get_folder_info_by_foldername(sqlite3 *handle, const char *folder_name, char *folder_id, time_t *modified_time);
+int _media_svc_get_folder_info_by_foldername(sqlite3 *handle, const char *storage_id, const char *folder_name, char *folder_id, time_t *modified_time);
 int _media_svc_delete_invalid_folder(sqlite3 *handle, const char *storage_id, uid_t uid);
 int _media_svc_set_folder_validity(sqlite3 *handle, const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid);
 int _media_svc_delete_folder_by_storage_id(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid);
 GList ** _media_svc_get_folder_list_ptr(void);
+int _media_svc_delete_invalid_folder_by_path(sqlite3 *handle, const char *storage_id, const char *folder_path, uid_t uid, int *del_count);
+int _media_svc_count_folder_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count);
+int _media_svc_count_subfolder_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count);
+int _media_svc_get_folder_uuid(sqlite3 *handle, const char *storage_id, const char *path, char *folder_id);
+
+
 #endif /*_MEDIA_SVC_MEDIA_FOLDER_H_*/
index 93ffa67..e8d1c1c 100755 (executable)
@@ -26,6 +26,7 @@
 #include "media-svc-env.h"
 #include "media-svc-debug.h"
 #include <media-util-noti.h>
+#include <media-util-noti-internal.h>
 
 typedef struct _media_svc_noti_item media_svc_noti_item;
 
@@ -46,12 +47,32 @@ int _media_svc_destroy_noti_list(int all_cnt);
 int _media_svc_publish_noti_list(int all_cnt);
 int _media_svc_destroy_noti_item(media_svc_noti_item *item);
 int _media_svc_publish_noti(media_item_type_e update_item,
-                            media_item_update_type_e update_type,
-                            const char *path,
-                            media_type_e media_type,
-                            const char *uuid,
-                            const char *mime_type
-                           );
+                                                       media_item_update_type_e update_type,
+                                                       const char *path,
+                                                       media_type_e media_type,
+                                                       const char *uuid,
+                                                       const char *mime_type
+);
+int _media_svc_publish_dir_noti(media_item_type_e update_item,
+                                                       media_item_update_type_e update_type,
+                                                       const char *path,
+                                                       media_type_e media_type,
+                                                       const char *uuid,
+                                                       const char *mime_type,
+                                                       int pid
+);
+int _media_svc_publish_dir_noti_v2(media_item_type_e update_item,
+                                                       media_item_update_type_e update_type,
+                                                       const char *path,
+                                                       media_type_e media_type,
+                                                       const char *uuid,
+                                                       const char *mime_type,
+                                                       int pid
+);
+
+
+
+
 
 #endif /*_MEDIA_SVC_NOTI_H_*/
 
index 241e0df..4a84c8d 100755 (executable)
@@ -27,6 +27,7 @@
 #include <string.h>
 #include <stdbool.h>
 #include <sqlite3.h>
+#include <iniparser.h>
 #include "media-svc-types.h"
 #include "media-svc-env.h"
 
@@ -69,6 +70,7 @@ int _media_svc_request_thumbnail_with_origin_size(const char *path, char *thumb_
 int _media_svc_get_pinyin_str(const char *src_str, char **pinyin_str);
 bool _media_svc_check_pinyin_support(void);
 int _media_svc_extract_music_metadata_for_update(sqlite3 *handle, media_svc_content_info_s *content_info, media_svc_media_type_e media_type);
+int _media_svc_get_ini_value();
 char *_media_svc_get_title_from_path(const char *path);
 void _media_svc_print_stderror(void);