Add isf_control_get_ime_info() API 95/279495/1
authorInHong Han <inhong1.han@samsung.com>
Wed, 10 Aug 2022 08:05:49 +0000 (17:05 +0900)
committerInHong Han <inhong1.han@samsung.com>
Wed, 10 Aug 2022 08:05:49 +0000 (17:05 +0900)
Change-Id: I019fc68fc6df06f47410870f46fae9f8ebe405f8

ism/src/isf_control.cpp
ism/src/isf_control.h

index 373fdb7..78dc6a3 100644 (file)
@@ -385,6 +385,48 @@ EXAPI int isf_control_get_all_ime_info (ime_info_s **info)
     return count;
 }
 
+EXAPI int isf_control_get_ime_info (int index, ime_info_s **info)
+{
+    int ret = 0;
+    int count = -1;
+    HELPER_ISE_INFO helper_info;
+    ime_info_s *ime_info = NULL;
+
+    if (info == NULL)
+        return -1;
+
+    IMControlClient imcontrol_client;
+    if (!imcontrol_client.open_connection ())
+        return -1;
+
+    imcontrol_client.prepare ();
+    if (!imcontrol_client.get_all_helper_ise_info (helper_info))
+        ret = -1;
+
+    imcontrol_client.close_connection ();
+
+    if (ret == -1)
+        return -1;
+
+    count = static_cast<int>(helper_info.label.size());
+    if (count > 0 && index < count) {
+        ime_info = (ime_info_s *)calloc (1, sizeof (ime_info_s));
+        if (ime_info) {
+            snprintf(ime_info->appid, sizeof (ime_info->appid), "%s", helper_info.appid[index].c_str());
+            snprintf(ime_info->label, sizeof (ime_info->label), "%s", helper_info.label[index].c_str());
+            ime_info->is_enabled = static_cast<bool>(helper_info.is_enabled[index]);
+            ime_info->is_preinstalled = static_cast<bool>(helper_info.is_preinstalled[index]);
+            ime_info->has_option = static_cast<int>(helper_info.has_option[index]);
+            *info = ime_info;
+        }
+        else {
+            ret = -1;
+        }
+    }
+
+    return ret;
+}
+
 EXAPI int isf_control_open_ime_option_window (void)
 {
     return isf_control_show_ise_option_window ();
index 8171e94..4d118fb 100644 (file)
@@ -205,6 +205,20 @@ int isf_control_show_ise_option_window (void);
 int isf_control_get_all_ime_info (ime_info_s **info);
 
 /**
+ * @brief Gets the information of IME (on-screen keyboard).
+ *
+ * @remarks This API should not be used by IME process.
+ *
+ * @param index The IME's index.
+ * @param[out] info The parameter is used to store IME information. Application needs to free @a *info variable
+ *
+ * @return 0 if successfully, otherwise return -1
+ *
+ * @post The current active IME's has_option variable will have 0 or 1 value. Other IME's has_option variable might be -1 (unknown).
+ */
+int isf_control_get_ime_info (int index, ime_info_s **info);
+
+/**
  * @brief Requests to open the current IME's option window.
  *
  * @remarks Each IME might have its option (setting) or not. This function should be called only if the current IME provides its option.