From 705c8a2f4bd8cfdd121ff16c2dc326032c41edb2 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 20 Jul 2020 22:08:46 +0900 Subject: [PATCH] Add new interfaces to pass event to ise-engine-loader Change-Id: Ic90cd18593e06b910654d9f3380436c981d9a932 --- inputmethod/include/inputmethod_internal.h | 677 +++++++++++++++++++++++++++++ inputmethod/src/inputmethod.cpp | 674 ++++++++++++++++++++++++++++ 2 files changed, 1351 insertions(+) diff --git a/inputmethod/include/inputmethod_internal.h b/inputmethod/include/inputmethod_internal.h index c15e487..7ba5673 100644 --- a/inputmethod/include/inputmethod_internal.h +++ b/inputmethod/include/inputmethod_internal.h @@ -24,6 +24,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -104,6 +105,170 @@ typedef void (*ime_lookup_table_changed_cb)(Eina_List *list, void *user_data); typedef void (*ime_optimization_hint_set_cb)(ime_optimization_hint_e hint, void *user_data); /** + * @brief Called when a key event is received from external devices or ime_send_key_event(). + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @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); + +/** + * @brief Called when a autocapital type is set. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] type The autocapital type to be set to the input panel + * @param[in] user_data User data to be passed to the callback function + */ +typedef void (*ime_autocapital_type_set_cb)(uint32_t type, void *user_data); + +/** + * @brief Called when a prediction allow is set. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] prediction_allow The prediction allow to be set to the input panel + * @param[in] user_data User data to be passed to the callback function + */ +typedef void (*ime_prediction_allow_set_cb)(uint32_t prediction_allow, void *user_data); + +/** + * @brief Called when a trigger property value is set. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] property The trigger property + * @param[in] user_data User data to be passed to the callback function + */ +typedef void (*ime_trigger_property_set_cb)(const char *property, void *user_data); + +/** + * @brief Called when a candidate more window is shown. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] user_data User data to be passed to the callback function + */ +typedef void (*ime_candidate_more_window_show_cb)(void *user_data); + +/** + * @brief Called when a candidate more window is hidden. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] user_data User data to be passed to the callback function + */ +typedef void (*ime_candidate_more_window_hide_cb)(void *user_data); + +/** + * @brief Called when an AUX item is selected + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] item The AUX item + * @param[in] user_data User data to be passed to the callback function + */ +typedef void (*ime_aux_select_cb)(uint32_t item, void *user_data); + +/** + * @brief Called when a candidate item is selected + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] item The cadidate item + * @param[in] user_data User data to be passed to the callback function + */ +typedef void (*ime_candidate_select_cb)(uint32_t item, void *user_data); + +/** + * @brief Called when a candidate table page is up + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] user_data User data to be passed to the callback function + */ +typedef void (*ime_candidate_table_page_up_cb)(void *user_data); + +/** + * @brief Called when a candidate table page is down + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] user_data User data to be passed to the callback function + */ +typedef void (*ime_candidate_table_page_down_cb)(void *user_data); + +/** + * @brief Called when a page size of the candidate window is changed. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] size The page size of the candidate window + * @param[in] user_data User data to be passed from the callback registration function + */ +typedef void (*ime_candidate_table_page_size_chaned_cb)(uint32_t size, void *user_data); + +/** + * @brief Called when a candidate item layout is set. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] item The candidate item layout + * @param[in] user_data User data to be passed to the callback function + */ +typedef void (*ime_candidate_item_layout_set_cb)(std::vector item, void *user_data); + +/** + * @brief Called when a displayed candidate number is changed. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] page_num The displayed candidate number + * @param[in] user_data User data to be passed from the callback registration function + */ +typedef void (*ime_displayed_candidate_number_chaned_cb)(uint32_t page_num, void *user_data); + +/** + * @brief Called when the candidate item is long pressed. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] index The index of the candidate item + * @param[in] user_data User data to be passed from the callback registration function + */ +typedef void (*ime_candidate_item_long_pressed_cb)(uint32_t index, void *user_data); + +/** * @brief Sets @c ime_caps_mode_changed_cb() event callback function. * * @since_tizen 3.0 @@ -395,6 +560,518 @@ int ime_set_window_creation_defer_flag(bool flag); */ int ime_event_set_optimization_hint_set_cb(ime_optimization_hint_set_cb callback_func, void *user_data); +/** + * @brief Sets @c ime_process_key_event_with_imengine_cb() event callback function. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_process_key_event_cb() callback function is called when the key event + * is received from the external keyboard devices or ime_send_key_event() function. + * + * @param[in] callback_func @c ime_process_key_event_with_imengine_cb() event callback function + * @param[in] user_data User data to be passed to the callback function + * + * @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_INVALID_PARAMETER Invalid parameter + * + * @post The ime_run() function should be called to start to run IME application's main loop. + * + * @see ime_run() + */ +int ime_event_set_process_key_event_with_imengine_cb(ime_process_key_event_with_imengine_cb callback_func, void *user_data); + +/** + * @brief Sets @c ime_autocapital_type_set_cb() event callback function. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_autocapital_type_set_cb() callback function is called when an optimization hint is set + * + * @param[in] callback_func @c ime_autocapital_type_set_cb() event callback function + * @param[in] user_data User data to be passed to the callback function + * + * @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_INVALID_PARAMETER Invalid parameter + * + * @post The ime_run() function should be called to start to run IME application's main loop. + * + * @see ime_run() + */ +int ime_event_set_autocapital_type_set_cb(ime_autocapital_type_set_cb callback_func, void *user_data); + +/** + * @brief Sets @c ime_prediction_allow_set_cb() event callback function. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_prediction_allow_set_cb() callback function is called when an optimization hint is set + * + * @param[in] callback_func @c ime_prediction_allow_set_cb() event callback function + * @param[in] user_data User data to be passed to the callback function + * + * @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_INVALID_PARAMETER Invalid parameter + * + * @post The ime_run() function should be called to start to run IME application's main loop. + * + * @see ime_run() + */ +int ime_event_set_prediction_allow_set_cb(ime_prediction_allow_set_cb callback_func, void *user_data); + +/** + * @brief Sets @c ime_trigger_property_set_cb() event callback function. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] callback_func @c ime_trigger_property_set_cb() event callback function + * @param[in] user_data User data to be passed to the callback function + * + * @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_INVALID_PARAMETER Invalid parameter + * + * @post The ime_run() function should be called to start to run IME application's main loop. + * + * @see ime_run() + */ +int ime_event_set_trigger_property_set_cb(ime_trigger_property_set_cb callback_func, void *user_data); + +/** + * @brief Sets @c ime_candidate_more_window_show_cb() event callback function. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] callback_func @c ime_candidate_more_window_show_cb() event callback function + * @param[in] user_data User data to be passed to the callback function + * + * @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_INVALID_PARAMETER Invalid parameter + * + * @post The ime_run() function should be called to start to run IME application's main loop. + * + * @see ime_run() + */ +int ime_event_set_candidate_more_window_show_cb(ime_candidate_more_window_show_cb callback_func, void *user_data); + +/** + * @brief Sets @c ime_candidate_more_window_hide_cb() event callback function. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] callback_func @c ime_candidate_more_window_hide_cb() event callback function + * @param[in] user_data User data to be passed to the callback function + * + * @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_INVALID_PARAMETER Invalid parameter + * + * @post The ime_run() function should be called to start to run IME application's main loop. + * + * @see ime_run() + */ +int ime_event_set_candidate_more_window_hide_cb(ime_candidate_more_window_hide_cb callback_func, void *user_data); + +/** + * @brief Sets @c ime_aux_select_cb() event callback function. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] callback_func @c ime_aux_select_cb() event callback function + * @param[in] user_data User data to be passed to the callback function + * + * @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_INVALID_PARAMETER Invalid parameter + * + * @post The ime_run() function should be called to start to run IME application's main loop. + * + * @see ime_run() + */ +int ime_event_set_aux_select_cb(ime_aux_select_cb callback_func, void *user_data); + +/** + * @brief Sets @c ime_candidate_select_cb() event callback function. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] callback_func @c ime_candidate_select_cb() event callback function + * @param[in] user_data User data to be passed to the callback function + * + * @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_INVALID_PARAMETER Invalid parameter + * + * @post The ime_run() function should be called to start to run IME application's main loop. + * + * @see ime_run() + */ +int ime_event_set_candidate_select_cb(ime_candidate_select_cb callback_func, void *user_data); + +/** + * @brief Sets @c ime_candidate_table_page_up_cb() event callback function. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] callback_func @c ime_candidate_table_page_up_cb() event callback function + * @param[in] user_data User data to be passed to the callback function + * + * @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_INVALID_PARAMETER Invalid parameter + * + * @post The ime_run() function should be called to start to run IME application's main loop. + * + * @see ime_run() + */ +int ime_event_set_candidate_table_page_up_cb(ime_candidate_table_page_up_cb callback_func, void *user_data); + +/** + * @brief Sets @c ime_candidate_table_page_down_cb() event callback function. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] callback_func @c ime_candidate_table_page_down_cb() event callback function + * @param[in] user_data User data to be passed to the callback function + * + * @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_INVALID_PARAMETER Invalid parameter + * + * @post The ime_run() function should be called to start to run IME application's main loop. + * + * @see ime_run() + */ +int ime_event_set_candidate_table_page_down_cb(ime_candidate_table_page_down_cb callback_func, void *user_data); + +/** + * @brief Sets @c ime_candidate_table_page_size_chaned_cb() event callback function. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] callback_func @c ime_candidate_table_page_size_chaned_cb() event callback function + * @param[in] user_data User data to be passed to the callback function + * + * @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_INVALID_PARAMETER Invalid parameter + * + * @post The ime_run() function should be called to start to run IME application's main loop. + * + * @see ime_run() + */ +int ime_event_set_candidate_table_page_size_chaned_cb(ime_candidate_table_page_size_chaned_cb callback_func, void *user_data); + +/** + * @brief Sets @c ime_candidate_item_layout_set_cb() event callback function. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] callback_func @c ime_candidate_item_layout_set_cb() event callback function + * @param[in] user_data User data to be passed to the callback function + * + * @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_INVALID_PARAMETER Invalid parameter + * + * @post The ime_run() function should be called to start to run IME application's main loop. + * + * @see ime_run() + */ +int ime_event_set_candidate_item_layout_set_cb(ime_candidate_item_layout_set_cb callback_func, void *user_data); + +/** + * @brief Sets @c ime_displayed_candidate_number_chaned_cb() event callback function. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] callback_func @c ime_displayed_candidate_number_chaned_cb() event callback function + * @param[in] user_data User data to be passed to the callback function + * + * @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_INVALID_PARAMETER Invalid parameter + * + * @post The ime_run() function should be called to start to run IME application's main loop. + * + * @see ime_run() + */ +int ime_event_set_displayed_candidate_number_chaned_cb(ime_displayed_candidate_number_chaned_cb callback_func, void *user_data); + +/** + * @brief Sets @c ime_candidate_item_long_pressed_cb() event callback function. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] callback_func @c ime_candidate_item_long_pressed_cb() event callback function + * @param[in] user_data User data to be passed to the callback function + * + * @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_INVALID_PARAMETER Invalid parameter + * + * @post The ime_run() function should be called to start to run IME application's main loop. + * + * @see ime_run() + */ +int ime_event_set_candidate_item_long_pressed_cb(ime_candidate_item_long_pressed_cb callback_func, void *user_data); + +/** + * @brief Requests to show aux string. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @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 + */ +int ime_show_aux_string(void); + +/** + * @brief Requests to hide aux string. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @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 + */ +int ime_hide_aux_string(void); + +/** + * @brief Requests to show lookup table. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @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 + */ +int ime_show_lookup_table(void); + +/** + * @brief Requests to hide lookup table. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @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 + */ +int ime_hide_lookup_table(void); + +/** + * @brief Requests to update preedit caret. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] caret The preedit caret + * + * @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_INVALID_PARAMETER Invalid parameter + */ +int ime_update_preedit_caret(int caret); + +/** + * @brief Requests to update preedit string with commit string. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] preedit The UTF-8 string to be updated in preedit + * @param[in] commit The UTF-8 string to be committed + * @param[in] attrs @a preedit can be composed of multiple string attributes: underline, highlight color and reversal color + * @param[in] caret The preedit caret + * + * @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_INVALID_PARAMETER Invalid parameter + */ +int ime_update_preedit_string_with_commit(const char *preedit, const char *commit, scim::AttributeList &attrs, int caret); + +/** + * @brief Requests to update aux string. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] str The aux string + * + * @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_INVALID_PARAMETER Invalid parameter + */ +int ime_update_aux_string(const char *str); + +/** + * @brief Requests to update recapture string. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] offset The offset value from the cursor position + * @param[in] len The length of the preedit + * @param[in] preedit The UTF-8 string to be updated in preedit + * @param[in] commit The UTF-8 string to be committed + * @param[in] attrs @a preedit can be composed of multiple string attributes: underline, highlight color and reversal color + * + * @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_INVALID_PARAMETER Invalid parameter + */ +int ime_recapture_string(int offset, int len, const char *preedit, const char *commit, scim::AttributeList &attrs); + +/** + * @brief Requests to update lookup table. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] table The lookup table + * + * @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 + */ +int ime_update_lookup_table(scim::LookupTable &table); + +/** + * @brief Requests to register properties. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] properties The property list + * + * @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 + */ +int ime_register_properties(scim::PropertyList &properties); + +/** + * @brief Requests to update property. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] property The imengine property + * + * @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 + */ +int ime_update_property(scim::Property &property); + +/** + * @brief Requests to expand candidate. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @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 + */ +int ime_expand_candidate(void); + +/** + * @brief Requests to contract candidate. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @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 + */ +int ime_contract_candidate(void); + +/** + * @brief Requests to set candidate sytle. + * + * @since_tizen 5.5 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] portrait_line The candidate portrait line + * @param[in] mode The candidate mode + * + * @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_INVALID_PARAMETER Invalid parameter + */ +int ime_set_candidate_style(scim::ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, scim::ISF_CANDIDATE_MODE_T mode); + #ifdef __cplusplus } #endif diff --git a/inputmethod/src/inputmethod.cpp b/inputmethod/src/inputmethod.cpp index f8e036f..e24db10 100644 --- a/inputmethod/src/inputmethod.cpp +++ b/inputmethod/src/inputmethod.cpp @@ -72,6 +72,20 @@ 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_set_autocapital_type(sclu32 type); + void on_set_prediction_allow(sclu32 prediction_allow); + void on_trigger_property(const sclchar *property); + void on_candidate_more_window_show(sclint ic, const sclchar *uuid); + void on_candidate_more_window_hide(sclint ic, const sclchar *uuid); + void on_select_aux(sclint ic, const sclchar *uuid, sclint index); + void on_select_candidate(sclint ic, const sclchar *uuid, sclint index); + void on_candidate_table_page_up(sclint ic, const sclchar *uuid); + void on_candidate_table_page_down(sclint ic, const sclchar *uuid); + void on_update_candidate_table_page_size(sclint ic, const sclchar *uuid, sclint page_size); + void on_update_candidate_item_layout(const std::vector item); + void on_update_displayed_candidate_number(sclu32 size); + void on_longpress_candidate(sclu32 index); }; typedef struct @@ -105,6 +119,20 @@ typedef struct ime_mime_type_set_request_cb mime_type_set; ime_prediction_hint_data_set_cb prediction_hint_data_set; ime_optimization_hint_set_cb optimization_hint_set; + ime_process_key_event_with_imengine_cb process_key_event_with_imengine; + ime_autocapital_type_set_cb autocapital_type_set; + ime_prediction_allow_set_cb prediction_allow_set; + ime_trigger_property_set_cb trigger_property_set; + ime_candidate_more_window_show_cb candidate_more_window_show; + ime_candidate_more_window_hide_cb candidate_more_window_hide; + ime_aux_select_cb aux_select; + ime_candidate_select_cb candidate_select; + ime_candidate_table_page_up_cb candidate_table_page_up; + ime_candidate_table_page_down_cb candidate_table_page_down; + ime_candidate_table_page_size_chaned_cb candidate_table_page_size_chaned; + ime_candidate_item_layout_set_cb candidate_item_layout_set; + ime_displayed_candidate_number_chaned_cb displayed_candidate_number_chaned; + ime_candidate_item_long_pressed_cb candidate_item_long_pressed; void *focus_in_user_data; void *focus_out_user_data; void *surrounding_text_updated_user_data; @@ -134,6 +162,20 @@ typedef struct void *mime_type_set_user_data; void *prediction_hint_data_set_user_data; void *optimization_hint_set_user_data; + void *process_key_event_with_imengine_user_data; + void *autocapital_type_set_user_data; + void *prediction_allow_set_user_data; + void *trigger_property_set_user_data; + void *candidate_more_window_show_user_data; + void *candidate_more_window_hide_user_data; + void *aux_select_user_data; + void *candidate_select_user_data; + void *candidate_table_page_up_user_data; + void *candidate_table_page_down_user_data; + void *candidate_table_page_size_chaned_user_data; + void *candidate_item_layout_set_user_data; + void *displayed_candidate_number_chaned_user_data; + void *candidate_item_long_pressed_user_data; } ime_event_callback_s; typedef struct { @@ -507,6 +549,109 @@ void CCoreEventCallback::on_set_optimization_hint(sclu32 hint) } } +void CCoreEventCallback::on_process_key_event_with_imengine(scim::KeyEvent &key, sclu32 *ret) +{ + 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; + } +} + +void CCoreEventCallback::on_set_autocapital_type(sclu32 type) +{ + if (g_event_callback.autocapital_type_set) { + g_event_callback.autocapital_type_set(type, g_event_callback.autocapital_type_set_user_data); + } +} + +void CCoreEventCallback::on_set_prediction_allow(sclu32 prediction_allow) +{ + if (g_event_callback.prediction_allow_set) { + g_event_callback.prediction_allow_set(prediction_allow, g_event_callback.prediction_allow_set_user_data); + } +} + +void CCoreEventCallback::on_trigger_property(const sclchar *property) +{ + if (g_event_callback.trigger_property_set) { + g_event_callback.trigger_property_set(property, g_event_callback.trigger_property_set_user_data); + } +} + +void CCoreEventCallback::on_candidate_more_window_show(sclint ic, const sclchar *uuid) +{ + if (g_event_callback.candidate_more_window_show) { + g_event_callback.candidate_more_window_show(g_event_callback.candidate_more_window_show_user_data); + } +} + +void CCoreEventCallback::on_candidate_more_window_hide(sclint ic, const sclchar *uuid) +{ + if (g_event_callback.candidate_more_window_hide) { + g_event_callback.candidate_more_window_hide(g_event_callback.candidate_more_window_hide_user_data); + } +} + +void CCoreEventCallback::on_select_aux(sclint ic, const sclchar *uuid, sclint index) +{ + if (g_event_callback.aux_select) { + g_event_callback.aux_select((uint32_t)index, g_event_callback.aux_select_user_data); + } +} + +void CCoreEventCallback::on_select_candidate(sclint ic, const sclchar *uuid, sclint index) +{ + if (g_event_callback.candidate_select) { + g_event_callback.candidate_select((uint32_t)index, g_event_callback.candidate_select_user_data); + } +} + +void CCoreEventCallback::on_candidate_table_page_up(sclint ic, const sclchar *uuid) +{ + if (g_event_callback.candidate_table_page_up) { + g_event_callback.candidate_table_page_up(g_event_callback.candidate_table_page_up_user_data); + } +} + +void CCoreEventCallback::on_candidate_table_page_down(sclint ic, const sclchar *uuid) +{ + if (g_event_callback.candidate_table_page_down) { + g_event_callback.candidate_table_page_down(g_event_callback.candidate_table_page_down_user_data); + } +} + +void CCoreEventCallback::on_update_candidate_table_page_size(sclint ic, const sclchar *uuid, sclint page_size) +{ + if (g_event_callback.candidate_table_page_size_chaned) { + g_event_callback.candidate_table_page_size_chaned((uint32_t)page_size, g_event_callback.candidate_table_page_size_chaned_user_data); + } +} + +void CCoreEventCallback::on_update_candidate_item_layout(const std::vector item) +{ + if (g_event_callback.candidate_item_layout_set) { + g_event_callback.candidate_item_layout_set(item, g_event_callback.candidate_item_layout_set_user_data); + } +} + +void CCoreEventCallback::on_update_displayed_candidate_number(sclu32 size) +{ + if (g_event_callback.displayed_candidate_number_chaned) { + g_event_callback.displayed_candidate_number_chaned(size, g_event_callback.displayed_candidate_number_chaned_user_data); + } +} + +void CCoreEventCallback::on_longpress_candidate(sclu32 index) +{ + if (g_event_callback.candidate_item_long_pressed) { + g_event_callback.candidate_item_long_pressed(index, g_event_callback.candidate_item_long_pressed_user_data); + } +} + void ime_privilege_cache_init() { g_permission_allowed = false; @@ -2228,6 +2373,535 @@ EXPORT_API int ime_event_set_optimization_hint_set_cb(ime_optimization_hint_set_ return IME_ERROR_NONE; } + +EXPORT_API int ime_event_set_process_key_event_with_imengine_cb(ime_process_key_event_with_imengine_cb callback_func, void *user_data) +{ + LOGD(""); + ime_error_e retVal = IME_ERROR_NONE; + + if (!callback_func) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.process_key_event_with_imengine = callback_func; + g_event_callback.process_key_event_with_imengine_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_autocapital_type_set_cb(ime_autocapital_type_set_cb callback_func, void *user_data) +{ + LOGD(""); + ime_error_e retVal = IME_ERROR_NONE; + + if (!callback_func) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.autocapital_type_set = callback_func; + g_event_callback.autocapital_type_set_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_prediction_allow_set_cb(ime_prediction_allow_set_cb callback_func, void *user_data) +{ + LOGD(""); + ime_error_e retVal = IME_ERROR_NONE; + + if (!callback_func) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.prediction_allow_set = callback_func; + g_event_callback.prediction_allow_set_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_trigger_property_set_cb(ime_trigger_property_set_cb callback_func, void *user_data) +{ + LOGD(""); + ime_error_e retVal = IME_ERROR_NONE; + + if (!callback_func) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.trigger_property_set = callback_func; + g_event_callback.trigger_property_set_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_candidate_more_window_show_cb(ime_candidate_more_window_show_cb callback_func, void *user_data) +{ + LOGD(""); + ime_error_e retVal = IME_ERROR_NONE; + + if (!callback_func) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.candidate_more_window_show = callback_func; + g_event_callback.candidate_more_window_show_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_candidate_more_window_hide_cb(ime_candidate_more_window_hide_cb callback_func, void *user_data) +{ + LOGD(""); + ime_error_e retVal = IME_ERROR_NONE; + + if (!callback_func) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.candidate_more_window_hide = callback_func; + g_event_callback.candidate_more_window_hide_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_aux_select_cb(ime_aux_select_cb callback_func, void *user_data) +{ + LOGD(""); + ime_error_e retVal = IME_ERROR_NONE; + + if (!callback_func) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.aux_select = callback_func; + g_event_callback.aux_select_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_candidate_select_cb(ime_candidate_select_cb callback_func, void *user_data) +{ + LOGD(""); + ime_error_e retVal = IME_ERROR_NONE; + + if (!callback_func) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.candidate_select = callback_func; + g_event_callback.candidate_select_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_candidate_table_page_up_cb(ime_candidate_table_page_up_cb callback_func, void *user_data) +{ + LOGD(""); + ime_error_e retVal = IME_ERROR_NONE; + + if (!callback_func) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.candidate_table_page_up = callback_func; + g_event_callback.candidate_table_page_up_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_candidate_table_page_down_cb(ime_candidate_table_page_down_cb callback_func, void *user_data) +{ + LOGD(""); + ime_error_e retVal = IME_ERROR_NONE; + + if (!callback_func) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.candidate_table_page_down = callback_func; + g_event_callback.candidate_table_page_down_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_candidate_table_page_size_chaned_cb(ime_candidate_table_page_size_chaned_cb callback_func, void *user_data) +{ + LOGD(""); + ime_error_e retVal = IME_ERROR_NONE; + + if (!callback_func) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.candidate_table_page_size_chaned = callback_func; + g_event_callback.candidate_table_page_size_chaned_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_candidate_item_layout_set_cb(ime_candidate_item_layout_set_cb callback_func, void *user_data) +{ + LOGD(""); + ime_error_e retVal = IME_ERROR_NONE; + + if (!callback_func) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.candidate_item_layout_set = callback_func; + g_event_callback.candidate_item_layout_set_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_displayed_candidate_number_chaned_cb(ime_displayed_candidate_number_chaned_cb callback_func, void *user_data) +{ + LOGD(""); + ime_error_e retVal = IME_ERROR_NONE; + + if (!callback_func) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.displayed_candidate_number_chaned = callback_func; + g_event_callback.displayed_candidate_number_chaned_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_candidate_item_long_pressed_cb(ime_candidate_item_long_pressed_cb callback_func, void *user_data) +{ + LOGD(""); + ime_error_e retVal = IME_ERROR_NONE; + + if (!callback_func) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.candidate_item_long_pressed = callback_func; + g_event_callback.candidate_item_long_pressed_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_show_aux_string(void) +{ + ime_error_e retVal = IME_ERROR_NONE; + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + g_core.show_aux_string(); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_hide_aux_string(void) +{ + ime_error_e retVal = IME_ERROR_NONE; + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + g_core.hide_aux_string(); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_show_lookup_table(void) +{ + ime_error_e retVal = IME_ERROR_NONE; + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + g_core.show_candidate_string(); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_hide_lookup_table(void) +{ + ime_error_e retVal = IME_ERROR_NONE; + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + g_core.hide_candidate_string(); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_update_preedit_caret(int caret) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (caret < 0) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + 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.update_preedit_caret(caret); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_update_preedit_string_with_commit(const char *preedit, const char *commit, scim::AttributeList &attrs, int caret) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!preedit && !commit) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + 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.update_preedit_string_with_commit(preedit, commit, attrs, caret); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_update_aux_string(const char *str) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!str) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + 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.update_aux_string(str); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_recapture_string(int offset, int len, const char *preedit, const char *commit, scim::AttributeList &attrs) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (len < 0) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + 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.recapture_string(offset, len, preedit, commit, attrs); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_update_lookup_table(scim::LookupTable &table) +{ + 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.update_lookup_table(table); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_register_properties(scim::PropertyList &properties) +{ + 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.register_properties(properties); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_update_property(scim::Property &property) +{ + 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.update_property(property); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_expand_candidate(void) +{ + ime_error_e retVal = IME_ERROR_NONE; + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + g_core.expand_candidate(); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_contract_candidate(void) +{ + ime_error_e retVal = IME_ERROR_NONE; + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + g_core.contract_candidate(); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_set_candidate_style(scim::ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, scim::ISF_CANDIDATE_MODE_T mode) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (portrait_line < 0 || mode < 0) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + 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.set_candidate_style(portrait_line, mode); + + return IME_ERROR_NONE; +} //LCOV_EXCL_STOP EXPORT_API int ime_update_input_panel_event(ime_event_type_e type, unsigned int value) -- 2.7.4