feedback: Change feedback theme index handling to id-base 24/301124/3
authorYunhee Seo <yuni.seo@samsung.com>
Tue, 7 Nov 2023 10:16:42 +0000 (19:16 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Fri, 10 Nov 2023 04:54:54 +0000 (13:54 +0900)
Previously, the feedback theme was dealt with based on index.
As handling policy is changed, feedback theme can be selected through id.
Feedback themes are no longer treated sequentially, also not dependent on index.
It is managed through a unique id.

Change-Id: I7556e7d877c106f9a311bed1558cddf0ff61dcc9
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
15 files changed:
CMakeLists.txt
common/data/sound-theme1.conf [new file with mode: 0644]
common/data/sound.conf
include/feedback-internal.h
src/devices.h
src/feedback.c
src/sound-parser.c [new file with mode: 0644]
src/sound-parser.h [new file with mode: 0644]
src/sound-theme-manager.c [new file with mode: 0644]
src/sound-theme-manager.h [new file with mode: 0644]
src/sound.c
src/vibrator.c
tests/main.c
tests/test-feedback-internal.c
tests/test-feedback-internal.h

index a0eceb9..40da24a 100644 (file)
@@ -17,6 +17,8 @@ SET(SRCS
        src/feedback-config.c
        src/feedback.c
        src/check.c
+       src/sound-parser.c
+       src/sound-theme-manager.c
        src/util/feedback-privilege.c)
 
 SET(HEADERS
diff --git a/common/data/sound-theme1.conf b/common/data/sound-theme1.conf
new file mode 100644 (file)
index 0000000..5e7a881
--- /dev/null
@@ -0,0 +1,29 @@
+[Sound]
+FEEDBACK_PATTERN_TAP=/usr/share/feedback/sound/touch/touch.wav
+FEEDBACK_PATTERN_SIP=/usr/share/feedback/sound/touch/sip.wav
+FEEDBACK_PATTERN_KEY0=/usr/share/feedback/sound/touch/key0.wav
+FEEDBACK_PATTERN_KEY1=/usr/share/feedback/sound/touch/key1.wav
+FEEDBACK_PATTERN_KEY2=/usr/share/feedback/sound/touch/key2.wav
+FEEDBACK_PATTERN_KEY3=/usr/share/feedback/sound/touch/key3.wav
+FEEDBACK_PATTERN_KEY4=/usr/share/feedback/sound/touch/key4.wav
+FEEDBACK_PATTERN_KEY5=/usr/share/feedback/sound/touch/key5.wav
+FEEDBACK_PATTERN_KEY6=/usr/share/feedback/sound/touch/key6.wav
+FEEDBACK_PATTERN_KEY7=/usr/share/feedback/sound/touch/key7.wav
+FEEDBACK_PATTERN_KEY8=/usr/share/feedback/sound/touch/key8.wav
+FEEDBACK_PATTERN_KEY9=/usr/share/feedback/sound/touch/key9.wav
+FEEDBACK_PATTERN_KEY_STAR=/usr/share/feedback/sound/touch/keyasterisk.wav
+FEEDBACK_PATTERN_KEY_SHARP=/usr/share/feedback/sound/touch/keysharp.wav
+FEEDBACK_PATTERN_KEY_BACK=/usr/share/feedback/sound/touch/touch.wav
+FEEDBACK_PATTERN_HW_TAP=/usr/share/feedback/sound/touch/touch.wav
+FEEDBACK_PATTERN_POWERON=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_CHARGERCONN=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_LOWBATT=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_LOCK=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_UNLOCK=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_SILENT_OFF=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_LIST_REORDER=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_LIST_SLIDER=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_VOLUME_KEY=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_CHARGERCONN_ON_CALL=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_LOWBATT_ON_CALL=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_SCREEN_CAPTURE=/usr/share/feedback/sound/operation/shutter.wav
\ No newline at end of file
index 4f4c93c..f1680c9 100644 (file)
@@ -1,64 +1,37 @@
-# [SoundMultiTheme]
-# - As put this section, This means this conf file supports multi theme.
-#   Thus if you define this section, please remove [Sound] section in this file.
-#   It cannot be defined together, so put [Sound] section to another conf files alone.
+# [SoundTheme]
+# - As put this section, conf file and id can be matched one-on-one.
+#   This section and [Sound] cannot be defined together , so put [Sound] section to another conf files alone.
 #   Furthermore, this section must be located sound.conf(default file).
 #   If you define this section to another file, it will be not work properly.
-#   If you do not define this section in this file, then default theme number will be 0.
-#   It means if you define [SoundMultiTheme], you cannot use 0 as theme index.
+#   Only one default file must be set otherwise conf file parsing will fail.
 #   And also [Sound] will be parsed and used like the existing operation.
-#  number_of_theme=int(range=1~N)
-#   - Define how many conf file will be used.
-#     The number_of_theme should be start with 1 to N.
-#  name_of_default_theme=string
-#   - Define default theme conf file as put SoundThemeN name, The N number file will be selected
-#     as a default theme conf file.
-#     The N number range=1~N
-# [SoundThemeN]
-# - This section determines that the file is defined as the Nth theme.
-#   The N number range=1~N
-#  file_path_of_theme=string
+#  SoundThemeId=unsigned integer
+#   - Define an positive number to use specific conf file.
+#     The SoundThemeId should be set by positive value.
+#  SoundThemePath=string
 #   - Defines the path of the corresponding number file.
 #     In this file, [Sound] section and new patterns, new files should be defined.
+#  SoundThemeDefault=string
+#   - Define default sound theme. Value is "yes" or "no"
+#     At least one sound theme should be specified.
+#     It's not allowed to set serveral default sound theme.
+#     If there is no default SoundTheme, parsing will fail.
 #
-# When you use SoundMultiTheme, You should follow the accurate range of number according to above description.
+# When you use SoundTheme, You should follow the accurate range of number according to above description.
 # If you do not follow above description, the conf file parsing will be fail.
 #
 # Example
-# [SoundMultiTheme]
-# number_of_theme=2
-# name_of_default_theme=SoundTheme2
-# [SoundTheme1]
-# file_path_of_theme=/usr/share/feedback/sound-theme1.conf
-# [SoundTheme2]
-# file_path_of_theme=/usr/share/feedback/sound-theme2.conf
+# [SoundTheme]
+# SoundThemeId=5
+# SoundThemePath=/usr/share/feedback/sound-theme2.conf
+# SoundThemeDefault=no
+#
+# [SoundTheme]
+# SoundThemeId=1
+# SoundThemePath=/usr/share/feedback/sound-theme1.conf
+# SoundThemeDefault=yes
 
-[Sound]
-FEEDBACK_PATTERN_TAP=/usr/share/feedback/sound/touch/touch.wav
-FEEDBACK_PATTERN_SIP=/usr/share/feedback/sound/touch/sip.wav
-FEEDBACK_PATTERN_KEY0=/usr/share/feedback/sound/touch/key0.wav
-FEEDBACK_PATTERN_KEY1=/usr/share/feedback/sound/touch/key1.wav
-FEEDBACK_PATTERN_KEY2=/usr/share/feedback/sound/touch/key2.wav
-FEEDBACK_PATTERN_KEY3=/usr/share/feedback/sound/touch/key3.wav
-FEEDBACK_PATTERN_KEY4=/usr/share/feedback/sound/touch/key4.wav
-FEEDBACK_PATTERN_KEY5=/usr/share/feedback/sound/touch/key5.wav
-FEEDBACK_PATTERN_KEY6=/usr/share/feedback/sound/touch/key6.wav
-FEEDBACK_PATTERN_KEY7=/usr/share/feedback/sound/touch/key7.wav
-FEEDBACK_PATTERN_KEY8=/usr/share/feedback/sound/touch/key8.wav
-FEEDBACK_PATTERN_KEY9=/usr/share/feedback/sound/touch/key9.wav
-FEEDBACK_PATTERN_KEY_STAR=/usr/share/feedback/sound/touch/keyasterisk.wav
-FEEDBACK_PATTERN_KEY_SHARP=/usr/share/feedback/sound/touch/keysharp.wav
-FEEDBACK_PATTERN_KEY_BACK=/usr/share/feedback/sound/touch/touch.wav
-FEEDBACK_PATTERN_HW_TAP=/usr/share/feedback/sound/touch/touch.wav
-FEEDBACK_PATTERN_POWERON=/usr/share/feedback/sound/operation/operation.wav
-FEEDBACK_PATTERN_CHARGERCONN=/usr/share/feedback/sound/operation/operation.wav
-FEEDBACK_PATTERN_LOWBATT=/usr/share/feedback/sound/operation/operation.wav
-FEEDBACK_PATTERN_LOCK=/usr/share/feedback/sound/operation/operation.wav
-FEEDBACK_PATTERN_UNLOCK=/usr/share/feedback/sound/operation/operation.wav
-FEEDBACK_PATTERN_SILENT_OFF=/usr/share/feedback/sound/operation/operation.wav
-FEEDBACK_PATTERN_LIST_REORDER=/usr/share/feedback/sound/operation/operation.wav
-FEEDBACK_PATTERN_LIST_SLIDER=/usr/share/feedback/sound/operation/operation.wav
-FEEDBACK_PATTERN_VOLUME_KEY=/usr/share/feedback/sound/operation/operation.wav
-FEEDBACK_PATTERN_CHARGERCONN_ON_CALL=/usr/share/feedback/sound/operation/operation.wav
-FEEDBACK_PATTERN_LOWBATT_ON_CALL=/usr/share/feedback/sound/operation/operation.wav
-FEEDBACK_PATTERN_SCREEN_CAPTURE=/usr/share/feedback/sound/operation/shutter.wav
+[SoundTheme]
+SoundThemeId=1
+SoundThemePath=/usr/share/feedback/sound-theme1.conf
+SoundThemeDefault=yes
index 2782dda..2038bf7 100755 (executable)
@@ -176,12 +176,12 @@ int feedback_play_type_soundpath_internal(feedback_type_e type, feedback_pattern
 int feedback_get_count_of_theme_internal(feedback_type_e feedback_type, unsigned int *count_of_theme);
 
 /**
- * @brief Gets the current index of theme selected.
- * @details This function gets the current index of theme selected.
- *          The range of theme index will be 1~N according to conf file.
+ * @brief Gets the current id of theme selected.
+ * @details This function gets the current theme id selected.
+ *          The theme id is positive value according to conf file.
  * @since_tizen 7.0
  * @param[in] type The feedback type
- * @param[out] index_of_theme The current index of theme selected
+ * @param[out] id_of_theme The current id of theme selected
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #FEEDBACK_ERROR_NONE Successful
@@ -189,18 +189,18 @@ int feedback_get_count_of_theme_internal(feedback_type_e feedback_type, unsigned
  * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
  */
-int feedback_get_theme_index_internal(feedback_type_e feedback_type, unsigned int *index_of_theme);
+int feedback_get_theme_id_internal(feedback_type_e feedback_type, unsigned int *id_of_theme);
 
 /**
- * @brief Sets the current index of theme.
- * @details This function sets the index of theme.
- *          The range of theme index will be 1~N according to conf file.
- *          Please put the accurate index_of_theme value.
+ * @brief Sets the current id of theme.
+ * @details This function sets the theme id.
+ *          The theme id is positive value according to conf file.
+ *          Please put the accurate theme id value.
  * @since_tizen 7.0
- * @remarks For setting feedback theme index, the privilege should be set to, %http://tizen.org/privilege/systemsettings.admin.
+ * @remarks For setting feedback theme id, the privilege should be set to, %http://tizen.org/privilege/systemsettings.admin.
  *          If app doesn't have the privilege, it returns FEEDBACK_ERROR_PERMISSION_DENIED error.
  * @param[in] type The feedback type
- * @param[in] index_of_theme The index of theme will be selected
+ * @param[in] id_of_theme The id of theme will be selected
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #FEEDBACK_ERROR_NONE Successful
@@ -209,7 +209,7 @@ int feedback_get_theme_index_internal(feedback_type_e feedback_type, unsigned in
  * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
  * @retval #FEEDBACK_ERROR_PERMISSION_DENIED Permission denied
  */
-int feedback_set_theme_index_internal(feedback_type_e feedback_type, unsigned int index_of_theme);
+int feedback_set_theme_id_internal(feedback_type_e feedback_type, unsigned int id_of_theme);
 
 /**
  * @brief Stops various types of reactions by feedback type.
index e7cca85..c8f4394 100644 (file)
@@ -35,8 +35,8 @@ struct device_ops {
        int (*get_path) (int, char *, unsigned int);
        int (*set_path) (int, char *);
        int (*get_count_of_theme) (unsigned int *);
-       int (*get_theme_index) (unsigned int *);
-       int (*set_theme_index) (unsigned int);
+       int (*get_theme_id) (unsigned int *);
+       int (*set_theme_id) (unsigned int);
 };
 
 void devices_init(void);
index 2fed02c..2abfc30 100644 (file)
@@ -560,12 +560,12 @@ API int feedback_get_count_of_theme_internal(feedback_type_e feedback_type, unsi
        return FEEDBACK_ERROR_NONE;
 }
 
-API int feedback_get_theme_index_internal(feedback_type_e feedback_type, unsigned int *index_of_theme)
+API int feedback_get_theme_id_internal(feedback_type_e feedback_type, unsigned int *id_of_theme)
 {
        const struct device_ops *dev = NULL;
        int ret = 0;
 
-       if (feedback_type <= FEEDBACK_TYPE_NONE || feedback_type >= profile->max_type || !index_of_theme) {
+       if (feedback_type <= FEEDBACK_TYPE_NONE || feedback_type >= profile->max_type || !id_of_theme) {
                _E("Invalid parameter : type(%d)", feedback_type);
                return FEEDBACK_ERROR_INVALID_PARAMETER;
        }
@@ -576,11 +576,11 @@ API int feedback_get_theme_index_internal(feedback_type_e feedback_type, unsigne
                return FEEDBACK_ERROR_NOT_SUPPORTED;
        }
 
-       if (!dev->get_theme_index)
+       if (!dev->get_theme_id)
                return FEEDBACK_ERROR_NOT_SUPPORTED;
 
        pthread_mutex_lock(&fmutex);
-       ret = dev->get_theme_index(index_of_theme);
+       ret = dev->get_theme_id(id_of_theme);
        pthread_mutex_unlock(&fmutex);
        if (ret < 0)
                return FEEDBACK_ERROR_OPERATION_FAILED;
@@ -588,7 +588,7 @@ API int feedback_get_theme_index_internal(feedback_type_e feedback_type, unsigne
        return FEEDBACK_ERROR_NONE;
 }
 
-API int feedback_set_theme_index_internal(feedback_type_e feedback_type, unsigned int index_of_theme)
+API int feedback_set_theme_id_internal(feedback_type_e feedback_type, unsigned int id_of_theme)
 {
        const struct device_ops *dev = NULL;
        int ret = 0;
@@ -607,11 +607,11 @@ API int feedback_set_theme_index_internal(feedback_type_e feedback_type, unsigne
                return FEEDBACK_ERROR_NOT_SUPPORTED;
        }
 
-       if (!dev->set_theme_index)
+       if (!dev->set_theme_id)
                return FEEDBACK_ERROR_NOT_SUPPORTED;
 
        pthread_mutex_lock(&fmutex);
-       ret = dev->set_theme_index(index_of_theme);
+       ret = dev->set_theme_id(id_of_theme);
        pthread_mutex_unlock(&fmutex);
        if (ret < 0)
                return FEEDBACK_ERROR_OPERATION_FAILED;
diff --git a/src/sound-parser.c b/src/sound-parser.c
new file mode 100644 (file)
index 0000000..53c7dc2
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * libfeedback
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <libsyscommon/ini-parser.h>
+#include <libsyscommon/list.h>
+
+#include "log.h"
+#include "sound-theme-manager.h"
+
+#define INITIAL_DEFAULT_SOUND_THEME_ID                         -1
+static int default_sound_theme_id = INITIAL_DEFAULT_SOUND_THEME_ID;
+
+static GHashTable *g_hash_table_to_check_id_duplicated;
+
+struct sound_theme_info {
+       int id;
+       int is_default;
+       char *conf_file_path;
+};
+
+static bool is_sound_theme_id_duplicated(int sound_theme_id)
+{
+       gint *hash_key = g_new(gint, 1);
+       *hash_key = sound_theme_id;
+       if (g_hash_table_contains(g_hash_table_to_check_id_duplicated, hash_key)) {
+               g_free(hash_key);
+               return true;
+       }
+
+       g_hash_table_insert(g_hash_table_to_check_id_duplicated, hash_key, NULL);
+       return false;
+}
+
+static int parse_sound_theme_property(gpointer data, gpointer user_data)
+{
+       struct section_property *prop = (struct section_property *) data;
+       struct sound_theme_info *sound_theme_elem = (struct sound_theme_info *)user_data;
+
+       if (!prop || !sound_theme_elem)
+               return 0;
+
+       if (MATCH(prop->key, "SoundThemeId")) {
+               sscanf(prop->value, "%d", (&sound_theme_elem->id));
+               if (sound_theme_elem->id < 0)
+                       return -EPERM;
+       } else if (MATCH(prop->key, "SoundThemePath")) {
+               int str_len = sizeof(prop->value);
+               sound_theme_elem->conf_file_path = strndup(prop->value, str_len);
+       } else if (MATCH(prop->key, "SoundThemeDefault")) {
+               if (MATCH(prop->value, "yes"))
+                       sound_theme_elem->is_default = 1;
+               else if (MATCH(prop->value, "no"))
+                       sound_theme_elem->is_default = 0;
+               else
+                       return -EPERM;
+       }
+       return 0;
+}
+
+
+static int parse_sound_theme_section(const struct parse_result *result, void *data)
+{
+       struct sound_theme_info sound_theme_elem = {0,};
+       struct section_property *extracted_section_prop = NULL;
+       GList *temp_glist = NULL;
+       int ret = 0;
+
+       if (!result || !result->props)
+               return 0;
+
+       if (!MATCH("SoundTheme", result->section))
+               return 0;
+
+       SYS_G_LIST_FOREACH(result->props, temp_glist, extracted_section_prop) {
+               if (parse_sound_theme_property(extracted_section_prop, &sound_theme_elem) < 0)
+                       goto out_parsing_fail;
+       }
+
+       if (sound_theme_elem.is_default && (sound_theme_elem.id == default_sound_theme_id)) {
+               _E("Failed to parse sound conf file, default sound theme is duplicated.");
+               goto out_parsing_fail;
+       }
+
+       if (is_sound_theme_id_duplicated(sound_theme_elem.id)) {
+               _E("Failed to parse sound conf file, sound theme id is duplicated.");
+               goto out_parsing_fail;
+       }
+
+       if (sound_theme_elem.is_default) {
+               default_sound_theme_id = sound_theme_elem.id;
+               sound_thememan_set_default_sound_theme_id(default_sound_theme_id);
+       }
+
+       ret = sound_thememan_add_sound_theme(sound_theme_elem.id, sound_theme_elem.conf_file_path);
+       free(sound_theme_elem.conf_file_path);
+
+       if (ret < 0)
+               return ret;
+
+       return 0;
+
+out_parsing_fail:
+       _E("Failed to parse sound conf file, please check conf file description and follow the rules");
+       free(sound_theme_elem.conf_file_path);
+
+       return -EPERM;
+}
+
+int sound_parser_init(const char* sound_file_path)
+{
+       int ret = 0;
+       default_sound_theme_id = INITIAL_DEFAULT_SOUND_THEME_ID;
+
+       g_hash_table_to_check_id_duplicated = g_hash_table_new_full(g_int_hash, g_int_equal,
+                                                                       g_free, g_free);
+
+       ret = libsys_config_parse_by_section(sound_file_path, parse_sound_theme_section, NULL);
+
+       if (default_sound_theme_id == INITIAL_DEFAULT_SOUND_THEME_ID) {
+               _E("Failed to parse sound conf file. There is no default sound theme id");
+               ret = -EPERM;
+       }
+
+       if (g_hash_table_to_check_id_duplicated)
+               g_hash_table_destroy(g_steal_pointer(&g_hash_table_to_check_id_duplicated));
+
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
\ No newline at end of file
diff --git a/src/sound-parser.h b/src/sound-parser.h
new file mode 100644 (file)
index 0000000..b25bc81
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * libfeedback
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __SOUND_PARSER_H__
+#define __SOUND_PARSER_H__
+
+int sound_parser_init(const char* sound_file_path);
+
+#endif
\ No newline at end of file
diff --git a/src/sound-theme-manager.c b/src/sound-theme-manager.c
new file mode 100644 (file)
index 0000000..dc5db9c
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * libfeedback
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+
+#include "feedback-config.h"
+#include "profiles.h"
+#include "log.h"
+
+#define SOUND_NAME                             "Sound"
+
+struct sound_theme_element {
+       unsigned int id;
+       struct feedback_config_info *sound_info;
+};
+
+static unsigned int default_sound_theme_id;
+static GHashTable *g_sound_theme_list;
+
+static void destroy_sound_theme_hashtable_value(gpointer data)
+{
+       struct feedback_config_info *sound_info = (struct feedback_config_info*)data;
+
+       if (!sound_info)
+               return;
+
+       feedback_free_config(sound_info);
+       free(sound_info);
+}
+
+static bool is_g_sound_theme_list_initialized(void)
+{
+       if (!g_sound_theme_list) {
+               _E("Sound theme is not initialized. please check sound config file.");
+               return false;
+       }
+       return true;
+}
+
+bool sound_thememan_is_sound_theme_id_exist(unsigned int sound_theme_id)
+{
+       gint *hash_key = g_new(gint, 1);
+
+       *hash_key = sound_theme_id;
+       if (!is_g_sound_theme_list_initialized())
+               return false;
+
+       if (!g_hash_table_lookup(g_sound_theme_list, hash_key)) {
+               g_free(hash_key);
+               return false;
+       }
+
+       g_free(hash_key);
+       return true;
+}
+
+void sound_thememan_set_default_sound_theme_id(unsigned int sound_theme_id)
+{
+       default_sound_theme_id = sound_theme_id;
+}
+
+void sound_thememan_get_default_sound_theme_id(unsigned int *sound_theme_id)
+{
+       *sound_theme_id = default_sound_theme_id;
+}
+
+int sound_thememan_get_number_of_theme(unsigned int *number_of_theme)
+{
+       if (!is_g_sound_theme_list_initialized())
+               return -EPERM;
+
+       *number_of_theme = (unsigned int)g_hash_table_size(g_sound_theme_list);
+       return 0;
+}
+
+int sound_thememan_get_sound_theme_info(unsigned int sound_theme_id, void *sound_info)
+{
+       gint *hash_key = g_new(gint, 1);
+       struct feedback_config_info* sound_theme_info;
+
+       if (!is_g_sound_theme_list_initialized())
+               return -EPERM;
+
+       *hash_key = sound_theme_id;
+       sound_theme_info = (struct feedback_config_info*)g_hash_table_lookup(g_sound_theme_list, hash_key);
+       g_free(hash_key);
+
+       *(struct feedback_config_info**)sound_info = sound_theme_info;
+       if (!sound_theme_info)
+               return -EPERM;
+
+       return 0;
+}
+
+int sound_thememan_add_sound_theme(unsigned int sound_theme_id, const char* conf_file_path)
+{
+       struct feedback_config_info *sound_info = NULL;
+       gint *hash_key = g_new(gint, 1);
+       int ret = 0;
+
+       if (!is_g_sound_theme_list_initialized())
+               return -EPERM;
+
+       sound_info = (struct feedback_config_info*)calloc(1, sizeof(struct feedback_config_info));
+       if (!sound_info) {
+               _E("Failed to allocate memory for sound_info.");
+               return -ENOMEM;
+       }
+
+       sound_info->name = SOUND_NAME;
+       ret = feedback_load_config(conf_file_path, sound_info);
+       if (ret < 0) {
+               _E("Failed to load config file %s", conf_file_path);
+               return ret;
+       }
+
+       *hash_key = sound_theme_id;
+       g_hash_table_insert(g_sound_theme_list, hash_key, (gpointer)sound_info);
+       return 0;
+}
+
+int sound_thememan_init(void)
+{
+       g_sound_theme_list = g_hash_table_new_full(g_int_hash, g_int_equal, g_free,
+                                                       destroy_sound_theme_hashtable_value);
+       if (!g_sound_theme_list)
+               return -EPERM;
+
+       return 0;
+}
+
+void sound_thememan_exit(void)
+{
+       if (g_sound_theme_list)
+               g_hash_table_destroy(g_steal_pointer(&g_sound_theme_list));
+}
+
diff --git a/src/sound-theme-manager.h b/src/sound-theme-manager.h
new file mode 100644 (file)
index 0000000..bb2e3cb
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * libfeedback
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __SOUND_THEME_MANAGER_H__
+#define __SOUND_THEME_MANAGER_H__
+
+bool sound_thememan_is_sound_theme_id_exist(unsigned int sound_theme_id);
+void sound_thememan_set_default_sound_theme_id(unsigned int sound_theme_id);
+void sound_thememan_get_default_sound_theme_id(unsigned int *sound_theme_id);
+int sound_thememan_get_sound_theme_info(unsigned int sound_theme_id, void *sound_info);
+int sound_thememan_get_number_of_theme(unsigned int *number_of_theme);
+int sound_thememan_add_sound_theme(unsigned int sound_theme_id, const char* conf_file_path);
+int sound_thememan_init(void);
+void sound_thememan_exit(void);
+
+#endif
\ No newline at end of file
index e08e281..01ccfff 100644 (file)
@@ -37,6 +37,8 @@
 #include "devices.h"
 #include "log.h"
 #include "feedback-config.h"
+#include "sound-parser.h"
+#include "sound-theme-manager.h"
 
 #define SOUND_CONF_FILE FEEDBACK_SYS_RO_SHARE"/feedback/sound.conf"
 #define SOUND_NAME                             "Sound"
 static int sndstatus;
 static int touch_sndstatus;
 static int keytone_sndstatus;
-static int current_theme_index = 0;
-static int number_of_theme = 0;
-static struct feedback_config_info *sound_info;
+static unsigned int current_theme_id = 0;
 
 static char *get_data(feedback_pattern_e pattern)
 {
        char *data;
        int i;
        int index = -1;
+       int ret = 0;
+       struct feedback_config_info *sound_info = NULL;
 
        if (pattern <= FEEDBACK_PATTERN_NONE ||
            pattern >= profile->max_pattern)
@@ -66,8 +68,12 @@ static char *get_data(feedback_pattern_e pattern)
        if (data)
                return data;
 
+       ret = sound_thememan_get_sound_theme_info(current_theme_id, &sound_info);
+       if (ret < 0)
+               return NULL;
+
        for (i = 0; i < profile->get_num_of_pattern(); i++) {
-               if (pattern == sound_info[current_theme_index].data[i].pattern) {
+               if (pattern == sound_info->data[i].pattern) {
                        index = i;
                        break;
                }
@@ -77,10 +83,10 @@ static char *get_data(feedback_pattern_e pattern)
                return NULL;
        }
 
-       if (sound_info[current_theme_index].data[index].changed)
-               data = sound_info[current_theme_index].data[index].changed;
+       if (sound_info->data[index].changed)
+               data = sound_info->data[index].changed;
        else
-               data = sound_info[current_theme_index].data[index].origin;
+               data = sound_info->data[index].origin;
 
        return data;
 }
@@ -119,158 +125,36 @@ static void feedback_keytone_sndstatus_cb(keynode_t *key, void* data)
 
 static void feedback_sound_theme_changed_cb(keynode_t *key, void* data)
 {
-       int vconf_sound_theme_index = vconf_keynode_get_int(key);
+       int vconf_sound_theme_id = vconf_keynode_get_int(key);
 
-       if (vconf_sound_theme_index <= 0) {
-               current_theme_index = 0;
+       if (vconf_sound_theme_id <= 0) {
+               current_theme_id = 0;
                return;
        }
 
-       current_theme_index = vconf_keynode_get_int(key) - 1;
-}
-
-static int feedback_parse_sound_multi_theme_section(const struct parse_result *result, void *data)
-{
-       struct section_property *extracted_section_prop = NULL;
-       GList *temp_glist = NULL;
-
-       if (!result || !result->props)
-               return 0;
-
-       if (!MATCH("SoundMultiTheme", result->section))
-               return 0;
-
-       SYS_G_LIST_FOREACH(result->props, temp_glist, extracted_section_prop) {
-               if (MATCH("number_of_theme", extracted_section_prop->key)) {
-                       sscanf(extracted_section_prop->value, "%d", &number_of_theme);
-               } else if (MATCH("name_of_default_theme", extracted_section_prop->key)) {
-                       sscanf(extracted_section_prop->value, "SoundTheme%d", &current_theme_index);
-                       current_theme_index--;
-               } else {
-                       _E("Failed to parse SoundMultiTheme section. Please check your config file, \
-                               check the value or typo of key value");
-                       return -EINVAL;
-               }
-       }
-
-       if (number_of_theme <= current_theme_index) {
-               _E("Failed to parse SoundMultiTheme section. Please check your config file, \
-                       default theme number cannot be greater then the number of theme");
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-static bool feedback_is_multi_theme_support(const char *path)
-{
-       int ret = 0;
-
-       if (!path)
-               return false;
-
-       ret = libsys_config_parse_by_section(path, feedback_parse_sound_multi_theme_section, NULL);
-       if (ret < 0)
-               return false;
-
-       if (number_of_theme > 0)
-               return true;
-
-       return false;
-}
-
-static int feedback_parse_multi_theme_conf_path_section(const struct parse_result *result, void *data)
-{
-       struct section_property *extracted_section_prop = NULL;
-       GList *temp_glist = NULL;
-       int multi_theme_index = 0;
-       int ret = 0;
-
-       if (!result || !result->props)
-               return 0;
-
-       if (!strstr(result->section, "SoundTheme"))
-               return 0;
-
-       ret = sscanf(result->section, "SoundTheme%d", &multi_theme_index);
-       if (ret == EOF)
-               return 0;
-
-       if (multi_theme_index <= 0) {
-               _E("Failed to parse SoundThemeN section, you should check range of SoundThemeN(1~N)");
-               return -EINVAL;
-       }
-
-       if (multi_theme_index > number_of_theme) {
-               _E("Failed to parse SoundThemeN section, you cannot put N value over number_of_theme value");
-               return -EINVAL;
-       }
-
-       SYS_G_LIST_FOREACH(result->props, temp_glist, extracted_section_prop) {
-               if (MATCH("file_path_of_theme", extracted_section_prop->key)) {
-                       feedback_load_config(extracted_section_prop->value, &sound_info[multi_theme_index-1]);
-               } else {
-                       _E("Failed to parse SoundThemeN section, Please check your config file, \
-                               check the value or typo of key value");
-                       return -EINVAL;
-               }
-       }
-
-       return 0;
+       current_theme_id = vconf_keynode_get_int(key);
 }
 
-static int feedback_multi_theme_load_config(const char *path)
+static void sound_init(void)
 {
        int ret = 0;
 
-       if (!path)
-               return -EINVAL;
-
-       ret = libsys_config_parse_by_section(path, feedback_parse_multi_theme_conf_path_section, NULL);
-
-       return ret;
-}
-
-static int sound_get_config(void)
-{
-       bool is_support_multi_theme = false;
-
-       is_support_multi_theme = feedback_is_multi_theme_support(SOUND_CONF_FILE);
-       if (!is_support_multi_theme)
-               number_of_theme++;
+       current_theme_id = 0;
 
-       sound_info = (struct feedback_config_info*)calloc(number_of_theme, sizeof(struct feedback_config_info));
-       if (!sound_info) {
-               _E("Failed to allocate memory for sound_info.");
-               return -ENOMEM;
+       ret = sound_thememan_init();
+       if (ret < 0) {
+               _E("Failed to initialize sound theme manager(%d)", ret);
+               sound_thememan_exit();
        }
 
-       for (int i = 0; i < number_of_theme; i++)
-               sound_info[i].name = SOUND_NAME;
-
-       if (is_support_multi_theme) {
-               feedback_multi_theme_load_config(SOUND_CONF_FILE);
-       } else {
-               current_theme_index = 0;
-               feedback_load_config(SOUND_CONF_FILE, &sound_info[current_theme_index]);
+       ret = sound_parser_init(SOUND_CONF_FILE);
+       if (ret < 0) {
+               _E("Failed to parsing sound config file(%d)", ret);
+               sound_thememan_exit();
        }
 
-       return 0;
-}
-
-static void sound_init(void)
-{
-       int ret = 0;
-
-       number_of_theme = 0;
-       current_theme_index = 0;
-
-       if (vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME, &current_theme_index) < 0)
-               _W("Failed to get VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME");
-
-       ret = sound_get_config();
-       if (ret < 0)
-               _W("Failed to load configuration file(%s): %d", SOUND_CONF_FILE, ret);
+       sound_thememan_get_default_sound_theme_id(&current_theme_id);
+       ret = vconf_set_int(VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME, current_theme_id);
 
        /* check sound status */
        if (vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &touch_sndstatus) < 0)
@@ -299,22 +183,12 @@ static void sound_init(void)
                _W("Add watch for VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME failed");
 }
 
-static void sound_put_config(void)
-{
-       if (!sound_info)
-               return;
-
-       /* free sound data */
-       for (int i = 0; i < number_of_theme; i++) {
-               feedback_free_config(&sound_info[i]);
-       }
-       sound_info = NULL;
-}
-
 static void sound_exit(void)
 {
        int ret;
 
+       sound_thememan_exit();
+
        /* remove watch */
        ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, feedback_sndstatus_cb);
        if (ret != 0)
@@ -330,7 +204,6 @@ static void sound_exit(void)
        if (ret != 0)
                _W("Remove watch for VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME failed");
 
-       sound_put_config();
 }
 
 //LCOV_EXCL_START
