Support prediction_hint_data interface 56/160656/4
authorJihoon Kim <jihoon48.kim@samsung.com>
Thu, 26 Oct 2017 08:53:22 +0000 (17:53 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Fri, 15 Dec 2017 06:08:50 +0000 (15:08 +0900)
Change-Id: Iaa7ba0674cdd6bca1bd16333461fb29404137dca
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
include/inputmethod.h
src/inputmethod.cpp

index 9adc218ee5cb644620332af959aa54fb1a2452ac..b621accc62aeb551edae2c8105b7fdc02fa77b47 100644 (file)
@@ -705,6 +705,28 @@ typedef void (*ime_prediction_hint_set_cb)(const char *prediction_hint, void *us
  */
 typedef void (*ime_mime_type_set_request_cb)(const char *mime_type, void *user_data);
 
+/**
+ * @brief Called to set the prediction hint key and value to deliver to the input panel.
+ *
+ * @since_tizen 5.0
+ *
+ * @privlevel public
+ *
+ * @privilege %http://tizen.org/privilege/ime
+ *
+ * @remarks @a prediction_hint_data is valid only in the callback. To use outside the callback, make a copy.
+ * This function is used by the applications to deliver the prediction hint data message to the input panel.
+ *
+ * @param[in] key The prediction hint key to be set to the input panel
+ * @param[in] value The prediction hint value 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_data_set_cb() function.
+ *
+ * @see ime_event_set_prediction_hint_data_set_cb()
+ */
+typedef void (*ime_prediction_hint_data_set_cb)(const char *key, const char *value, void *user_data);
+
 /**
  * @brief The structure type to contain the set of the essential callback functions for IME application lifecycle and appearance.
  *
@@ -2357,6 +2379,33 @@ int ime_set_floating_drag_start(void);
  */
 int ime_set_floating_drag_end(void);
 
+/**
+ * @brief Sets prediction hint data event callback function.
+ *
+ * @since_tizen 5.0
+ *
+ * @privlevel public
+ *
+ * @privilege %http://tizen.org/privilege/ime
+ *
+ * @remarks The ime_prediction_hint_data_set_cb() callback function is called to set the prediction
+ * hint key and value to deliver to the input panel.
+ *
+ * @param[in] callback_func The prediction hint 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
+ *
+ * @post The ime_run() function should be called to start to run IME application's main loop.
+ *
+ * @see ime_prediction_hint_data_set_cb()
+ * @see ime_run()
+ */
+int ime_event_set_prediction_hint_data_set_cb(ime_prediction_hint_data_set_cb callback_func, void *user_data);
+
 /**
  * @}
  */
index b26098765d9f71ed311364162e3088861d11763c..b86b2bb4b37c14981d00637650474208fd030127 100644 (file)
@@ -69,6 +69,7 @@ class CCoreEventCallback : public ISCLCoreEventCallback
     void on_process_input_device_event(sclu32 &type, sclchar *data, size_t &len, sclu32 *ret);
     void on_set_prediction_hint(const sclchar *prediction_hint);
     void on_set_mime_type(const sclchar *mime_type);
+    void on_set_prediction_hint_data(const sclchar *key, const sclchar *value);
 };
 
 typedef struct
@@ -99,6 +100,7 @@ typedef struct
     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;
     ime_mime_type_set_request_cb mime_type_set;
+    ime_prediction_hint_data_set_cb prediction_hint_data_set;
     void *focus_in_user_data;
     void *focus_out_user_data;
     void *surrounding_text_updated_user_data;
@@ -125,6 +127,7 @@ typedef struct
     void *process_input_device_event_user_data;
     void *prediction_hint_set_user_data;
     void *mime_type_set_user_data;
+    void *prediction_hint_data_set_user_data;
 } ime_event_callback_s;
 
 typedef struct {
@@ -459,6 +462,13 @@ void CCoreEventCallback::on_set_mime_type(const sclchar *mime_type)
     }
 }
 
+void CCoreEventCallback::on_set_prediction_hint_data(const sclchar *key, const sclchar *value)
+{
+    if (g_event_callback.prediction_hint_data_set) {
+        g_event_callback.prediction_hint_data_set(key, value, g_event_callback.prediction_hint_data_set_user_data);
+    }
+}
+
 ime_error_e _check_privilege()
 {
     char uid[16];
@@ -1992,3 +2002,21 @@ EXPORT_API int ime_set_window_creation_defer_flag(bool flag)
 
     return IME_ERROR_NONE;
 }
+
+EXPORT_API int ime_event_set_prediction_hint_data_set_cb(ime_prediction_hint_data_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) return retVal;
+
+    g_event_callback.prediction_hint_data_set = callback_func;
+    g_event_callback.prediction_hint_data_set_user_data = user_data;
+
+    return IME_ERROR_NONE;
+}