Get Ringtone path from system setting api 77/64077/3 accepted/tizen/common/20160330.120433 accepted/tizen/ivi/20160330.062958 accepted/tizen/mobile/20160330.062848 accepted/tizen/tv/20160330.062914 accepted/tizen/wearable/20160330.062936 submit/tizen/20160330.041302
authorpr.jung <pr.jung@samsung.com>
Wed, 30 Mar 2016 02:01:49 +0000 (11:01 +0900)
committerpr.jung <pr.jung@samsung.com>
Wed, 30 Mar 2016 02:29:35 +0000 (11:29 +0900)
Change-Id: I4a837028d9e6b49c6d57b2d3c62da36a108e3784
Signed-off-by: pr.jung <pr.jung@samsung.com>
CMakeLists.txt
packaging/libstorage.spec
src/storage.c

index f621ade..a846ba6 100644 (file)
@@ -10,7 +10,7 @@ SET(VERSION 0.1)
 SET(INC_DIR include)
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/${INC_DIR})
 
-SET(dependents "dlog capi-base-common vconf glib-2.0 libtzplatform-config")
+SET(dependents "dlog capi-base-common vconf glib-2.0 libtzplatform-config capi-system-system-settings")
 SET(pc_dependents "capi-base-common")
 
 INCLUDE(FindPkgConfig)
index f9eef1f..9f1087a 100644 (file)
@@ -12,6 +12,7 @@ BuildRequires:  pkgconfig(capi-base-common)
 BuildRequires:  pkgconfig(vconf)
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(libtzplatform-config)
+BuildRequires:  pkgconfig(capi-system-system-settings)
 
 %description
 development package of library to get storage
index dcf301d..e21b0cd 100644 (file)
@@ -19,6 +19,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <system_settings.h>
 
 #include "common.h"
 #include "list.h"
@@ -33,7 +34,7 @@ const char *dir_path[STORAGE_DIRECTORY_MAX] = {
        [STORAGE_DIRECTORY_MUSIC] = "Music",
        [STORAGE_DIRECTORY_DOCUMENTS] = "Documents",
        [STORAGE_DIRECTORY_OTHERS] = "Others",
-       [STORAGE_DIRECTORY_SYSTEM_RINGTONES] = "/usr/apps/org.tizen.setting/shared/res/settings/Ringtones",
+       [STORAGE_DIRECTORY_SYSTEM_RINGTONES] = "",
 };
 
 static dd_list *st_head;
@@ -100,6 +101,8 @@ API int storage_get_directory(int storage_id, storage_directory_e type, char **p
        const struct storage_ops *st;
        const char *root;
        char temp[PATH_MAX];
+       char *temp2, *end;
+       int ret;
 
        if (!path) {
                _E("Invalid parameger");
@@ -124,9 +127,18 @@ API int storage_get_directory(int storage_id, storage_directory_e type, char **p
        }
 
        root = st->root();
-       if (type == STORAGE_DIRECTORY_SYSTEM_RINGTONES)
-               snprintf(temp, PATH_MAX, "%s", dir_path[type]);
-       else
+       if (type == STORAGE_DIRECTORY_SYSTEM_RINGTONES) {
+               ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, &temp2);
+               if (ret < 0) {
+                       _E("Failed to get ringtone path : %d", ret);
+                       return STORAGE_ERROR_OPERATION_FAILED;
+               }
+               end = strrchr(temp2, '/');
+               if (end)
+                       *end = '\0';
+               snprintf(temp, PATH_MAX, "%s", temp2);
+               free(temp2);
+       } else
                snprintf(temp, PATH_MAX, "%s/%s", root, dir_path[type]);
 
        *path = strdup(temp);