@@ -557,6 +430,8 @@ static int sound_set_path(feedback_pattern_e pattern, char *path)
        struct stat buf;
        int i;
        int index = -1;
+       int ret = 0;
+       struct feedback_config_info *sound_info = NULL;
 
        /*
         * check the path is valid
@@ -572,8 +447,12 @@ static int sound_set_path(feedback_pattern_e pattern, char *path)
                return -EPERM;
        }
 
+       ret = sound_thememan_get_sound_theme_info(current_theme_id, &sound_info);
+       if (ret < 0)
+               return -EPERM;
+
        for (i = 0; i < profile->get_num_of_pattern(); i++) {
-               if (pattern == sound_info[current_theme_index].data[i].pattern) {
+               if (pattern == sound_info->data[i].pattern) {
                        index = i;
                        break;
                }
@@ -581,14 +460,14 @@ static int sound_set_path(feedback_pattern_e pattern, char *path)
 
        if (index < 0) {
                for (i = 0; i < profile->get_num_of_pattern(); i++) {
-                       if (sound_info[current_theme_index].data[i].pattern != -1)
+                       if (sound_info->data[i].pattern != -1)
                                continue;
 
-                       sound_info[current_theme_index].data[i].pattern = pattern;
+                       sound_info->data[i].pattern = pattern;
                        if (path)
-                               sound_info[current_theme_index].data[i].changed = strdup(path);
+                               sound_info->data[i].changed = strdup(path);
                        else
-                               sound_info[current_theme_index].data[i].changed = NULL;
+                               sound_info->data[i].changed = NULL;
 
                        _D("The file of pattern(%s) is changed to [%s]",
                                        profile->str_pattern(pattern), path? path:"NULL");
@@ -599,14 +478,14 @@ static int sound_set_path(feedback_pattern_e pattern, char *path)
                return -EPERM;
        }
 
-       if (sound_info[current_theme_index].data[index].changed) {
-               free(sound_info[current_theme_index].data[index].changed);
-               sound_info[current_theme_index].data[index].changed = NULL;
+       if (sound_info->data[index].changed) {
+               free(sound_info->data[index].changed);
+               sound_info->data[index].changed = NULL;
        }
 
        /* if path is NULL, this pattern set to default file */
        if (path)
