Move vconf related code to TVPD feature 60/303460/2
authorminje.ahn <minje.ahn@samsung.com>
Thu, 28 Dec 2023 04:43:22 +0000 (13:43 +0900)
committerminje.ahn <minje.ahn@samsung.com>
Wed, 17 Jan 2024 06:32:11 +0000 (15:32 +0900)
'VCONFKEY_FILEMANAGER_DB_STATUS' is no longer used in scanner-v1.
So, move related code to scanner-v2.

Change-Id: I47136d68c4e1accb1d494d0c635fa3508c401047
Signed-off-by: minje.ahn <minje.ahn@samsung.com>
src/common/include/media-common-utils.h
src/common/media-common-db-svc.c
src/common/media-common-utils.c
src/scanner-v2/media-scanner-scan-v2.c
src/scanner/media-scanner-scan.c
src/server/media-server-main.c
src/server/media-server-scanner.c

index 41f299a..14e0d61 100755 (executable)
 #include "media-util.h"
 #include "media-common-types.h"
 
-bool ms_config_get_int(const char *key, int *value);
-bool ms_config_set_int(const char *key, int value);
-
 bool ms_is_valid_symlink(const char *path);
-int ms_check_file_path(const char *file_path, uid_t uid);
-int ms_check_ignore_dir(const char *full_path, uid_t uid);
-int ms_check_scan_ignore(char * path, uid_t uid);
-int ms_set_db_status(ms_db_status_type_t status);
+int ms_verify_all_parent_dirs(const char *full_path, uid_t uid);
+int ms_check_scan_ignore(char *path, uid_t uid);
 int ms_set_power_mode(ms_db_status_type_t status);
 void ms_trim_dir_path(char *dir_path);
 
 #ifdef _USE_TVPD_MODE
+
+bool ms_config_get_int(const char *key, int *value);
+bool ms_config_set_int(const char *key, int value);
+int ms_set_db_status(ms_db_status_type_t status);
 int ms_get_remain_space(uint64_t *free_space);
 int ms_check_size_mediadb(uid_t uid, uint64_t *db_size);
-bool ms_storage_mount_status(const charstart_path);
+bool ms_storage_mount_status(const char *start_path);
 bool ms_is_support_pvr(void);
 int ms_set_vip_process(void);
 #endif
index 3fd8e29..832a3ae 100644 (file)
@@ -45,24 +45,24 @@ typedef int (*GET_STORAGE_ID)(sqlite3 *, const char *, char *, uid_t uid);
 typedef int (*INSERT_FOLDER)(sqlite3 *, const char *, const char *, int, uid_t);
 typedef int (*SET_FOLDER_VALIDITY)(sqlite3 *, const char *, const char *, int, bool, uid_t);
 
-typedef int (*CHECK_DB)(sqlite3*, uid_t);
+typedef int (*CHECK_DB)(sqlite3 *, uid_t);
 typedef int (*CHECK_STORAGE)(sqlite3 *, const char *, char **, int *, uid_t);
 typedef int (*INSERT_STORAGE)(sqlite3 *, const char *, int, const char *, uid_t);
 typedef int (*UPDATE_STORAGE)(sqlite3 *, const char *, const char *, uid_t);
 typedef int (*SET_STORAGE_VALIDITY)(sqlite3 *, const char *, int, uid_t uid);
 typedef int (*SET_ALL_STORAGE_VALIDITY)(sqlite3 *, int, uid_t);
-typedef int (*CHECK_FOLDER_EXIST)(sqlite3*, const char*, const char*);
+typedef int (*CHECK_FOLDER_EXIST)(sqlite3 *, const char *, const char *);
 typedef int (*GET_MEDIA_TYPE)(const char *, int *);
 typedef int (*REFRESH_ITEM)(sqlite3 *, const char *, const char *, uid_t);
 
 #ifdef _USE_TVPD_MODE
-typedef int (*CLEANUP_DB)(sqlite3*, uid_t);
+typedef int (*CLEANUP_DB)(sqlite3 *, uid_t);
 typedef int (*UPDATE_FOLDER_TIME)(sqlite3 *, const char *, const char *, uid_t);
 typedef int (*GET_UUID)(char **);
 typedef int (*SET_STORAGE_SCAN_STATUS)(sqlite3 *, const char *, int, uid_t);
 typedef int (*INSERT_ITEM_SCAN)(sqlite3 *, const char *, const char *, int, uid_t);
-typedef int (*GET_EXTRACT_LIST)(sqlite3*, const char*, int, const char*, int, void*);
-typedef int (*UPDATE_ONE_EXTRACT_ITEM)(sqlite3*, const char*, int, void *);
+typedef int (*GET_EXTRACT_LIST)(sqlite3 *, const char*, int, const char *, int, void*);
+typedef int (*UPDATE_ONE_EXTRACT_ITEM)(sqlite3 *, const char *, int, void *);
 typedef int (*DELETE_ALL_INVALID_ITEMS_IN_FOLDER)(sqlite3 *, const char *, const char *, bool, uid_t);
 typedef int (*DELETE_INVALID_FOLDER_BY_PATH)(sqlite3 *, const char *, const char *, uid_t);
 typedef int (*GET_FOLDER_SCAN_STATUS)(sqlite3 *, const char *, const char *, int *);
