Fix issue preference_changed_cb() isn't registered in encryption mode 64/170864/5
authorInHong Han <inhong1.han@samsung.com>
Fri, 23 Feb 2018 01:51:36 +0000 (10:51 +0900)
committerInHong Han <inhong1.han@samsung.com>
Mon, 26 Feb 2018 04:45:54 +0000 (13:45 +0900)
Change-Id: I9ca15997cc2a4ef8c2de82160883fc1a3a0674c6

CMakeLists.txt
packaging/ise-default.spec
src/ise.cpp

index 0f6062d..61fe0fc 100644 (file)
@@ -77,6 +77,7 @@ SET(PKGS_CHECK_MODULES
         capi-ui-inputmethod
         smartreply
         key-manager
+        ode
         )
 
 IF (with_cbhm)
index 13f4506..f6ab54c 100644 (file)
@@ -23,6 +23,7 @@ BuildRequires:  pkgconfig(capi-media-audio-io)
 BuildRequires:  pkgconfig(capi-ui-inputmethod)
 BuildRequires:  pkgconfig(smartreply)
 BuildRequires:  pkgconfig(key-manager)
+BuildRequires:  pkgconfig(ode)
 Requires:       ise-engine-tables
 Requires:       ise-engine-tables-zh
 Requires:       ise-engine-hangul
index 65ee189..ba91930 100644 (file)
@@ -29,6 +29,7 @@
 #include <inputmethod_internal.h>
 #include <app_control.h>
 #include <app_preference.h>
+#include <ode/internal-encryption.h>
 #ifdef HAVE_CBHM
 #include <cbhm.h>
 #endif
@@ -1766,6 +1767,47 @@ static void ise_floating_mode_changed_cb(const char *key, void *user_data)
     set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
 }
 
+static void register_preference_changed_callback(void)
+{
+    if (preference_set_changed_cb(ISE_CONFIG_KEYPAD_MODE, ise_keypad_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
+        LOGW("Failed to set ise_keypad_mode_changed_cb()");
+
+    if (preference_set_changed_cb(ISE_CONFIG_ENABLED_LANGUAGES, ise_enabled_languages_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
+        LOGW("Failed to set ise_enabled_languages_changed_cb()");
+
+    if (preference_set_changed_cb(ISE_CONFIG_SELECTED_LANGUAGE, ise_selected_language_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
+        LOGW("Failed to set ise_selected_language_changed_cb()");
+
+    if (preference_set_changed_cb(ISE_CONFIG_AUTO_CAPITALISE, ise_autocapital_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
+        LOGW("Failed to set ise_autocapital_mode_changed_cb()");
+
+    if (preference_set_changed_cb(ISE_CONFIG_AUTO_PUNCTUATE, ise_autopunctuate_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
+        LOGW("Failed to set ise_autopunctuate_mode_changed_cb()");
+
+    if (preference_set_changed_cb(ISE_CONFIG_SOUND_ON, ise_sound_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
+        LOGW("Failed to set ise_sound_mode_changed_cb()");
+
+    if (preference_set_changed_cb(ISE_CONFIG_VIBRATION_ON, ise_vibration_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
+        LOGW("Failed to set ise_vibration_mode_changed_cb()");
+
+    if (preference_set_changed_cb(ISE_CONFIG_PREVIEW_ON, ise_character_preview_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
+        LOGW("Failed to set ise_character_preview_mode_changed_cb()");
+
+    if (preference_set_changed_cb(ISE_CONFIG_FIRST_GUIDELINE_POPUP_FOR_SETTING, ise_setting_guide_popup_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
+        LOGW("Failed to set ise_setting_guide_popup_changed_cb()");
+
+    if (preference_set_changed_cb(ISE_CONFIG_FIRST_GUIDELINE_POPUP_FOR_LANGUAGE_CHANGE, ise_language_guide_popup_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
+        LOGW("Failed to set ise_language_guide_popup_changed_cb()");
+
+    if (preference_set_changed_cb(ISE_CONFIG_FLOATING_MODE, ise_floating_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
+        LOGW("Failed to set ise_floating_mode_changed_cb()");
+}
+
+static void ise_mount_changed_cb(void *user_data)
+{
+    register_preference_changed_callback();
+}
+
 void
 ise_create()
 {
@@ -1858,28 +1900,17 @@ ise_create()
         if (!exist)
             write_ise_config_values();
 
-        if (preference_set_changed_cb(ISE_CONFIG_KEYPAD_MODE, ise_keypad_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
-            LOGW("Faild to set ise_keypad_mode_changed_cb()");
-        if (preference_set_changed_cb(ISE_CONFIG_ENABLED_LANGUAGES, ise_enabled_languages_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
-            LOGW("Faild to set ise_enabled_languages_changed_cb()");
-        if (preference_set_changed_cb(ISE_CONFIG_SELECTED_LANGUAGE, ise_selected_language_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
-            LOGW("Faild to set ise_selected_language_changed_cb()");
-        if (preference_set_changed_cb(ISE_CONFIG_AUTO_CAPITALISE, ise_autocapital_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
-            LOGW("Faild to set ise_autocapital_mode_changed_cb()");
-        if (preference_set_changed_cb(ISE_CONFIG_AUTO_PUNCTUATE, ise_autopunctuate_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
-            LOGW("Faild to set ise_autopunctuate_mode_changed_cb()");
-        if (preference_set_changed_cb(ISE_CONFIG_SOUND_ON, ise_sound_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
-            LOGW("Faild to set ise_sound_mode_changed_cb()");
-        if (preference_set_changed_cb(ISE_CONFIG_VIBRATION_ON, ise_vibration_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
-            LOGW("Faild to set ise_vibration_mode_changed_cb()");
-        if (preference_set_changed_cb(ISE_CONFIG_PREVIEW_ON, ise_character_preview_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
-            LOGW("Faild to set ise_character_preview_mode_changed_cb()");
-        if (preference_set_changed_cb(ISE_CONFIG_FIRST_GUIDELINE_POPUP_FOR_SETTING, ise_setting_guide_popup_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
-            LOGW("Faild to set ise_setting_guide_popup_changed_cb()");
-        if (preference_set_changed_cb(ISE_CONFIG_FIRST_GUIDELINE_POPUP_FOR_LANGUAGE_CHANGE, ise_language_guide_popup_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
-            LOGW("Faild to set ise_language_guide_popup_changed_cb()");
-        if (preference_set_changed_cb(ISE_CONFIG_FLOATING_MODE, ise_floating_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
-            LOGW("Faild to set ise_floating_mode_changed_cb()");
+        int state;
+        if (ode_internal_encryption_get_state(&state) == ODE_ERROR_NONE) {
+            if (state == ODE_STATE_ENCRYPTED) {
+                if (ode_internal_encryption_set_mount_event_cb(ise_mount_changed_cb, NULL) != ODE_ERROR_NONE)
+                    LOGW("Failed to set mount_event_cb()");
+            } else if (state == ODE_STATE_UNENCRYPTED) {
+                register_preference_changed_callback();
+            }
+        } else {
+            LOGW("Failed to get encryption_state");
+        }
     }
     init_recent_used_punctuation();
 }