From: Jihoon Kim Date: Fri, 3 Feb 2017 01:56:03 +0000 (+0900) Subject: Use preference API for writing or reading IME option value X-Git-Tag: accepted/tizen/3.0/common/20170208.145338~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=71faf13564e4a5c68eb255881c0325d88cb47dd8;p=platform%2Fcore%2Fuifw%2Fise-default.git Use preference API for writing or reading IME option value Change-Id: I674f64ac5b51d520347650b216fdce85bedc8564 Signed-off-by: Jihoon Kim --- diff --git a/src/config.cpp b/src/config.cpp index 5290339..6640f7a 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -20,15 +20,13 @@ #include #include -#include +#include #include "config.h" #include "languages.h" using namespace scl; -extern CSCLCore g_core; - #ifdef _TV #define SOUND_ON FALSE #define VIBRATION_ON FALSE @@ -58,21 +56,32 @@ CONFIG_VALUES::CONFIG_VALUES() { CONFIG_VALUES g_config_values; +void read_ise_config_string(const char *key, std::string &value) +{ + char *pref_str = NULL; + int ret; + + ret = preference_get_string(key, &pref_str); + if (ret == PREFERENCE_ERROR_NONE && pref_str) { + value.assign(pref_str, strlen(pref_str)); + free(pref_str); + } +} + void read_ise_config_values() { - g_core.config_reload(); sclint integer_value = 0; std::string string_value; integer_value = KEYPAD_MODE_QTY; - g_core.config_read_int(ISE_CONFIG_KEYPAD_MODE, integer_value); + preference_get_int(ISE_CONFIG_KEYPAD_MODE, &integer_value); g_config_values.keypad_mode = static_cast(integer_value); integer_value = 0; - g_core.config_read_int(ISE_CONFIG_PREDICTION_ON, integer_value); + preference_get_int(ISE_CONFIG_PREDICTION_ON, &integer_value); g_config_values.prediction_on = integer_value; string_value = ""; - g_core.config_read_string(ISE_CONFIG_ENABLED_LANGUAGES, string_value); + read_ise_config_string(ISE_CONFIG_ENABLED_LANGUAGES, string_value); if (string_value.length() > 0) { std::stringstream ss(string_value); std::istream_iterator begin(ss); @@ -80,30 +89,31 @@ void read_ise_config_values() { std::vector vstrings(begin, end); g_config_values.enabled_languages = vstrings; } + string_value = ""; - g_core.config_read_string(ISE_CONFIG_SELECTED_LANGUAGE, string_value); + read_ise_config_string(ISE_CONFIG_SELECTED_LANGUAGE, string_value); if (string_value.length() > 0) { g_config_values.selected_language = string_value; } integer_value = 1; - g_core.config_read_int(ISE_CONFIG_AUTO_CAPITALISE, integer_value); + preference_get_int(ISE_CONFIG_AUTO_CAPITALISE, &integer_value); g_config_values.auto_capitalise = integer_value; integer_value = AUTOPUNCTUATE_ON; - g_core.config_read_int(ISE_CONFIG_AUTO_PUNCTUATE, integer_value); + preference_get_int(ISE_CONFIG_AUTO_PUNCTUATE, &integer_value); g_config_values.auto_punctuate = integer_value; integer_value = SOUND_ON; - g_core.config_read_int(ISE_CONFIG_SOUND_ON, integer_value); + preference_get_int(ISE_CONFIG_SOUND_ON, &integer_value); g_config_values.sound_on = integer_value; integer_value = VIBRATION_ON; - g_core.config_read_int(ISE_CONFIG_VIBRATION_ON, integer_value); + preference_get_int(ISE_CONFIG_VIBRATION_ON, &integer_value); g_config_values.vibration_on = integer_value; integer_value = PREVIEW_ON; - g_core.config_read_int(ISE_CONFIG_PREVIEW_ON, integer_value); + preference_get_int(ISE_CONFIG_PREVIEW_ON, &integer_value); g_config_values.preview_on = integer_value; #ifdef _TV g_config_values.enabled_languages.push_back("English"); @@ -117,35 +127,34 @@ void read_ise_config_values() { void write_ise_config_values() { std::string string_value; - g_core.config_write_int(ISE_CONFIG_KEYPAD_MODE, g_config_values.keypad_mode); - g_core.config_write_int(ISE_CONFIG_PREDICTION_ON, g_config_values.prediction_on); + preference_set_int(ISE_CONFIG_KEYPAD_MODE, g_config_values.keypad_mode); + preference_set_int(ISE_CONFIG_PREDICTION_ON, g_config_values.prediction_on); + for (std::vector::iterator it = g_config_values.enabled_languages.begin(); it != g_config_values.enabled_languages.end();std::advance(it, 1)) { string_value += *it; string_value += " "; } - g_core.config_write_string(ISE_CONFIG_ENABLED_LANGUAGES, string_value); - g_core.config_write_string(ISE_CONFIG_SELECTED_LANGUAGE, g_config_values.selected_language); - g_core.config_write_int(ISE_CONFIG_AUTO_CAPITALISE, g_config_values.auto_capitalise); - g_core.config_write_int(ISE_CONFIG_AUTO_PUNCTUATE, g_config_values.auto_punctuate); - g_core.config_write_int(ISE_CONFIG_SOUND_ON, g_config_values.sound_on); - g_core.config_write_int(ISE_CONFIG_VIBRATION_ON, g_config_values.vibration_on); - g_core.config_write_int(ISE_CONFIG_PREVIEW_ON, g_config_values.preview_on); - g_core.config_flush(); - g_core.config_reload(); + + preference_set_string(ISE_CONFIG_ENABLED_LANGUAGES, string_value.c_str()); + preference_set_string(ISE_CONFIG_SELECTED_LANGUAGE, g_config_values.selected_language.c_str()); + preference_set_int(ISE_CONFIG_AUTO_CAPITALISE, g_config_values.auto_capitalise); + preference_set_int(ISE_CONFIG_AUTO_PUNCTUATE, g_config_values.auto_punctuate); + preference_set_int(ISE_CONFIG_SOUND_ON, g_config_values.sound_on); + preference_set_int(ISE_CONFIG_VIBRATION_ON, g_config_values.vibration_on); + preference_set_int(ISE_CONFIG_PREVIEW_ON, g_config_values.preview_on); } void erase_ise_config_values() { - g_core.config_erase(ISE_CONFIG_KEYPAD_MODE); - g_core.config_erase(ISE_CONFIG_PREDICTION_ON); - g_core.config_erase(ISE_CONFIG_ENABLED_LANGUAGES); - g_core.config_erase(ISE_CONFIG_SELECTED_LANGUAGE); - g_core.config_erase(ISE_CONFIG_AUTO_CAPITALISE); - g_core.config_erase(ISE_CONFIG_AUTO_PUNCTUATE); - g_core.config_erase(ISE_CONFIG_SOUND_ON); - g_core.config_erase(ISE_CONFIG_VIBRATION_ON); - g_core.config_erase(ISE_CONFIG_PREVIEW_ON); - g_core.config_reload(); + preference_remove(ISE_CONFIG_KEYPAD_MODE); + preference_remove(ISE_CONFIG_PREDICTION_ON); + preference_remove(ISE_CONFIG_ENABLED_LANGUAGES); + preference_remove(ISE_CONFIG_SELECTED_LANGUAGE); + preference_remove(ISE_CONFIG_AUTO_CAPITALISE); + preference_remove(ISE_CONFIG_AUTO_PUNCTUATE); + preference_remove(ISE_CONFIG_SOUND_ON); + preference_remove(ISE_CONFIG_VIBRATION_ON); + preference_remove(ISE_CONFIG_PREVIEW_ON); } void reset_ise_config_values() { diff --git a/src/include/config.h b/src/include/config.h index 5a789f1..796e461 100644 --- a/src/include/config.h +++ b/src/include/config.h @@ -55,6 +55,8 @@ struct CONFIG_VALUES { sclboolean preview_on; }; +void read_ise_config_string(const char *key, std::string &value); + /** * Reads all option values from SCIM config file @return Nothing. diff --git a/src/ise-emoticon-mode.cpp b/src/ise-emoticon-mode.cpp index 8f20e58..bbd795f 100644 --- a/src/ise-emoticon-mode.cpp +++ b/src/ise-emoticon-mode.cpp @@ -21,13 +21,15 @@ #include #include #include -#include #include +#include +#include +#include +#include + #include "ise-emoticon-mode.h" #include "ise.h" #include "config.h" -#include "sclutils.h" -#include "sclfeedback.h" #include "candidate-factory.h" #undef LOG_TAG @@ -104,7 +106,6 @@ std::vector emoticon_list_recent; bool is_recently_used_emoticon_mode_disabled = true; extern CSCLUI *g_ui; -extern CSCLCore g_core; extern int * emoticon_list[]; extern CONFIG_VALUES g_config_values; extern Candidate *g_candidate; @@ -174,7 +175,8 @@ void ise_read_recent_emoticon_list_from_scim(void) { LOGD("Enter\n"); std::string string_value; - g_core.config_read_string(ISE_CONFIG_RECENT_EMOTICONS_LIST, string_value); + read_ise_config_string(ISE_CONFIG_RECENT_EMOTICONS_LIST, string_value); + if (string_value.length() > 0) { LOGD("read recent emoticon:%s\n", string_value.c_str()); std::stringstream ss(string_value); @@ -201,8 +203,7 @@ void ise_write_recent_emoticon_list_to_scim(void) string_value += " "; } if (string_value.length() > 0) { - g_core.config_write_string(ISE_CONFIG_RECENT_EMOTICONS_LIST, string_value); - g_core.config_flush(); + preference_set_string(ISE_CONFIG_RECENT_EMOTICONS_LIST, string_value.c_str()); LOGD("write recent emoticon:%s\n", string_value.c_str()); } } diff --git a/src/ise.cpp b/src/ise.cpp index b7604f5..6ded7d9 100644 --- a/src/ise.cpp +++ b/src/ise.cpp @@ -29,10 +29,10 @@ #ifdef HAVE_CBHM #include #endif +#include +#include +#include -#include "sclui.h" -#include "sclcore.h" -#include "sclutils.h" #include "ise.h" #include "utils.h" #include "option.h" @@ -42,7 +42,6 @@ #include "ise-stt-mode.h" #include "ise-stt-option.h" #include "modeindicator.h" -#include #define CANDIDATE_WINDOW_HEIGHT 84 using namespace scl; @@ -51,10 +50,6 @@ using namespace std; CSCLUI *g_ui = NULL; -#include - -#include "ise.h" - #ifdef HAVE_CBHM static cbhm_h cbhm_handle; #endif diff --git a/src/sdk/sdk.cpp b/src/sdk/sdk.cpp index d39e853..0f12421 100644 --- a/src/sdk/sdk.cpp +++ b/src/sdk/sdk.cpp @@ -16,15 +16,14 @@ */ #include +#include +#include + #include "ise.h" #include "sdk.h" #include "option.h" -#include "sclcore.h" #include "candidate.h" - #include "ise_lang_table.h" - -#include #include "cji.h" using namespace scl;