-               sound_info[current_theme_index].data[index].changed = strdup(path);
+               sound_info->data[index].changed = strdup(path);
 
        _D("The file of pattern(%s) is changed to [%s]",
                        profile->str_pattern(pattern), path);
@@ -616,38 +495,41 @@ static int sound_set_path(feedback_pattern_e pattern, char *path)
 
 static int sound_get_count_of_theme(unsigned int *count_of_theme)
 {
+       int ret = 0;
        if (!count_of_theme)
                return -EINVAL;
 
-       *count_of_theme = number_of_theme;
+       ret = sound_thememan_get_number_of_theme(count_of_theme);
+       if (ret < 0)
+               return -EPERM;
 
        return 0;
 }
 
-static int sound_get_theme_index(unsigned int *index_of_theme)
+static int sound_get_theme_id(unsigned int *id_of_theme)
 {
-       if (!index_of_theme)
+       if (!id_of_theme)
                return -EINVAL;
 
-       *index_of_theme = current_theme_index + 1;
+       *id_of_theme = current_theme_id;
 
        return 0;
 }
 
-static int sound_set_theme_index(unsigned int index_of_theme)
+static int sound_set_theme_id(unsigned int id_of_theme)
 {
        int ret = 0;
 
-       if (index_of_theme > number_of_theme || index_of_theme <= 0)
+       if (!sound_thememan_is_sound_theme_id_exist(id_of_theme))
                return -EINVAL;
 
-       ret = vconf_set_int(VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME, index_of_theme);
+       ret = vconf_set_int(VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME, id_of_theme);
        if (ret < 0) {
                _E("Failed to set vconf value for VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME");
                return -EPERM;
        }
 
-       current_theme_index = index_of_theme - 1;
+       current_theme_id = id_of_theme;
 
        return 0;
 }