index 063619a..b8f0fb8 100644 (file)
 
 #include <sys/types.h>
 #include <fcntl.h>
-#include <vconf.h>
 #include <sys/statvfs.h>
 #include <sys/stat.h>
 
 #ifdef _USE_TVPD_MODE
+#include <vconf.h>
 #include <sys/prctl.h>
 #include <usb-device.h>
 #endif
@@ -38,6 +38,7 @@
 #include "media-common-system.h"
 #include "media-common-utils.h"
 
+#ifdef _USE_TVPD_MODE
 bool ms_config_get_int(const char *key, int *value)
 {
        int err;
@@ -74,7 +75,6 @@ bool ms_config_set_int(const char *key, int value)
        return false;
 }
 
-#ifdef _USE_TVPD_MODE
 int ms_get_remain_space(uint64_t *free_space)
 {
        int ret = MS_MEDIA_ERR_NONE;
@@ -122,46 +122,26 @@ bool ms_is_valid_symlink(const char *path)
 #endif
 }
 
-int ms_check_file_path(const char *file_path, uid_t uid)
-{
-       ms_user_storage_type_e storage_type = -1;
-       int ret = MS_MEDIA_ERR_NONE;
-
-       if (!MS_STRING_VALID(file_path)) {
-               MS_DBG_ERR("Invalid path");
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
-
-       ret = ms_user_get_storage_type(uid, file_path, &storage_type);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
-
-       if (!g_file_test(file_path, G_FILE_TEST_IS_REGULAR)) {
-               MS_DBG_SERR("g_file_test fail [%s]", file_path);
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
-
-       return MS_MEDIA_ERR_NONE;
-}
-
-int ms_check_ignore_dir(const char *full_path, uid_t uid)
+int ms_verify_all_parent_dirs(const char *full_path, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
        char *dir_path = NULL;
        char *next = NULL;
        int next_pos = 0;
+       ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
 
-       ret = ms_check_file_path(full_path, uid);
-       MS_DBG_RETV_IF(ret != MS_MEDIA_ERR_NONE, ret);
+       ret = ms_user_get_storage_type(uid, full_path, &storage_type);
+       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Invalid path");
 
-       if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && !strncmp(full_path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB))) {
-               next_pos = strlen(MEDIA_ROOT_PATH_USB) + 1;
-       } else {
+       if (storage_type == MS_USER_STORAGE_INTERNAL) {
                ret = ms_user_get_internal_root_path(uid, &dir_path);
                MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "ms_user_get_internal_root_path() fail");
 
                next_pos = strlen(dir_path);
                g_free(dir_path);
                dir_path = NULL;
+       } else {
+               next_pos = strlen(MEDIA_ROOT_PATH_USB) + 1;
        }
 
        while ((next = strstr(full_path + next_pos, "/"))) {
@@ -178,7 +158,7 @@ int ms_check_ignore_dir(const char *full_path, uid_t uid)
        return ret;
 }
 
-int ms_check_scan_ignore(char * path, uid_t uid)
+int ms_check_scan_ignore(char *path, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
        const char *ignore_file = ".scan_ignore";
@@ -317,7 +297,6 @@ int ms_check_size_mediadb(uid_t uid, uint64_t *db_size)
 
        return ret;
 }
-#endif
 
 int ms_set_db_status(ms_db_status_type_t status)
 {
@@ -340,6 +319,7 @@ ERROR:
        MS_DBG_ERR("ms_config_set_int failed");
        return MS_MEDIA_ERR_INTERNAL;
 }
+#endif
 
 int ms_set_power_mode(ms_db_status_type_t status)
 {
index f9a314a..76e39aa 100644 (file)
@@ -1152,7 +1152,7 @@ static int __msc_batch_insert(int pid, const char *request_path, uid_t uid)
        ms_register_start(true, pid);
 
        for (i = 0; path_list[i][0] != '\0'; i++) {
-               ret = ms_check_ignore_dir(path_list[i], uid);
+               ret = ms_verify_all_parent_dirs(path_list[i], uid);
                if (ret != MS_MEDIA_ERR_NONE) {
                        MS_DBG_SERR("Invalid path : %s", path_list[i]);
                        continue;
index 7dc40a9..0075de1 100644 (file)
@@ -319,7 +319,7 @@ static int __msc_storage_scan_partial(ms_comm_msg_s *scan_data)
        ret = ms_connect_db(&handle, scan_data->uid);
        MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "ms_connect_db failed");
 
-       ms_set_db_status(MS_DB_UPDATING);
+       ms_set_power_mode(MS_DB_UPDATING);
 
        ret = ms_validity_change_all_items(handle, scan_data->storage_id, false, scan_data->uid);
        if (ret != MS_MEDIA_ERR_NONE) {
@@ -352,7 +352,7 @@ static int __msc_storage_scan_all(ms_comm_msg_s *scan_data)
        ret = ms_connect_db(&handle, scan_data->uid);
        MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "ms_connect_db failed");
 
-       ms_set_db_status(MS_DB_UPDATING);
+       ms_set_power_mode(MS_DB_UPDATING);
 
        ms_register_start(false, 0);
        ret = __msc_db_update(handle, scan_data->storage_id, scan_data);
@@ -396,10 +396,8 @@ gpointer msc_storage_scan_thread(gpointer data)
                /* send notification */
                ms_send_dir_update_noti(scan_data->msg, NULL, MS_ITEM_UPDATE, scan_data->pid);
 
-               if (ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP)
-                       ms_set_db_status(MS_DB_STOPPED);
-               else
-                       ms_set_db_status(MS_DB_UPDATED);
+               if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP)
+                       ms_set_power_mode(MS_DB_UPDATED);
 NEXT:
                if (__msc_is_power_off())
                        goto _POWEROFF;
@@ -457,7 +455,7 @@ static int __msc_batch_insert(int pid, const char *request_path, uid_t uid)
        ms_register_start(true, pid);
 
        for (i = 0; path_list[i][0] != '\0'; i++) {
-               ret = ms_check_ignore_dir(path_list[i], uid);
+               ret = ms_verify_all_parent_dirs(path_list[i], uid);
                if (ret != MS_MEDIA_ERR_NONE) {
                        MS_DBG_SERR("Invalid path : %s", path_list[i]);
                        continue;
index 6b9d1fa..7d3699f 100644 (file)
@@ -22,7 +22,6 @@
 #include <sys/wait.h>
 #include <sys/types.h>
 #include <malloc.h>
-#include <vconf.h>
 #include <iniparser.h>
 #include <cpu-boosting.h>
 
@@ -41,6 +40,8 @@
 #include "media-server-db-manage.h"
 
 #ifdef _USE_TVPD_MODE
+#include <vconf.h>
+
 #define MS_VCONF_KEY_RESET_STATUS "db/media_server/reset_status"
 #define SMARTHUB_RESET_VCONF "db/smarthub/reset/firstscreen"
 
index 8a97fd5..74d84d6 100755 (executable)
@@ -20,7 +20,6 @@
  */
 
 #include <glib.h>
-#include <vconf.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include "media-server-scanner.h"
 
 #include <tzplatform_config.h>
-
+#ifdef _USE_TVPD_MODE
+#include <vconf.h>
 #define VCONFKEY_PRIVATE_EXTRACTSTATUS "db/private/extractstatus"
+#endif
 #define MEDIA_SERVER_PATH tzplatform_mkpath(TZ_SYS_BIN, "media-scanner")
 #define MEDIA_SERVER_PATH_V2 tzplatform_mkpath(TZ_SYS_BIN, "media-scanner-v2")
 
@@ -57,7 +58,7 @@ static int __ms_get_remained_task(void)
 {
        return (owner_list) ? owner_list->len : 0;
 }
-
+#ifdef _USE_TVPD_MODE
 static ms_db_status_type_t __ms_check_scanning_status(void)
 {
        int status;
@@ -66,15 +67,15 @@ static ms_db_status_type_t __ms_check_scanning_status(void)
                if (status == VCONFKEY_FILEMANAGER_DB_UPDATING)
                        return MS_DB_UPDATING;
        }
-#ifdef _USE_TVPD_MODE
+
        if (ms_config_get_int(VCONFKEY_PRIVATE_EXTRACTSTATUS, &status)) {
                MS_DBG("extract status %d", status);
                if (status == MS_DB_UPDATING)
                        return MS_DB_UPDATING;
        }
-#endif
        return MS_DB_UPDATED;
 }
+#endif
 
 static gboolean __ms_stop_scanner(gpointer user_data)
 {
@@ -90,13 +91,13 @@ static gboolean __ms_stop_scanner(gpointer user_data)
                g_mutex_unlock(&scanner_mutex);
                return G_SOURCE_CONTINUE;
        }
-
+#ifdef _USE_TVPD_MODE
        if (__ms_check_scanning_status() == MS_DB_UPDATING) {
                MS_DBG("DB is updating");
                g_mutex_unlock(&scanner_mutex);
                return G_SOURCE_CONTINUE;
        }
-
+#endif
        if (ms_req_num > 0) {
                MS_DBG("[%d] request(s) remain(s)", ms_req_num);
                g_mutex_unlock(&scanner_mutex);