From: InHong Han Date: Mon, 29 May 2017 11:11:47 +0000 (+0900) Subject: Added ime_event_set_mime_type_cb() API X-Git-Tag: submit/tizen/20170613.070433~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1ed90f7af244c6482a803ac8e45da9bab7556c29;p=platform%2Fcore%2Fapi%2Finputmethod.git Added ime_event_set_mime_type_cb() API Change-Id: Ie2ef23f39c6937da3ec44d56e0a89999bad95b72 --- diff --git a/include/inputmethod.h b/include/inputmethod.h index 3c2db3c..961332c 100644 --- a/include/inputmethod.h +++ b/include/inputmethod.h @@ -684,6 +684,26 @@ typedef void (*ime_option_window_destroyed_cb)(Evas_Object *window, void *user_d typedef void (*ime_prediction_hint_set_cb)(const char *prediction_hint, void *user_data); /** + * @brief Called to set the mime type 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 mime type to the input panel. + * + * @param[in] mime_type The mime type 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_mime_type_cb() function. + * + * @see ime_event_set_mime_type_cb() + */ +typedef void (*ime_mime_type_set_cb)(const char *mime_type, void *user_data); + +/** * @brief The structure type to contain the set of the essential callback functions for IME application lifecycle and appearance. * * @since_tizen @if MOBILE 2.4 @else 3.0 @endif @@ -2160,7 +2180,6 @@ EXPORT_API int ime_device_info_get_subclass(ime_device_info_h dev_info, Ecore_IM * @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. * @@ -2170,6 +2189,32 @@ EXPORT_API int ime_device_info_get_subclass(ime_device_info_h dev_info, Ecore_IM EXPORT_API int ime_event_set_prediction_hint_cb(ime_prediction_hint_set_cb callback_func, void *user_data); /** + * @brief Sets @c mime_type_set event callback function. + * + * @since_tizen 4.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_mime_type_set_cb() callback function is called to set the mime type to deliver to the input panel. + * + * @param[in] callback_func @c mime_type_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 + * + * @post The ime_run() function should be called to start to run IME application's main loop. + * + * @see ime_mime_type_set_cb() + * @see ime_run() + */ +EXPORT_API int ime_event_set_mime_type_cb(ime_mime_type_set_cb callback_func, void *user_data); + +/** * @brief Send a private command to the associated text input UI control. * This can be used by IME to deliver specific data to an application. * The data format MUST be negotiated by both application and IME. diff --git a/src/inputmethod.cpp b/src/inputmethod.cpp index fffc030..d54162c 100644 --- a/src/inputmethod.cpp +++ b/src/inputmethod.cpp @@ -68,6 +68,7 @@ class CCoreEventCallback : public ISCLCoreEventCallback 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); + void on_set_mime_type(const sclchar *mime_type); }; typedef struct @@ -97,6 +98,7 @@ typedef struct 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; + ime_mime_type_set_cb mime_type_set; void *focus_in_user_data; void *focus_out_user_data; void *surrounding_text_updated_user_data; @@ -122,6 +124,7 @@ typedef struct void *lookup_table_changed_user_data; void *process_input_device_event_user_data; void *prediction_hint_set_user_data; + void *mime_type_set_user_data; } ime_event_callback_s; typedef struct { @@ -453,6 +456,13 @@ void CCoreEventCallback::on_set_prediction_hint(const sclchar *prediction_hint) } } +void CCoreEventCallback::on_set_mime_type(const sclchar *mime_type) +{ + if (g_event_callback.mime_type_set) { + g_event_callback.mime_type_set(mime_type, g_event_callback.mime_type_set_user_data); + } +} + ime_error_e _check_privilege() { char uid[16]; @@ -2006,3 +2016,24 @@ int ime_event_set_prediction_hint_cb(ime_prediction_hint_set_cb callback_func, v return IME_ERROR_NONE; } + +int ime_event_set_mime_type_cb(ime_mime_type_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.mime_type_set = callback_func; + g_event_callback.mime_type_set_user_data = user_data; + + return IME_ERROR_NONE; +}