@@ -664,8 +546,8 @@ static const struct device_ops sound_device_ops = {
        .get_path = sound_get_path,
        .set_path = sound_set_path,
        .get_count_of_theme = sound_get_count_of_theme,
-       .get_theme_index = sound_get_theme_index,
-       .set_theme_index = sound_set_theme_index,
+       .get_theme_id = sound_get_theme_id,
+       .set_theme_id = sound_set_theme_id,
 };
 
 DEVICE_OPS_REGISTER(&sound_device_ops);
index f25f584..12a9a94 100644 (file)
@@ -55,7 +55,7 @@ enum haptic_iteration {
 
 static int vibstatus;
 static unsigned int v_handle;
-static int current_theme_index = 0;
+static int current_theme_id = 0;
 
 static inline char *trim_str(char *s)
 {
@@ -149,7 +149,7 @@ static void feedback_vibstatus_cb(keynode_t *key, void* data)
 
 static void feedback_vibration_theme_changed_cb(keynode_t *key, void* data)
 {
-       current_theme_index = vconf_keynode_get_int(key) - 1;
+       current_theme_id = vconf_keynode_get_int(key);
 }
 
 static void vibrator_init(void)
@@ -157,7 +157,7 @@ static void vibrator_init(void)
        int ret_val;
        bool haptic_avail;
 
-       if (vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_VIBRATION_FEEDBACK_THEME, &current_theme_index) < 0)
+       if (vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_VIBRATION_FEEDBACK_THEME, &current_theme_id) < 0)
                _W("Failed to get VCONFKEY_SETAPPL_ACCESSIBILITY_VIBRATION_FEEDBACK_THEME");
 
        ret_val = system_info_get_platform_bool(VIBRATION_FEATURE, &haptic_avail);
