#define VCKEY_LCD_BACKLIGHT_NORMAL "db/setting/lcd_backlight_normal"
typedef struct {
- int init;
- int read_description;
- int read_list_grid_information;
- int haptic;
- int keyboard_feedback;
- int sound_feedback;
+ bool init;
+ bool read_description;
+ bool read_list_grid_information;
+ bool haptic;
+ bool keyboard_feedback;
+ bool sound_feedback;
int lcd_backlight_timeout;
int tts_speed;
int tts_voice_type;
}
}
+static bool vcwrap_get_key_bool(const char *key, bool def)
+{
+ int result = def; // Needs to be 'int' for vconf_get_bool()
+ if (vconf_get_bool(key, &result)) {
+ ERROR("vconf_get_bool failed! key=%s", key);
+ }
+ return !!result;
+}
+
static int vcwrap_get_key_int(const char *key, int def)
{
int result = def;
return result;
}
+static void vcwrap_field_updater_bool(keynode_t *node, void *destination)
+{
+ if (!destination)
+ return;
+ *((bool*)destination) = !!vconf_keynode_get_bool(node);
+ vcwrap_update_derived_fields(destination);
+}
+
static void vcwrap_field_updater_int(keynode_t *node, void *destination)
{
if (!destination)
vcwrap_update_derived_fields(destination);
}
+static void vcwrap_set_field_updater_bool(const char *key, bool *data)
+{
+ if (vconf_notify_key_changed(key, vcwrap_field_updater_bool, data))
+ ERROR("Could not create updater for key=%s", key);
+}
+
static void vcwrap_set_field_updater_int(const char *key, int *data)
{
if (vconf_notify_key_changed(key, vcwrap_field_updater_int, data))
ERROR("Could not create updater for key=%s", key);
}
+static void vcwrap_unset_field_updater_bool(const char *key)
+{
+ if (vconf_ignore_key_changed(key, vcwrap_field_updater_bool))
+ DEBUG("Could not delete notify callback for key=%s", key);
+}
+
static void vcwrap_unset_field_updater_int(const char *key)
{
if (vconf_ignore_key_changed(key, vcwrap_field_updater_int))
DEBUG("--------------------- VCONF_init START ---------------------");
- vconf_data.init = 1;
- vconf_data.read_description = vcwrap_get_key_int(VCKEY_DESCRIPTION, true);
- vconf_data.read_list_grid_information = vcwrap_get_key_int(VCKEY_LIST_GRID_INFORMATION, true);
- vconf_data.haptic = vcwrap_get_key_int(VCKEY_HAPTIC, true);
- vconf_data.keyboard_feedback = vcwrap_get_key_int(VCKEY_KEYBOARD_FEEDBACK, true);
- vconf_data.sound_feedback = vcwrap_get_key_int(VCKEY_SOUND_FEEDBACK, true);
+ vconf_data.init = true;
+ vconf_data.read_description = vcwrap_get_key_bool(VCKEY_DESCRIPTION, true);
+ vconf_data.read_list_grid_information = vcwrap_get_key_bool(VCKEY_LIST_GRID_INFORMATION, true);
+ vconf_data.haptic = vcwrap_get_key_bool(VCKEY_HAPTIC, true);
+ vconf_data.keyboard_feedback = vcwrap_get_key_bool(VCKEY_KEYBOARD_FEEDBACK, true);
+ vconf_data.sound_feedback = vcwrap_get_key_bool(VCKEY_SOUND_FEEDBACK, true);
vconf_data.lcd_backlight_timeout = vcwrap_get_key_int(VCKEY_LCD_BACKLIGHT_NORMAL, -1);
vconf_data.tts_speed = vcwrap_get_key_int(VCKEY_TTS_SPEED, 0);
vconf_data.tts_language = vcwrap_get_key_str(VCKEY_TTS_VOICE, NULL);
appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE, display_language_changed_cb, NULL);
- vcwrap_set_field_updater_int(VCKEY_DESCRIPTION, &(vconf_data.read_description));
- vcwrap_set_field_updater_int(VCKEY_LIST_GRID_INFORMATION, &(vconf_data.read_list_grid_information));
- vcwrap_set_field_updater_int(VCKEY_HAPTIC, &(vconf_data.haptic));
- vcwrap_set_field_updater_int(VCKEY_KEYBOARD_FEEDBACK, &(vconf_data.keyboard_feedback));
- vcwrap_set_field_updater_int(VCKEY_SOUND_FEEDBACK, &(vconf_data.sound_feedback));
+ vcwrap_set_field_updater_bool(VCKEY_DESCRIPTION, &(vconf_data.read_description));
+ vcwrap_set_field_updater_bool(VCKEY_LIST_GRID_INFORMATION, &(vconf_data.read_list_grid_information));
+ vcwrap_set_field_updater_bool(VCKEY_HAPTIC, &(vconf_data.haptic));
+ vcwrap_set_field_updater_bool(VCKEY_KEYBOARD_FEEDBACK, &(vconf_data.keyboard_feedback));
+ vcwrap_set_field_updater_bool(VCKEY_SOUND_FEEDBACK, &(vconf_data.sound_feedback));
vcwrap_set_field_updater_int(VCKEY_LCD_BACKLIGHT_NORMAL, &(vconf_data.lcd_backlight_timeout));
vcwrap_set_field_updater_int(VCKEY_TTS_SPEED, &(vconf_data.tts_speed));
vcwrap_set_field_updater_str(VCKEY_TTS_VOICE, &(vconf_data.tts_language));
void vc_exit(void)
{
VConfData *vconf_data = vc_get_instance();
- vconf_data->init = 0;
+ vconf_data->init = false;
appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE, NULL, NULL);
- vcwrap_unset_field_updater_int(VCKEY_KEYBOARD_FEEDBACK);
- vcwrap_unset_field_updater_int(VCKEY_HAPTIC);
- vcwrap_unset_field_updater_int(VCKEY_DESCRIPTION);
- vcwrap_unset_field_updater_int(VCKEY_LIST_GRID_INFORMATION);
- vcwrap_unset_field_updater_int(VCKEY_SOUND_FEEDBACK);
+ vcwrap_unset_field_updater_bool(VCKEY_KEYBOARD_FEEDBACK);
+ vcwrap_unset_field_updater_bool(VCKEY_HAPTIC);
+ vcwrap_unset_field_updater_bool(VCKEY_DESCRIPTION);
+ vcwrap_unset_field_updater_bool(VCKEY_LIST_GRID_INFORMATION);
+ vcwrap_unset_field_updater_bool(VCKEY_SOUND_FEEDBACK);
vcwrap_unset_field_updater_int(VCKEY_LCD_BACKLIGHT_NORMAL);
vcwrap_unset_field_updater_int(VCKEY_TTS_SPEED);
vcwrap_unset_field_updater_str(VCKEY_TTS_VOICE);
vconf_data->tts_language = NULL;
}
-int vc_get_read_description(void)
+bool vc_get_read_description(void)
{
return vc_get_instance()->read_description;
}
-int vc_get_read_list_grid_information(void)
+bool vc_get_read_list_grid_information(void)
{
return vc_get_instance()->read_list_grid_information;
}
-int vc_get_haptic(void)
+bool vc_get_haptic(void)
{
return vc_get_instance()->haptic;
}
-int vc_get_keyboard_feedback(void)
+bool vc_get_keyboard_feedback(void)
{
return vc_get_instance()->keyboard_feedback;
}
-int vc_get_sound_feedback(void)
+bool vc_get_sound_feedback(void)
{
return vc_get_instance()->sound_feedback;
}
vconf_data->tts_voice_validator_cb = cb;
if (cb)
vcwrap_update_derived_fields(&(vconf_data->tts_language));
-}
\ No newline at end of file
+}