Remove ms_config_get_str()
[platform/core/multimedia/media-server.git] / src / common / media-common-utils.c
index 66d1616..a861da4 100644 (file)
 
 #ifdef _USE_TVPD_MODE
 #include <sys/prctl.h>
+#include <usb-device.h>
 #endif
 #include <system_info.h>
 #include <device/power.h>
 
-#ifndef _USE_DEVICED_DBUS
-#include <usb-device.h>
-#endif
-
 #include "media-util.h"
 #include "media-server-ipc.h"
 #include "media-common-dbg.h"
@@ -77,26 +74,7 @@ bool ms_config_set_int(const char *key, int value)
        return false;
 }
 
-bool ms_config_get_str(const char *key, char **value)
-{
-       char *res = NULL;
-
-       if (key == NULL || value == NULL) {
-               MS_DBG_ERR("Arguments key or value is NULL");
-               return false;
-       }
-
-       res = vconf_get_str(key);
-       if (MS_STRING_VALID(res)) {
-               *value = g_strdup(res);
-               MS_SAFE_FREE(res);
-               return true;
-       }
-
-       return false;
-}
-
-int ms_get_remain_space(double *free_space)
+int ms_get_remain_space(uint64_t *free_space)
 {
        int ret = MS_MEDIA_ERR_NONE;
        const char *path = "/opt";
@@ -110,7 +88,7 @@ int ms_get_remain_space(double *free_space)
        }
 
        /* f_bsize:unsigned long, f_bavail:fsblkcnt_t(unsigned long) */
-       *free_space = (double)(s.f_bsize * s.f_bavail);
+       *free_space = (uint64_t)s.f_bsize * (uint64_t)s.f_bavail;
 
        return MS_MEDIA_ERR_NONE;
 }
@@ -130,6 +108,20 @@ bool ms_is_support_pvr(void)
 }
 #endif
 
+bool ms_is_valid_symlink(const char *path)
+{
+#ifdef _USE_TVPD_MODE
+       return false;
+#else
+       g_autofree char *real_path = realpath(path, NULL);
+
+       if (!real_path)
+               return false;
+
+       return (g_strcmp0(real_path, MEDIA_SHARE_PATH) == 0);
+#endif
+}
+
 int ms_check_file_path(const char *file_path, uid_t uid)
 {
        ms_user_storage_type_e storage_type = -1;
@@ -262,8 +254,7 @@ int ms_check_scan_ignore(char * path, uid_t uid)
        return ret;
 }
 
-#ifndef _USE_DEVICED_DBUS
-
+#ifdef _USE_TVPD_MODE
 typedef struct storage_result {
        char *storage_path;
        bool result;
@@ -286,7 +277,7 @@ static void __ms_check_mount_status(usb_device_h usb_device, void *user_data)
 bool ms_storage_mount_status(const char *start_path)
 {
        bool ret = false;
-#ifndef _USE_DEVICED_DBUS
+#ifdef _USE_TVPD_MODE
        storage_result_s res = {0, };
        char *remain_path = NULL;
        int remain_len = 0;
@@ -375,7 +366,7 @@ void ms_trim_dir_path(char *dir_path)
                dir_path[len -1] = '\0';
 }
 
-int ms_check_size_mediadb(uid_t uid, double *db_size)
+int ms_check_size_mediadb(uid_t uid, uint64_t *db_size)
 {
        int ret = MS_MEDIA_ERR_NONE;
        char *db_path = NULL;
@@ -384,7 +375,7 @@ int ms_check_size_mediadb(uid_t uid, double *db_size)
        ret = ms_user_get_media_db_path(uid, &db_path);
 
        if (stat(db_path, &buf) == 0) {
-               *db_size = buf.st_size;
+               *db_size = (uint64_t)buf.st_size;
        } else {
                MS_DBG_STRERROR("stat failed");
                ret = MS_MEDIA_ERR_INTERNAL;