@@ -391,8 +391,8 @@ static const struct device_ops vibrator_device_ops = {
        .get_path = vibrator_get_path,
        .set_path = vibrator_set_path,
        .get_count_of_theme = NULL,
-       .set_theme_index = NULL,
-       .get_theme_index = NULL,
+       .set_theme_id = NULL,
+       .get_theme_id = NULL,
 };
 
 DEVICE_OPS_REGISTER(&vibrator_device_ops);
index 42ea7b6..85e51f5 100644 (file)
@@ -28,8 +28,8 @@ void test_all()
        LOG_RESULT(TEST_FEEDBACK_PLAY_TYPE_INTERNAL(), "TEST_FEEDBACK_PLAY_TYPE_INTERNAL");
        LOG_RESULT(TEST_FEEDBACK_PLAY_TYPE_SOUNDPATH_INTERNAL(), "TEST_FEEDBACK_PLAY_TYPE_SOUNDPATH_INTERNAL");
        LOG_RESULT(TEST_FEEDBACK_GET_COUNT_OF_SOUND_THEME_INTERNAL(), "TEST_FEEDBACK_GET_COUNT_OF_SOUND_THEME_INTERNAL");
-       LOG_RESULT(TEST_FEEDBACK_GET_SOUND_THEME_INDEX_INTERNAL(), "TEST_FEEDBACK_GET_SOUND_THEME_INDEX_INTERNAL");
-       LOG_RESULT(TEST_FEEDBACK_SET_SOUND_THEME_INDEX_INTERNAL(), "TEST_FEEDBACK_SET_SOUND_THEME_INDEX_INTERNAL");
+       LOG_RESULT(TEST_FEEDBACK_GET_SOUND_THEME_ID_INTERNAL(), "TEST_FEEDBACK_GET_SOUND_THEME_ID_INTERNAL");
+       LOG_RESULT(TEST_FEEDBACK_SET_SOUND_THEME_ID_INTERNAL(), "TEST_FEEDBACK_SET_SOUND_THEME_ID_INTERNAL");
 }
 
 void show_usage()
