Add a new internal API to pass processing result asynchronously 17/250617/1
authorInHong Han <inhong1.han@samsung.com>
Wed, 30 Dec 2020 06:46:04 +0000 (15:46 +0900)
committerInHong Han <inhong1.han@samsung.com>
Wed, 30 Dec 2020 08:03:03 +0000 (17:03 +0900)
Change-Id: Ib2b1876fbc459c4b5483211e42d45297a9b6b8d8

inputmethod/include/inputmethod_internal.h
inputmethod/src/inputmethod.cpp

index 83420af..0b8002b 100644 (file)
@@ -114,7 +114,7 @@ typedef void (*ime_optimization_hint_set_cb)(ime_optimization_hint_e hint, void
  * @param[in] key The key event of the keyboard
  * @param[in] user_data User data to be passed from the callback registration function
  */
-typedef bool (*ime_process_key_event_with_imengine_cb)(scim::KeyEvent &key, void *user_data);
+typedef void (*ime_process_key_event_with_imengine_cb)(scim::KeyEvent &key, uint32_t serial, void *user_data);
 
 /**
  * @brief Called when a autocapital type is set.
@@ -1087,6 +1087,21 @@ int ime_set_candidate_style(scim::ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, s
  */
 int ime_set_engine_loader_flag(bool flag);
 
+/**
+ * @brief Sends the key event processing result.
+ *
+ * @since_tizen 6.0
+ *
+ * @privilege %http://tizen.org/privilege/ime
+ *
+ * @param[in] is_success The result value to be sent, indicating whether the key event processing succeeded or not
+ * @return 0 on success, otherwise a negative error value
+ * @retval #IME_ERROR_NONE No error
+ * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
+ * @retval #IME_ERROR_NOT_RUNNING IME main loop isn't started yet
+ */
+int ime_send_key_event_processing_result(scim::KeyEvent &key, uint32_t serial, bool is_success);
+
 #ifdef __cplusplus
 }
 #endif
index b2b9e8f..69c8881 100644 (file)
@@ -72,7 +72,7 @@ class CCoreEventCallback : public ISCLCoreEventCallback
     void on_set_mime_type(const sclchar *mime_type);
     void on_set_prediction_hint_data(const sclchar *key, const sclchar *value);
     void on_set_optimization_hint(sclu32 hint);
-    void on_process_key_event_with_imengine(scim::KeyEvent &key, sclu32 *ret);
+    void on_process_key_event_with_imengine(scim::KeyEvent &key, sclu32 serial);
     void on_set_autocapital_type(sclu32 type);
     void on_set_prediction_allow(sclu32 prediction_allow);
     void on_trigger_property(const sclchar *property);
@@ -549,15 +549,10 @@ void CCoreEventCallback::on_set_optimization_hint(sclu32 hint)
     }
 }
 
-void CCoreEventCallback::on_process_key_event_with_imengine(scim::KeyEvent &key, sclu32 *ret)
+void CCoreEventCallback::on_process_key_event_with_imengine(scim::KeyEvent &key, sclu32 serial)
 {
     if (g_event_callback.process_key_event_with_imengine) {
-        bool processed = g_event_callback.process_key_event_with_imengine(key, g_event_callback.process_key_event_with_imengine_user_data);
-
-        if (ret)
-            *ret = processed ? 1 : 0;
-    } else {
-        if (ret) *ret = 0;
+        g_event_callback.process_key_event_with_imengine(key, serial, g_event_callback.process_key_event_with_imengine_user_data);
     }
 }
 
@@ -2914,6 +2909,23 @@ EXPORT_API int ime_set_engine_loader_flag(bool flag)
 
     return IME_ERROR_NONE;
 }
+
+EXPORT_API int ime_send_key_event_processing_result(scim::KeyEvent &key, uint32_t serial, bool is_success)
+{
+    ime_error_e retVal = IME_ERROR_NONE;
+
+    if (!g_running) {
+        LOGW("IME_ERROR_NOT_RUNNING");
+        return IME_ERROR_NOT_RUNNING;
+    }
+
+    retVal = _check_privilege();
+    if (retVal != IME_ERROR_NONE) return retVal;
+
+    g_core.send_key_event_processing_result(key, serial, is_success);
+
+    return IME_ERROR_NONE;
+}
 //LCOV_EXCL_STOP
 
 EXPORT_API int ime_update_input_panel_event(ime_event_type_e type, unsigned int value)