Move set_folder_item_validity 24/198724/1 submit/tizen/20190129.064431
authorMinje Ahn <minje.ahn@samsung.com>
Tue, 29 Jan 2019 05:28:45 +0000 (14:28 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Tue, 29 Jan 2019 05:28:45 +0000 (14:28 +0900)
Move plugin to media-common

Change-Id: If42952a34de232b0bc95aa52040b05e90a4ca061
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/common/include/media-common-db-svc.h
src/common/media-common-db-svc.c

index 5eb592b..2eeacad 100755 (executable)
@@ -60,7 +60,6 @@ typedef int (*SET_ITEM_VALIDITY_END)(uid_t);
 
 typedef int (*SEND_DIR_UPDATE_NOTI)(sqlite3 *, const char *, const char *, const char *, int, int);
 typedef int (*INSERT_ITEM)(sqlite3 *, const char *, const char *, int, uid_t);
-typedef int (*SET_FOLDER_ITEM_VALIDITY)(sqlite3 *, const char *, const char *, int, int, uid_t);
 typedef int (*SET_ITEM_VALIDITY)(const char *, const char *, int, int, uid_t);
 typedef int (*DELETE_ITEM)(sqlite3 *, const char *, const char *, uid_t);
 typedef int (*DELETE_ALL_INVALID_ITEMS_IN_FOLDER)(sqlite3 *, const char *, const char *, bool, uid_t);
index 6314533..a02759a 100755 (executable)
@@ -50,7 +50,6 @@ enum func_list {
        eSET_VALIDITY_BEGIN,
        eSET_VALIDITY_END,
        eSET_VALIDITY,
-       eSET_FOLDER_ITEM_VALIDITY,
        eDELETE_FOLDER,
        eSEND_DIR_UPDATE_NOTI,
        eDELETE_ITEM,
@@ -149,7 +148,6 @@ int ms_load_functions(void)
                "set_item_validity_begin",
                "set_item_validity_end",
                "set_item_validity",
-               "set_folder_item_validity",
                "delete_all_invalid_items_in_folder",
                "send_dir_update_noti",
                "delete_item",
@@ -596,13 +594,19 @@ bool ms_delete_invalid_items(sqlite3 *handle, const char *storage_id, uid_t uid)
 
 int ms_set_folder_item_validity(sqlite3 *handle, const char *storage_id, const char *path, int validity, int recursive, uid_t uid)
 {
-       int lib_index;
        int ret = MS_MEDIA_ERR_NONE;
+       char *sql = NULL;
 
-       for (lib_index = 0; lib_index < lib_num; lib_index++) {
-               ret = ((SET_FOLDER_ITEM_VALIDITY)func_array[lib_index][eSET_FOLDER_ITEM_VALIDITY])(handle, storage_id, path, validity, recursive, uid); /*dlopen*/
-               MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Error : %s", g_array_index(so_array, char*, lib_index));
-       }
+       MS_DBG_RETVM_IF(!MS_STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
+       MS_DBG_RETVM_IF(!MS_STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
+
+       if (recursive)
+               sql = sqlite3_mprintf("UPDATE '%q' SET validity=%d WHERE (storage_type = 0 OR storage_type = 1) AND path LIKE '%q/%%';", storage_id, validity, path);
+       else
+               sql = sqlite3_mprintf("UPDATE '%q' SET validity=%d WHERE folder_uuid IN (SELECT folder_uuid FROM folder WHERE path='%q' AND storage_uuid='%q');", storage_id, validity, path, storage_id);
+
+       ret = media_db_request_update_db(sql, uid);
+       MS_SQLITE3_SAFE_FREE(sql);
 
        return ret;
 }