index 8968c14..39a0202 100644 (file)
@@ -365,61 +365,48 @@ bool TEST_FEEDBACK_GET_COUNT_OF_SOUND_THEME_INTERNAL(void)
        REPORT_AND_RETURN();
 }
 
-static void test_get_sound_theme_index_internal(void)
+static void test_get_sound_theme_id_internal(void)
 {
-       unsigned int index_of_theme = 0;
+       unsigned int id_of_theme = 0;
 
        feedback_initialize();
-       RESULT(feedback_get_theme_index_internal(FEEDBACK_TYPE_SOUND, NULL),
+       RESULT(feedback_get_theme_id_internal(FEEDBACK_TYPE_SOUND, NULL),
                FEEDBACK_ERROR_INVALID_PARAMETER, "invalid parameter");
-       RESULT(feedback_get_theme_index_internal(FEEDBACK_TYPE_VIBRATION, &index_of_theme),
+       RESULT(feedback_get_theme_id_internal(FEEDBACK_TYPE_VIBRATION, &id_of_theme),
                FEEDBACK_ERROR_NOT_SUPPORTED, "not supported");
-       RESULT(feedback_get_theme_index_internal(FEEDBACK_TYPE_SOUND, &index_of_theme),
+       RESULT(feedback_get_theme_id_internal(FEEDBACK_TYPE_SOUND, &id_of_theme),
                FEEDBACK_ERROR_NONE, "error none");
-       _D("Feedback type=%d sound theme index=%d is get", FEEDBACK_TYPE_SOUND, index_of_theme);
+       _D("Feedback type=%d sound theme id=%d is get", FEEDBACK_TYPE_SOUND, id_of_theme);
        feedback_deinitialize();
 }
 
-bool TEST_FEEDBACK_GET_SOUND_THEME_INDEX_INTERNAL(void)
+bool TEST_FEEDBACK_GET_SOUND_THEME_ID_INTERNAL(void)
 {
        INIT();
-       test_get_sound_theme_index_internal();
+       test_get_sound_theme_id_internal();
        REPORT_AND_RETURN();
 }
 
-static void test_set_sound_theme_index_internal(void)
+static void test_set_sound_theme_id_internal(void)
 {
-       unsigned int count_of_theme = 0;
-       unsigned int index = 0;
+       unsigned int id = 0;
 
        feedback_initialize();
-       feedback_get_count_of_theme_internal(FEEDBACK_TYPE_SOUND, &count_of_theme);
+       feedback_get_theme_id_internal(FEEDBACK_TYPE_SOUND, &id);
 
-       RESULT(feedback_set_theme_index_internal(FEEDBACK_TYPE_SOUND, count_of_theme + 1),
-               FEEDBACK_ERROR_OPERATION_FAILED, "operation failed");
+       RESULT(feedback_set_theme_id_internal(FEEDBACK_TYPE_SOUND, id),
+               FEEDBACK_ERROR_NONE, "error none");
 
-       RESULT(feedback_set_theme_index_internal(FEEDBACK_TYPE_VIBRATION, index),
+       RESULT(feedback_set_theme_id_internal(FEEDBACK_TYPE_VIBRATION, id),
                FEEDBACK_ERROR_NOT_SUPPORTED, "not supported");
-       if (count_of_theme > index) {
-               for (int index = 1; index <= count_of_theme; index++) {
-                       RESULT(feedback_set_theme_index_internal(FEEDBACK_TYPE_SOUND, index),
-                               FEEDBACK_ERROR_NONE, "error none");
-                       test_play_type_by_name_p();
-                       _D("Feedback type=%d sound theme index=%d is set", FEEDBACK_TYPE_SOUND, index);
-               }
-       } else if (count_of_theme == 0) {
-               RESULT(feedback_set_theme_index_internal(FEEDBACK_TYPE_SOUND, index),
-                       FEEDBACK_ERROR_NONE, "error none");
-               test_play_type_by_name_p();
-               _D("Feedback type=%d sound theme index=%d is set", FEEDBACK_TYPE_SOUND, index);
-       }
+
        feedback_deinitialize();
 }
 
-bool TEST_FEEDBACK_SET_SOUND_THEME_INDEX_INTERNAL(void)
+bool TEST_FEEDBACK_SET_SOUND_THEME_ID_INTERNAL(void)
 {
        INIT();
-       test_set_sound_theme_index_internal();
+       test_set_sound_theme_id_internal();
        REPORT_AND_RETURN();
 }
 
index 1946c9a..e317087 100644 (file)
@@ -121,8 +121,8 @@ bool TEST_FEEDBACK_PLAY_SOUNDPATH_INTERNAL(void);
 bool TEST_FEEDBACK_PLAY_TYPE_INTERNAL(void);
 bool TEST_FEEDBACK_PLAY_TYPE_SOUNDPATH_INTERNAL(void);
 bool TEST_FEEDBACK_GET_COUNT_OF_SOUND_THEME_INTERNAL(void);
-bool TEST_FEEDBACK_GET_SOUND_THEME_INDEX_INTERNAL(void);
-bool TEST_FEEDBACK_SET_SOUND_THEME_INDEX_INTERNAL(void);
+bool TEST_FEEDBACK_GET_SOUND_THEME_ID_INTERNAL(void);
+bool TEST_FEEDBACK_SET_SOUND_THEME_ID_INTERNAL(void);
 
 void TEST_INTERNAL_INIT(void);