Use preference API for writing or reading IME option value 05/112805/3
authorJihoon Kim <jihoon48.kim@samsung.com>
Fri, 3 Feb 2017 01:56:03 +0000 (10:56 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Fri, 3 Feb 2017 08:14:45 +0000 (17:14 +0900)
Change-Id: I674f64ac5b51d520347650b216fdce85bedc8564
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/config.cpp
src/include/config.h
src/ise-emoticon-mode.cpp
src/ise.cpp
src/sdk/sdk.cpp

index 5290339..6640f7a 100644 (file)
 #include <sstream>
 #include <iterator>
 
-#include <sclcore.h>
+#include <app_preference.h>
 
 #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<KEYPAD_MODE>(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<std::string> begin(ss);
@@ -80,30 +89,31 @@ void read_ise_config_values() {
         std::vector<std::string> 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<std::string>::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() {
index 5a789f1..796e461 100644 (file)
@@ -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.
index 8f20e58..bbd795f 100644 (file)
 #include <vector>
 #include <sstream>
 #include <iterator>
-#include <Elementary.h>
 #include <algorithm>
+#include <Elementary.h>
+#include <app_preference.h>
+#include <sclutils.h>
+#include <sclfeedback.h>
+
 #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 <int> 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());
     }
 }
index b7604f5..6ded7d9 100644 (file)
 #ifdef HAVE_CBHM
 #include <cbhm.h>
 #endif
+#include <sclui.h>
+#include <sclcore.h>
+#include <sclutils.h>
 
-#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 <stt.h>
 
 #define CANDIDATE_WINDOW_HEIGHT 84
 using namespace scl;
@@ -51,10 +50,6 @@ using namespace std;
 
 CSCLUI *g_ui = NULL;
 
-#include <sclcore.h>
-
-#include "ise.h"
-
 #ifdef HAVE_CBHM
 static cbhm_h cbhm_handle;
 #endif
index d39e853..0f12421 100644 (file)
  */
 
 #include <sclui.h>
+#include <sclcore.h>
+#include <iconv.h>
+
 #include "ise.h"
 #include "sdk.h"
 #include "option.h"
-#include "sclcore.h"
 #include "candidate.h"
-
 #include "ise_lang_table.h"
-
-#include <iconv.h>
 #include "cji.h"
 
 using namespace scl;