Add a new api to set prediction_hint text 47/124447/3
authorInHong Han <inhong1.han@samsung.com>
Mon, 10 Apr 2017 05:27:18 +0000 (14:27 +0900)
committerInHong Han <inhong1.han@samsung.com>
Fri, 28 Apr 2017 09:06:04 +0000 (18:06 +0900)
Change-Id: I6575c032acc535be39b8a78f5f5b87078181442b

include/inputmethod.h
src/inputmethod.cpp

index 7aad329890dbd773d4690b363b6298177df7f589..85d4ec23ad9296c4684facf07694498a6b12bed4 100644 (file)
@@ -663,6 +663,26 @@ typedef void (*ime_option_window_created_cb)(Evas_Object *window, ime_option_win
  */
 typedef void (*ime_option_window_destroyed_cb)(Evas_Object *window, void *user_data);
 
+/**
+ * @brief Called to set the prediction hint string to deliver to the input panel.
+ *
+ * @since_tizen 4.0
+ *
+ * @privlevel public
+ *
+ * @privilege %http://tizen.org/privilege/ime
+ *
+ * @remarks This function is used by the applications to deliver the prediction hint message to the input panel.
+ *
+ * @param[in] prediction_hint The prediction hint to be set to the input panel
+ * @param[in] user_data User data to be passed to the callback function
+ *
+ * @pre The callback can be registered using ime_event_set_prediction_hint_cb() function.
+ *
+ * @see ime_event_set_prediction_hint_cb()
+ */
+typedef void (*ime_prediction_hint_set_cb)(const char *prediction_hint, void *user_data);
+
 /**
  * @brief The structure type to contain the set of the essential callback functions for IME application lifecycle and appearance.
  *
@@ -728,6 +748,7 @@ typedef struct {
  * @see ime_event_set_accessibility_state_changed_cb()
  * @see ime_event_set_option_window_created_cb()
  * @see ime_event_set_option_window_destroyed_cb()
+ * @see ime_event_set_prediction_hint_cb()
  *
  * @code
  static void inputmethod_create_cb(void *user_data);
@@ -2120,6 +2141,34 @@ EXPORT_API int ime_device_info_get_class(ime_device_info_h dev_info, Ecore_IMF_D
  */
 EXPORT_API int ime_device_info_get_subclass(ime_device_info_h dev_info, Ecore_IMF_Device_Subclass *dev_subclass);
 
+/**
+ * @brief Sets @c prediction_hint_set event callback function.
+ *
+ * @since_tizen 4.0
+ *
+ * @privlevel public
+ *
+ * @privilege %http://tizen.org/privilege/ime
+ *
+ * @remarks The ime_prediction_hint_set_cb() callback function is called to set the prediction
+ * hint string to deliver to the input panel.
+ *
+ * @param[in] callback_func @c prediction_hint_set 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_INVALID_PARAMETER Invalid parameter
+ * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
+ * @retval #IME_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @post The ime_run() function should be called to start to run IME application's main loop.
+ *
+ * @see ime_prediction_hint_set_cb()
+ * @see ime_run()
+ */
+EXPORT_API int ime_event_set_prediction_hint_cb(ime_prediction_hint_set_cb callback_func, void *user_data);
+
 /**
  * @}
  */
index 4ff94c6c4da24cd2411b99d06f1b047b5d4dd86e..7fd90807f526938f2f7586c6fd9e236d7367681d 100644 (file)
@@ -67,6 +67,7 @@ class CCoreEventCallback : public ISCLCoreEventCallback
     void on_candidate_hide(sclint ic, const sclchar *ic_uuid);
     void on_update_lookup_table(SclCandidateTable &table);
     void on_process_input_device_event(sclu32 &type, sclchar *data, size_t &len, sclu32 *ret);
+    void on_set_prediction_hint(const sclchar *prediction_hint);
 };
 
 typedef struct
@@ -95,6 +96,7 @@ typedef struct
     ime_candidate_hide_cb candidate_hide;
     ime_lookup_table_changed_cb lookup_table_changed;
     ime_process_input_device_event_cb process_input_device_event;   /**< Called when the event is received from the unconventional input devices */
+    ime_prediction_hint_set_cb prediction_hint_set;
     void *focus_in_user_data;
     void *focus_out_user_data;
     void *surrounding_text_updated_user_data;
@@ -119,6 +121,7 @@ typedef struct
     void *candidate_hide_user_data;
     void *lookup_table_changed_user_data;
     void *process_input_device_event_user_data;
+    void *prediction_hint_set_user_data;
 } ime_event_callback_s;
 
 typedef struct {
@@ -439,6 +442,13 @@ void CCoreEventCallback::on_process_input_device_event(sclu32 &type, sclchar *da
     }
 }
 
+void CCoreEventCallback::on_set_prediction_hint(const sclchar *prediction_hint)
+{
+    if (g_event_callback.prediction_hint_set) {
+        g_event_callback.prediction_hint_set(prediction_hint, g_event_callback.prediction_hint_set_user_data);
+    }
+}
+
 ime_error_e _check_privilege()
 {
     char uid[16];
@@ -1921,3 +1931,24 @@ int ime_input_device_rotary_get_direction(ime_input_device_event_h event_handle,
 
     return IME_ERROR_NONE;
 }
+
+int ime_event_set_prediction_hint_cb(ime_prediction_hint_set_cb callback_func, void *user_data)
+{
+    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) {
+        LOGE("_check_privilege returned %d.", retVal);
+        return retVal;
+    }
+
+    g_event_callback.prediction_hint_set = callback_func;
+    g_event_callback.prediction_hint_set_user_data = user_data;
+
+    return IME_ERROR_NONE;
+}
\ No newline at end of file