Refactor to reduce the duplicated code 07/256207/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 31 Mar 2021 02:05:05 +0000 (11:05 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 31 Mar 2021 02:20:20 +0000 (11:20 +0900)
Change-Id: I1d9012af90df0171b4978fb6e314581be84d7f3c
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
ism/extras/efl_panel/isf_panel_efl.cpp

index 6e29501..f5360cc 100644 (file)
@@ -6798,6 +6798,22 @@ static void keyboard_mode_changed_cb (keynode_t *key, void* data)
 }
 #endif
 
+static void set_hw_keyboard_input_detect_flag(bool flag)
+{
+#ifdef HAVE_VCONF
+    int input_detect = false;
+
+    if (vconf_get_bool (VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, &input_detect) == 0) {
+        if (input_detect != flag) {
+            if (vconf_set_bool (VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, flag) != 0)
+                LOGW ("Failed to set vconf key");
+            else
+                LOGD ("Succeeded to set vconf key");
+        }
+    }
+#endif
+}
+
 /**
  * @brief Change keyboard mode.
  *
@@ -6815,10 +6831,6 @@ static void change_keyboard_mode (TOOLBAR_MODE_T mode)
     unsigned int val = 0;
 #endif
 
-#ifdef HAVE_VCONF
-    int input_detect = false;
-#endif
-
     String helper_uuid = _config->read (SCIM_CONFIG_DEFAULT_HELPER_ISE, String (""));
     String default_uuid = scim_global_config_read (String (SCIM_GLOBAL_CONFIG_DEFAULT_ISE_UUID), String (""));
     _support_hw_keyboard_mode = scim_global_config_read (String (SCIM_GLOBAL_CONFIG_SUPPORT_HW_KEYBOARD_MODE), _support_hw_keyboard_mode);
@@ -6892,16 +6904,7 @@ static void change_keyboard_mode (TOOLBAR_MODE_T mode)
         }
 #endif
 
-#ifdef HAVE_VCONF
-        vconf_get_bool (VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, &input_detect);
-
-        if (!input_detect) {
-            if (vconf_set_bool (VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, 1) != 0)
-                LOGW ("Failed to set vconf key");
-            else
-                LOGD ("Succeeded to set vconf key");
-        }
-#endif
+        set_hw_keyboard_input_detect_flag(true);
     } else if (mode == TOOLBAR_HELPER_MODE) {
         LOGD ("SOFTWARE KEYBOARD MODE");
         /* When switching back to S/W keyboard mode, let's hide candidate window first */
@@ -6933,16 +6936,7 @@ static void change_keyboard_mode (TOOLBAR_MODE_T mode)
         delete_notification (&hwkbd_module_noti);
 #endif
 
-#ifdef HAVE_VCONF
-        vconf_get_bool (VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, &input_detect);
-
-        if (input_detect) {
-            if (vconf_set_bool (VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, 0) != 0)
-                LOGW ("Failed to set vconf key");
-            else
-                LOGD ("Succeeded to set vconf key");
-        }
-#endif
+        set_hw_keyboard_input_detect_flag(false);
     }
     _config->reload ();
 }