From: InHong Han Date: Mon, 2 Sep 2019 05:12:32 +0000 (+0900) Subject: Support Remote Input interface X-Git-Tag: submit/tizen/20190904.093136~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F49%2F213149%2F9;p=platform%2Fcore%2Fapi%2Finputmethod.git Support Remote Input interface Change-Id: Icbcd0daac6e06f056783f33f20f2bfcda281eb0d --- diff --git a/AUTHORS b/AUTHORS index 6fbb84d..3718db6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -2,3 +2,4 @@ Sungmin Kwak Ji-hoon Lee Jihoon Kim Jae Yong Lee +Inhong Han \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index de97864..1994c9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,9 @@ SET(maintainer "Ji-hoon Lee ") SET(description "Input Method APIs") SET(service "ui") SET(submodule "inputmethod") +SET(remote_submodule "remote-input") SET(dependents "capi-base-common dlog evas eina ecore-imf libscl-core isf cynara-client cynara-session") +SET(remote_dependents "capi-base-common dlog ecore-imf isf cynara-client cynara-session") SET(LIBDIR ${LIB_INSTALL_DIR}) SET(Services @@ -45,15 +47,19 @@ IF( ${sfind} EQUAL -1 ) ENDIF( ${sfind} EQUAL -1 ) SET(fw_name "${project_prefix}-${service}-${submodule}") +SET(remote_fw_name "${project_prefix}-${service}-${remote_submodule}") PROJECT(${fw_name} CXX) +PROJECT(${remote_fw_name} CXX) SET(CMAKE_INSTALL_PREFIX ${prefix}) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(VERSION ${version}) -SET(INC_DIR include) -INCLUDE_DIRECTORIES(${INC_DIR}) +SET(INC_DIR inputmethod/include) +SET(REMOTE_INC_DIR remote_input/include) +INCLUDE_DIRECTORIES(${INC_DIR} + ${REMOTE_INC_DIR}) INCLUDE(FindPkgConfig) pkg_check_modules(${fw_name} REQUIRED ${dependents}) @@ -61,6 +67,11 @@ FOREACH(flag ${${fw_name}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) +pkg_check_modules(${remote_fw_name} REQUIRED ${remote_dependents}) +FOREACH(flag ${${remote_fw_name}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -fpermissive") SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") @@ -73,11 +84,18 @@ ADD_DEFINITIONS("-DTIZEN_DEBUG") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib") -aux_source_directory(src SOURCES) +aux_source_directory(inputmethod/src SOURCES) ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) - TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS}) +SET(REMOTE-SRCS + remote_input/src/remote_input.cpp + inputmethod/src/privilege_checker.cpp +) + +ADD_LIBRARY(${remote_fw_name} SHARED ${REMOTE-SRCS}) +TARGET_LINK_LIBRARIES(${remote_fw_name} ${${remote_fw_name}_LDFLAGS}) + SET_TARGET_PROPERTIES(${fw_name} PROPERTIES VERSION ${FULLVER} @@ -85,6 +103,13 @@ SET_TARGET_PROPERTIES(${fw_name} CLEAN_DIRECT_OUTPUT 1 ) +SET_TARGET_PROPERTIES(${remote_fw_name} + PROPERTIES + VERSION ${FULLVER} + SOVERSION ${MAJORVER} + CLEAN_DIRECT_OUTPUT 1 +) + INSTALL(TARGETS ${fw_name} DESTINATION ${LIBDIR}) INSTALL( DIRECTORY ${INC_DIR}/ DESTINATION include @@ -93,6 +118,14 @@ INSTALL( PATTERN "${INC_DIR}/*.h" ) +INSTALL(TARGETS ${remote_fw_name} DESTINATION ${LIBDIR}) +INSTALL( + DIRECTORY ${REMOTE_INC_DIR}/ DESTINATION include + FILES_MATCHING + PATTERN "*_private.h" EXCLUDE + PATTERN "${REMOTE_INC_DIR}/*.h" + ) + SET(PC_NAME ${fw_name}) SET(PC_REQUIRED ${dependents}) SET(PC_LDFLAGS -l${fw_name}) @@ -104,6 +137,18 @@ CONFIGURE_FILE( ) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIBDIR}/pkgconfig) +SET(REMOTE_PC_NAME ${remote_fw_name}) +SET(REMOTE_PC_DESCRIPTION "Remote Input APIs") +SET(REMOTE_PC_REQUIRED ${remote_dependents}) +SET(REMOTE_PC_LDFLAGS -l${remote_fw_name}) + +CONFIGURE_FILE( + capi-ui-remote-input.pc.in + ${CMAKE_CURRENT_SOURCE_DIR}/${remote_fw_name}.pc + @ONLY +) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${remote_fw_name}.pc DESTINATION ${LIBDIR}/pkgconfig) + IF(UNIX) ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) diff --git a/capi-ui-remote-input.pc.in b/capi-ui-remote-input.pc.in new file mode 100644 index 0000000..496e105 --- /dev/null +++ b/capi-ui-remote-input.pc.in @@ -0,0 +1,13 @@ +# Package Information for pkg-config + +prefix=@PREFIX@ +exec_prefix=/usr +libdir=@LIBDIR@ +includedir=/usr/include + +Name: @REMOTE_PC_NAME@ +Description: @REMOTE_PC_DESCRIPTION@ +Version: @VERSION@ +Requires: @REMOTE_PC_REQUIRED@ +Libs: -L${libdir} @REMOTE_PC_LDFLAGS@ +Cflags: -I${includedir} diff --git a/include/inputmethod.h b/include/inputmethod.h deleted file mode 100644 index 4f6f3d7..0000000 --- a/include/inputmethod.h +++ /dev/null @@ -1,2571 +0,0 @@ -/* - * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __TIZEN_UIX_INPUTMETHOD_H__ -#define __TIZEN_UIX_INPUTMETHOD_H__ - -/** - * @file inputmethod.h - * @brief This file contains input method APIs and related enumeration. - */ - -#include -#include -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup CAPI_UIX_INPUTMETHOD_MODULE - * @{ - */ - -/** - * @brief Enumeration for input method function error. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - */ -typedef enum { - IME_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - IME_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - IME_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ - IME_ERROR_NO_CALLBACK_FUNCTION = TIZEN_ERROR_IME | 0x0001, /**< Necessary callback function is not set */ - IME_ERROR_NOT_RUNNING = TIZEN_ERROR_IME | 0x0002, /**< IME main loop is not started yet */ - IME_ERROR_OPERATION_FAILED = TIZEN_ERROR_IME | 0x0003, /**< Operation failed */ - IME_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< out of memory */ -} ime_error_e; - -/** - * @brief Enumeration of the option window type. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @see ime_option_window_created_cb() - */ -typedef enum { - IME_OPTION_WINDOW_TYPE_KEYBOARD, /**< Open from Keyboard */ - IME_OPTION_WINDOW_TYPE_SETTING_APPLICATION, /**< Open from Setting application */ -} ime_option_window_type_e; - -/** - * @brief Enumeration of layout variation. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @see ime_context_get_layout_variation() - */ -typedef enum { - IME_LAYOUT_NORMAL_VARIATION_NORMAL = 0, /**< The plain normal layout */ - IME_LAYOUT_NORMAL_VARIATION_FILENAME, /**< Filename layout; symbols such as '/', '*', '\', '|', '<', '>', '?', '"' and ':' should be disabled */ - IME_LAYOUT_NORMAL_VARIATION_PERSON_NAME, /**< The name of a person */ - IME_LAYOUT_NUMBERONLY_VARIATION_NORMAL = 0, /**< The plain normal number layout */ - IME_LAYOUT_NUMBERONLY_VARIATION_SIGNED, /**< The number layout to allow a negative sign */ - IME_LAYOUT_NUMBERONLY_VARIATION_DECIMAL, /**< The number layout to allow decimal point to provide fractional value */ - IME_LAYOUT_NUMBERONLY_VARIATION_SIGNED_AND_DECIMAL, /**< The number layout to allow decimal point and negative sign */ - IME_LAYOUT_PASSWORD_VARIATION_NORMAL = 0, /**< The normal password layout */ - IME_LAYOUT_PASSWORD_VARIATION_NUMBERONLY, /**< The password layout to allow only number */ -} ime_layout_variation_e; - -/** - * @brief Enumeration of string attribute type. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @remarks Currently, a font style is available to use. - * - * @see ime_preedit_attribute() - * @see ime_update_preedit_string() - */ -typedef enum { - IME_ATTR_NONE, /**< No attribute */ - IME_ATTR_FONTSTYLE, /**< A font style attribute, e.g., underline, etc. */ -} ime_attribute_type; - -/** - * @brief Enumeration containing input panel events. - * - * @since_tizen 5.5 - * - * @see ime_update_input_panel_event() - */ -typedef enum { - IME_EVENT_TYPE_LANGUAGE = 1, /**< The language of the input panel */ - IME_EVENT_TYPE_SHIFT_MODE, /**< The shift key state of the input panel */ - IME_EVENT_TYPE_GEOMETRY, /**< The size of the input panel */ -} ime_event_type_e; - -/** - * @brief Value for #IME_ATTR_FONTSTYLE. Draw a line under the text. - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - */ -#define IME_ATTR_FONTSTYLE_UNDERLINE 1 - -/** - * @brief Value for #IME_ATTR_FONTSTYLE. Draw text in highlighted color. - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - */ -#define IME_ATTR_FONTSTYLE_HIGHLIGHT 2 - -/** - * @brief Value for #IME_ATTR_FONTSTYLE. Draw text in reversal color. - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - */ -#define IME_ATTR_FONTSTYLE_REVERSAL 4 - -/** - * @brief The structure type to contain the attributes for preedit string. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @remarks A preedit string may have one or more different attributes. This structure describes each attribute of the string. - * - * @see ime_update_preedit_string() - * @see ime_attribute_type - */ -typedef struct { - unsigned int start; /**< The start position in the string of this attribute */ - unsigned int length; /**< The character length of this attribute, the range is [start, start+length] */ - ime_attribute_type type; /**< The type of this attribute */ - unsigned int value; /**< The value of this attribute */ -} ime_preedit_attribute; - -/** - * @brief Handle of an associated text input UI control's input context. - * - * @details This is one of parameters of ime_show_cb() callback function. IME application - * should configure its input panel with this structure information. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @see ime_context_get_layout() - * @see ime_context_get_layout_variation() - * @see ime_context_get_cursor_position() - * @see ime_context_get_autocapital_type() - * @see ime_context_get_return_key_type() - * @see ime_context_get_return_key_state() - * @see ime_context_get_prediction_mode() - * @see ime_context_get_password_mode() - * @see ime_context_get_input_hint() - * @see ime_context_get_bidi_direction() - * @see ime_context_get_language() - */ -typedef struct _ime_context *ime_context_h; - -/** - * @brief Handle of the device information of the key event. - * - * @details This is one of parameters of ime_process_key_event_cb() callback function. IME application - * may distinguish the key event by using this if necessary. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @see ime_process_key_event_cb() - * @see ime_device_info_get_name() - * @see ime_device_info_get_class() - * @see ime_device_info_get_subclass() - */ -typedef struct _ime_device_info *ime_device_info_h; - -/** - * @brief Called when the input panel is created. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks This callback function is mandatory and must be registered using ime_run(). The - * ime_get_main_window() can be used to get the created input panel window. - * - * @param[in] user_data User data to be passed from the callback registration function - * - * @pre The ime_run() function calls this callback function. - * - * @see ime_run() - * @see ime_set_size() - * @see ime_get_main_window() - */ -typedef void (*ime_create_cb)(void *user_data); - -/** - * @brief Called when the input panel is terminated. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks This callback function is mandatory and must be registered using ime_run(). The - * ime_get_main_window() can be used to get the created input panel window. - * - * @param[in] user_data User data to be passed from the callback registration function - * - * @see ime_run() - * @see ime_get_main_window() - */ -typedef void (*ime_terminate_cb)(void *user_data); - -/** - * @brief Called when an associated text input UI control requests the input panel to show itself. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks This callback function is mandatory and must be registered using ime_run(). - * IME application should configure its input panel with #ime_context_h structure information. - * The ime_get_main_window() can be used to get the created input panel window. - * @a context should not be released. - * - * @param[in] context_id The input context identification value of an associated text input UI control - * @param[in] context The input context information handle - * @param[in] user_data User data to be passed from the callback registration function - * - * @see ime_run() - * @see ime_get_main_window() - * @see ime_context_get_layout() - * @see ime_context_get_layout_variation() - * @see ime_context_get_cursor_position() - * @see ime_context_get_autocapital_type() - * @see ime_context_get_return_key_type() - * @see ime_context_get_return_key_state() - * @see ime_context_get_prediction_mode() - * @see ime_context_get_password_mode() - * @see ime_context_get_input_hint() - * @see ime_context_get_bidi_direction() - * @see ime_context_get_language() - */ -typedef void (*ime_show_cb)(int context_id, ime_context_h context, void *user_data); - -/** - * @brief Called when an associated text input UI control requests the input panel to hide itself. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks This callback function is mandatory and must be registered using ime_run(). The - * ime_get_main_window() can be used to get the created input panel window. - * - * @param[in] context_id The input context identification value of an associated text input UI control - * @param[in] user_data User data to be passed from the callback registration function - * - * @see ime_run() - * @see ime_get_main_window() - */ -typedef void (*ime_hide_cb)(int context_id, void *user_data); - -/** - * @brief Called when an associated text input UI control has focus. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] context_id The input context identification value of an associated text input UI control - * @param[in] user_data User data to be passed from the callback registration function - * - * @pre The callback can be registered using ime_event_set_focus_in_cb() function. - * - * @see ime_event_set_focus_in_cb() - */ -typedef void (*ime_focus_in_cb)(int context_id, void *user_data); - -/** - * @brief Called when an associated text input UI control loses focus. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] context_id The input context identification value of an associated text input UI control - * @param[in] user_data User data to be passed from the callback registration function - * - * @pre The callback can be registered using ime_event_set_focus_out_cb() function. - * - * @see ime_event_set_focus_out_cb() - */ -typedef void (*ime_focus_out_cb)(int context_id, void *user_data); - -/** - * @brief Called when an associated text input UI control responds to a request with the surrounding text. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_request_surrounding_text() must be called to invoke this callback function, asynchronously. - * @remarks @a text can be used only in the callback. To use outside, make a copy. - * - * @param[in] context_id The input context identification value of an associated text input UI control - * @param[in] text The UTF-8 string requested - * @param[in] cursor_pos The cursor position - * @param[in] user_data User data to be passed from the callback registration function - * - * @pre The callback can be registered using ime_event_set_surrounding_text_updated_cb() function. - * - * @see ime_event_set_surrounding_text_updated_cb() - * @see ime_request_surrounding_text() - */ -typedef void (*ime_surrounding_text_updated_cb)(int context_id, const char *text, int cursor_pos, void *user_data); - -/** - * @brief Called to reset the input context of an associated text input UI control. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] user_data User data to be passed from the callback registration function - * - * @pre The callback can be registered using ime_event_set_input_context_reset_cb() function. - * - * @see ime_event_set_input_context_reset_cb() - */ -typedef void (*ime_input_context_reset_cb)(void *user_data); - -/** - * @brief Called when the position of the cursor in an associated text input UI control changes. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] cursor_pos The cursor position - * @param[in] user_data User data to be passed from the callback registration function - * - * @pre The callback can be registered using ime_event_set_cursor_position_updated_cb() function. - * - * @see ime_event_set_cursor_position_updated_cb() - */ -typedef void (*ime_cursor_position_updated_cb)(int cursor_pos, void *user_data); - -/** - * @brief Called when an associated text input UI control requests the language from the input panel. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The allocated @a lang_code will be released internally. - * - * @param[in] user_data User data to be passed from the callback registration function - * @param[out] lang_code Input panel's current input language code (e.g., "en_US") - * - * @pre The callback can be registered using ime_event_set_language_requested_cb() function. - * - * @see ime_event_set_language_requested_cb() - */ -typedef void (*ime_language_requested_cb)(void *user_data, char **lang_code); - -/** - * @brief Called to set the preferred language to the input panel. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks @a language information is already set to the input panel when it is shown - * through #ime_context_h. This callback function will be only called when the client - * application changes the edit field's language attribute after the input panel is shown. - * - * @param[in] language The preferred language that the client application wants - * @param[in] user_data User data to be passed from the callback registration function - * - * @pre The callback can be registered using ime_event_set_language_set_cb() function. - * - * @see ime_event_set_language_set_cb() - */ -typedef void (*ime_language_set_cb)(Ecore_IMF_Input_Panel_Lang language, void *user_data); - -/** - * @brief Called to set the application specific data to deliver to the input panel. - * - * @details This function is used by the applications to deliver the specific data to the input panel. - * The data format MUST be negotiated by both application and input panel. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks @data should not be released. - * - * @param[in] data The specific data to be set to the input panel - * @param[in] data_length The length of data, in bytes, to send to the input panel - * @param[in] user_data User data to be passed from the callback registration function - * - * @pre The callback can be registered using ime_event_set_imdata_set_cb() function. - * - * @see ime_event_set_imdata_set_cb() - */ -typedef void (*ime_imdata_set_cb)(void *data, unsigned int data_length, void *user_data); - -/** - * @brief Called when an associated text input UI control requests the application specific data from the input panel. - * - * @details This API is used by the applications to request the specific data from the input panel. - * The data format MUST be negotiated by both application and input panel. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The allocated @a data and @a data_length will be released internally. - * - * @param[in] user_data User data to be passed from the callback registration function - * @param[out] data Input panel's data to be set to the application - * @param[out] data_length The length of data, in bytes, to send to the application - * - * @pre The callback can be registered using ime_event_set_imdata_requested_cb() function. - * - * @see ime_event_set_imdata_requested_cb() - */ -typedef void (*ime_imdata_requested_cb)(void *user_data, void **data, unsigned int *data_length); - -/** - * @brief Called when an associated text input UI control requests the input panel to set its layout. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks @a layout information is already set to the input panel when it is shown - * through #ime_context_h. This callback function will be only called when the client - * application changes the edit field's layout attribute after the input panel is shown. - * - * @param[in] layout The input panel layout - * @param[in] user_data User data to be passed from the callback registration function - * - * @pre The callback can be registered using ime_event_set_layout_set_cb() function. - * - * @see ime_event_set_layout_set_cb() - */ -typedef void (*ime_layout_set_cb)(Ecore_IMF_Input_Panel_Layout layout, void *user_data); - -/** - * @brief Called when an associated text input UI control requests the input panel to set the @c Return key label. - * The input panel can show text or image on the @c Return button according to the @c Return key action. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks @a type information is already set to the input panel when it is shown - * through #ime_context_h. This callback function will be only called when the client - * application changes the edit field's @c Return key type attribute after the input panel - * is shown. - * - * @param[in] type The type of @c Return key on the input panel - * @param[in] user_data User data to be passed from the callback registration function - * - * @pre The callback can be registered using ime_event_set_return_key_type_set_cb() function. - * - * @see ime_event_set_return_key_type_set_cb() - */ -typedef void (*ime_return_key_type_set_cb)(Ecore_IMF_Input_Panel_Return_Key_Type type, void *user_data); - -/** - * @brief Called when an associated text input UI control requests the input panel to enable - * or disable the @c Return key state. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks @a disabled information is already set to the input panel when it is shown - * through #ime_context_h. This callback function will be only called when the client - * application changes the edit field's @c Return key disable attribute after the input panel - * is shown. - * - * @param[in] disabled The Boolean state to disable @c Return key. The @c Return key is enabled by default - * @param[in] user_data User data to be passed from the callback registration function - * - * @pre The callback can be registered using ime_event_set_return_key_state_set_cb() function. - * - * @see ime_event_set_return_key_state_set_cb() - */ -typedef void (*ime_return_key_state_set_cb)(bool disabled, void *user_data); - -/** - * @brief Called when an associated text input UI control requests the position and size from the input panel. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks @a x, @a y, @a w, and @a h should not be released. - * - * @param[in] user_data User data to be passed from the callback registration function - * @param[out] x The x position in screen - * @param[out] y The y position in screen - * @param[out] w The window width - * @param[out] h The window height - * - * @pre The callback can be registered using ime_event_set_geometry_requested_cb() function. - * - * @see ime_event_set_geometry_requested_cb() - */ -typedef void (*ime_geometry_requested_cb)(void *user_data, int *x, int *y, int *w, int *h); - -/** - * @brief Called when a key event is received from external devices or ime_send_key_event(). - * - * @details This function processes the key event before an associated text input UI control does. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks If the key event is from the external device, @a dev_info will have its name, class and subclass information. - * @a dev_info should not be released by the application. The platform manages the handle; the handle is released when ime_process_key_event_cb() exits. - * - * @param[in] key_code The key code to be sent - * @param[in] key_mask The modifier key mask - * @param[in] dev_info The device information handle - * @param[in] user_data User data to be passed from the callback registration function - * - * @return @c true if the event was processed, otherwise the event was not processed and was forwarded to the client application. - * - * @pre The callback should be registered using ime_event_set_process_key_event_cb() function. - * - * @see ime_event_set_process_key_event_cb() - * @see ime_device_info_get_name() - * @see ime_device_info_get_class() - * @see ime_device_info_get_subclass() - * @see ime_send_key_event() - * @see ime_commit_string() - * @see ime_show_preedit_string() - * @see ime_hide_preedit_string() - * @see ime_update_preedit_string() - */ -typedef bool (*ime_process_key_event_cb)(ime_key_code_e key_code, ime_key_mask_e key_mask, ime_device_info_h dev_info, void *user_data); - -/** - * @brief Called when a key event is received from external devices or ime_send_key_event(). - * - * @details This function processes a key event with a keycode before an associated UI control for the text input deals with the key event. - * - * @since_tizen 5.5 - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks If the key event is from the external device, @a dev_info will have its name, class and subclass information. - * @a dev_info should not be released by the application. The platform manages the handle; the handle is released when ime_process_key_event_with_keycode_cb() exits. - * - * @param[in] key_code The X11 key code to be sent - * @param[in] key_sym The key symbol to be sent - * @param[in] key_mask The modifier key mask - * @param[in] dev_info The device information handle - * @param[in] user_data User data to be passed from the callback registration function - * - * @return @c true if the event was processed, otherwise @c false. When @c false returns, the event was not processed and was forwarded to the client application. - * - * @pre The callback should be registered using ime_event_set_process_key_event_with_keycode_cb() function. - * - * @see ime_event_set_process_key_event_with_keycode_cb() - * @see ime_device_info_get_name() - * @see ime_device_info_get_class() - * @see ime_device_info_get_subclass() - * @see ime_send_key_event() - * @see ime_commit_string() - * @see ime_show_preedit_string() - * @see ime_hide_preedit_string() - * @see ime_update_preedit_string() - */ -typedef bool (*ime_process_key_event_with_keycode_cb)(unsigned int key_code, ime_key_code_e key_sym, ime_key_mask_e key_mask, ime_device_info_h dev_info, void *user_data); - -/** - * @brief Called when the system display language is changed. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] language The language code - * @param[in] user_data User data to be passed from the callback registration function - * - * @pre The callback can be registered using ime_event_set_display_language_changed_cb() function. - * - * @see ime_event_set_display_language_changed_cb() - */ -typedef void (*ime_display_language_changed_cb)(const char *language, void *user_data); - -/** - * @brief Called when the device is rotated. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] degree The rotation degree - * @param[in] user_data User data to be passed from the callback registration function - * - * @pre The callback can be registered using ime_event_set_rotation_degree_changed_cb() function. - * - * @see ime_event_set_rotation_degree_changed_cb() - */ -typedef void (*ime_rotation_degree_changed_cb)(int degree, void *user_data); - -/** - * @brief Called when Accessibility in Settings application is on or off. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] state Accessibility option state - * @param[in] user_data User data to be passed from the callback registration function - * - * @pre The callback can be registered using ime_event_set_accessibility_state_changed_cb() function. - * - * @see ime_event_set_accessibility_state_changed_cb() - */ -typedef void (*ime_accessibility_state_changed_cb)(bool state, void *user_data); - -/** - * @brief Called to create the option window. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks if Input panel requests to open the option window, @a type will be #IME_OPTION_WINDOW_TYPE_KEYBOARD. - * And if Settings application requests to open it, @a type will be #IME_OPTION_WINDOW_TYPE_SETTING_APPLICATION. - * The @a window should not be released. The @a window can be used until ime_option_window_destroyed_cb() will be called. - * - * @param[in] window The created window object - * @param[in] type The type of option window - * @param[in] user_data User data to be passed from the callback registration function - * - * @pre The callback can be registered using ime_event_set_option_window_created_cb() function. The - * ime_create_option_window() calls this callback function or Settings application can call this callback function. - * - * @see ime_event_set_option_window_created_cb() - * @see ime_create_option_window() - */ -typedef void (*ime_option_window_created_cb)(Evas_Object *window, ime_option_window_type_e type, void *user_data); - -/** - * @brief Called to destroy the option window. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The @a window should be released using evas_object_del(). - * - * @param[in] window The window object to destroy - * @param[in] user_data User data to be passed to the callback function - * - * @pre The callback can be registered using ime_event_set_option_window_destroyed_cb() function. - * ime_destroy_option_window() calls this callback function. - * - * @see ime_event_set_option_window_destroyed_cb() - */ -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 @a prediction_hint 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 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_set_cb() function. - * - * @see ime_event_set_prediction_hint_set_cb() - */ -typedef void (*ime_prediction_hint_set_cb)(const char *prediction_hint, void *user_data); - -/** - * @brief Called when an associated text input UI control requests the text entry to set the MIME type. - * - * @since_tizen 4.0 - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks @a mime_type is valid only in the callback. To use outside the callback, make a copy. - * 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_set_request_cb() function. - * - * @see ime_event_set_mime_type_set_request_cb() - */ -typedef void (*ime_mime_type_set_request_cb)(const char *mime_type, void *user_data); - -/** - * @brief Called to set key-value pairs of predicting messages to deliver to the input panel. - * - * @since_tizen 5.0 - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks @a key and @a value is valid only in the callback. To use outside the callback, make a copy. - * This function is used by applications to deliver predicted hint messages 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. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @remarks These four callback functions are mandatory for IME application. - * - * @see ime_run() - */ -typedef struct { - ime_create_cb create; /**< Called when the input panel is created */ - ime_terminate_cb terminate; /**< Called when the input panel is terminated */ - ime_show_cb show; /**< Called when the input panel is requested to show itself */ - ime_hide_cb hide; /**< Called when the input panel is requested to hide itself */ -} ime_callback_s; - -/** - * @brief Runs the main loop of IME application. - * - * @details This function starts to run IME application's main loop. The ime_create_cb() - * callback function is called to initialize IME application before the main loop starts up. And - * the ime_terminate_cb() callback function is called when IME application is terminated. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks IME application MUST implement ime_app_main() function which is the main - * entry point of IME application. In ime_app_main() function, the ime_run() - * function MUST be called with the necessary callback functions; ime_create_cb(), - * ime_terminate_cb(), ime_show_cb(), and ime_hide_cb() callback functions - * are mandatory for IME application. - * - * @param[in] basic_cb The structure pointer of the essential callback functions - * @param[in] user_data User data to be passed to the callback functions - * - * @return 0 if IME application ends successfully, 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_NO_CALLBACK_FUNCTION Necessary callback function is not set - * @retval #IME_ERROR_OPERATION_FAILED Operation failed - * - * @pre The ime_event_set_***() functions can be called to set the event handling callback functions. - * - * @see ime_callback_s() - * @see ime_event_set_focus_in_cb() - * @see ime_event_set_focus_out_cb() - * @see ime_event_set_surrounding_text_updated_cb() - * @see ime_event_set_input_context_reset_cb() - * @see ime_event_set_cursor_position_updated_cb() - * @see ime_event_set_language_requested_cb() - * @see ime_event_set_language_set_cb() - * @see ime_event_set_imdata_set_cb() - * @see ime_event_set_layout_set_cb() - * @see ime_event_set_return_key_type_set_cb() - * @see ime_event_set_return_key_state_set_cb() - * @see ime_event_set_geometry_requested_cb() - * @see ime_event_set_display_language_changed_cb() - * @see ime_event_set_rotation_degree_changed_cb() - * @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_set_cb() - * - * @code - static void inputmethod_create_cb(void *user_data); - static void inputmethod_terminate_cb(void *user_data); - static void inputmethod_show_cb(int context_id, ime_context_h context, void *user_data); - static void inputmethod_hide_cb(int context_id, void *user_data); - static void inputmethod_focus_in_cb(int context_id, void *user_data); - static void inputmethod_focus_out_cb(int context_id, void *user_data); - static void inputmethod_cursor_position_updated_cb(int cursor_pos, void *user_data); - - static void inputmethod_create_cb(void *user_data) - { - Evas_Object *ime_win = NULL; - - ime_set_size(480, 400, 800, 400); - ime_win = ime_get_main_window(); - if (ime_win) { - // Prepare before showing IME window. - } - } - - static void inputmethod_show_cb(int context_id, ime_context_h context, void *user_data) - { - Ecore_IMF_Input_Panel_Layout layout; - ime_layout_variation_e layout_variation; - Evas_Object *ime_win; - - ime_context_get_layout(context, &layout); - ime_context_get_layout_variation(context, &layout_variation); - - ime_win = ime_get_main_window(); - if (ime_win) { - // Compose IME UI properly with the context information and show. - - evas_object_show(ime_win); - } - } - - static void inputmethod_hide_cb(int context_id, void *user_data) - { - Evas_Object *ime_win = ime_get_main_window(); - if (ime_win) { - evas_object_hide(ime_win); - } - } - - void ime_app_main(int argc, char **argv) - { - ime_callback_s basic_callback = { - inputmethod_create_cb, - inputmethod_terminate_cb, - inputmethod_show_cb, - inputmethod_hide_cb, - }; - - ime_event_set_focus_in_cb(inputmethod_focus_in_cb, NULL); - ime_event_set_focus_out_cb(inputmethod_focus_out_cb, NULL); - ime_event_set_cursor_position_updated_cb(inputmethod_cursor_position_updated_cb, NULL); - - ime_run(&basic_callback, NULL); - } - * @endcode - */ -int ime_run(ime_callback_s *basic_cb, void *user_data); - -/** - * @brief Sets @c focus_in event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_focus_in_cb() callback function is called when an associated text input - * UI control has focus. - * - * @param[in] callback_func @c focus_in 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 the IME application's main loop. - * - * @see ime_focus_in_cb() - * @see ime_run() - */ -int ime_event_set_focus_in_cb(ime_focus_in_cb callback_func, void *user_data); - -/** - * @brief Sets @c focus_out event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_focus_out_cb() callback function is called when an associated text input - * UI control loses focus. - * - * @param[in] callback_func @c focus_out 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 the IME application's main loop. - * - * @see ime_focus_out_cb() - * @see ime_run() - */ -int ime_event_set_focus_out_cb(ime_focus_out_cb callback_func, void *user_data); - -/** - * @brief Sets @c surrounding_text_updated event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_surrounding_text_updated_cb() callback function is called when an - * associated text input UI control responds to a request with the surrounding text. - * - * @param[in] callback_func @c surrounding_text_updated 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 the IME application's main loop. - * - * @see ime_surrounding_text_updated_cb() - * @see ime_run() - */ -int ime_event_set_surrounding_text_updated_cb(ime_surrounding_text_updated_cb callback_func, void *user_data); - -/** - * @brief Sets @c input_context_reset event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_input_context_reset_cb() callback function is called to reset the input - * context of an associated text input UI control. - * - * @param[in] callback_func @c input_context_reset 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 the IME application's main loop. - * - * @see ime_input_context_reset_cb() - * @see ime_run() - */ -int ime_event_set_input_context_reset_cb(ime_input_context_reset_cb callback_func, void *user_data); - -/** - * @brief Sets @c cursor_position_updated event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_cursor_position_updated_cb() callback function is called when the position - * of the cursor in an associated text input UI control changes. - * - * @param[in] callback_func @c cursor_position_updated 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 the IME application's main loop. - * - * @see ime_cursor_position_updated_cb() - * @see ime_run() - */ -int ime_event_set_cursor_position_updated_cb(ime_cursor_position_updated_cb callback_func, void *user_data); - -/** - * @brief Sets @c language_requested event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_language_requested_cb() callback function is called when an associated - * text input UI control requests the language from the input panel. - * - * @param[in] callback_func @c language_requested 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 the IME application's main loop. - * - * @see ime_language_requested_cb() - * @see ime_run() - */ -int ime_event_set_language_requested_cb(ime_language_requested_cb callback_func, void *user_data); - -/** - * @brief Sets @c language_set event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_language_set_cb() callback function is called to set the preferred - * language to the input panel. - * - * @param[in] callback_func @c language_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 the IME application's main loop. - * - * @see ime_language_set_cb() - * @see ime_run() - */ -int ime_event_set_language_set_cb(ime_language_set_cb callback_func, void *user_data); - -/** - * @brief Sets @c imdata_set event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_imdata_set_cb() callback function is called to set the application - * specific data to deliver to the input panel. - * - * @param[in] callback_func @c imdata_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 the IME application's main loop. - * - * @see ime_imdata_set_cb() - * @see ime_event_set_imdata_requested_cb() - * @see ime_run() - */ -int ime_event_set_imdata_set_cb(ime_imdata_set_cb callback_func, void *user_data); - -/** - * @brief Sets @c imdata_requested event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_imdata_requested_cb() callback function is called when an associated - * text input UI control requests the application specific data from the input panel. - * - * @param[in] callback_func @c imdata_requested 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 the IME application's main loop. - * - * @see ime_imdata_requested_cb() - * @see ime_event_set_imdata_set_cb() - * @see ime_run() - */ -int ime_event_set_imdata_requested_cb(ime_imdata_requested_cb callback_func, void *user_data); - -/** - * @brief Sets @c layout_set event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_layout_set_cb() callback function is called when an associated text input - * UI control requests the input panel to set its layout. - * - * @param[in] callback_func @c layout_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 the IME application's main loop. - * - * @see ime_layout_set_cb() - * @see ime_run() - */ -int ime_event_set_layout_set_cb(ime_layout_set_cb callback_func, void *user_data); - -/** - * @brief Sets @c return_key_type_set event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_return_key_type_set_cb() callback function is called when an associated - * text input UI control requests the input panel to set the @c Return key label. - * - * @param[in] callback_func @c return_key_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. - * @retval #IME_ERROR_OPERATION_FAILED Operation failed - * - * @post The ime_run() function should be called to start the IME application's main loop. - * - * @see ime_return_key_type_set_cb() - * @see ime_run() - */ -int ime_event_set_return_key_type_set_cb(ime_return_key_type_set_cb callback_func, void *user_data); - -/** - * @brief Sets @c return_key_state_set event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_return_key_state_set_cb() callback function is called when an associated - * text input UI control requests the input panel to enable or disable the @c Return key state. - * - * @param[in] callback_func @c return_key_state_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 the IME application's main loop. - * - * @see ime_return_key_state_set_cb() - * @see ime_run() - */ -int ime_event_set_return_key_state_set_cb(ime_return_key_state_set_cb callback_func, void *user_data); - -/** - * @brief Sets @c geometry_requested event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_geometry_requested_cb() callback function is called when an associated - * text input UI control requests the position and size from the input panel. - * - * @param[in] callback_func @c geometry_requested 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 the IME application's main loop. - * - * @see ime_geometry_requested_cb() - * @see ime_run() - */ -int ime_event_set_geometry_requested_cb(ime_geometry_requested_cb callback_func, void *user_data); - -/** - * @brief Sets @c process_key_event event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @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 process_key_event 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 the IME application's main loop. - * - * @see ime_process_key_event_cb() - * @see ime_run() - * - * @code - static void inputmethod_create_cb(void *user_data); - static void inputmethod_terminate_cb(void *user_data); - static void inputmethod_show_cb(int context_id, ime_context_h context, void *user_data); - static void inputmethod_hide_cb(int context_id, void *user_data); - - static bool inputmethod_process_key_event_cb(ime_key_code_e keycode, ime_key_mask_e keymask, void *user_data); - { - if (keymask & IME_KEY_MASK_CONTROL) { - return false; // e.g., Control+C key event would be forwarded to UI control of the client application - } - if (keymask & IME_KEY_MASK_ALT) { - return false; - } - - if (!(keymask & IME_KEY_MASK_RELEASED)) { // The key is pressed - if (keycode == IME_KEY_1) { - ime_update_preedit_string("1"); // Show "1" preedit string - return true; - } - else if (keycode == IME_KEY_2) { - ime_commit_string("12"); // Input "12" string - return true; - } - } - - return false; - } - - void ime_app_main(int argc, char **argv) - { - ime_callback_s basic_callback = { - inputmethod_create_cb, - inputmethod_terminate_cb, - inputmethod_show_cb, - inputmethod_hide_cb, - }; - - ime_event_set_process_key_event_cb(inputmethod_process_key_event_cb, NULL); - - ime_run(&basic_callback, NULL); - } - * @endcode - */ -int ime_event_set_process_key_event_cb(ime_process_key_event_cb callback_func, void *user_data); - -/** - * @brief Sets @c process_key_event_with_keycode callback function to handle the key event with a keycode. - * - * @since_tizen 5.5 - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_process_key_event_with_keycode_cb() callback function is called when the key event - * is received from external keyboard devices or ime_send_key_event(). - * - * @param[in] callback_func @c process_key_event_with_keycode() 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 the IME application's main loop. - * - * @see ime_process_key_event_with_keycode_cb() - * @see ime_run() - */ -int ime_event_set_process_key_event_with_keycode_cb(ime_process_key_event_with_keycode_cb callback_func, void *user_data); - -/** - * @brief Sets @c display_language_changed event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_display_language_changed_cb() callback function is called when the system - * display language is changed. - * - * @param[in] callback_func @c display_language_changed 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 the IME application's main loop. - * - * @see ime_display_language_changed_cb() - * @see ime_run() - */ -int ime_event_set_display_language_changed_cb(ime_display_language_changed_cb callback_func, void *user_data); - -/** - * @brief Sets @c rotation_degree_changed event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_rotation_degree_changed_cb() callback function is called when the device - * is rotated. - * - * @param[in] callback_func @c rotation_degree_changed 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 the IME application's main loop. - * - * @see ime_rotation_degree_changed_cb() - * @see ime_run() - */ -int ime_event_set_rotation_degree_changed_cb(ime_rotation_degree_changed_cb callback_func, void *user_data); - -/** - * @brief Sets @c accessibility_state_changed event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_accessibility_state_changed_cb() callback function is called when - * Accessibility in Settings application is on or off. - * - * @param[in] callback_func @c accessibility_state_changed 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 the IME application's main loop. - * - * @see ime_accessibility_state_changed_cb() - * @see ime_run() - */ -int ime_event_set_accessibility_state_changed_cb(ime_accessibility_state_changed_cb callback_func, void *user_data); - -/** - * @brief Sets @c option_window_created event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_option_window_created_cb() callback function is called to create the option window. - * - * @param[in] callback_func @c option_window_created 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 the IME application's main loop. - * - * @see ime_option_window_created_cb() - * @see ime_run() - */ -int ime_event_set_option_window_created_cb(ime_option_window_created_cb callback_func, void *user_data); - -/** - * @brief Sets @c option_window_destroyed event callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_option_window_destroyed_cb() callback function is called to destroy the option window. - * - * @param[in] callback_func @c option_window_destroyed 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 the IME application's main loop. - * - * @see ime_option_window_destroyed_cb() - * @see ime_run() - */ -int ime_event_set_option_window_destroyed_cb(ime_option_window_destroyed_cb callback_func, void *user_data); - -/** - * @brief Sends a key event to the associated text input UI control. - * - * @details This function sends key down or up event with key mask to the client application. - * If @a forward_key is @c true, this key event goes to the edit field directly. And if @a forward_key - * is @c false, the ime_process_key_event_cb() callback function receives the key event before the edit field. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] keycode The key code to be sent - * @param[in] keymask The modifier key mask - * @param[in] forward_key The flag to send the key event directly to the edit field - * - * @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 is not started yet - * - * @post If @a forward_key is @c false, the ime_process_key_event_cb() callback function can compose the text with the key events. - * - * @see ime_key_code_e - * @see ime_key_mask_e - * @see ime_process_key_event_cb() - */ -int ime_send_key_event(ime_key_code_e keycode, ime_key_mask_e keymask, bool forward_key); - -/** - * @brief Sends the text to the associated text input UI control. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] str The UTF-8 string to be committed - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @see ime_show_preedit_string() - * @see ime_hide_preedit_string() - * @see ime_update_preedit_string() - */ -int ime_commit_string(const char *str); - -/** - * @brief Requests to show preedit string. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @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. - * @retval #IME_ERROR_NOT_RUNNING IME main loop is not started yet - * - * @see ime_commit_string() - * @see ime_hide_preedit_string() - * @see ime_update_preedit_string() - */ -int ime_show_preedit_string(void); - -/** - * @brief Requests to hide preedit string. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @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. - * @retval #IME_ERROR_NOT_RUNNING IME main loop is not started yet - * - * @see ime_commit_string() - * @see ime_show_preedit_string() - * @see ime_update_preedit_string() - */ -int ime_hide_preedit_string(void); - -/** - * @brief Updates a new preedit string. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] str The UTF-8 string to be updated in preedit - * @param[in] attrs The Eina_List which has #ime_preedit_attribute lists; @a str can be composed of multiple - * string attributes: underline, highlight color and reversal color. The @a attrs will be released internally - * on success and it can be NULL if no attributes to set - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @post This function is supposed to be followed by the ime_show_preedit_string() function. - * - * @see ime_preedit_attribute - * @see ime_commit_string() - * @see ime_show_preedit_string() - * @see ime_hide_preedit_string() - * - * @code - { - int ret; - Eina_List *list = NULL; - - ime_preedit_attribute *attr = calloc(1, sizeof(ime_preedit_attribute)); - attr->start = 0; - attr->length = 1; - attr->type = IME_ATTR_FONTSTYLE; - attr->value = IME_ATTR_FONTSTYLE_UNDERLINE; - list = eina_list_append(list, attr); - - attr = calloc(1, sizeof(ime_preedit_attribute)); - attr->start = 1; - attr->length = 1; - attr->type = IME_ATTR_FONTSTYLE; - attr->value = IME_ATTR_FONTSTYLE_HIGHLIGHT; - list = eina_list_append(list, attr); - - attr = calloc(1, sizeof(ime_preedit_attribute)); - attr->start = 2; - attr->length = 1; - attr->type = IME_ATTR_FONTSTYLE; - attr->value = IME_ATTR_FONTSTYLE_REVERSAL; - list = eina_list_append(list, attr); - - ret = ime_update_preedit_string("abcd", list); - if (ret != IME_ERROR_NONE) { - EINA_LIST_FREE(list, attr) - free(attr); - } - } - * @endcode - */ -int ime_update_preedit_string(const char *str, Eina_List *attrs); - -/** - * @brief Requests the surrounding text from the position of the cursor, asynchronously. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] maxlen_before The maximum length of string to be retrieved before the cursor; -1 means unlimited - * @param[in] maxlen_after The maximum length of string to be retrieved after the cursor; -1 means unlimited - * - * @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_NO_CALLBACK_FUNCTION Necessary callback function is not set - * @retval #IME_ERROR_NOT_RUNNING IME main loop is not started yet - * - * @pre The ime_surrounding_text_updated_cb() callback function MUST be set by ime_event_set_surrounding_text_updated_cb(). - * - * @post The requested surrounding text can be received using the ime_surrounding_text_updated_cb() callback function. - * - * @see ime_delete_surrounding_text() - * @see ime_event_set_surrounding_text_updated_cb() - * @see ime_surrounding_text_updated_cb() - */ -int ime_request_surrounding_text(int maxlen_before, int maxlen_after); - -/** - * @brief Requests to delete surrounding text. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] offset The offset value from the cursor position - * @param[in] len The length of the text to delete - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @see ime_request_surrounding_text() - */ -int ime_delete_surrounding_text(int offset, int len); - -/** - * @brief Gets the surrounding text from the position of the cursor, synchronously. - * - * @since_tizen 3.0 - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks @a text must be released using free(). - * - * @param[in] maxlen_before The maximum length of string to be retrieved before the cursor; -1 means unlimited - * @param[in] maxlen_after The maximum length of string to be retrieved after the cursor; -1 means unlimited - * @param[out] text The surrounding text - * @param[out] cursor_pos The cursor position - * - * @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_NOT_RUNNING IME main loop is not started yet - * @retval #IME_ERROR_OUT_OF_MEMORY Failed to obtain text due to out of memory - * - * @see ime_delete_surrounding_text() - */ -int ime_get_surrounding_text(int maxlen_before, int maxlen_after, char **text, int *cursor_pos); - -/** - * @brief Requests to set selection. - * - * @since_tizen 3.0 - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] start The start cursor position in text (in characters not bytes) - * @param[in] end The end cursor position in text (in characters not bytes) - * - * @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_NOT_RUNNING IME main loop is not started yet - */ -int ime_set_selection(int start, int end); - -/** - * @brief Gets the selected text synchronously. - * - * @details If multi-line text is selected, the result will contain '\n' for each newline character. - * And if the selected text is empty, the result will be an empty string. - * - * @since_tizen 4.0 - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks @a text must be released using free(). - * - * @param[out] text The selected text - * - * @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_NOT_RUNNING IME main loop is not started yet - */ -int ime_get_selected_text(char **text); - -/** - * @brief Gets the pointer of input panel main window. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The specific error code can be obtained using the get_last_result() method if this function returns NULL. - * @remarks The returned value should not be released. The returned value is managed by the platform and will be released when terminating this process. - * - * @return The input panel main window object on success, otherwise NULL - * - * @exception #IME_ERROR_NONE Successful - * @exception #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function. - * @exception #IME_ERROR_NOT_RUNNING IME main loop is not started yet - * @exception #IME_ERROR_OPERATION_FAILED Operation failed - * - * @see get_last_result() - * @see ime_create_cb() - * @see ime_terminate_cb() - * @see ime_show_cb() - * @see ime_hide_cb() - */ -Evas_Object* ime_get_main_window(void); - -/** - * @brief Updates the input panel window's size information. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] portrait_width The width in portrait mode - * @param[in] portrait_height The height in portrait mode - * @param[in] landscape_width The width in landscape mode - * @param[in] landscape_height The height in landscape mode - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @see ime_create_cb() - */ -int ime_set_size(int portrait_width, int portrait_height, int landscape_width, int landscape_height); - -/** - * @brief Requests to create an option window from the input panel. - * - * @details The input panel can call this function to open the option window. This - * function calls ime_option_window_created_cb() callback function with - * #IME_OPTION_WINDOW_TYPE_KEYBOARD parameter. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @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. - * @retval #IME_ERROR_NO_CALLBACK_FUNCTION Necessary callback function is not set - * @retval #IME_ERROR_NOT_RUNNING IME main loop is not started yet - * @retval #IME_ERROR_OPERATION_FAILED Operation failed - * - * @pre The ime_option_window_created_cb() and ime_option_window_destroyed_cb() - * callback functions MUST be set by ime_event_set_option_window_created_cb() and - * ime_event_set_option_window_destroyed_cb() respectively. - * - * @post This function calls ime_option_window_created_cb() callback function to - * create the option window. And ime_destroy_option_window() function can be called - * to close the option window. - * - * @see ime_event_set_option_window_created_cb() - * @see ime_option_window_created_cb() - * @see ime_destroy_option_window() - */ -int ime_create_option_window(void); - -/** - * @brief Requests to destroy an option window. - * - * @details The input panel can call this function to close the option window which - * is created from either the input panel or Settings application. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] window The option window to destroy - * - * @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_NO_CALLBACK_FUNCTION Necessary callback function is not set - * @retval #IME_ERROR_NOT_RUNNING IME main loop is not started yet - * - * @pre The ime_option_window_created_cb() and ime_option_window_destroyed_cb() - * callback functions MUST be set by ime_event_set_option_window_created_cb() and - * ime_event_set_option_window_destroyed_cb() respectively. - * - * @post This function calls ime_option_window_destroyed_cb() callback function - * to destroy the option window. - * - * @see ime_event_set_option_window_destroyed_cb() - * @see ime_option_window_destroyed_cb() - * @see ime_create_option_window() - */ -int ime_destroy_option_window(Evas_Object *window); - -/** - * @brief Gets the layout information from the given input context. - * - * @details Each edit field has various attributes for input panel. This function can be - * called to get the layout information in ime_show_cb() callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] context The input context information of an associated text input UI control - * @param[out] layout Layout information - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @post Input panel UI should be drawn or operated by this information accordingly. - * - * @see ime_show_cb() - * @see ime_layout_set_cb() - */ -int ime_context_get_layout(ime_context_h context, Ecore_IMF_Input_Panel_Layout *layout); - -/** - * @brief Gets the layout variation information from the given input context. - * - * @details Each edit field has various attributes for input panel. This function can be - * called to get the layout variation information in ime_show_cb() callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] context The input context information of an associated text input UI control - * @param[out] layout_variation Layout variation information - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @post Input panel UI should be drawn or operated by this information accordingly. - * - * @see ime_show_cb() - * @see ime_layout_variation_e - */ -int ime_context_get_layout_variation(ime_context_h context, ime_layout_variation_e *layout_variation); - -/** - * @brief Gets the cursor position information from the given input context. - * - * @details Each edit field has various attributes for input panel. This function can be - * called to get the cursor position information in ime_show_cb() callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] context The input context information of an associated text input UI control - * @param[out] cursor_pos Cursor position information - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @post Input panel UI should be drawn or operated by this information accordingly. - * - * @see ime_show_cb() - * @see ime_cursor_position_updated_cb() - */ -int ime_context_get_cursor_position(ime_context_h context, int *cursor_pos); - -/** - * @brief Gets the autocapital type information from the given input context. - * - * @details Each edit field has various attributes for input panel. This function can be - * called to get the autocapital type information in ime_show_cb() callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] context The input context information of an associated text input UI control - * @param[out] autocapital_type Autocapital type information - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @post Input panel UI should be drawn or operated by this information accordingly. - * - * @see ime_show_cb() - */ -int ime_context_get_autocapital_type(ime_context_h context, Ecore_IMF_Autocapital_Type *autocapital_type); - -/** - * @brief Gets the @c Return key label type information from the given input context. - * - * @details Each edit field has various attributes for input panel. This function can be - * called to get the @c Return key label type information in ime_show_cb() callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] context The input context information of an associated text input UI control - * @param[out] return_key_type The @c Return key label type information - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @post Input panel UI should be drawn or operated by this information accordingly. - * - * @see ime_show_cb() - * @see ime_return_key_type_set_cb() - */ -int ime_context_get_return_key_type(ime_context_h context, Ecore_IMF_Input_Panel_Return_Key_Type *return_key_type); - -/** - * @brief Gets the @c Return key state information from the given input context. - * - * @details Each edit field has various attributes for input panel. This function can be - * called to get the @c Return key state information in ime_show_cb() callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] context The input context information of an associated text input UI control - * @param[out] return_key_state The @c Return key state information \n @c true to enable @c Return key - * button, @c false to disable @c Return key button - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @post Input panel UI should be drawn or operated by this information accordingly. - * - * @see ime_show_cb() - * @see ime_return_key_state_set_cb() - */ -int ime_context_get_return_key_state(ime_context_h context, bool *return_key_state); - -/** - * @brief Gets the prediction mode information from the given input context. - * - * @details Each edit field has various attributes for input panel. This function can be - * called to get the prediction mode information in ime_show_cb() callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] context The input context information of an associated text input UI control - * @param[out] prediction_mode Prediction mode information \n @c true to allow the predictive - * text feature if available, @c false to disable the predictive text feature - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @post Input panel UI should be drawn or operated by this information accordingly. - * - * @see ime_show_cb() - */ -int ime_context_get_prediction_mode(ime_context_h context, bool *prediction_mode); - -/** - * @brief Gets the password mode information from the given input context. - * - * @details Each edit field has various attributes for input panel. This function can be - * called to get the password mode information in ime_show_cb() callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks If @a password_mode is @c true, the input panel is advised not to support the predictive text. - * - * @param[in] context The input context information of an associated text input UI control - * @param[out] password_mode Password mode information \n @c true to indicate that a password being inputted, - * @c false to indicate non-password edit field. - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @post Input panel UI should be drawn or operated by this information accordingly. - * - * @see ime_show_cb() - */ -int ime_context_get_password_mode(ime_context_h context, bool *password_mode); - -/** - * @brief Gets the input hint information from the given input context. - * - * @details Each edit field has various attributes for input panel. This function can be - * called to get the input hint information in ime_show_cb() callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks @a input_hint is a bit-wise value which recommends the input panel provide - * an auto completion and so on if it is capable of supporting such features. - * - * @param[in] context The input context information of an associated text input UI control - * @param[out] input_hint Input hint information - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @post Input panel UI should be drawn or operated by this information accordingly. - * - * @see ime_show_cb() - */ -int ime_context_get_input_hint(ime_context_h context, Ecore_IMF_Input_Hints *input_hint); - -/** - * @brief Gets the text bidirectional information from the given input context. - * - * @details Each edit field has various attributes for input panel. This function can be - * called to get the bidirectional information in ime_show_cb() callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] context The input context information of an associated text input UI control - * @param[out] bidi Text bidirectional information - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @post Input panel UI should be drawn or operated by this information accordingly. - * - * @see ime_show_cb() - */ -int ime_context_get_bidi_direction(ime_context_h context, Ecore_IMF_BiDi_Direction *bidi); - -/** - * @brief Gets the preferred language information from the given input context. - * - * @details Each edit field has various attributes for input panel. This function can be - * called to get the preferred language information in ime_show_cb() callback function. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] context The input context information of an associated text input UI control - * @param[out] language Preferred language information - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @post Input panel UI should be drawn or operated by this information accordingly. - * - * @see ime_show_cb() - */ -int ime_context_get_language(ime_context_h context, Ecore_IMF_Input_Panel_Lang *language); - -/** - * @brief Gets the device name of the key event. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks @a dev_name must be released using free(). - * - * @param[in] dev_info The device information from the key event - * @param[out] dev_name The name of key input device. This can be an empty string if the device name is not available - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @see ime_process_key_event_cb() - * @see ime_device_info_get_class() - * @see ime_device_info_get_subclass() - */ -int ime_device_info_get_name(ime_device_info_h dev_info, char **dev_name); - -/** - * @brief Gets the device class of the key event. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] dev_info The device information from the key event - * @param[out] dev_class The class of key input device. This can be #ECORE_IMF_DEVICE_CLASS_NONE if the device class is not available - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @see ime_process_key_event_cb() - * @see ime_device_info_get_name() - * @see ime_device_info_get_subclass() - */ -int ime_device_info_get_class(ime_device_info_h dev_info, Ecore_IMF_Device_Class *dev_class); -/** - * @brief Gets the device subclass of the key event. - * - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] dev_info The device information from the key event - * @param[out] dev_subclass The subclass of key input device. This can be #ECORE_IMF_DEVICE_SUBCLASS_NONE if the device subclass is not available - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @see ime_process_key_event_cb() - * @see ime_device_info_get_name() - * @see ime_device_info_get_class() - */ -int ime_device_info_get_subclass(ime_device_info_h dev_info, Ecore_IMF_Device_Subclass *dev_subclass); - -/** - * @brief Sets prediction hint 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 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 the IME application's main loop. - * - * @see ime_prediction_hint_set_cb() - * @see ime_run() - */ -int ime_event_set_prediction_hint_set_cb(ime_prediction_hint_set_cb callback_func, void *user_data); - -/** - * @brief Sets MIME type event callback function. - * - * @since_tizen 4.0 - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_mime_type_set_request_cb() callback function is called when an associated text input - * UI control requests the text entry to set the MIME type. - * - * @param[in] callback_func MIME type 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 the IME application's main loop. - * - * @see ime_mime_type_set_request_cb() - * @see ime_run() - */ -int ime_event_set_mime_type_set_request_cb(ime_mime_type_set_request_cb callback_func, void *user_data); - -/** - * @brief Sends a private command to the associated text input UI control. - * - * @details This can be used by IME to deliver specific data to an application. - * The data format MUST be negotiated by both application and IME. - * - * @since_tizen 4.0 - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] command The UTF-8 string to be sent - * - * @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_NOT_RUNNING IME main loop is not started yet - */ -int ime_send_private_command(const char *command); - -/** - * @brief Commits contents such as image to the associated text input UI control. - * - * @since_tizen 4.0 - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] content The content URI to be sent - * @param[in] description The content description - * @param[in] mime_type The MIME type received from the ime_mime_type_set_request_cb() - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @see ime_mime_type_set_request_cb() - * @see ime_event_set_mime_type_set_request_cb() - */ -int ime_commit_content(const char *content, const char *description, const char *mime_type); - -/** - * @brief Sets the floating mode or not. - * - * @since_tizen 4.0 - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] floating_mode @c true - floating mode on, @c false - floating mode off - * - * @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 is not started yet - * - * @see ime_set_floating_drag_start() - * @see ime_set_floating_drag_end() - */ -int ime_set_floating_mode(bool floating_mode); - -/** - * @brief Allows the floating input panel window to move along with the mouse pointer when the mouse is pressed. - * - * @since_tizen 4.0 - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks This function can be used in floating mode. If the floating mode is deactivated, calling this function has no effect. - * - * @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 is not started yet - * - * @pre The floating mode was turned on with ime_set_floating_mode(). - * - * @see ime_set_floating_mode() - * @see ime_set_floating_drag_end() - */ -int ime_set_floating_drag_start(void); - -/** - * @brief Disallows the movement of the floating input panel window with the mouse pointer when the mouse is pressed. - * - * @details This function must be called after invoking ime_set_floating_drag_start(). Otherwise the call is ignored. - * - * @since_tizen 4.0 - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks This function can be used in floating mode. If the floating mode is deactivated, calling this function has no effect. - * - * @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 is not started yet - * - * @pre The floating mode was turned on with ime_set_floating_mode(). - * @pre ime_set_floating_drag_start() was called before. - * - * @see ime_set_floating_mode() - * @see ime_set_floating_drag_start() - */ -int ime_set_floating_drag_end(void); - -/** - * @brief Sets a callback function to give a hint about predicted words. - * - * @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 provide the prediction - * hint key and value which can be delivered to the input panel. - * - * @param[in] callback_func The callback function to give hints - * @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 the 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); - -/** - * @brief Sends the request to hide IME. - * - * @since_tizen 5.0 - * - * @privlevel public - * - * @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. - * @retval #IME_ERROR_NOT_RUNNING IME main loop is not started yet - */ -int ime_request_hide(void); - -/** - * @brief Updates the state of input panel event. - * - * @since_tizen 5.5 - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] type The input panel event type - * @param[in] value The value of event type - * - * @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_NOT_RUNNING IME main loop is not started yet - * - * @see ime_event_type_e - */ -int ime_update_input_panel_event(ime_event_type_e type, unsigned int value); - -/** - * @brief Enables whether candidate strings show or not. - * - * @since_tizen 5.5 - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] visible @c true if candidate strings show, @c false otherwise. - * - * @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 is not started yet - */ -int ime_set_candidate_visibility_state(bool visible); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_UIX_INPUTMETHOD_H__ */ - diff --git a/include/inputmethod_device_event.h b/include/inputmethod_device_event.h deleted file mode 100644 index 8ecbd10..0000000 --- a/include/inputmethod_device_event.h +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __TIZEN_UIX_INPUTMETHOD_DEVICE_EVENT_H__ -#define __TIZEN_UIX_INPUTMETHOD_DEVICE_EVENT_H__ - -/** - * @file inputmethod_device_event.h - * @brief This file contains definitions for unconventional input device events. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup CAPI_UIX_INPUTMETHOD_MODULE - * @{ - */ - - /** - * @brief The handle to retrieve unconventional input device specific event data. - * - * @since_tizen @if WEARABLE 3.0 @endif - * - * @see ime_event_set_process_input_device_event_cb() - */ -typedef void *ime_input_device_event_h; - -/** - * @brief Enumeration of unconventional input devices. - * - * @since_tizen @if WEARABLE 3.0 @endif - * - * @see ime_event_set_process_input_device_event_cb() - */ -typedef enum { - IME_INPUT_DEVICE_TYPE_UNKNOWN, /**< Undefined unconventional input device */ - IME_INPUT_DEVICE_TYPE_ROTARY, /**< A rotary input device such as bezel that can be found on a wearable device */ -} ime_input_device_type_e; - -/** - * @brief Enumeration of directions for rotary input device's rotation event. - * - * @since_tizen @if WEARABLE 3.0 @endif - * - * @see ime_input_device_rotary_get_direction() - */ -typedef enum -{ - IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE, /**< Rotary is rotated clockwise direction */ - IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE /**< Rotary is rotated counter clockwise direction */ -} ime_input_device_rotary_direction_e; - -/** - * @brief Called when the input event is received from an unconventional input device that does not generate key events. - * - * @details This function processes the input event before an associated text input UI control does. - * - * @since_tizen @if WEARABLE 3.0 @endif - * - * @remarks @a device_type contains the information what kind of unconventional input device generated the given event, - * and the handle @a device_event is used for obtaining device-specific input device event data. - * @a device_event should not be released. - * - * @param[in] device_type The unconventional input device type - * @param[in] device_event The handle for device_type specific input device event - * @param[in] user_data User data to be passed to the callback function - * - * @pre The callback can be registered using ime_event_set_input_device_event_cb() function. - * - * @see ime_event_set_process_input_device_event_cb() - */ -typedef void(*ime_process_input_device_event_cb)(ime_input_device_type_e device_type, ime_input_device_event_h device_event, void *user_data); - -/** - * @brief Sets @c process_input_device_event event callback function. - * - * @since_tizen @if WEARABLE 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_process_input_device_event_cb() callback function is called when the event - * is received from unconventional input devices that needs to be handled by IMEs. - * - * @param[in] callback_func @c inputmethod_process_input_device_event_cb 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_process_input_device_event_cb() - * @see ime_event_unset_process_input_device_event_cb() - * @see ime_run() - * - * @code - static void inputmethod_create_cb(void *user_data); - static void inputmethod_terminate_cb(void *user_data); - static void inputmethod_show_cb(int context_id, ime_context_h context, void *user_data); - static void inputmethod_hide_cb(int context_id, void *user_data); - - static void inputmethod_process_input_device_event_cb(ime_input_device_type_e device_type, ime_input_device_event_h device_event, void *user_data) - { - if (device_type == IME_INPUT_DEVICE_TYPE_ROTARY) { - dlog_print(DLOG_INFO, "INPUTMETHOD", "Input device type is rotary\n"); - } - } - - void ime_app_main(int argc, char **argv) - { - ime_callback_s basic_callback = { - inputmethod_create_cb, - inputmethod_terminate_cb, - inputmethod_show_cb, - inputmethod_hide_cb, - }; - - ime_event_set_process_input_device_event_cb(inputmethod_process_input_device_event_cb, NULL); - - ime_run(&basic_callback, NULL); - } - * @endcode - */ - -int ime_event_set_process_input_device_event_cb(ime_process_input_device_event_cb callback_func, void *user_data); - -/** - * @brief Unsets @c process_input_device_event event callback function. - * - * @since_tizen @if WEARABLE 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_process_input_device_event_cb() callback function is called when the event - * is received from unconventional input devices that needs to be handled by IMEs. - * - * @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_OPERATION_FAILED Operation failed - * - * @see ime_process_input_device_event_cb() - * @see ime_event_set_process_input_device_event_cb() - */ -int ime_event_unset_process_input_device_event_cb(void); - -/** - * @brief Gets the direction of the rotary input device event - * - * If the device_type parameter of the ime_process_input_device_event_cb() function indicates - * the current input device type is #IME_INPUT_DEVICE_TYPE_ROTARY, then the device_event parameter - * can be used to retrieve rotary device specific parameters, such as direction, as shown in the sample code. - * - * @since_tizen @if WEARABLE 3.0 @endif - * - * @privlevel public - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] event_handle The input device event handle - * @param[out] direction The direction that the rotary input device was rotated to - * - * @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_NOT_RUNNING IME main loop isn't started yet - * - * @see ime_rotary_input_device_direction_e - * @see ime_process_input_device_event_cb() - * - * @code - static void inputmethod_process_input_device_event_cb(ime_input_device_type_e device_type, ime_input_device_event_h device_event) - { - if (device_type == IME_INPUT_DEVICE_TYPE_ROTARY) { - ime_input_device_rotary_direction_e direction; - if (IME_ERROR_NONE == ime_input_device_rotary_get_direction(device_event, &direction)) { - dlog_print(DLOG_INFO, "INPUTMETHOD", "Direction : %d", direction); - } - } - } - * @endcode - */ -int ime_input_device_rotary_get_direction(ime_input_device_event_h event_handle, ime_input_device_rotary_direction_e *direction); - -#ifdef __cplusplus -} -#endif - -/** - * @} - */ - -#endif /* __TIZEN_UIX_INPUTMETHOD_DEVICE_EVENT_H__ */ diff --git a/include/inputmethod_internal.h b/include/inputmethod_internal.h deleted file mode 100644 index 5e40eb4..0000000 --- a/include/inputmethod_internal.h +++ /dev/null @@ -1,390 +0,0 @@ -/* - * Copyright (c) 2014-2017 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __TIZEN_UIX_INPUTMETHOD_INTERNAL_H__ -#define __TIZEN_UIX_INPUTMETHOD_INTERNAL_H__ - -/** - * @file inputmethod_internal.h - * @brief This file contains input method internal APIs and related enumeration. - */ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Enumeration for input method optimization hint. - * - * @since_tizen 5.0 - */ -typedef enum { - IME_OPTIMIZATION_HINT_NONE = 0, /**< No hint provided */ - IME_OPTIMIZATION_HINT_SHOW_PREPARE, /**< This IME is going to be displayed on screen soon */ -} ime_optimization_hint_e; - -typedef struct _ime_context *ime_context_h; - -/** - * @brief Called when an caps mode is changed. - * - * @since_tizen 3.0 - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] mode caps mode - * @param[in] user_data User data to be passed from the callback registration function - */ -typedef void (*ime_caps_mode_changed_cb)(int mode, void *user_data); - -/** - * @brief Called when a candidate list provided by IMEngine should be shown. - * - * @since_tizen 3.0 - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] context_id The input context identification value of an associated text input UI control - * @param[in] user_data User data to be passed from the callback registration function - */ -typedef void (*ime_candidate_show_cb)(int context_id, void *user_data); - -/** - * @brief Called when a candidate list provided by IMEngine should be hidden. - * - * @since_tizen 3.0 - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] context_id The input context identification value of an associated text input UI control - * @param[in] user_data User data to be passed from the callback registration function - */ -typedef void (*ime_candidate_hide_cb)(int context_id, void *user_data); - -/** - * @brief Called when a candidate list provided by IMEngine is changed. - * - * @since_tizen 3.0 - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks @a list should not be released. - * - * @param[in] list candidate list - * @param[in] user_data User data to be passed from the callback registration function - */ -typedef void (*ime_lookup_table_changed_cb)(Eina_List *list, void *user_data); - -/** - * @brief Called when a optimization hint value is set. - * - * @since_tizen 5.0 - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] hint The hint value used for optimization - * @param[in] user_data User data to be passed from the callback registration function - */ -typedef void (*ime_optimization_hint_set_cb)(ime_optimization_hint_e hint, void *user_data); - -/** - * @brief Sets @c ime_caps_mode_changed_cb() event callback function. - * - * @since_tizen 3.0 - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_caps_mode_changed_cb() callback function is called when an associated text input - * UI control sends the change of caps mode. - * - * @param[in] callback_func @c ime_caps_mode_changed_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_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_run() - */ -int ime_event_set_caps_mode_changed_cb(ime_caps_mode_changed_cb callback_func, void *user_data); - -/** - * @brief Sets @c ime_candidate_show_cb() event callback function. - * - * @since_tizen 3.0 - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] callback_func @c ime_candidate_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_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_run() - */ -int ime_event_set_candidate_show_cb(ime_candidate_show_cb callback_func, void *user_data); - -int ime_event_set_candidate_hide_cb(ime_candidate_hide_cb callback_func, void *user_data); - -/** - * @brief Sets @c ime_lookup_table_changed_cb() event callback function. - * - * @since_tizen 3.0 - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_lookup_table_changed_cb() callback function is called when an associated text input - * UI control sends the change of caps mode. - * - * @param[in] callback_func @c ime_lookup_table_changed_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_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_run() - */ -int ime_event_set_lookup_table_changed_cb(ime_lookup_table_changed_cb callback_func, void *user_data); - -/** - * @brief Gets the caps mode information from the given input context. - * - * @details Each edit field has various attributes for input panel. This function can be - * called to get the caps mode information in ime_show_cb() callback function. - * - * @since_tizen 3.0 - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] context The input context information of an associated text input UI control - * @param[out] caps_mode Caps mode information \n @c true to turn on shift mode - * text feature if available, @c false to disable the predictive text feature - * - * @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_NOT_RUNNING IME main loop isn't started yet - * - * @post Input panel UI should be drawn or operated by this information accordingly. - * - * @see ime_show_cb() - */ -int ime_context_get_caps_mode(ime_context_h context, bool *caps_mode); - -/** - * @brief Sets keyboard engine. - * - * @since_tizen 3.0 - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] engine_id The engine UUID - * - * @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_NOT_RUNNING IME main loop isn't started yet - */ -int ime_set_imengine(const char *engine_id); - -/** - * @brief Flushes state in Input Method engine. - * - * @since_tizen 3.0 - * - * @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 - * @retval #IME_ERROR_NOT_RUNNING IME main loop isn't started yet - */ -int ime_flush_imengine(void); - -/** - * @brief Resets state in Input Method engine. - * - * @since_tizen 3.0 - * - * @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 - * @retval #IME_ERROR_NOT_RUNNING IME main loop isn't started yet - */ -int ime_reset_imengine(void); - -/** - * @brief Sends the selected item index in the candidate list. - * - * @since_tizen 3.0 - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] index the selected index in the candidate 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 - * @retval #IME_ERROR_NOT_RUNNING IME main loop isn't started yet - */ -int ime_select_candidate(unsigned int index); - -/** - * @brief Sends the input context event. - * - * @since_tizen 3.0 - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] type the event type - * @param[in] value the event value - * - * @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_update_input_context(unsigned int type, unsigned int value); - -/** - * @brief Requests IME to initialize explicitly. - * - * @details When using ime_run API, the initialize / prepare / finalize procedures - * are processed automatically inside the IME application loop. - * But in case of not using ime_run API, which means the IME application has - * its own main loop, these procedures need to be requested explicitly. - * - * @since_tizen 4.0 - * - * @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_initialize(void); - -/** - * @brief Requests IME to prepare resources such as IME window and socket connection. - * - * @details Like ime_initialize() function, this procedure is automatically processed - * when using ime_run() API. Call this function only when ime_run() is not used and - * the IME application has to handle main loop by itself. - * - * @since_tizen 4.0 - * - * @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 - * @retval #IME_ERROR_OPERATION_FAILED Operation failed - */ -int ime_prepare(void); - -/** - * @brief Requests IME to finalize explicitly. - * - * @since_tizen 4.0 - * - * @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_finalize(void); - -/** - * @brief Sets flag whether IME is called from dotnet. - * - * @since_tizen 4.0 - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] set Set with Dotnet 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 - */ -int ime_set_dotnet_flag(bool set); - -/** - * @brief Sets flag whether creating IME window should be defered until there is a access request. - * - * @since_tizen 5.0 - * - * @privilege %http://tizen.org/privilege/ime - * - * @param[in] flag true if deferring window creation is desired - * @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_set_window_creation_defer_flag(bool flag); - -/** - * @brief Sets @c ime_optimization_hint_set_cb() event callback function. - * - * @since_tizen 5.0 - * - * @privilege %http://tizen.org/privilege/ime - * - * @remarks The ime_optimization_hint_set_cb() callback function is called when an optimization hint is set - * - * @param[in] callback_func @c ime_optimization_hint_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_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_run() - */ -int ime_event_set_optimization_hint_set_cb(ime_optimization_hint_set_cb callback_func, void *user_data); - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_UIX_INPUTMETHOD_INTERNAL_H__ */ - diff --git a/include/inputmethod_keydef.h b/include/inputmethod_keydef.h deleted file mode 100644 index 9d266a9..0000000 --- a/include/inputmethod_keydef.h +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef __TIZEN_UIX_INPUTMETHOD_KEYDEF_H__ -#define __TIZEN_UIX_INPUTMETHOD_KEYDEF_H__ - - -/** - * @file inputmethod_keydef.h - * @brief This file contains key code and mask enumeration. - */ - - -/** - * @addtogroup CAPI_UIX_INPUTMETHOD_MODULE - * @{ - */ - - -/** - * @brief Enumeration for the key codes. - * If keycode & 0xff000000 == 0x01000000 then this key code is directly encoded 24-bit UCS character. - * The UCS value is keycode & 0x00ffffff. - * @details Defines the list of keys supported by the system. - * Note that certain keys may not be available on all devices. - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - */ -typedef enum { - IME_KEY_BackSpace = 0xFF08, /**< The backspace key */ - IME_KEY_Tab = 0xFF09, /**< The tab key */ - IME_KEY_Linefeed = 0xFF0A, /**< The linefeed key */ - IME_KEY_Clear = 0xFF0B, /**< The clear key */ - IME_KEY_Return = 0xFF0D, /**< The return key */ - IME_KEY_Pause = 0xFF13, /**< The pause key */ - IME_KEY_Scroll_Lock = 0xFF14, /**< The scroll lock key */ - IME_KEY_Sys_Req = 0xFF15, /**< The sys req key */ - IME_KEY_Escape = 0xFF1B, /**< The escape key */ - IME_KEY_Delete = 0xFFFF, /**< The delete key */ - - /* Cursor control & motion */ - IME_KEY_Home = 0xFF50, /**< The home key */ - IME_KEY_Left = 0xFF51, /**< The left directional key */ - IME_KEY_Up = 0xFF52, /**< The up directional key */ - IME_KEY_Right = 0xFF53, /**< The right directional key */ - IME_KEY_Down = 0xFF54, /**< The down directional key */ - IME_KEY_Prior = 0xFF55, /**< The prior, previous key */ - IME_KEY_Page_Up = 0xFF55, /**< The page up key */ - IME_KEY_Next = 0xFF56, /**< The next key */ - IME_KEY_Page_Down = 0xFF56, /**< The page down key */ - IME_KEY_End = 0xFF57, /**< The end key */ - IME_KEY_Begin = 0xFF58, /**< The begin key */ - - /* Misc Functions */ - IME_KEY_Select = 0xFF60, /**< The select key */ - IME_KEY_Print = 0xFF61, /**< The print key */ - IME_KEY_Execute = 0xFF62, /**< The execute, run, do key */ - IME_KEY_Insert = 0xFF63, /**< The insert key */ - IME_KEY_Undo = 0xFF65, /**< The undo key */ - IME_KEY_Redo = 0xFF66, /**< The redo key */ - IME_KEY_Menu = 0xFF67, /**< The menu key */ - IME_KEY_Find = 0xFF68, /**< The find key */ - IME_KEY_Cancel = 0xFF69, /**< The cancel, stop, abort, exit key */ - IME_KEY_Help = 0xFF6A, /**< The help key */ - IME_KEY_Break = 0xFF6B, /**< The break key */ - IME_KEY_Mode_switch = 0xFF7E, /**< The character set switch key */ - IME_KEY_Num_Lock = 0xFF7F, /**< The num lock key */ - - /* Keypad */ - IME_KEY_KP_Space = 0xFF80, /**< The Numpad space key */ - IME_KEY_KP_Tab = 0xFF89, /**< The Numpad tab key */ - IME_KEY_KP_Enter = 0xFF8D, /**< The Numpad enter key */ - IME_KEY_KP_F1 = 0xFF91, /**< The Numpad function 1 key */ - IME_KEY_KP_F2 = 0xFF92, /**< The Numpad function 2 key */ - IME_KEY_KP_F3 = 0xFF93, /**< The Numpad function 3 key */ - IME_KEY_KP_F4 = 0xFF94, /**< The Numpad function 4 key */ - IME_KEY_KP_Home = 0xFF95, /**< The Numpad home key */ - IME_KEY_KP_Left = 0xFF96, /**< The Numpad left key */ - IME_KEY_KP_Up = 0xFF97, /**< The Numpad up key */ - IME_KEY_KP_Right = 0xFF98, /**< The Numpad right key */ - IME_KEY_KP_Down = 0xFF99, /**< The Numpad down key */ - IME_KEY_KP_Prior = 0xFF9A, /**< The Numpad prior, previous key */ - IME_KEY_KP_Page_Up = 0xFF9A, /**< The Numpad page up key */ - IME_KEY_KP_Next = 0xFF9B, /**< The Numpad next key */ - IME_KEY_KP_Page_Down = 0xFF9B, /**< The Numpad page down key */ - IME_KEY_KP_End = 0xFF9C, /**< The Numpad end key */ - IME_KEY_KP_Begin = 0xFF9D, /**< The Numpad begin key */ - IME_KEY_KP_Insert = 0xFF9E, /**< The Numpad insert key */ - IME_KEY_KP_Delete = 0xFF9F, /**< The Numpad delete key */ - IME_KEY_KP_Equal = 0xFFBD, /**< The Numpad equal key */ - IME_KEY_KP_Multiply = 0xFFAA, /**< The Numpad multiply key */ - IME_KEY_KP_Add = 0xFFAB, /**< The Numpad add key */ - IME_KEY_KP_Separator = 0xFFAC, /**< The Numpad separator key */ - IME_KEY_KP_Subtract = 0xFFAD, /**< The Numpad subtract key */ - IME_KEY_KP_Decimal = 0xFFAE, /**< The Numpad decimal key */ - IME_KEY_KP_Divide = 0xFFAF, /**< The Numpad divide key */ - - IME_KEY_KP_0 = 0xFFB0, /**< The Numpad 0 key */ - IME_KEY_KP_1 = 0xFFB1, /**< The Numpad 1 key */ - IME_KEY_KP_2 = 0xFFB2, /**< The Numpad 2 key */ - IME_KEY_KP_3 = 0xFFB3, /**< The Numpad 3 key */ - IME_KEY_KP_4 = 0xFFB4, /**< The Numpad 4 key */ - IME_KEY_KP_5 = 0xFFB5, /**< The Numpad 5 key */ - IME_KEY_KP_6 = 0xFFB6, /**< The Numpad 6 key */ - IME_KEY_KP_7 = 0xFFB7, /**< The Numpad 7 key */ - IME_KEY_KP_8 = 0xFFB8, /**< The Numpad 8 key */ - IME_KEY_KP_9 = 0xFFB9, /**< The Numpad 9 key */ - - /* Auxilliary Functions */ - IME_KEY_F1 = 0xFFBE, /**< The function 1 key */ - IME_KEY_F2 = 0xFFBF, /**< The function 2 key */ - IME_KEY_F3 = 0xFFC0, /**< The function 3 key */ - IME_KEY_F4 = 0xFFC1, /**< The function 4 key */ - IME_KEY_F5 = 0xFFC2, /**< The function 5 key */ - IME_KEY_F6 = 0xFFC3, /**< The function 6 key */ - IME_KEY_F7 = 0xFFC4, /**< The function 7 key */ - IME_KEY_F8 = 0xFFC5, /**< The function 8 key */ - IME_KEY_F9 = 0xFFC6, /**< The function 9 key */ - IME_KEY_F10 = 0xFFC7, /**< The function 10 key */ - IME_KEY_F11 = 0xFFC8, /**< The function 11 key */ - IME_KEY_F12 = 0xFFC9, /**< The function 12 key */ - IME_KEY_F13 = 0xFFCA, /**< The function 13 key */ - IME_KEY_F14 = 0xFFCB, /**< The function 14 key */ - IME_KEY_F15 = 0xFFCC, /**< The function 15 key */ - IME_KEY_F16 = 0xFFCD, /**< The function 16 key */ - IME_KEY_F17 = 0xFFCE, /**< The function 17 key */ - IME_KEY_F18 = 0xFFCF, /**< The function 18 key */ - IME_KEY_F19 = 0xFFD0, /**< The function 19 key */ - IME_KEY_F20 = 0xFFD1, /**< The function 20 key */ - IME_KEY_F21 = 0xFFD2, /**< The function 21 key */ - IME_KEY_F22 = 0xFFD3, /**< The function 22 key */ - IME_KEY_F23 = 0xFFD4, /**< The function 23 key */ - IME_KEY_F24 = 0xFFD5, /**< The function 24 key */ - IME_KEY_F25 = 0xFFD6, /**< The function 25 key */ - IME_KEY_F26 = 0xFFD7, /**< The function 26 key */ - IME_KEY_F27 = 0xFFD8, /**< The function 27 key */ - IME_KEY_F28 = 0xFFD9, /**< The function 28 key */ - IME_KEY_F29 = 0xFFDA, /**< The function 29 key */ - IME_KEY_F30 = 0xFFDB, /**< The function 30 key */ - IME_KEY_F31 = 0xFFDC, /**< The function 31 key */ - IME_KEY_F32 = 0xFFDD, /**< The function 32 key */ - IME_KEY_F33 = 0xFFDE, /**< The function 33 key */ - IME_KEY_F34 = 0xFFDF, /**< The function 34 key */ - IME_KEY_F35 = 0xFFE0, /**< The function 35 key */ - - /* Modifier keys */ - IME_KEY_Shift_L = 0xFFE1, /**< The left shift key */ - IME_KEY_Shift_R = 0xFFE2, /**< The right shift key */ - IME_KEY_Control_L = 0xFFE3, /**< The left control key */ - IME_KEY_Control_R = 0xFFE4, /**< The right control key */ - IME_KEY_Caps_Lock = 0xFFE5, /**< The caps lock key */ - IME_KEY_Shift_Lock = 0xFFE6, /**< The shift lock key */ - - IME_KEY_Meta_L = 0xFFE7, /**< The left meta key */ - IME_KEY_Meta_R = 0xFFE8, /**< The right meta key */ - IME_KEY_Alt_L = 0xFFE9, /**< The left alt key */ - IME_KEY_Alt_R = 0xFFEA, /**< The right alt key */ - IME_KEY_Super_L = 0xFFEB, /**< The left super key */ - IME_KEY_Super_R = 0xFFEC, /**< The right super key */ - IME_KEY_Hyper_L = 0xFFED, /**< The left hyper key */ - IME_KEY_Hyper_R = 0xFFEE, /**< The right hyper key */ - - /* Latin 1 */ - IME_KEY_space = 0x020, /**< The space key */ - IME_KEY_exclam = 0x021, /**< The exclamation key */ - IME_KEY_quotedbl = 0x022, /**< The quotedbl key */ - IME_KEY_numbersign = 0x023, /**< The number sign key */ - IME_KEY_dollar = 0x024, /**< The dollar key */ - IME_KEY_percent = 0x025, /**< The percent key */ - IME_KEY_ampersand = 0x026, /**< The ampersand key */ - IME_KEY_apostrophe = 0x027, /**< The apostrophe key */ - IME_KEY_parenleft = 0x028, /**< The parenleft key */ - IME_KEY_parenright = 0x029, /**< The parenright key */ - IME_KEY_asterisk = 0x02a, /**< The asterisk key */ - IME_KEY_plus = 0x02b, /**< The plus key */ - IME_KEY_comma = 0x02c, /**< The comma key */ - IME_KEY_minus = 0x02d, /**< The minus key */ - IME_KEY_period = 0x02e, /**< The period key */ - IME_KEY_slash = 0x02f, /**< The slash key */ - IME_KEY_0 = 0x030, /**< The 0 key */ - IME_KEY_1 = 0x031, /**< The 1 key */ - IME_KEY_2 = 0x032, /**< The 2 key */ - IME_KEY_3 = 0x033, /**< The 3 key */ - IME_KEY_4 = 0x034, /**< The 4 key */ - IME_KEY_5 = 0x035, /**< The 5 key */ - IME_KEY_6 = 0x036, /**< The 6 key */ - IME_KEY_7 = 0x037, /**< The 7 key */ - IME_KEY_8 = 0x038, /**< The 8 key */ - IME_KEY_9 = 0x039, /**< The 9 key */ - IME_KEY_colon = 0x03a, /**< The colon key */ - IME_KEY_semicolon = 0x03b, /**< The semicolon key */ - IME_KEY_less = 0x03c, /**< The less key */ - IME_KEY_equal = 0x03d, /**< The equal key */ - IME_KEY_greater = 0x03e, /**< The greater key */ - IME_KEY_question = 0x03f, /**< The question key */ - IME_KEY_at = 0x040, /**< The at key */ - IME_KEY_A = 0x041, /**< The A key */ - IME_KEY_B = 0x042, /**< The B key */ - IME_KEY_C = 0x043, /**< The C key */ - IME_KEY_D = 0x044, /**< The D key */ - IME_KEY_E = 0x045, /**< The E key */ - IME_KEY_F = 0x046, /**< The F key */ - IME_KEY_G = 0x047, /**< The G key */ - IME_KEY_H = 0x048, /**< The H key */ - IME_KEY_I = 0x049, /**< The I key */ - IME_KEY_J = 0x04a, /**< The J key */ - IME_KEY_K = 0x04b, /**< The K key */ - IME_KEY_L = 0x04c, /**< The L key */ - IME_KEY_M = 0x04d, /**< The M key */ - IME_KEY_N = 0x04e, /**< The N key */ - IME_KEY_O = 0x04f, /**< The O key */ - IME_KEY_P = 0x050, /**< The P key */ - IME_KEY_Q = 0x051, /**< The Q key */ - IME_KEY_R = 0x052, /**< The R key */ - IME_KEY_S = 0x053, /**< The S key */ - IME_KEY_T = 0x054, /**< The T key */ - IME_KEY_U = 0x055, /**< The U key */ - IME_KEY_V = 0x056, /**< The V key */ - IME_KEY_W = 0x057, /**< The W key */ - IME_KEY_X = 0x058, /**< The X key */ - IME_KEY_Y = 0x059, /**< The Y key */ - IME_KEY_Z = 0x05a, /**< The Z key */ - IME_KEY_bracketleft = 0x05b, /**< The left bracket key */ - IME_KEY_backslash = 0x05c, /**< The backslash key */ - IME_KEY_bracketright = 0x05d, /**< The right bracket key */ - IME_KEY_asciicircum = 0x05e, /**< The circumflex key */ - IME_KEY_underscore = 0x05f, /**< The underscore key */ - IME_KEY_grave = 0x060, /**< The grave key */ - IME_KEY_a = 0x061, /**< The a key */ - IME_KEY_b = 0x062, /**< The b key */ - IME_KEY_c = 0x063, /**< The c key */ - IME_KEY_d = 0x064, /**< The d key */ - IME_KEY_e = 0x065, /**< The e key */ - IME_KEY_f = 0x066, /**< The f key */ - IME_KEY_g = 0x067, /**< The g key */ - IME_KEY_h = 0x068, /**< The h key */ - IME_KEY_i = 0x069, /**< The i key */ - IME_KEY_j = 0x06a, /**< The j key */ - IME_KEY_k = 0x06b, /**< The k key */ - IME_KEY_l = 0x06c, /**< The l key */ - IME_KEY_m = 0x06d, /**< The m key */ - IME_KEY_n = 0x06e, /**< The n key */ - IME_KEY_o = 0x06f, /**< The o key */ - IME_KEY_p = 0x070, /**< The p key */ - IME_KEY_q = 0x071, /**< The q key */ - IME_KEY_r = 0x072, /**< The r key */ - IME_KEY_s = 0x073, /**< The s key */ - IME_KEY_t = 0x074, /**< The t key */ - IME_KEY_u = 0x075, /**< The u key */ - IME_KEY_v = 0x076, /**< The v key */ - IME_KEY_w = 0x077, /**< The w key */ - IME_KEY_x = 0x078, /**< The x key */ - IME_KEY_y = 0x079, /**< The y key */ - IME_KEY_z = 0x07a, /**< The z key */ - IME_KEY_braceleft = 0x07b, /**< The left brace key */ - IME_KEY_bar = 0x07c, /**< The bar key */ - IME_KEY_braceright = 0x07d, /**< The right brace key */ - IME_KEY_asciitilde = 0x07e, /**< The tilde key */ -} ime_key_code_e; - - -/** - * @brief Enumeration for the key masks. - * The key masks indicate which modifier keys is pressed down during the keyboard hit. - * The special #IME_KEY_MASK_RELEASED indicates the key release event. - * @since_tizen @if MOBILE 2.4 @else 3.0 @endif - */ -typedef enum { - IME_KEY_MASK_PRESSED = 0, /**< Key press event without modifier key */ - IME_KEY_MASK_SHIFT = (1<<0), /**< The Shift key is pressed down */ - IME_KEY_MASK_CAPSLOCK = (1<<1), /**< The CapsLock key is pressed down */ - IME_KEY_MASK_CONTROL = (1<<2), /**< The Control key is pressed down */ - IME_KEY_MASK_ALT = (1<<3), /**< The Alt key is pressed down */ - IME_KEY_MASK_META = (1<<4), /**< The Meta key is pressed down */ - IME_KEY_MASK_WIN = (1<<5), /**< The Win (between Control and Alt) is pressed down */ - IME_KEY_MASK_HYPER = (1<<6), /**< The Hyper key is pressed down */ - IME_KEY_MASK_NUMLOCK = (1<<7), /**< The NumLock key is pressed down */ - IME_KEY_MASK_RELEASED = (1<<15) /**< Key release event */ -} ime_key_mask_e; - - -/** - * @} - */ - - -#endif /* __TIZEN_UIX_INPUTMETHOD_KEYDEF_H__ */ - diff --git a/include/inputmethod_private.h b/include/inputmethod_private.h deleted file mode 100644 index b30bb44..0000000 --- a/include/inputmethod_private.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __TIZEN_UIX_INPUTMETHOD_PRIVATE_H__ -#define __TIZEN_UIX_INPUTMETHOD_PRIVATE_H__ - -struct _ime_context { - Ecore_IMF_Input_Panel_Layout layout; /**< Input panel (keyboard) layout types */ - int layout_variation; /**< Layout variation */ - int cursor_pos; /**< Cursor position in edit field */ - Ecore_IMF_Autocapital_Type autocapital_type; /**< Auto capital mode */ - Ecore_IMF_Input_Panel_Return_Key_Type return_key_type; /**< "Return" key types */ - Eina_Bool return_key_disabled; /**< The state of "Return" key */ - Eina_Bool prediction_allow; /**< Boolean to allow predictive text */ - Eina_Bool password_mode; /**< Password input mode of edit field */ - int imdata_size; /**< The size of application specific data to input panel */ - Ecore_IMF_Input_Hints input_hint; /**< Edit field hint */ - Ecore_IMF_BiDi_Direction bidi_direction;/**< Bidirectional mode */ - Ecore_IMF_Input_Panel_Lang language; /**< Preferred input language */ - unsigned int client_window; /**< Client application window object */ - Eina_Bool caps_mode; /**< Caps mode */ -}; - -struct _ime_device_info { - const char *dev_name; /**< The device name */ - Ecore_IMF_Device_Class dev_class; /**< The device class */ - Ecore_IMF_Device_Subclass dev_subclass; /**< The device subclass */ -}; - -#endif /* __TIZEN_UIX_INPUTMETHOD_PRIVATE_H__ */ - diff --git a/include/privilege_checker_private.h b/include/privilege_checker_private.h deleted file mode 100644 index 345affe..0000000 --- a/include/privilege_checker_private.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __PRIVILEGE_CHECKER_H__ -#define __PRIVILEGE_CHECKER_H__ - -#define IME_PRIVILEGE "http://tizen.org/privilege/ime" - -bool inputmethod_cynara_initialize(void); -void inputmethod_cynara_finish(void); -bool check_privilege(const char *uid, const char *privilege); - -#endif /*__PRIVILEGE_CHECKER_H__ */ diff --git a/inputmethod/include/inputmethod.h b/inputmethod/include/inputmethod.h new file mode 100644 index 0000000..4f6f3d7 --- /dev/null +++ b/inputmethod/include/inputmethod.h @@ -0,0 +1,2571 @@ +/* + * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_UIX_INPUTMETHOD_H__ +#define __TIZEN_UIX_INPUTMETHOD_H__ + +/** + * @file inputmethod.h + * @brief This file contains input method APIs and related enumeration. + */ + +#include +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_UIX_INPUTMETHOD_MODULE + * @{ + */ + +/** + * @brief Enumeration for input method function error. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + */ +typedef enum { + IME_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + IME_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + IME_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + IME_ERROR_NO_CALLBACK_FUNCTION = TIZEN_ERROR_IME | 0x0001, /**< Necessary callback function is not set */ + IME_ERROR_NOT_RUNNING = TIZEN_ERROR_IME | 0x0002, /**< IME main loop is not started yet */ + IME_ERROR_OPERATION_FAILED = TIZEN_ERROR_IME | 0x0003, /**< Operation failed */ + IME_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< out of memory */ +} ime_error_e; + +/** + * @brief Enumeration of the option window type. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @see ime_option_window_created_cb() + */ +typedef enum { + IME_OPTION_WINDOW_TYPE_KEYBOARD, /**< Open from Keyboard */ + IME_OPTION_WINDOW_TYPE_SETTING_APPLICATION, /**< Open from Setting application */ +} ime_option_window_type_e; + +/** + * @brief Enumeration of layout variation. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @see ime_context_get_layout_variation() + */ +typedef enum { + IME_LAYOUT_NORMAL_VARIATION_NORMAL = 0, /**< The plain normal layout */ + IME_LAYOUT_NORMAL_VARIATION_FILENAME, /**< Filename layout; symbols such as '/', '*', '\', '|', '<', '>', '?', '"' and ':' should be disabled */ + IME_LAYOUT_NORMAL_VARIATION_PERSON_NAME, /**< The name of a person */ + IME_LAYOUT_NUMBERONLY_VARIATION_NORMAL = 0, /**< The plain normal number layout */ + IME_LAYOUT_NUMBERONLY_VARIATION_SIGNED, /**< The number layout to allow a negative sign */ + IME_LAYOUT_NUMBERONLY_VARIATION_DECIMAL, /**< The number layout to allow decimal point to provide fractional value */ + IME_LAYOUT_NUMBERONLY_VARIATION_SIGNED_AND_DECIMAL, /**< The number layout to allow decimal point and negative sign */ + IME_LAYOUT_PASSWORD_VARIATION_NORMAL = 0, /**< The normal password layout */ + IME_LAYOUT_PASSWORD_VARIATION_NUMBERONLY, /**< The password layout to allow only number */ +} ime_layout_variation_e; + +/** + * @brief Enumeration of string attribute type. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @remarks Currently, a font style is available to use. + * + * @see ime_preedit_attribute() + * @see ime_update_preedit_string() + */ +typedef enum { + IME_ATTR_NONE, /**< No attribute */ + IME_ATTR_FONTSTYLE, /**< A font style attribute, e.g., underline, etc. */ +} ime_attribute_type; + +/** + * @brief Enumeration containing input panel events. + * + * @since_tizen 5.5 + * + * @see ime_update_input_panel_event() + */ +typedef enum { + IME_EVENT_TYPE_LANGUAGE = 1, /**< The language of the input panel */ + IME_EVENT_TYPE_SHIFT_MODE, /**< The shift key state of the input panel */ + IME_EVENT_TYPE_GEOMETRY, /**< The size of the input panel */ +} ime_event_type_e; + +/** + * @brief Value for #IME_ATTR_FONTSTYLE. Draw a line under the text. + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + */ +#define IME_ATTR_FONTSTYLE_UNDERLINE 1 + +/** + * @brief Value for #IME_ATTR_FONTSTYLE. Draw text in highlighted color. + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + */ +#define IME_ATTR_FONTSTYLE_HIGHLIGHT 2 + +/** + * @brief Value for #IME_ATTR_FONTSTYLE. Draw text in reversal color. + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + */ +#define IME_ATTR_FONTSTYLE_REVERSAL 4 + +/** + * @brief The structure type to contain the attributes for preedit string. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @remarks A preedit string may have one or more different attributes. This structure describes each attribute of the string. + * + * @see ime_update_preedit_string() + * @see ime_attribute_type + */ +typedef struct { + unsigned int start; /**< The start position in the string of this attribute */ + unsigned int length; /**< The character length of this attribute, the range is [start, start+length] */ + ime_attribute_type type; /**< The type of this attribute */ + unsigned int value; /**< The value of this attribute */ +} ime_preedit_attribute; + +/** + * @brief Handle of an associated text input UI control's input context. + * + * @details This is one of parameters of ime_show_cb() callback function. IME application + * should configure its input panel with this structure information. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @see ime_context_get_layout() + * @see ime_context_get_layout_variation() + * @see ime_context_get_cursor_position() + * @see ime_context_get_autocapital_type() + * @see ime_context_get_return_key_type() + * @see ime_context_get_return_key_state() + * @see ime_context_get_prediction_mode() + * @see ime_context_get_password_mode() + * @see ime_context_get_input_hint() + * @see ime_context_get_bidi_direction() + * @see ime_context_get_language() + */ +typedef struct _ime_context *ime_context_h; + +/** + * @brief Handle of the device information of the key event. + * + * @details This is one of parameters of ime_process_key_event_cb() callback function. IME application + * may distinguish the key event by using this if necessary. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @see ime_process_key_event_cb() + * @see ime_device_info_get_name() + * @see ime_device_info_get_class() + * @see ime_device_info_get_subclass() + */ +typedef struct _ime_device_info *ime_device_info_h; + +/** + * @brief Called when the input panel is created. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks This callback function is mandatory and must be registered using ime_run(). The + * ime_get_main_window() can be used to get the created input panel window. + * + * @param[in] user_data User data to be passed from the callback registration function + * + * @pre The ime_run() function calls this callback function. + * + * @see ime_run() + * @see ime_set_size() + * @see ime_get_main_window() + */ +typedef void (*ime_create_cb)(void *user_data); + +/** + * @brief Called when the input panel is terminated. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks This callback function is mandatory and must be registered using ime_run(). The + * ime_get_main_window() can be used to get the created input panel window. + * + * @param[in] user_data User data to be passed from the callback registration function + * + * @see ime_run() + * @see ime_get_main_window() + */ +typedef void (*ime_terminate_cb)(void *user_data); + +/** + * @brief Called when an associated text input UI control requests the input panel to show itself. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks This callback function is mandatory and must be registered using ime_run(). + * IME application should configure its input panel with #ime_context_h structure information. + * The ime_get_main_window() can be used to get the created input panel window. + * @a context should not be released. + * + * @param[in] context_id The input context identification value of an associated text input UI control + * @param[in] context The input context information handle + * @param[in] user_data User data to be passed from the callback registration function + * + * @see ime_run() + * @see ime_get_main_window() + * @see ime_context_get_layout() + * @see ime_context_get_layout_variation() + * @see ime_context_get_cursor_position() + * @see ime_context_get_autocapital_type() + * @see ime_context_get_return_key_type() + * @see ime_context_get_return_key_state() + * @see ime_context_get_prediction_mode() + * @see ime_context_get_password_mode() + * @see ime_context_get_input_hint() + * @see ime_context_get_bidi_direction() + * @see ime_context_get_language() + */ +typedef void (*ime_show_cb)(int context_id, ime_context_h context, void *user_data); + +/** + * @brief Called when an associated text input UI control requests the input panel to hide itself. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks This callback function is mandatory and must be registered using ime_run(). The + * ime_get_main_window() can be used to get the created input panel window. + * + * @param[in] context_id The input context identification value of an associated text input UI control + * @param[in] user_data User data to be passed from the callback registration function + * + * @see ime_run() + * @see ime_get_main_window() + */ +typedef void (*ime_hide_cb)(int context_id, void *user_data); + +/** + * @brief Called when an associated text input UI control has focus. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] context_id The input context identification value of an associated text input UI control + * @param[in] user_data User data to be passed from the callback registration function + * + * @pre The callback can be registered using ime_event_set_focus_in_cb() function. + * + * @see ime_event_set_focus_in_cb() + */ +typedef void (*ime_focus_in_cb)(int context_id, void *user_data); + +/** + * @brief Called when an associated text input UI control loses focus. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] context_id The input context identification value of an associated text input UI control + * @param[in] user_data User data to be passed from the callback registration function + * + * @pre The callback can be registered using ime_event_set_focus_out_cb() function. + * + * @see ime_event_set_focus_out_cb() + */ +typedef void (*ime_focus_out_cb)(int context_id, void *user_data); + +/** + * @brief Called when an associated text input UI control responds to a request with the surrounding text. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_request_surrounding_text() must be called to invoke this callback function, asynchronously. + * @remarks @a text can be used only in the callback. To use outside, make a copy. + * + * @param[in] context_id The input context identification value of an associated text input UI control + * @param[in] text The UTF-8 string requested + * @param[in] cursor_pos The cursor position + * @param[in] user_data User data to be passed from the callback registration function + * + * @pre The callback can be registered using ime_event_set_surrounding_text_updated_cb() function. + * + * @see ime_event_set_surrounding_text_updated_cb() + * @see ime_request_surrounding_text() + */ +typedef void (*ime_surrounding_text_updated_cb)(int context_id, const char *text, int cursor_pos, void *user_data); + +/** + * @brief Called to reset the input context of an associated text input UI control. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] user_data User data to be passed from the callback registration function + * + * @pre The callback can be registered using ime_event_set_input_context_reset_cb() function. + * + * @see ime_event_set_input_context_reset_cb() + */ +typedef void (*ime_input_context_reset_cb)(void *user_data); + +/** + * @brief Called when the position of the cursor in an associated text input UI control changes. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] cursor_pos The cursor position + * @param[in] user_data User data to be passed from the callback registration function + * + * @pre The callback can be registered using ime_event_set_cursor_position_updated_cb() function. + * + * @see ime_event_set_cursor_position_updated_cb() + */ +typedef void (*ime_cursor_position_updated_cb)(int cursor_pos, void *user_data); + +/** + * @brief Called when an associated text input UI control requests the language from the input panel. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The allocated @a lang_code will be released internally. + * + * @param[in] user_data User data to be passed from the callback registration function + * @param[out] lang_code Input panel's current input language code (e.g., "en_US") + * + * @pre The callback can be registered using ime_event_set_language_requested_cb() function. + * + * @see ime_event_set_language_requested_cb() + */ +typedef void (*ime_language_requested_cb)(void *user_data, char **lang_code); + +/** + * @brief Called to set the preferred language to the input panel. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks @a language information is already set to the input panel when it is shown + * through #ime_context_h. This callback function will be only called when the client + * application changes the edit field's language attribute after the input panel is shown. + * + * @param[in] language The preferred language that the client application wants + * @param[in] user_data User data to be passed from the callback registration function + * + * @pre The callback can be registered using ime_event_set_language_set_cb() function. + * + * @see ime_event_set_language_set_cb() + */ +typedef void (*ime_language_set_cb)(Ecore_IMF_Input_Panel_Lang language, void *user_data); + +/** + * @brief Called to set the application specific data to deliver to the input panel. + * + * @details This function is used by the applications to deliver the specific data to the input panel. + * The data format MUST be negotiated by both application and input panel. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks @data should not be released. + * + * @param[in] data The specific data to be set to the input panel + * @param[in] data_length The length of data, in bytes, to send to the input panel + * @param[in] user_data User data to be passed from the callback registration function + * + * @pre The callback can be registered using ime_event_set_imdata_set_cb() function. + * + * @see ime_event_set_imdata_set_cb() + */ +typedef void (*ime_imdata_set_cb)(void *data, unsigned int data_length, void *user_data); + +/** + * @brief Called when an associated text input UI control requests the application specific data from the input panel. + * + * @details This API is used by the applications to request the specific data from the input panel. + * The data format MUST be negotiated by both application and input panel. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The allocated @a data and @a data_length will be released internally. + * + * @param[in] user_data User data to be passed from the callback registration function + * @param[out] data Input panel's data to be set to the application + * @param[out] data_length The length of data, in bytes, to send to the application + * + * @pre The callback can be registered using ime_event_set_imdata_requested_cb() function. + * + * @see ime_event_set_imdata_requested_cb() + */ +typedef void (*ime_imdata_requested_cb)(void *user_data, void **data, unsigned int *data_length); + +/** + * @brief Called when an associated text input UI control requests the input panel to set its layout. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks @a layout information is already set to the input panel when it is shown + * through #ime_context_h. This callback function will be only called when the client + * application changes the edit field's layout attribute after the input panel is shown. + * + * @param[in] layout The input panel layout + * @param[in] user_data User data to be passed from the callback registration function + * + * @pre The callback can be registered using ime_event_set_layout_set_cb() function. + * + * @see ime_event_set_layout_set_cb() + */ +typedef void (*ime_layout_set_cb)(Ecore_IMF_Input_Panel_Layout layout, void *user_data); + +/** + * @brief Called when an associated text input UI control requests the input panel to set the @c Return key label. + * The input panel can show text or image on the @c Return button according to the @c Return key action. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks @a type information is already set to the input panel when it is shown + * through #ime_context_h. This callback function will be only called when the client + * application changes the edit field's @c Return key type attribute after the input panel + * is shown. + * + * @param[in] type The type of @c Return key on the input panel + * @param[in] user_data User data to be passed from the callback registration function + * + * @pre The callback can be registered using ime_event_set_return_key_type_set_cb() function. + * + * @see ime_event_set_return_key_type_set_cb() + */ +typedef void (*ime_return_key_type_set_cb)(Ecore_IMF_Input_Panel_Return_Key_Type type, void *user_data); + +/** + * @brief Called when an associated text input UI control requests the input panel to enable + * or disable the @c Return key state. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks @a disabled information is already set to the input panel when it is shown + * through #ime_context_h. This callback function will be only called when the client + * application changes the edit field's @c Return key disable attribute after the input panel + * is shown. + * + * @param[in] disabled The Boolean state to disable @c Return key. The @c Return key is enabled by default + * @param[in] user_data User data to be passed from the callback registration function + * + * @pre The callback can be registered using ime_event_set_return_key_state_set_cb() function. + * + * @see ime_event_set_return_key_state_set_cb() + */ +typedef void (*ime_return_key_state_set_cb)(bool disabled, void *user_data); + +/** + * @brief Called when an associated text input UI control requests the position and size from the input panel. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks @a x, @a y, @a w, and @a h should not be released. + * + * @param[in] user_data User data to be passed from the callback registration function + * @param[out] x The x position in screen + * @param[out] y The y position in screen + * @param[out] w The window width + * @param[out] h The window height + * + * @pre The callback can be registered using ime_event_set_geometry_requested_cb() function. + * + * @see ime_event_set_geometry_requested_cb() + */ +typedef void (*ime_geometry_requested_cb)(void *user_data, int *x, int *y, int *w, int *h); + +/** + * @brief Called when a key event is received from external devices or ime_send_key_event(). + * + * @details This function processes the key event before an associated text input UI control does. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks If the key event is from the external device, @a dev_info will have its name, class and subclass information. + * @a dev_info should not be released by the application. The platform manages the handle; the handle is released when ime_process_key_event_cb() exits. + * + * @param[in] key_code The key code to be sent + * @param[in] key_mask The modifier key mask + * @param[in] dev_info The device information handle + * @param[in] user_data User data to be passed from the callback registration function + * + * @return @c true if the event was processed, otherwise the event was not processed and was forwarded to the client application. + * + * @pre The callback should be registered using ime_event_set_process_key_event_cb() function. + * + * @see ime_event_set_process_key_event_cb() + * @see ime_device_info_get_name() + * @see ime_device_info_get_class() + * @see ime_device_info_get_subclass() + * @see ime_send_key_event() + * @see ime_commit_string() + * @see ime_show_preedit_string() + * @see ime_hide_preedit_string() + * @see ime_update_preedit_string() + */ +typedef bool (*ime_process_key_event_cb)(ime_key_code_e key_code, ime_key_mask_e key_mask, ime_device_info_h dev_info, void *user_data); + +/** + * @brief Called when a key event is received from external devices or ime_send_key_event(). + * + * @details This function processes a key event with a keycode before an associated UI control for the text input deals with the key event. + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks If the key event is from the external device, @a dev_info will have its name, class and subclass information. + * @a dev_info should not be released by the application. The platform manages the handle; the handle is released when ime_process_key_event_with_keycode_cb() exits. + * + * @param[in] key_code The X11 key code to be sent + * @param[in] key_sym The key symbol to be sent + * @param[in] key_mask The modifier key mask + * @param[in] dev_info The device information handle + * @param[in] user_data User data to be passed from the callback registration function + * + * @return @c true if the event was processed, otherwise @c false. When @c false returns, the event was not processed and was forwarded to the client application. + * + * @pre The callback should be registered using ime_event_set_process_key_event_with_keycode_cb() function. + * + * @see ime_event_set_process_key_event_with_keycode_cb() + * @see ime_device_info_get_name() + * @see ime_device_info_get_class() + * @see ime_device_info_get_subclass() + * @see ime_send_key_event() + * @see ime_commit_string() + * @see ime_show_preedit_string() + * @see ime_hide_preedit_string() + * @see ime_update_preedit_string() + */ +typedef bool (*ime_process_key_event_with_keycode_cb)(unsigned int key_code, ime_key_code_e key_sym, ime_key_mask_e key_mask, ime_device_info_h dev_info, void *user_data); + +/** + * @brief Called when the system display language is changed. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] language The language code + * @param[in] user_data User data to be passed from the callback registration function + * + * @pre The callback can be registered using ime_event_set_display_language_changed_cb() function. + * + * @see ime_event_set_display_language_changed_cb() + */ +typedef void (*ime_display_language_changed_cb)(const char *language, void *user_data); + +/** + * @brief Called when the device is rotated. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] degree The rotation degree + * @param[in] user_data User data to be passed from the callback registration function + * + * @pre The callback can be registered using ime_event_set_rotation_degree_changed_cb() function. + * + * @see ime_event_set_rotation_degree_changed_cb() + */ +typedef void (*ime_rotation_degree_changed_cb)(int degree, void *user_data); + +/** + * @brief Called when Accessibility in Settings application is on or off. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] state Accessibility option state + * @param[in] user_data User data to be passed from the callback registration function + * + * @pre The callback can be registered using ime_event_set_accessibility_state_changed_cb() function. + * + * @see ime_event_set_accessibility_state_changed_cb() + */ +typedef void (*ime_accessibility_state_changed_cb)(bool state, void *user_data); + +/** + * @brief Called to create the option window. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks if Input panel requests to open the option window, @a type will be #IME_OPTION_WINDOW_TYPE_KEYBOARD. + * And if Settings application requests to open it, @a type will be #IME_OPTION_WINDOW_TYPE_SETTING_APPLICATION. + * The @a window should not be released. The @a window can be used until ime_option_window_destroyed_cb() will be called. + * + * @param[in] window The created window object + * @param[in] type The type of option window + * @param[in] user_data User data to be passed from the callback registration function + * + * @pre The callback can be registered using ime_event_set_option_window_created_cb() function. The + * ime_create_option_window() calls this callback function or Settings application can call this callback function. + * + * @see ime_event_set_option_window_created_cb() + * @see ime_create_option_window() + */ +typedef void (*ime_option_window_created_cb)(Evas_Object *window, ime_option_window_type_e type, void *user_data); + +/** + * @brief Called to destroy the option window. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The @a window should be released using evas_object_del(). + * + * @param[in] window The window object to destroy + * @param[in] user_data User data to be passed to the callback function + * + * @pre The callback can be registered using ime_event_set_option_window_destroyed_cb() function. + * ime_destroy_option_window() calls this callback function. + * + * @see ime_event_set_option_window_destroyed_cb() + */ +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 @a prediction_hint 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 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_set_cb() function. + * + * @see ime_event_set_prediction_hint_set_cb() + */ +typedef void (*ime_prediction_hint_set_cb)(const char *prediction_hint, void *user_data); + +/** + * @brief Called when an associated text input UI control requests the text entry to set the MIME type. + * + * @since_tizen 4.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks @a mime_type is valid only in the callback. To use outside the callback, make a copy. + * 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_set_request_cb() function. + * + * @see ime_event_set_mime_type_set_request_cb() + */ +typedef void (*ime_mime_type_set_request_cb)(const char *mime_type, void *user_data); + +/** + * @brief Called to set key-value pairs of predicting messages to deliver to the input panel. + * + * @since_tizen 5.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks @a key and @a value is valid only in the callback. To use outside the callback, make a copy. + * This function is used by applications to deliver predicted hint messages 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. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @remarks These four callback functions are mandatory for IME application. + * + * @see ime_run() + */ +typedef struct { + ime_create_cb create; /**< Called when the input panel is created */ + ime_terminate_cb terminate; /**< Called when the input panel is terminated */ + ime_show_cb show; /**< Called when the input panel is requested to show itself */ + ime_hide_cb hide; /**< Called when the input panel is requested to hide itself */ +} ime_callback_s; + +/** + * @brief Runs the main loop of IME application. + * + * @details This function starts to run IME application's main loop. The ime_create_cb() + * callback function is called to initialize IME application before the main loop starts up. And + * the ime_terminate_cb() callback function is called when IME application is terminated. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks IME application MUST implement ime_app_main() function which is the main + * entry point of IME application. In ime_app_main() function, the ime_run() + * function MUST be called with the necessary callback functions; ime_create_cb(), + * ime_terminate_cb(), ime_show_cb(), and ime_hide_cb() callback functions + * are mandatory for IME application. + * + * @param[in] basic_cb The structure pointer of the essential callback functions + * @param[in] user_data User data to be passed to the callback functions + * + * @return 0 if IME application ends successfully, 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_NO_CALLBACK_FUNCTION Necessary callback function is not set + * @retval #IME_ERROR_OPERATION_FAILED Operation failed + * + * @pre The ime_event_set_***() functions can be called to set the event handling callback functions. + * + * @see ime_callback_s() + * @see ime_event_set_focus_in_cb() + * @see ime_event_set_focus_out_cb() + * @see ime_event_set_surrounding_text_updated_cb() + * @see ime_event_set_input_context_reset_cb() + * @see ime_event_set_cursor_position_updated_cb() + * @see ime_event_set_language_requested_cb() + * @see ime_event_set_language_set_cb() + * @see ime_event_set_imdata_set_cb() + * @see ime_event_set_layout_set_cb() + * @see ime_event_set_return_key_type_set_cb() + * @see ime_event_set_return_key_state_set_cb() + * @see ime_event_set_geometry_requested_cb() + * @see ime_event_set_display_language_changed_cb() + * @see ime_event_set_rotation_degree_changed_cb() + * @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_set_cb() + * + * @code + static void inputmethod_create_cb(void *user_data); + static void inputmethod_terminate_cb(void *user_data); + static void inputmethod_show_cb(int context_id, ime_context_h context, void *user_data); + static void inputmethod_hide_cb(int context_id, void *user_data); + static void inputmethod_focus_in_cb(int context_id, void *user_data); + static void inputmethod_focus_out_cb(int context_id, void *user_data); + static void inputmethod_cursor_position_updated_cb(int cursor_pos, void *user_data); + + static void inputmethod_create_cb(void *user_data) + { + Evas_Object *ime_win = NULL; + + ime_set_size(480, 400, 800, 400); + ime_win = ime_get_main_window(); + if (ime_win) { + // Prepare before showing IME window. + } + } + + static void inputmethod_show_cb(int context_id, ime_context_h context, void *user_data) + { + Ecore_IMF_Input_Panel_Layout layout; + ime_layout_variation_e layout_variation; + Evas_Object *ime_win; + + ime_context_get_layout(context, &layout); + ime_context_get_layout_variation(context, &layout_variation); + + ime_win = ime_get_main_window(); + if (ime_win) { + // Compose IME UI properly with the context information and show. + + evas_object_show(ime_win); + } + } + + static void inputmethod_hide_cb(int context_id, void *user_data) + { + Evas_Object *ime_win = ime_get_main_window(); + if (ime_win) { + evas_object_hide(ime_win); + } + } + + void ime_app_main(int argc, char **argv) + { + ime_callback_s basic_callback = { + inputmethod_create_cb, + inputmethod_terminate_cb, + inputmethod_show_cb, + inputmethod_hide_cb, + }; + + ime_event_set_focus_in_cb(inputmethod_focus_in_cb, NULL); + ime_event_set_focus_out_cb(inputmethod_focus_out_cb, NULL); + ime_event_set_cursor_position_updated_cb(inputmethod_cursor_position_updated_cb, NULL); + + ime_run(&basic_callback, NULL); + } + * @endcode + */ +int ime_run(ime_callback_s *basic_cb, void *user_data); + +/** + * @brief Sets @c focus_in event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_focus_in_cb() callback function is called when an associated text input + * UI control has focus. + * + * @param[in] callback_func @c focus_in 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 the IME application's main loop. + * + * @see ime_focus_in_cb() + * @see ime_run() + */ +int ime_event_set_focus_in_cb(ime_focus_in_cb callback_func, void *user_data); + +/** + * @brief Sets @c focus_out event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_focus_out_cb() callback function is called when an associated text input + * UI control loses focus. + * + * @param[in] callback_func @c focus_out 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 the IME application's main loop. + * + * @see ime_focus_out_cb() + * @see ime_run() + */ +int ime_event_set_focus_out_cb(ime_focus_out_cb callback_func, void *user_data); + +/** + * @brief Sets @c surrounding_text_updated event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_surrounding_text_updated_cb() callback function is called when an + * associated text input UI control responds to a request with the surrounding text. + * + * @param[in] callback_func @c surrounding_text_updated 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 the IME application's main loop. + * + * @see ime_surrounding_text_updated_cb() + * @see ime_run() + */ +int ime_event_set_surrounding_text_updated_cb(ime_surrounding_text_updated_cb callback_func, void *user_data); + +/** + * @brief Sets @c input_context_reset event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_input_context_reset_cb() callback function is called to reset the input + * context of an associated text input UI control. + * + * @param[in] callback_func @c input_context_reset 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 the IME application's main loop. + * + * @see ime_input_context_reset_cb() + * @see ime_run() + */ +int ime_event_set_input_context_reset_cb(ime_input_context_reset_cb callback_func, void *user_data); + +/** + * @brief Sets @c cursor_position_updated event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_cursor_position_updated_cb() callback function is called when the position + * of the cursor in an associated text input UI control changes. + * + * @param[in] callback_func @c cursor_position_updated 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 the IME application's main loop. + * + * @see ime_cursor_position_updated_cb() + * @see ime_run() + */ +int ime_event_set_cursor_position_updated_cb(ime_cursor_position_updated_cb callback_func, void *user_data); + +/** + * @brief Sets @c language_requested event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_language_requested_cb() callback function is called when an associated + * text input UI control requests the language from the input panel. + * + * @param[in] callback_func @c language_requested 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 the IME application's main loop. + * + * @see ime_language_requested_cb() + * @see ime_run() + */ +int ime_event_set_language_requested_cb(ime_language_requested_cb callback_func, void *user_data); + +/** + * @brief Sets @c language_set event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_language_set_cb() callback function is called to set the preferred + * language to the input panel. + * + * @param[in] callback_func @c language_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 the IME application's main loop. + * + * @see ime_language_set_cb() + * @see ime_run() + */ +int ime_event_set_language_set_cb(ime_language_set_cb callback_func, void *user_data); + +/** + * @brief Sets @c imdata_set event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_imdata_set_cb() callback function is called to set the application + * specific data to deliver to the input panel. + * + * @param[in] callback_func @c imdata_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 the IME application's main loop. + * + * @see ime_imdata_set_cb() + * @see ime_event_set_imdata_requested_cb() + * @see ime_run() + */ +int ime_event_set_imdata_set_cb(ime_imdata_set_cb callback_func, void *user_data); + +/** + * @brief Sets @c imdata_requested event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_imdata_requested_cb() callback function is called when an associated + * text input UI control requests the application specific data from the input panel. + * + * @param[in] callback_func @c imdata_requested 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 the IME application's main loop. + * + * @see ime_imdata_requested_cb() + * @see ime_event_set_imdata_set_cb() + * @see ime_run() + */ +int ime_event_set_imdata_requested_cb(ime_imdata_requested_cb callback_func, void *user_data); + +/** + * @brief Sets @c layout_set event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_layout_set_cb() callback function is called when an associated text input + * UI control requests the input panel to set its layout. + * + * @param[in] callback_func @c layout_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 the IME application's main loop. + * + * @see ime_layout_set_cb() + * @see ime_run() + */ +int ime_event_set_layout_set_cb(ime_layout_set_cb callback_func, void *user_data); + +/** + * @brief Sets @c return_key_type_set event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_return_key_type_set_cb() callback function is called when an associated + * text input UI control requests the input panel to set the @c Return key label. + * + * @param[in] callback_func @c return_key_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. + * @retval #IME_ERROR_OPERATION_FAILED Operation failed + * + * @post The ime_run() function should be called to start the IME application's main loop. + * + * @see ime_return_key_type_set_cb() + * @see ime_run() + */ +int ime_event_set_return_key_type_set_cb(ime_return_key_type_set_cb callback_func, void *user_data); + +/** + * @brief Sets @c return_key_state_set event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_return_key_state_set_cb() callback function is called when an associated + * text input UI control requests the input panel to enable or disable the @c Return key state. + * + * @param[in] callback_func @c return_key_state_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 the IME application's main loop. + * + * @see ime_return_key_state_set_cb() + * @see ime_run() + */ +int ime_event_set_return_key_state_set_cb(ime_return_key_state_set_cb callback_func, void *user_data); + +/** + * @brief Sets @c geometry_requested event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_geometry_requested_cb() callback function is called when an associated + * text input UI control requests the position and size from the input panel. + * + * @param[in] callback_func @c geometry_requested 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 the IME application's main loop. + * + * @see ime_geometry_requested_cb() + * @see ime_run() + */ +int ime_event_set_geometry_requested_cb(ime_geometry_requested_cb callback_func, void *user_data); + +/** + * @brief Sets @c process_key_event event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @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 process_key_event 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 the IME application's main loop. + * + * @see ime_process_key_event_cb() + * @see ime_run() + * + * @code + static void inputmethod_create_cb(void *user_data); + static void inputmethod_terminate_cb(void *user_data); + static void inputmethod_show_cb(int context_id, ime_context_h context, void *user_data); + static void inputmethod_hide_cb(int context_id, void *user_data); + + static bool inputmethod_process_key_event_cb(ime_key_code_e keycode, ime_key_mask_e keymask, void *user_data); + { + if (keymask & IME_KEY_MASK_CONTROL) { + return false; // e.g., Control+C key event would be forwarded to UI control of the client application + } + if (keymask & IME_KEY_MASK_ALT) { + return false; + } + + if (!(keymask & IME_KEY_MASK_RELEASED)) { // The key is pressed + if (keycode == IME_KEY_1) { + ime_update_preedit_string("1"); // Show "1" preedit string + return true; + } + else if (keycode == IME_KEY_2) { + ime_commit_string("12"); // Input "12" string + return true; + } + } + + return false; + } + + void ime_app_main(int argc, char **argv) + { + ime_callback_s basic_callback = { + inputmethod_create_cb, + inputmethod_terminate_cb, + inputmethod_show_cb, + inputmethod_hide_cb, + }; + + ime_event_set_process_key_event_cb(inputmethod_process_key_event_cb, NULL); + + ime_run(&basic_callback, NULL); + } + * @endcode + */ +int ime_event_set_process_key_event_cb(ime_process_key_event_cb callback_func, void *user_data); + +/** + * @brief Sets @c process_key_event_with_keycode callback function to handle the key event with a keycode. + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_process_key_event_with_keycode_cb() callback function is called when the key event + * is received from external keyboard devices or ime_send_key_event(). + * + * @param[in] callback_func @c process_key_event_with_keycode() 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 the IME application's main loop. + * + * @see ime_process_key_event_with_keycode_cb() + * @see ime_run() + */ +int ime_event_set_process_key_event_with_keycode_cb(ime_process_key_event_with_keycode_cb callback_func, void *user_data); + +/** + * @brief Sets @c display_language_changed event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_display_language_changed_cb() callback function is called when the system + * display language is changed. + * + * @param[in] callback_func @c display_language_changed 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 the IME application's main loop. + * + * @see ime_display_language_changed_cb() + * @see ime_run() + */ +int ime_event_set_display_language_changed_cb(ime_display_language_changed_cb callback_func, void *user_data); + +/** + * @brief Sets @c rotation_degree_changed event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_rotation_degree_changed_cb() callback function is called when the device + * is rotated. + * + * @param[in] callback_func @c rotation_degree_changed 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 the IME application's main loop. + * + * @see ime_rotation_degree_changed_cb() + * @see ime_run() + */ +int ime_event_set_rotation_degree_changed_cb(ime_rotation_degree_changed_cb callback_func, void *user_data); + +/** + * @brief Sets @c accessibility_state_changed event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_accessibility_state_changed_cb() callback function is called when + * Accessibility in Settings application is on or off. + * + * @param[in] callback_func @c accessibility_state_changed 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 the IME application's main loop. + * + * @see ime_accessibility_state_changed_cb() + * @see ime_run() + */ +int ime_event_set_accessibility_state_changed_cb(ime_accessibility_state_changed_cb callback_func, void *user_data); + +/** + * @brief Sets @c option_window_created event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_option_window_created_cb() callback function is called to create the option window. + * + * @param[in] callback_func @c option_window_created 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 the IME application's main loop. + * + * @see ime_option_window_created_cb() + * @see ime_run() + */ +int ime_event_set_option_window_created_cb(ime_option_window_created_cb callback_func, void *user_data); + +/** + * @brief Sets @c option_window_destroyed event callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_option_window_destroyed_cb() callback function is called to destroy the option window. + * + * @param[in] callback_func @c option_window_destroyed 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 the IME application's main loop. + * + * @see ime_option_window_destroyed_cb() + * @see ime_run() + */ +int ime_event_set_option_window_destroyed_cb(ime_option_window_destroyed_cb callback_func, void *user_data); + +/** + * @brief Sends a key event to the associated text input UI control. + * + * @details This function sends key down or up event with key mask to the client application. + * If @a forward_key is @c true, this key event goes to the edit field directly. And if @a forward_key + * is @c false, the ime_process_key_event_cb() callback function receives the key event before the edit field. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] keycode The key code to be sent + * @param[in] keymask The modifier key mask + * @param[in] forward_key The flag to send the key event directly to the edit field + * + * @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 is not started yet + * + * @post If @a forward_key is @c false, the ime_process_key_event_cb() callback function can compose the text with the key events. + * + * @see ime_key_code_e + * @see ime_key_mask_e + * @see ime_process_key_event_cb() + */ +int ime_send_key_event(ime_key_code_e keycode, ime_key_mask_e keymask, bool forward_key); + +/** + * @brief Sends the text to the associated text input UI control. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] str The UTF-8 string to be committed + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @see ime_show_preedit_string() + * @see ime_hide_preedit_string() + * @see ime_update_preedit_string() + */ +int ime_commit_string(const char *str); + +/** + * @brief Requests to show preedit string. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @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. + * @retval #IME_ERROR_NOT_RUNNING IME main loop is not started yet + * + * @see ime_commit_string() + * @see ime_hide_preedit_string() + * @see ime_update_preedit_string() + */ +int ime_show_preedit_string(void); + +/** + * @brief Requests to hide preedit string. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @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. + * @retval #IME_ERROR_NOT_RUNNING IME main loop is not started yet + * + * @see ime_commit_string() + * @see ime_show_preedit_string() + * @see ime_update_preedit_string() + */ +int ime_hide_preedit_string(void); + +/** + * @brief Updates a new preedit string. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] str The UTF-8 string to be updated in preedit + * @param[in] attrs The Eina_List which has #ime_preedit_attribute lists; @a str can be composed of multiple + * string attributes: underline, highlight color and reversal color. The @a attrs will be released internally + * on success and it can be NULL if no attributes to set + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @post This function is supposed to be followed by the ime_show_preedit_string() function. + * + * @see ime_preedit_attribute + * @see ime_commit_string() + * @see ime_show_preedit_string() + * @see ime_hide_preedit_string() + * + * @code + { + int ret; + Eina_List *list = NULL; + + ime_preedit_attribute *attr = calloc(1, sizeof(ime_preedit_attribute)); + attr->start = 0; + attr->length = 1; + attr->type = IME_ATTR_FONTSTYLE; + attr->value = IME_ATTR_FONTSTYLE_UNDERLINE; + list = eina_list_append(list, attr); + + attr = calloc(1, sizeof(ime_preedit_attribute)); + attr->start = 1; + attr->length = 1; + attr->type = IME_ATTR_FONTSTYLE; + attr->value = IME_ATTR_FONTSTYLE_HIGHLIGHT; + list = eina_list_append(list, attr); + + attr = calloc(1, sizeof(ime_preedit_attribute)); + attr->start = 2; + attr->length = 1; + attr->type = IME_ATTR_FONTSTYLE; + attr->value = IME_ATTR_FONTSTYLE_REVERSAL; + list = eina_list_append(list, attr); + + ret = ime_update_preedit_string("abcd", list); + if (ret != IME_ERROR_NONE) { + EINA_LIST_FREE(list, attr) + free(attr); + } + } + * @endcode + */ +int ime_update_preedit_string(const char *str, Eina_List *attrs); + +/** + * @brief Requests the surrounding text from the position of the cursor, asynchronously. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] maxlen_before The maximum length of string to be retrieved before the cursor; -1 means unlimited + * @param[in] maxlen_after The maximum length of string to be retrieved after the cursor; -1 means unlimited + * + * @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_NO_CALLBACK_FUNCTION Necessary callback function is not set + * @retval #IME_ERROR_NOT_RUNNING IME main loop is not started yet + * + * @pre The ime_surrounding_text_updated_cb() callback function MUST be set by ime_event_set_surrounding_text_updated_cb(). + * + * @post The requested surrounding text can be received using the ime_surrounding_text_updated_cb() callback function. + * + * @see ime_delete_surrounding_text() + * @see ime_event_set_surrounding_text_updated_cb() + * @see ime_surrounding_text_updated_cb() + */ +int ime_request_surrounding_text(int maxlen_before, int maxlen_after); + +/** + * @brief Requests to delete surrounding text. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] offset The offset value from the cursor position + * @param[in] len The length of the text to delete + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @see ime_request_surrounding_text() + */ +int ime_delete_surrounding_text(int offset, int len); + +/** + * @brief Gets the surrounding text from the position of the cursor, synchronously. + * + * @since_tizen 3.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks @a text must be released using free(). + * + * @param[in] maxlen_before The maximum length of string to be retrieved before the cursor; -1 means unlimited + * @param[in] maxlen_after The maximum length of string to be retrieved after the cursor; -1 means unlimited + * @param[out] text The surrounding text + * @param[out] cursor_pos The cursor position + * + * @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_NOT_RUNNING IME main loop is not started yet + * @retval #IME_ERROR_OUT_OF_MEMORY Failed to obtain text due to out of memory + * + * @see ime_delete_surrounding_text() + */ +int ime_get_surrounding_text(int maxlen_before, int maxlen_after, char **text, int *cursor_pos); + +/** + * @brief Requests to set selection. + * + * @since_tizen 3.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] start The start cursor position in text (in characters not bytes) + * @param[in] end The end cursor position in text (in characters not bytes) + * + * @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_NOT_RUNNING IME main loop is not started yet + */ +int ime_set_selection(int start, int end); + +/** + * @brief Gets the selected text synchronously. + * + * @details If multi-line text is selected, the result will contain '\n' for each newline character. + * And if the selected text is empty, the result will be an empty string. + * + * @since_tizen 4.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks @a text must be released using free(). + * + * @param[out] text The selected text + * + * @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_NOT_RUNNING IME main loop is not started yet + */ +int ime_get_selected_text(char **text); + +/** + * @brief Gets the pointer of input panel main window. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The specific error code can be obtained using the get_last_result() method if this function returns NULL. + * @remarks The returned value should not be released. The returned value is managed by the platform and will be released when terminating this process. + * + * @return The input panel main window object on success, otherwise NULL + * + * @exception #IME_ERROR_NONE Successful + * @exception #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function. + * @exception #IME_ERROR_NOT_RUNNING IME main loop is not started yet + * @exception #IME_ERROR_OPERATION_FAILED Operation failed + * + * @see get_last_result() + * @see ime_create_cb() + * @see ime_terminate_cb() + * @see ime_show_cb() + * @see ime_hide_cb() + */ +Evas_Object* ime_get_main_window(void); + +/** + * @brief Updates the input panel window's size information. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] portrait_width The width in portrait mode + * @param[in] portrait_height The height in portrait mode + * @param[in] landscape_width The width in landscape mode + * @param[in] landscape_height The height in landscape mode + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @see ime_create_cb() + */ +int ime_set_size(int portrait_width, int portrait_height, int landscape_width, int landscape_height); + +/** + * @brief Requests to create an option window from the input panel. + * + * @details The input panel can call this function to open the option window. This + * function calls ime_option_window_created_cb() callback function with + * #IME_OPTION_WINDOW_TYPE_KEYBOARD parameter. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @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. + * @retval #IME_ERROR_NO_CALLBACK_FUNCTION Necessary callback function is not set + * @retval #IME_ERROR_NOT_RUNNING IME main loop is not started yet + * @retval #IME_ERROR_OPERATION_FAILED Operation failed + * + * @pre The ime_option_window_created_cb() and ime_option_window_destroyed_cb() + * callback functions MUST be set by ime_event_set_option_window_created_cb() and + * ime_event_set_option_window_destroyed_cb() respectively. + * + * @post This function calls ime_option_window_created_cb() callback function to + * create the option window. And ime_destroy_option_window() function can be called + * to close the option window. + * + * @see ime_event_set_option_window_created_cb() + * @see ime_option_window_created_cb() + * @see ime_destroy_option_window() + */ +int ime_create_option_window(void); + +/** + * @brief Requests to destroy an option window. + * + * @details The input panel can call this function to close the option window which + * is created from either the input panel or Settings application. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] window The option window to destroy + * + * @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_NO_CALLBACK_FUNCTION Necessary callback function is not set + * @retval #IME_ERROR_NOT_RUNNING IME main loop is not started yet + * + * @pre The ime_option_window_created_cb() and ime_option_window_destroyed_cb() + * callback functions MUST be set by ime_event_set_option_window_created_cb() and + * ime_event_set_option_window_destroyed_cb() respectively. + * + * @post This function calls ime_option_window_destroyed_cb() callback function + * to destroy the option window. + * + * @see ime_event_set_option_window_destroyed_cb() + * @see ime_option_window_destroyed_cb() + * @see ime_create_option_window() + */ +int ime_destroy_option_window(Evas_Object *window); + +/** + * @brief Gets the layout information from the given input context. + * + * @details Each edit field has various attributes for input panel. This function can be + * called to get the layout information in ime_show_cb() callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] context The input context information of an associated text input UI control + * @param[out] layout Layout information + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @post Input panel UI should be drawn or operated by this information accordingly. + * + * @see ime_show_cb() + * @see ime_layout_set_cb() + */ +int ime_context_get_layout(ime_context_h context, Ecore_IMF_Input_Panel_Layout *layout); + +/** + * @brief Gets the layout variation information from the given input context. + * + * @details Each edit field has various attributes for input panel. This function can be + * called to get the layout variation information in ime_show_cb() callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] context The input context information of an associated text input UI control + * @param[out] layout_variation Layout variation information + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @post Input panel UI should be drawn or operated by this information accordingly. + * + * @see ime_show_cb() + * @see ime_layout_variation_e + */ +int ime_context_get_layout_variation(ime_context_h context, ime_layout_variation_e *layout_variation); + +/** + * @brief Gets the cursor position information from the given input context. + * + * @details Each edit field has various attributes for input panel. This function can be + * called to get the cursor position information in ime_show_cb() callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] context The input context information of an associated text input UI control + * @param[out] cursor_pos Cursor position information + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @post Input panel UI should be drawn or operated by this information accordingly. + * + * @see ime_show_cb() + * @see ime_cursor_position_updated_cb() + */ +int ime_context_get_cursor_position(ime_context_h context, int *cursor_pos); + +/** + * @brief Gets the autocapital type information from the given input context. + * + * @details Each edit field has various attributes for input panel. This function can be + * called to get the autocapital type information in ime_show_cb() callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] context The input context information of an associated text input UI control + * @param[out] autocapital_type Autocapital type information + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @post Input panel UI should be drawn or operated by this information accordingly. + * + * @see ime_show_cb() + */ +int ime_context_get_autocapital_type(ime_context_h context, Ecore_IMF_Autocapital_Type *autocapital_type); + +/** + * @brief Gets the @c Return key label type information from the given input context. + * + * @details Each edit field has various attributes for input panel. This function can be + * called to get the @c Return key label type information in ime_show_cb() callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] context The input context information of an associated text input UI control + * @param[out] return_key_type The @c Return key label type information + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @post Input panel UI should be drawn or operated by this information accordingly. + * + * @see ime_show_cb() + * @see ime_return_key_type_set_cb() + */ +int ime_context_get_return_key_type(ime_context_h context, Ecore_IMF_Input_Panel_Return_Key_Type *return_key_type); + +/** + * @brief Gets the @c Return key state information from the given input context. + * + * @details Each edit field has various attributes for input panel. This function can be + * called to get the @c Return key state information in ime_show_cb() callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] context The input context information of an associated text input UI control + * @param[out] return_key_state The @c Return key state information \n @c true to enable @c Return key + * button, @c false to disable @c Return key button + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @post Input panel UI should be drawn or operated by this information accordingly. + * + * @see ime_show_cb() + * @see ime_return_key_state_set_cb() + */ +int ime_context_get_return_key_state(ime_context_h context, bool *return_key_state); + +/** + * @brief Gets the prediction mode information from the given input context. + * + * @details Each edit field has various attributes for input panel. This function can be + * called to get the prediction mode information in ime_show_cb() callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] context The input context information of an associated text input UI control + * @param[out] prediction_mode Prediction mode information \n @c true to allow the predictive + * text feature if available, @c false to disable the predictive text feature + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @post Input panel UI should be drawn or operated by this information accordingly. + * + * @see ime_show_cb() + */ +int ime_context_get_prediction_mode(ime_context_h context, bool *prediction_mode); + +/** + * @brief Gets the password mode information from the given input context. + * + * @details Each edit field has various attributes for input panel. This function can be + * called to get the password mode information in ime_show_cb() callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks If @a password_mode is @c true, the input panel is advised not to support the predictive text. + * + * @param[in] context The input context information of an associated text input UI control + * @param[out] password_mode Password mode information \n @c true to indicate that a password being inputted, + * @c false to indicate non-password edit field. + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @post Input panel UI should be drawn or operated by this information accordingly. + * + * @see ime_show_cb() + */ +int ime_context_get_password_mode(ime_context_h context, bool *password_mode); + +/** + * @brief Gets the input hint information from the given input context. + * + * @details Each edit field has various attributes for input panel. This function can be + * called to get the input hint information in ime_show_cb() callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks @a input_hint is a bit-wise value which recommends the input panel provide + * an auto completion and so on if it is capable of supporting such features. + * + * @param[in] context The input context information of an associated text input UI control + * @param[out] input_hint Input hint information + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @post Input panel UI should be drawn or operated by this information accordingly. + * + * @see ime_show_cb() + */ +int ime_context_get_input_hint(ime_context_h context, Ecore_IMF_Input_Hints *input_hint); + +/** + * @brief Gets the text bidirectional information from the given input context. + * + * @details Each edit field has various attributes for input panel. This function can be + * called to get the bidirectional information in ime_show_cb() callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] context The input context information of an associated text input UI control + * @param[out] bidi Text bidirectional information + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @post Input panel UI should be drawn or operated by this information accordingly. + * + * @see ime_show_cb() + */ +int ime_context_get_bidi_direction(ime_context_h context, Ecore_IMF_BiDi_Direction *bidi); + +/** + * @brief Gets the preferred language information from the given input context. + * + * @details Each edit field has various attributes for input panel. This function can be + * called to get the preferred language information in ime_show_cb() callback function. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] context The input context information of an associated text input UI control + * @param[out] language Preferred language information + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @post Input panel UI should be drawn or operated by this information accordingly. + * + * @see ime_show_cb() + */ +int ime_context_get_language(ime_context_h context, Ecore_IMF_Input_Panel_Lang *language); + +/** + * @brief Gets the device name of the key event. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks @a dev_name must be released using free(). + * + * @param[in] dev_info The device information from the key event + * @param[out] dev_name The name of key input device. This can be an empty string if the device name is not available + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @see ime_process_key_event_cb() + * @see ime_device_info_get_class() + * @see ime_device_info_get_subclass() + */ +int ime_device_info_get_name(ime_device_info_h dev_info, char **dev_name); + +/** + * @brief Gets the device class of the key event. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] dev_info The device information from the key event + * @param[out] dev_class The class of key input device. This can be #ECORE_IMF_DEVICE_CLASS_NONE if the device class is not available + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @see ime_process_key_event_cb() + * @see ime_device_info_get_name() + * @see ime_device_info_get_subclass() + */ +int ime_device_info_get_class(ime_device_info_h dev_info, Ecore_IMF_Device_Class *dev_class); +/** + * @brief Gets the device subclass of the key event. + * + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] dev_info The device information from the key event + * @param[out] dev_subclass The subclass of key input device. This can be #ECORE_IMF_DEVICE_SUBCLASS_NONE if the device subclass is not available + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @see ime_process_key_event_cb() + * @see ime_device_info_get_name() + * @see ime_device_info_get_class() + */ +int ime_device_info_get_subclass(ime_device_info_h dev_info, Ecore_IMF_Device_Subclass *dev_subclass); + +/** + * @brief Sets prediction hint 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 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 the IME application's main loop. + * + * @see ime_prediction_hint_set_cb() + * @see ime_run() + */ +int ime_event_set_prediction_hint_set_cb(ime_prediction_hint_set_cb callback_func, void *user_data); + +/** + * @brief Sets MIME type event callback function. + * + * @since_tizen 4.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_mime_type_set_request_cb() callback function is called when an associated text input + * UI control requests the text entry to set the MIME type. + * + * @param[in] callback_func MIME type 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 the IME application's main loop. + * + * @see ime_mime_type_set_request_cb() + * @see ime_run() + */ +int ime_event_set_mime_type_set_request_cb(ime_mime_type_set_request_cb callback_func, void *user_data); + +/** + * @brief Sends a private command to the associated text input UI control. + * + * @details This can be used by IME to deliver specific data to an application. + * The data format MUST be negotiated by both application and IME. + * + * @since_tizen 4.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] command The UTF-8 string to be sent + * + * @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_NOT_RUNNING IME main loop is not started yet + */ +int ime_send_private_command(const char *command); + +/** + * @brief Commits contents such as image to the associated text input UI control. + * + * @since_tizen 4.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] content The content URI to be sent + * @param[in] description The content description + * @param[in] mime_type The MIME type received from the ime_mime_type_set_request_cb() + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @see ime_mime_type_set_request_cb() + * @see ime_event_set_mime_type_set_request_cb() + */ +int ime_commit_content(const char *content, const char *description, const char *mime_type); + +/** + * @brief Sets the floating mode or not. + * + * @since_tizen 4.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] floating_mode @c true - floating mode on, @c false - floating mode off + * + * @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 is not started yet + * + * @see ime_set_floating_drag_start() + * @see ime_set_floating_drag_end() + */ +int ime_set_floating_mode(bool floating_mode); + +/** + * @brief Allows the floating input panel window to move along with the mouse pointer when the mouse is pressed. + * + * @since_tizen 4.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks This function can be used in floating mode. If the floating mode is deactivated, calling this function has no effect. + * + * @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 is not started yet + * + * @pre The floating mode was turned on with ime_set_floating_mode(). + * + * @see ime_set_floating_mode() + * @see ime_set_floating_drag_end() + */ +int ime_set_floating_drag_start(void); + +/** + * @brief Disallows the movement of the floating input panel window with the mouse pointer when the mouse is pressed. + * + * @details This function must be called after invoking ime_set_floating_drag_start(). Otherwise the call is ignored. + * + * @since_tizen 4.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks This function can be used in floating mode. If the floating mode is deactivated, calling this function has no effect. + * + * @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 is not started yet + * + * @pre The floating mode was turned on with ime_set_floating_mode(). + * @pre ime_set_floating_drag_start() was called before. + * + * @see ime_set_floating_mode() + * @see ime_set_floating_drag_start() + */ +int ime_set_floating_drag_end(void); + +/** + * @brief Sets a callback function to give a hint about predicted words. + * + * @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 provide the prediction + * hint key and value which can be delivered to the input panel. + * + * @param[in] callback_func The callback function to give hints + * @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 the 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); + +/** + * @brief Sends the request to hide IME. + * + * @since_tizen 5.0 + * + * @privlevel public + * + * @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. + * @retval #IME_ERROR_NOT_RUNNING IME main loop is not started yet + */ +int ime_request_hide(void); + +/** + * @brief Updates the state of input panel event. + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] type The input panel event type + * @param[in] value The value of event type + * + * @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_NOT_RUNNING IME main loop is not started yet + * + * @see ime_event_type_e + */ +int ime_update_input_panel_event(ime_event_type_e type, unsigned int value); + +/** + * @brief Enables whether candidate strings show or not. + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] visible @c true if candidate strings show, @c false otherwise. + * + * @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 is not started yet + */ +int ime_set_candidate_visibility_state(bool visible); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_UIX_INPUTMETHOD_H__ */ + diff --git a/inputmethod/include/inputmethod_device_event.h b/inputmethod/include/inputmethod_device_event.h new file mode 100644 index 0000000..8ecbd10 --- /dev/null +++ b/inputmethod/include/inputmethod_device_event.h @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_UIX_INPUTMETHOD_DEVICE_EVENT_H__ +#define __TIZEN_UIX_INPUTMETHOD_DEVICE_EVENT_H__ + +/** + * @file inputmethod_device_event.h + * @brief This file contains definitions for unconventional input device events. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_UIX_INPUTMETHOD_MODULE + * @{ + */ + + /** + * @brief The handle to retrieve unconventional input device specific event data. + * + * @since_tizen @if WEARABLE 3.0 @endif + * + * @see ime_event_set_process_input_device_event_cb() + */ +typedef void *ime_input_device_event_h; + +/** + * @brief Enumeration of unconventional input devices. + * + * @since_tizen @if WEARABLE 3.0 @endif + * + * @see ime_event_set_process_input_device_event_cb() + */ +typedef enum { + IME_INPUT_DEVICE_TYPE_UNKNOWN, /**< Undefined unconventional input device */ + IME_INPUT_DEVICE_TYPE_ROTARY, /**< A rotary input device such as bezel that can be found on a wearable device */ +} ime_input_device_type_e; + +/** + * @brief Enumeration of directions for rotary input device's rotation event. + * + * @since_tizen @if WEARABLE 3.0 @endif + * + * @see ime_input_device_rotary_get_direction() + */ +typedef enum +{ + IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE, /**< Rotary is rotated clockwise direction */ + IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE /**< Rotary is rotated counter clockwise direction */ +} ime_input_device_rotary_direction_e; + +/** + * @brief Called when the input event is received from an unconventional input device that does not generate key events. + * + * @details This function processes the input event before an associated text input UI control does. + * + * @since_tizen @if WEARABLE 3.0 @endif + * + * @remarks @a device_type contains the information what kind of unconventional input device generated the given event, + * and the handle @a device_event is used for obtaining device-specific input device event data. + * @a device_event should not be released. + * + * @param[in] device_type The unconventional input device type + * @param[in] device_event The handle for device_type specific input device event + * @param[in] user_data User data to be passed to the callback function + * + * @pre The callback can be registered using ime_event_set_input_device_event_cb() function. + * + * @see ime_event_set_process_input_device_event_cb() + */ +typedef void(*ime_process_input_device_event_cb)(ime_input_device_type_e device_type, ime_input_device_event_h device_event, void *user_data); + +/** + * @brief Sets @c process_input_device_event event callback function. + * + * @since_tizen @if WEARABLE 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_process_input_device_event_cb() callback function is called when the event + * is received from unconventional input devices that needs to be handled by IMEs. + * + * @param[in] callback_func @c inputmethod_process_input_device_event_cb 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_process_input_device_event_cb() + * @see ime_event_unset_process_input_device_event_cb() + * @see ime_run() + * + * @code + static void inputmethod_create_cb(void *user_data); + static void inputmethod_terminate_cb(void *user_data); + static void inputmethod_show_cb(int context_id, ime_context_h context, void *user_data); + static void inputmethod_hide_cb(int context_id, void *user_data); + + static void inputmethod_process_input_device_event_cb(ime_input_device_type_e device_type, ime_input_device_event_h device_event, void *user_data) + { + if (device_type == IME_INPUT_DEVICE_TYPE_ROTARY) { + dlog_print(DLOG_INFO, "INPUTMETHOD", "Input device type is rotary\n"); + } + } + + void ime_app_main(int argc, char **argv) + { + ime_callback_s basic_callback = { + inputmethod_create_cb, + inputmethod_terminate_cb, + inputmethod_show_cb, + inputmethod_hide_cb, + }; + + ime_event_set_process_input_device_event_cb(inputmethod_process_input_device_event_cb, NULL); + + ime_run(&basic_callback, NULL); + } + * @endcode + */ + +int ime_event_set_process_input_device_event_cb(ime_process_input_device_event_cb callback_func, void *user_data); + +/** + * @brief Unsets @c process_input_device_event event callback function. + * + * @since_tizen @if WEARABLE 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_process_input_device_event_cb() callback function is called when the event + * is received from unconventional input devices that needs to be handled by IMEs. + * + * @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_OPERATION_FAILED Operation failed + * + * @see ime_process_input_device_event_cb() + * @see ime_event_set_process_input_device_event_cb() + */ +int ime_event_unset_process_input_device_event_cb(void); + +/** + * @brief Gets the direction of the rotary input device event + * + * If the device_type parameter of the ime_process_input_device_event_cb() function indicates + * the current input device type is #IME_INPUT_DEVICE_TYPE_ROTARY, then the device_event parameter + * can be used to retrieve rotary device specific parameters, such as direction, as shown in the sample code. + * + * @since_tizen @if WEARABLE 3.0 @endif + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] event_handle The input device event handle + * @param[out] direction The direction that the rotary input device was rotated to + * + * @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_NOT_RUNNING IME main loop isn't started yet + * + * @see ime_rotary_input_device_direction_e + * @see ime_process_input_device_event_cb() + * + * @code + static void inputmethod_process_input_device_event_cb(ime_input_device_type_e device_type, ime_input_device_event_h device_event) + { + if (device_type == IME_INPUT_DEVICE_TYPE_ROTARY) { + ime_input_device_rotary_direction_e direction; + if (IME_ERROR_NONE == ime_input_device_rotary_get_direction(device_event, &direction)) { + dlog_print(DLOG_INFO, "INPUTMETHOD", "Direction : %d", direction); + } + } + } + * @endcode + */ +int ime_input_device_rotary_get_direction(ime_input_device_event_h event_handle, ime_input_device_rotary_direction_e *direction); + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* __TIZEN_UIX_INPUTMETHOD_DEVICE_EVENT_H__ */ diff --git a/inputmethod/include/inputmethod_internal.h b/inputmethod/include/inputmethod_internal.h new file mode 100644 index 0000000..5e40eb4 --- /dev/null +++ b/inputmethod/include/inputmethod_internal.h @@ -0,0 +1,390 @@ +/* + * Copyright (c) 2014-2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_UIX_INPUTMETHOD_INTERNAL_H__ +#define __TIZEN_UIX_INPUTMETHOD_INTERNAL_H__ + +/** + * @file inputmethod_internal.h + * @brief This file contains input method internal APIs and related enumeration. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumeration for input method optimization hint. + * + * @since_tizen 5.0 + */ +typedef enum { + IME_OPTIMIZATION_HINT_NONE = 0, /**< No hint provided */ + IME_OPTIMIZATION_HINT_SHOW_PREPARE, /**< This IME is going to be displayed on screen soon */ +} ime_optimization_hint_e; + +typedef struct _ime_context *ime_context_h; + +/** + * @brief Called when an caps mode is changed. + * + * @since_tizen 3.0 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] mode caps mode + * @param[in] user_data User data to be passed from the callback registration function + */ +typedef void (*ime_caps_mode_changed_cb)(int mode, void *user_data); + +/** + * @brief Called when a candidate list provided by IMEngine should be shown. + * + * @since_tizen 3.0 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] context_id The input context identification value of an associated text input UI control + * @param[in] user_data User data to be passed from the callback registration function + */ +typedef void (*ime_candidate_show_cb)(int context_id, void *user_data); + +/** + * @brief Called when a candidate list provided by IMEngine should be hidden. + * + * @since_tizen 3.0 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] context_id The input context identification value of an associated text input UI control + * @param[in] user_data User data to be passed from the callback registration function + */ +typedef void (*ime_candidate_hide_cb)(int context_id, void *user_data); + +/** + * @brief Called when a candidate list provided by IMEngine is changed. + * + * @since_tizen 3.0 + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks @a list should not be released. + * + * @param[in] list candidate list + * @param[in] user_data User data to be passed from the callback registration function + */ +typedef void (*ime_lookup_table_changed_cb)(Eina_List *list, void *user_data); + +/** + * @brief Called when a optimization hint value is set. + * + * @since_tizen 5.0 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] hint The hint value used for optimization + * @param[in] user_data User data to be passed from the callback registration function + */ +typedef void (*ime_optimization_hint_set_cb)(ime_optimization_hint_e hint, void *user_data); + +/** + * @brief Sets @c ime_caps_mode_changed_cb() event callback function. + * + * @since_tizen 3.0 + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_caps_mode_changed_cb() callback function is called when an associated text input + * UI control sends the change of caps mode. + * + * @param[in] callback_func @c ime_caps_mode_changed_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_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_run() + */ +int ime_event_set_caps_mode_changed_cb(ime_caps_mode_changed_cb callback_func, void *user_data); + +/** + * @brief Sets @c ime_candidate_show_cb() event callback function. + * + * @since_tizen 3.0 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] callback_func @c ime_candidate_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_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_run() + */ +int ime_event_set_candidate_show_cb(ime_candidate_show_cb callback_func, void *user_data); + +int ime_event_set_candidate_hide_cb(ime_candidate_hide_cb callback_func, void *user_data); + +/** + * @brief Sets @c ime_lookup_table_changed_cb() event callback function. + * + * @since_tizen 3.0 + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_lookup_table_changed_cb() callback function is called when an associated text input + * UI control sends the change of caps mode. + * + * @param[in] callback_func @c ime_lookup_table_changed_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_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_run() + */ +int ime_event_set_lookup_table_changed_cb(ime_lookup_table_changed_cb callback_func, void *user_data); + +/** + * @brief Gets the caps mode information from the given input context. + * + * @details Each edit field has various attributes for input panel. This function can be + * called to get the caps mode information in ime_show_cb() callback function. + * + * @since_tizen 3.0 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] context The input context information of an associated text input UI control + * @param[out] caps_mode Caps mode information \n @c true to turn on shift mode + * text feature if available, @c false to disable the predictive text feature + * + * @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_NOT_RUNNING IME main loop isn't started yet + * + * @post Input panel UI should be drawn or operated by this information accordingly. + * + * @see ime_show_cb() + */ +int ime_context_get_caps_mode(ime_context_h context, bool *caps_mode); + +/** + * @brief Sets keyboard engine. + * + * @since_tizen 3.0 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] engine_id The engine UUID + * + * @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_NOT_RUNNING IME main loop isn't started yet + */ +int ime_set_imengine(const char *engine_id); + +/** + * @brief Flushes state in Input Method engine. + * + * @since_tizen 3.0 + * + * @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 + * @retval #IME_ERROR_NOT_RUNNING IME main loop isn't started yet + */ +int ime_flush_imengine(void); + +/** + * @brief Resets state in Input Method engine. + * + * @since_tizen 3.0 + * + * @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 + * @retval #IME_ERROR_NOT_RUNNING IME main loop isn't started yet + */ +int ime_reset_imengine(void); + +/** + * @brief Sends the selected item index in the candidate list. + * + * @since_tizen 3.0 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] index the selected index in the candidate 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 + * @retval #IME_ERROR_NOT_RUNNING IME main loop isn't started yet + */ +int ime_select_candidate(unsigned int index); + +/** + * @brief Sends the input context event. + * + * @since_tizen 3.0 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] type the event type + * @param[in] value the event value + * + * @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_update_input_context(unsigned int type, unsigned int value); + +/** + * @brief Requests IME to initialize explicitly. + * + * @details When using ime_run API, the initialize / prepare / finalize procedures + * are processed automatically inside the IME application loop. + * But in case of not using ime_run API, which means the IME application has + * its own main loop, these procedures need to be requested explicitly. + * + * @since_tizen 4.0 + * + * @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_initialize(void); + +/** + * @brief Requests IME to prepare resources such as IME window and socket connection. + * + * @details Like ime_initialize() function, this procedure is automatically processed + * when using ime_run() API. Call this function only when ime_run() is not used and + * the IME application has to handle main loop by itself. + * + * @since_tizen 4.0 + * + * @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 + * @retval #IME_ERROR_OPERATION_FAILED Operation failed + */ +int ime_prepare(void); + +/** + * @brief Requests IME to finalize explicitly. + * + * @since_tizen 4.0 + * + * @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_finalize(void); + +/** + * @brief Sets flag whether IME is called from dotnet. + * + * @since_tizen 4.0 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] set Set with Dotnet 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 + */ +int ime_set_dotnet_flag(bool set); + +/** + * @brief Sets flag whether creating IME window should be defered until there is a access request. + * + * @since_tizen 5.0 + * + * @privilege %http://tizen.org/privilege/ime + * + * @param[in] flag true if deferring window creation is desired + * @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_set_window_creation_defer_flag(bool flag); + +/** + * @brief Sets @c ime_optimization_hint_set_cb() event callback function. + * + * @since_tizen 5.0 + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_optimization_hint_set_cb() callback function is called when an optimization hint is set + * + * @param[in] callback_func @c ime_optimization_hint_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_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_run() + */ +int ime_event_set_optimization_hint_set_cb(ime_optimization_hint_set_cb callback_func, void *user_data); + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_UIX_INPUTMETHOD_INTERNAL_H__ */ + diff --git a/inputmethod/include/inputmethod_keydef.h b/inputmethod/include/inputmethod_keydef.h new file mode 100644 index 0000000..9d266a9 --- /dev/null +++ b/inputmethod/include/inputmethod_keydef.h @@ -0,0 +1,301 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_UIX_INPUTMETHOD_KEYDEF_H__ +#define __TIZEN_UIX_INPUTMETHOD_KEYDEF_H__ + + +/** + * @file inputmethod_keydef.h + * @brief This file contains key code and mask enumeration. + */ + + +/** + * @addtogroup CAPI_UIX_INPUTMETHOD_MODULE + * @{ + */ + + +/** + * @brief Enumeration for the key codes. + * If keycode & 0xff000000 == 0x01000000 then this key code is directly encoded 24-bit UCS character. + * The UCS value is keycode & 0x00ffffff. + * @details Defines the list of keys supported by the system. + * Note that certain keys may not be available on all devices. + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + */ +typedef enum { + IME_KEY_BackSpace = 0xFF08, /**< The backspace key */ + IME_KEY_Tab = 0xFF09, /**< The tab key */ + IME_KEY_Linefeed = 0xFF0A, /**< The linefeed key */ + IME_KEY_Clear = 0xFF0B, /**< The clear key */ + IME_KEY_Return = 0xFF0D, /**< The return key */ + IME_KEY_Pause = 0xFF13, /**< The pause key */ + IME_KEY_Scroll_Lock = 0xFF14, /**< The scroll lock key */ + IME_KEY_Sys_Req = 0xFF15, /**< The sys req key */ + IME_KEY_Escape = 0xFF1B, /**< The escape key */ + IME_KEY_Delete = 0xFFFF, /**< The delete key */ + + /* Cursor control & motion */ + IME_KEY_Home = 0xFF50, /**< The home key */ + IME_KEY_Left = 0xFF51, /**< The left directional key */ + IME_KEY_Up = 0xFF52, /**< The up directional key */ + IME_KEY_Right = 0xFF53, /**< The right directional key */ + IME_KEY_Down = 0xFF54, /**< The down directional key */ + IME_KEY_Prior = 0xFF55, /**< The prior, previous key */ + IME_KEY_Page_Up = 0xFF55, /**< The page up key */ + IME_KEY_Next = 0xFF56, /**< The next key */ + IME_KEY_Page_Down = 0xFF56, /**< The page down key */ + IME_KEY_End = 0xFF57, /**< The end key */ + IME_KEY_Begin = 0xFF58, /**< The begin key */ + + /* Misc Functions */ + IME_KEY_Select = 0xFF60, /**< The select key */ + IME_KEY_Print = 0xFF61, /**< The print key */ + IME_KEY_Execute = 0xFF62, /**< The execute, run, do key */ + IME_KEY_Insert = 0xFF63, /**< The insert key */ + IME_KEY_Undo = 0xFF65, /**< The undo key */ + IME_KEY_Redo = 0xFF66, /**< The redo key */ + IME_KEY_Menu = 0xFF67, /**< The menu key */ + IME_KEY_Find = 0xFF68, /**< The find key */ + IME_KEY_Cancel = 0xFF69, /**< The cancel, stop, abort, exit key */ + IME_KEY_Help = 0xFF6A, /**< The help key */ + IME_KEY_Break = 0xFF6B, /**< The break key */ + IME_KEY_Mode_switch = 0xFF7E, /**< The character set switch key */ + IME_KEY_Num_Lock = 0xFF7F, /**< The num lock key */ + + /* Keypad */ + IME_KEY_KP_Space = 0xFF80, /**< The Numpad space key */ + IME_KEY_KP_Tab = 0xFF89, /**< The Numpad tab key */ + IME_KEY_KP_Enter = 0xFF8D, /**< The Numpad enter key */ + IME_KEY_KP_F1 = 0xFF91, /**< The Numpad function 1 key */ + IME_KEY_KP_F2 = 0xFF92, /**< The Numpad function 2 key */ + IME_KEY_KP_F3 = 0xFF93, /**< The Numpad function 3 key */ + IME_KEY_KP_F4 = 0xFF94, /**< The Numpad function 4 key */ + IME_KEY_KP_Home = 0xFF95, /**< The Numpad home key */ + IME_KEY_KP_Left = 0xFF96, /**< The Numpad left key */ + IME_KEY_KP_Up = 0xFF97, /**< The Numpad up key */ + IME_KEY_KP_Right = 0xFF98, /**< The Numpad right key */ + IME_KEY_KP_Down = 0xFF99, /**< The Numpad down key */ + IME_KEY_KP_Prior = 0xFF9A, /**< The Numpad prior, previous key */ + IME_KEY_KP_Page_Up = 0xFF9A, /**< The Numpad page up key */ + IME_KEY_KP_Next = 0xFF9B, /**< The Numpad next key */ + IME_KEY_KP_Page_Down = 0xFF9B, /**< The Numpad page down key */ + IME_KEY_KP_End = 0xFF9C, /**< The Numpad end key */ + IME_KEY_KP_Begin = 0xFF9D, /**< The Numpad begin key */ + IME_KEY_KP_Insert = 0xFF9E, /**< The Numpad insert key */ + IME_KEY_KP_Delete = 0xFF9F, /**< The Numpad delete key */ + IME_KEY_KP_Equal = 0xFFBD, /**< The Numpad equal key */ + IME_KEY_KP_Multiply = 0xFFAA, /**< The Numpad multiply key */ + IME_KEY_KP_Add = 0xFFAB, /**< The Numpad add key */ + IME_KEY_KP_Separator = 0xFFAC, /**< The Numpad separator key */ + IME_KEY_KP_Subtract = 0xFFAD, /**< The Numpad subtract key */ + IME_KEY_KP_Decimal = 0xFFAE, /**< The Numpad decimal key */ + IME_KEY_KP_Divide = 0xFFAF, /**< The Numpad divide key */ + + IME_KEY_KP_0 = 0xFFB0, /**< The Numpad 0 key */ + IME_KEY_KP_1 = 0xFFB1, /**< The Numpad 1 key */ + IME_KEY_KP_2 = 0xFFB2, /**< The Numpad 2 key */ + IME_KEY_KP_3 = 0xFFB3, /**< The Numpad 3 key */ + IME_KEY_KP_4 = 0xFFB4, /**< The Numpad 4 key */ + IME_KEY_KP_5 = 0xFFB5, /**< The Numpad 5 key */ + IME_KEY_KP_6 = 0xFFB6, /**< The Numpad 6 key */ + IME_KEY_KP_7 = 0xFFB7, /**< The Numpad 7 key */ + IME_KEY_KP_8 = 0xFFB8, /**< The Numpad 8 key */ + IME_KEY_KP_9 = 0xFFB9, /**< The Numpad 9 key */ + + /* Auxilliary Functions */ + IME_KEY_F1 = 0xFFBE, /**< The function 1 key */ + IME_KEY_F2 = 0xFFBF, /**< The function 2 key */ + IME_KEY_F3 = 0xFFC0, /**< The function 3 key */ + IME_KEY_F4 = 0xFFC1, /**< The function 4 key */ + IME_KEY_F5 = 0xFFC2, /**< The function 5 key */ + IME_KEY_F6 = 0xFFC3, /**< The function 6 key */ + IME_KEY_F7 = 0xFFC4, /**< The function 7 key */ + IME_KEY_F8 = 0xFFC5, /**< The function 8 key */ + IME_KEY_F9 = 0xFFC6, /**< The function 9 key */ + IME_KEY_F10 = 0xFFC7, /**< The function 10 key */ + IME_KEY_F11 = 0xFFC8, /**< The function 11 key */ + IME_KEY_F12 = 0xFFC9, /**< The function 12 key */ + IME_KEY_F13 = 0xFFCA, /**< The function 13 key */ + IME_KEY_F14 = 0xFFCB, /**< The function 14 key */ + IME_KEY_F15 = 0xFFCC, /**< The function 15 key */ + IME_KEY_F16 = 0xFFCD, /**< The function 16 key */ + IME_KEY_F17 = 0xFFCE, /**< The function 17 key */ + IME_KEY_F18 = 0xFFCF, /**< The function 18 key */ + IME_KEY_F19 = 0xFFD0, /**< The function 19 key */ + IME_KEY_F20 = 0xFFD1, /**< The function 20 key */ + IME_KEY_F21 = 0xFFD2, /**< The function 21 key */ + IME_KEY_F22 = 0xFFD3, /**< The function 22 key */ + IME_KEY_F23 = 0xFFD4, /**< The function 23 key */ + IME_KEY_F24 = 0xFFD5, /**< The function 24 key */ + IME_KEY_F25 = 0xFFD6, /**< The function 25 key */ + IME_KEY_F26 = 0xFFD7, /**< The function 26 key */ + IME_KEY_F27 = 0xFFD8, /**< The function 27 key */ + IME_KEY_F28 = 0xFFD9, /**< The function 28 key */ + IME_KEY_F29 = 0xFFDA, /**< The function 29 key */ + IME_KEY_F30 = 0xFFDB, /**< The function 30 key */ + IME_KEY_F31 = 0xFFDC, /**< The function 31 key */ + IME_KEY_F32 = 0xFFDD, /**< The function 32 key */ + IME_KEY_F33 = 0xFFDE, /**< The function 33 key */ + IME_KEY_F34 = 0xFFDF, /**< The function 34 key */ + IME_KEY_F35 = 0xFFE0, /**< The function 35 key */ + + /* Modifier keys */ + IME_KEY_Shift_L = 0xFFE1, /**< The left shift key */ + IME_KEY_Shift_R = 0xFFE2, /**< The right shift key */ + IME_KEY_Control_L = 0xFFE3, /**< The left control key */ + IME_KEY_Control_R = 0xFFE4, /**< The right control key */ + IME_KEY_Caps_Lock = 0xFFE5, /**< The caps lock key */ + IME_KEY_Shift_Lock = 0xFFE6, /**< The shift lock key */ + + IME_KEY_Meta_L = 0xFFE7, /**< The left meta key */ + IME_KEY_Meta_R = 0xFFE8, /**< The right meta key */ + IME_KEY_Alt_L = 0xFFE9, /**< The left alt key */ + IME_KEY_Alt_R = 0xFFEA, /**< The right alt key */ + IME_KEY_Super_L = 0xFFEB, /**< The left super key */ + IME_KEY_Super_R = 0xFFEC, /**< The right super key */ + IME_KEY_Hyper_L = 0xFFED, /**< The left hyper key */ + IME_KEY_Hyper_R = 0xFFEE, /**< The right hyper key */ + + /* Latin 1 */ + IME_KEY_space = 0x020, /**< The space key */ + IME_KEY_exclam = 0x021, /**< The exclamation key */ + IME_KEY_quotedbl = 0x022, /**< The quotedbl key */ + IME_KEY_numbersign = 0x023, /**< The number sign key */ + IME_KEY_dollar = 0x024, /**< The dollar key */ + IME_KEY_percent = 0x025, /**< The percent key */ + IME_KEY_ampersand = 0x026, /**< The ampersand key */ + IME_KEY_apostrophe = 0x027, /**< The apostrophe key */ + IME_KEY_parenleft = 0x028, /**< The parenleft key */ + IME_KEY_parenright = 0x029, /**< The parenright key */ + IME_KEY_asterisk = 0x02a, /**< The asterisk key */ + IME_KEY_plus = 0x02b, /**< The plus key */ + IME_KEY_comma = 0x02c, /**< The comma key */ + IME_KEY_minus = 0x02d, /**< The minus key */ + IME_KEY_period = 0x02e, /**< The period key */ + IME_KEY_slash = 0x02f, /**< The slash key */ + IME_KEY_0 = 0x030, /**< The 0 key */ + IME_KEY_1 = 0x031, /**< The 1 key */ + IME_KEY_2 = 0x032, /**< The 2 key */ + IME_KEY_3 = 0x033, /**< The 3 key */ + IME_KEY_4 = 0x034, /**< The 4 key */ + IME_KEY_5 = 0x035, /**< The 5 key */ + IME_KEY_6 = 0x036, /**< The 6 key */ + IME_KEY_7 = 0x037, /**< The 7 key */ + IME_KEY_8 = 0x038, /**< The 8 key */ + IME_KEY_9 = 0x039, /**< The 9 key */ + IME_KEY_colon = 0x03a, /**< The colon key */ + IME_KEY_semicolon = 0x03b, /**< The semicolon key */ + IME_KEY_less = 0x03c, /**< The less key */ + IME_KEY_equal = 0x03d, /**< The equal key */ + IME_KEY_greater = 0x03e, /**< The greater key */ + IME_KEY_question = 0x03f, /**< The question key */ + IME_KEY_at = 0x040, /**< The at key */ + IME_KEY_A = 0x041, /**< The A key */ + IME_KEY_B = 0x042, /**< The B key */ + IME_KEY_C = 0x043, /**< The C key */ + IME_KEY_D = 0x044, /**< The D key */ + IME_KEY_E = 0x045, /**< The E key */ + IME_KEY_F = 0x046, /**< The F key */ + IME_KEY_G = 0x047, /**< The G key */ + IME_KEY_H = 0x048, /**< The H key */ + IME_KEY_I = 0x049, /**< The I key */ + IME_KEY_J = 0x04a, /**< The J key */ + IME_KEY_K = 0x04b, /**< The K key */ + IME_KEY_L = 0x04c, /**< The L key */ + IME_KEY_M = 0x04d, /**< The M key */ + IME_KEY_N = 0x04e, /**< The N key */ + IME_KEY_O = 0x04f, /**< The O key */ + IME_KEY_P = 0x050, /**< The P key */ + IME_KEY_Q = 0x051, /**< The Q key */ + IME_KEY_R = 0x052, /**< The R key */ + IME_KEY_S = 0x053, /**< The S key */ + IME_KEY_T = 0x054, /**< The T key */ + IME_KEY_U = 0x055, /**< The U key */ + IME_KEY_V = 0x056, /**< The V key */ + IME_KEY_W = 0x057, /**< The W key */ + IME_KEY_X = 0x058, /**< The X key */ + IME_KEY_Y = 0x059, /**< The Y key */ + IME_KEY_Z = 0x05a, /**< The Z key */ + IME_KEY_bracketleft = 0x05b, /**< The left bracket key */ + IME_KEY_backslash = 0x05c, /**< The backslash key */ + IME_KEY_bracketright = 0x05d, /**< The right bracket key */ + IME_KEY_asciicircum = 0x05e, /**< The circumflex key */ + IME_KEY_underscore = 0x05f, /**< The underscore key */ + IME_KEY_grave = 0x060, /**< The grave key */ + IME_KEY_a = 0x061, /**< The a key */ + IME_KEY_b = 0x062, /**< The b key */ + IME_KEY_c = 0x063, /**< The c key */ + IME_KEY_d = 0x064, /**< The d key */ + IME_KEY_e = 0x065, /**< The e key */ + IME_KEY_f = 0x066, /**< The f key */ + IME_KEY_g = 0x067, /**< The g key */ + IME_KEY_h = 0x068, /**< The h key */ + IME_KEY_i = 0x069, /**< The i key */ + IME_KEY_j = 0x06a, /**< The j key */ + IME_KEY_k = 0x06b, /**< The k key */ + IME_KEY_l = 0x06c, /**< The l key */ + IME_KEY_m = 0x06d, /**< The m key */ + IME_KEY_n = 0x06e, /**< The n key */ + IME_KEY_o = 0x06f, /**< The o key */ + IME_KEY_p = 0x070, /**< The p key */ + IME_KEY_q = 0x071, /**< The q key */ + IME_KEY_r = 0x072, /**< The r key */ + IME_KEY_s = 0x073, /**< The s key */ + IME_KEY_t = 0x074, /**< The t key */ + IME_KEY_u = 0x075, /**< The u key */ + IME_KEY_v = 0x076, /**< The v key */ + IME_KEY_w = 0x077, /**< The w key */ + IME_KEY_x = 0x078, /**< The x key */ + IME_KEY_y = 0x079, /**< The y key */ + IME_KEY_z = 0x07a, /**< The z key */ + IME_KEY_braceleft = 0x07b, /**< The left brace key */ + IME_KEY_bar = 0x07c, /**< The bar key */ + IME_KEY_braceright = 0x07d, /**< The right brace key */ + IME_KEY_asciitilde = 0x07e, /**< The tilde key */ +} ime_key_code_e; + + +/** + * @brief Enumeration for the key masks. + * The key masks indicate which modifier keys is pressed down during the keyboard hit. + * The special #IME_KEY_MASK_RELEASED indicates the key release event. + * @since_tizen @if MOBILE 2.4 @else 3.0 @endif + */ +typedef enum { + IME_KEY_MASK_PRESSED = 0, /**< Key press event without modifier key */ + IME_KEY_MASK_SHIFT = (1<<0), /**< The Shift key is pressed down */ + IME_KEY_MASK_CAPSLOCK = (1<<1), /**< The CapsLock key is pressed down */ + IME_KEY_MASK_CONTROL = (1<<2), /**< The Control key is pressed down */ + IME_KEY_MASK_ALT = (1<<3), /**< The Alt key is pressed down */ + IME_KEY_MASK_META = (1<<4), /**< The Meta key is pressed down */ + IME_KEY_MASK_WIN = (1<<5), /**< The Win (between Control and Alt) is pressed down */ + IME_KEY_MASK_HYPER = (1<<6), /**< The Hyper key is pressed down */ + IME_KEY_MASK_NUMLOCK = (1<<7), /**< The NumLock key is pressed down */ + IME_KEY_MASK_RELEASED = (1<<15) /**< Key release event */ +} ime_key_mask_e; + + +/** + * @} + */ + + +#endif /* __TIZEN_UIX_INPUTMETHOD_KEYDEF_H__ */ + diff --git a/inputmethod/include/inputmethod_private.h b/inputmethod/include/inputmethod_private.h new file mode 100644 index 0000000..b30bb44 --- /dev/null +++ b/inputmethod/include/inputmethod_private.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_UIX_INPUTMETHOD_PRIVATE_H__ +#define __TIZEN_UIX_INPUTMETHOD_PRIVATE_H__ + +struct _ime_context { + Ecore_IMF_Input_Panel_Layout layout; /**< Input panel (keyboard) layout types */ + int layout_variation; /**< Layout variation */ + int cursor_pos; /**< Cursor position in edit field */ + Ecore_IMF_Autocapital_Type autocapital_type; /**< Auto capital mode */ + Ecore_IMF_Input_Panel_Return_Key_Type return_key_type; /**< "Return" key types */ + Eina_Bool return_key_disabled; /**< The state of "Return" key */ + Eina_Bool prediction_allow; /**< Boolean to allow predictive text */ + Eina_Bool password_mode; /**< Password input mode of edit field */ + int imdata_size; /**< The size of application specific data to input panel */ + Ecore_IMF_Input_Hints input_hint; /**< Edit field hint */ + Ecore_IMF_BiDi_Direction bidi_direction;/**< Bidirectional mode */ + Ecore_IMF_Input_Panel_Lang language; /**< Preferred input language */ + unsigned int client_window; /**< Client application window object */ + Eina_Bool caps_mode; /**< Caps mode */ +}; + +struct _ime_device_info { + const char *dev_name; /**< The device name */ + Ecore_IMF_Device_Class dev_class; /**< The device class */ + Ecore_IMF_Device_Subclass dev_subclass; /**< The device subclass */ +}; + +#endif /* __TIZEN_UIX_INPUTMETHOD_PRIVATE_H__ */ + diff --git a/inputmethod/include/privilege_checker_private.h b/inputmethod/include/privilege_checker_private.h new file mode 100644 index 0000000..345affe --- /dev/null +++ b/inputmethod/include/privilege_checker_private.h @@ -0,0 +1,10 @@ +#ifndef __PRIVILEGE_CHECKER_H__ +#define __PRIVILEGE_CHECKER_H__ + +#define IME_PRIVILEGE "http://tizen.org/privilege/ime" + +bool inputmethod_cynara_initialize(void); +void inputmethod_cynara_finish(void); +bool check_privilege(const char *uid, const char *privilege); + +#endif /*__PRIVILEGE_CHECKER_H__ */ diff --git a/inputmethod/src/inputmethod.cpp b/inputmethod/src/inputmethod.cpp new file mode 100644 index 0000000..bf98918 --- /dev/null +++ b/inputmethod/src/inputmethod.cpp @@ -0,0 +1,2153 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "inputmethod_private.h" +#include +#include "inputmethod_internal.h" + +using namespace std; + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "INPUTMETHOD" + +using namespace scl; + +class CCoreEventCallback : public ISCLCoreEventCallback +{ + void on_init(); + void on_run(int argc, char **argv); + void on_exit(); + void on_update_cursor_position(sclint ic, const sclchar *ic_uuid, sclint cursor_pos); + void on_update_surrounding_text(sclint ic, const sclchar *text, sclint cursor); + void on_focus_out(sclint ic, const sclchar *ic_uuid); + void on_focus_in(sclint ic, const sclchar *ic_uuid); + void on_ise_show(sclint ic, const int degree, Ise_Context &context); + void on_ise_hide(sclint ic, const sclchar *ic_uuid); + void on_get_geometry(sclu32 *pos_x, sclu32 *pos_y, sclu32 *width, sclu32 *height); + void on_set_language(Ecore_IMF_Input_Panel_Lang language); + void on_set_imdata(sclchar *buf, sclu32 len); + void on_get_imdata(sclchar **buf, sclu32 *len); + void on_get_language_locale(sclint ic, sclchar **locale); + void on_set_return_key_type(Ecore_IMF_Input_Panel_Return_Key_Type type); + void on_set_return_key_disable(sclu32 disabled); + void on_set_layout(sclu32 layout); + void on_reset_input_context(sclint ic, const sclchar *uuid); + void on_process_key_event(scim::KeyEvent &key, sclu32 *ret); + void on_process_key_event_with_keycode(scim::KeyEvent &key, sclu32 *ret, sclu32 keycode); + void on_set_display_language(const sclchar *language); + void on_set_rotation_degree(sclint degree); + void on_set_accessibility_state(sclboolean state); + void on_create_option_window(sclwindow window, SCLOptionWindowType type); + void on_destroy_option_window(sclwindow window); + void on_check_option_window_availability(sclboolean *ret); + void on_set_caps_mode(sclu32 mode); + void on_candidate_show(sclint ic, const sclchar *ic_uuid); + 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); + 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); +}; + +typedef struct +{ + ime_focus_in_cb focus_in; /**< Called when an edit field has focus */ + ime_focus_out_cb focus_out; /**< Called when an edit field loses focus */ + ime_surrounding_text_updated_cb surrounding_text_updated; /**< Called when an edit field responds to a request with the surrounding text */ + ime_input_context_reset_cb input_context_reset; /**< Called to reset the input context of an edit field */ + ime_cursor_position_updated_cb cursor_position_updated; /**< Called when the position of the cursor in an edit field changes */ + ime_language_requested_cb language_requested; /**< Called when an edit field requests the language from the input panel */ + ime_language_set_cb language_set; /**< Called to set the preferred language to the input panel */ + ime_imdata_set_cb imdata_set; /**< Called to set the application specific data to deliver to the input panel */ + ime_imdata_requested_cb imdata_requested; /**< Called when an associated text input UI control requests the application specific data from the input panel */ + ime_layout_set_cb layout_set; /**< Called when an edit field requests the input panel to set its layout */ + ime_return_key_type_set_cb return_key_type_set; /**< Called when an edit field requests the input panel to set the "return" key label */ + ime_return_key_state_set_cb return_key_state_set; /**< Called when an edit field requests the input panel to enable or disable the "return" key state */ + ime_geometry_requested_cb geometry_requested; /**< Called when an edit field requests the position and size from the input panel */ + ime_process_key_event_cb process_key_event; /**< Called when the key event is received from the external keyboard devices */ + ime_process_key_event_with_keycode_cb process_key_event_with_keycode; /**< Called when the key event is received from the external keyboard devices */ + ime_display_language_changed_cb display_language_changed; /**< Called when the system display language is changed */ + ime_rotation_degree_changed_cb rotation_degree_changed; /**< Called when the device is rotated */ + ime_accessibility_state_changed_cb accessibility_state_changed; /**< Called when Accessibility in Settings application is on or off */ + ime_option_window_created_cb option_window_created; /**< Called to create the option window */ + ime_option_window_destroyed_cb option_window_destroyed; /**< Called to destroy the option window */ + ime_caps_mode_changed_cb caps_mode_changed; + ime_candidate_show_cb candidate_show; + 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; + 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; + void *focus_in_user_data; + void *focus_out_user_data; + void *surrounding_text_updated_user_data; + void *input_context_reset_user_data; + void *cursor_position_updated_user_data; + void *language_requested_user_data; + void *language_set_user_data; + void *imdata_set_user_data; + void *imdata_requested_user_data; + void *layout_set_user_data; + void *return_key_type_set_user_data; + void *return_key_state_set_user_data; + void *geometry_requested_user_data; + void *process_key_event_user_data; + void *process_key_event_with_keycode_user_data; + void *display_language_changed_user_data; + void *rotation_degree_changed_user_data; + void *accessibility_state_changed_user_data; + void *option_window_created_user_data; + void *option_window_destroyed_user_data; + void *caps_mode_changed_user_data; + void *candidate_show_user_data; + void *candidate_hide_user_data; + 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; + void *prediction_hint_data_set_user_data; + void *optimization_hint_set_user_data; +} ime_event_callback_s; + +typedef struct { + ime_input_device_type_e device_type; + void *event_data; +} ime_device_event_s; + +static ime_callback_s g_basic_callback = {NULL}; +static ime_event_callback_s g_event_callback = {NULL}; +static void *g_user_data = NULL; +static bool g_running = false; + +static CCoreEventCallback g_core_event_callback; +CSCLCore g_core(&g_core_event_callback); + +extern "C" { + extern void ime_app_main(int argc, char **argv); +} + +//LCOV_EXCL_START +void CCoreEventCallback::on_init() +{ + if (g_basic_callback.create) { + g_basic_callback.create(g_user_data); + } +} + +void CCoreEventCallback::on_run(int argc, char **argv) +{ + LOGD("on_run"); + ime_app_main(argc, argv); +} + +void CCoreEventCallback::on_exit() +{ + LOGD("on_exit"); + if (g_basic_callback.terminate) { + g_basic_callback.terminate(g_user_data); + } +} + +void CCoreEventCallback::on_update_cursor_position(sclint ic, const sclchar *ic_uuid, sclint cursor_pos) +{ + if (g_event_callback.cursor_position_updated) { + g_event_callback.cursor_position_updated(cursor_pos, g_event_callback.cursor_position_updated_user_data); + } +} + +void CCoreEventCallback::on_update_surrounding_text(sclint ic, const sclchar *text, sclint cursor) +{ + if (g_event_callback.surrounding_text_updated) { + g_event_callback.surrounding_text_updated(ic, text, cursor, g_event_callback.surrounding_text_updated_user_data); + } +} + +void CCoreEventCallback::on_focus_out(sclint ic, const sclchar *ic_uuid) +{ + if (g_event_callback.focus_out) { + g_event_callback.focus_out(ic, g_event_callback.focus_out_user_data); + } +} + +void CCoreEventCallback::on_focus_in(sclint ic, const sclchar *ic_uuid) +{ + if (g_event_callback.focus_in) { + g_event_callback.focus_in(ic, g_event_callback.focus_in_user_data); + } +} + +void CCoreEventCallback::on_ise_show(sclint ic, const int degree, Ise_Context &context) +{ + if (g_basic_callback.show) { + struct _ime_context input_context; + + memset(&input_context, 0, sizeof(struct _ime_context)); + input_context.layout = context.layout; + input_context.layout_variation = context.layout_variation; + input_context.cursor_pos = context.cursor_pos; + input_context.autocapital_type = context.autocapital_type; + input_context.return_key_type = context.return_key_type; + input_context.return_key_disabled = context.return_key_disabled; + input_context.prediction_allow = context.prediction_allow; + input_context.password_mode = context.password_mode; + input_context.imdata_size = context.imdata_size; + input_context.input_hint = context.input_hint; + input_context.bidi_direction = context.bidi_direction; + input_context.language = context.language; + input_context.client_window = context.client_window; + input_context.caps_mode = context.caps_mode; + + g_basic_callback.show(ic, static_cast(&input_context), g_user_data); + } +} + +void CCoreEventCallback::on_ise_hide(sclint ic, const sclchar *ic_uuid) +{ + if (g_basic_callback.hide) { + g_basic_callback.hide(ic, g_user_data); + } +} + +void CCoreEventCallback::on_get_geometry(sclu32 *pos_x, sclu32 *pos_y, sclu32 *width, sclu32 *height) +{ + int geometry_pos_x = 0; + int geometry_pos_y = 0; + int geometry_width = 0; + int geometry_height = 0; + + if (g_event_callback.geometry_requested) { + g_event_callback.geometry_requested(g_event_callback.geometry_requested_user_data, &geometry_pos_x, &geometry_pos_y, &geometry_width, &geometry_height); + } + + if (pos_x) + *pos_x = geometry_pos_x; + + if (pos_y) + *pos_y = geometry_pos_y; + + if (width) + *width = geometry_width; + + if (height) + *height = geometry_height; +} + +void CCoreEventCallback::on_set_language(Ecore_IMF_Input_Panel_Lang language) +{ + if (g_event_callback.language_set) { + g_event_callback.language_set(language, g_event_callback.language_set_user_data); + } +} + +void CCoreEventCallback::on_set_imdata(sclchar *buf, sclu32 len) +{ + if (g_event_callback.imdata_set) { + g_event_callback.imdata_set((void *)buf, len, g_event_callback.imdata_set_user_data); + } +} + +void CCoreEventCallback::on_get_imdata(sclchar **buf, sclu32 *len) +{ + if (g_event_callback.imdata_requested) { + g_event_callback.imdata_requested(g_event_callback.imdata_set_user_data, (void **)buf, len); + } +} + +void CCoreEventCallback::on_get_language_locale(sclint ic, sclchar **locale) +{ + if (g_event_callback.language_requested) { + g_event_callback.language_requested(g_event_callback.language_requested_user_data, locale); + } +} + +void CCoreEventCallback::on_set_return_key_type(Ecore_IMF_Input_Panel_Return_Key_Type type) +{ + if (g_event_callback.return_key_type_set) { + g_event_callback.return_key_type_set(type, g_event_callback.return_key_type_set_user_data); + } +} + +void CCoreEventCallback::on_set_return_key_disable(sclu32 disabled) +{ + bool return_key_disabled = !!disabled; + + if (g_event_callback.return_key_state_set) { + g_event_callback.return_key_state_set(return_key_disabled, g_event_callback.return_key_state_set_user_data); + } +} + +void CCoreEventCallback::on_set_layout(sclu32 layout) +{ + if (g_event_callback.layout_set) { + g_event_callback.layout_set(static_cast(layout), g_event_callback.layout_set_user_data); + } +} + +void CCoreEventCallback::on_reset_input_context(sclint ic, const sclchar *uuid) +{ + if (g_event_callback.input_context_reset) { + g_event_callback.input_context_reset(g_event_callback.input_context_reset_user_data); + } +} + +void CCoreEventCallback::on_process_key_event(scim::KeyEvent &key, sclu32 *ret) +{ + if (g_event_callback.process_key_event) { + struct _ime_device_info dev_info = {key.dev_name.c_str(), + static_cast(key.dev_class), static_cast(key.dev_subclass)}; + bool processed = g_event_callback.process_key_event(static_cast(key.code), static_cast(key.mask), + static_cast(&dev_info), g_event_callback.process_key_event_user_data); + + if (ret) { + if (processed) + *ret = 1; + else + *ret = 0; + } + } else { + if (ret) { + *ret = 0; + } + } +} + +void CCoreEventCallback::on_process_key_event_with_keycode(scim::KeyEvent &key, sclu32 *ret, sclu32 keycode) +{ + if (g_event_callback.process_key_event_with_keycode) { + struct _ime_device_info dev_info = {key.dev_name.c_str(), + static_cast(key.dev_class), static_cast(key.dev_subclass)}; + bool processed = g_event_callback.process_key_event_with_keycode(keycode, static_cast(key.code), static_cast(key.mask), + static_cast(&dev_info), g_event_callback.process_key_event_user_data); + + if (ret) { + if (processed) + *ret = 1; + else + *ret = 0; + } + } else { + if (ret) { + *ret = 0; + } + } +} + +void CCoreEventCallback::on_set_display_language(const sclchar *language) +{ + if (g_event_callback.display_language_changed) { + g_event_callback.display_language_changed(language, g_event_callback.display_language_changed_user_data); + } +} + +void CCoreEventCallback::on_set_rotation_degree(sclint degree) +{ + if (g_event_callback.rotation_degree_changed) { + g_event_callback.rotation_degree_changed(degree, g_event_callback.rotation_degree_changed_user_data); + } +} + +void CCoreEventCallback::on_set_accessibility_state(sclboolean state) +{ + if (g_event_callback.accessibility_state_changed) { + g_event_callback.accessibility_state_changed(state, g_event_callback.accessibility_state_changed_user_data); + } +} + +void CCoreEventCallback::on_create_option_window(sclwindow window, SCLOptionWindowType type) +{ + if (g_event_callback.option_window_created) { + g_event_callback.option_window_created(static_cast(window), static_cast(type), g_event_callback.option_window_created_user_data); + } +} + +void CCoreEventCallback::on_destroy_option_window(sclwindow window) +{ + if (g_event_callback.option_window_destroyed) { + g_event_callback.option_window_destroyed(static_cast(window), g_event_callback.option_window_destroyed_user_data); + } +} + +void CCoreEventCallback::on_check_option_window_availability(sclboolean *ret) +{ + if (ret) { + if (g_event_callback.option_window_created) // Instead of each 3rd party keyboard, inputmethod will reply the availability of the option (setting). + *ret = true; + else + *ret = false; + } +} + +void CCoreEventCallback::on_set_caps_mode(sclu32 mode) +{ + if (g_event_callback.caps_mode_changed) { + g_event_callback.caps_mode_changed(mode, g_event_callback.caps_mode_changed_user_data); + } +} + +void CCoreEventCallback::on_candidate_show(sclint ic, const sclchar *ic_uuid) +{ + if (g_event_callback.candidate_show) { + g_event_callback.candidate_show(ic, g_event_callback.candidate_show_user_data); + } +} + +void CCoreEventCallback::on_candidate_hide(sclint ic, const sclchar *ic_uuid) +{ + if (g_event_callback.candidate_hide) { + g_event_callback.candidate_hide(ic, g_event_callback.candidate_hide_user_data); + } +} + +void CCoreEventCallback::on_update_lookup_table(SclCandidateTable &table) +{ + Eina_List *string_list = NULL; + + if (g_event_callback.lookup_table_changed) { + vector::iterator iter = table.candidate.begin(); + for (; iter != table.candidate.end(); ++iter) { + string_list = eina_list_append(string_list, iter->c_str()); + } + + g_event_callback.lookup_table_changed(string_list, g_event_callback.lookup_table_changed_user_data); + } +} + +void CCoreEventCallback::on_process_input_device_event(sclu32 &type, sclchar *data, size_t &len, sclu32 *ret) +{ + typedef struct { + int ecore_event_id; + ime_input_device_type_e device_type; + } ime_device_type_conv_table; + + ime_device_type_conv_table conv_table[] = { + { ECORE_EVENT_DETENT_ROTATE , IME_INPUT_DEVICE_TYPE_ROTARY }, + }; + + ime_input_device_type_e device_type = IME_INPUT_DEVICE_TYPE_UNKNOWN; + for (unsigned int loop = 0; loop < sizeof(conv_table) / sizeof(ime_device_type_conv_table); loop++) { + if ((unsigned int)(conv_table[loop].ecore_event_id) == type) { + device_type = conv_table[loop].device_type; + } + } + + if (g_event_callback.process_input_device_event) { + ime_device_event_s device_event; + device_event.device_type = device_type; + device_event.event_data = static_cast(data); + void *input_data = static_cast(&device_event); + void *user_data = g_event_callback.process_input_device_event_user_data; + + g_event_callback.process_input_device_event(device_type, input_data, user_data); + + if (ret) { + *ret = 1; + } + } else { + if (ret) { + *ret = 0; + } + } +} + +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); + } +} + +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); + } +} + +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); + } +} + +void CCoreEventCallback::on_set_optimization_hint(sclu32 hint) +{ + if (g_event_callback.optimization_hint_set) { + g_event_callback.optimization_hint_set((ime_optimization_hint_e)hint, g_event_callback.optimization_hint_set_user_data); + } +} +//LCOV_EXCL_STOP + +ime_error_e _check_privilege() +{ + char uid[16]; + ime_error_e ret = IME_ERROR_NONE; + + if (inputmethod_cynara_initialize() == false) { + LOGE("inputmethod_cynara_initialize () == false"); + return IME_ERROR_PERMISSION_DENIED; + } + + snprintf(uid, 16, "%d", getuid()); + if (check_privilege(uid, IME_PRIVILEGE) == false) { + LOGE("check_privilege(uid, IME_PRIVILEGE) == false. uid : %s", uid); + ret = IME_ERROR_PERMISSION_DENIED; + } + + inputmethod_cynara_finish(); + + return ret; +} + +//LCOV_EXCL_START +bool g_from_dotnet = false; +EXPORT_API int ime_set_dotnet_flag(bool set) +{ + ime_error_e retVal = IME_ERROR_NONE; + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_from_dotnet = set; + + return retVal; +} +//LCOV_EXCL_STOP + +EXPORT_API int ime_run(ime_callback_s *basic_cb, void *user_data) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (g_running) { + LOGE("inputmethod main loop is already running."); + return IME_ERROR_OPERATION_FAILED; + } + + if (!basic_cb) { + LOGE("basic callbacks pointer is null."); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_basic_callback = *basic_cb; + + if (!g_basic_callback.create || !g_basic_callback.terminate || + !g_basic_callback.show || !g_basic_callback.hide) { + LOGE("mandatory callback funtions are not set"); + memset(&g_basic_callback, 0, sizeof(ime_callback_s)); + memset(&g_event_callback, 0, sizeof(ime_event_callback_s)); + return IME_ERROR_NO_CALLBACK_FUNCTION; + } + + g_user_data = user_data; + g_running = true; + + if (g_from_dotnet) { + LOGD("ime_run is called from dotnet"); + return IME_ERROR_NONE; + } + + try { + g_core.run(); + } catch (...) { + LOGW("exception is thrown from g_core.run()\n"); + } + + memset(&g_basic_callback, 0, sizeof(ime_callback_s)); + memset(&g_event_callback, 0, sizeof(ime_event_callback_s)); + g_user_data = NULL; + g_running = false; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_focus_in_cb(ime_focus_in_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.focus_in = callback_func; + g_event_callback.focus_in_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_focus_out_cb(ime_focus_out_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.focus_out = callback_func; + g_event_callback.focus_out_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_surrounding_text_updated_cb(ime_surrounding_text_updated_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.surrounding_text_updated = callback_func; + g_event_callback.surrounding_text_updated_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_input_context_reset_cb(ime_input_context_reset_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.input_context_reset = callback_func; + g_event_callback.input_context_reset_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_cursor_position_updated_cb(ime_cursor_position_updated_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.cursor_position_updated = callback_func; + g_event_callback.cursor_position_updated_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_language_requested_cb(ime_language_requested_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.language_requested = callback_func; + g_event_callback.language_requested_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_language_set_cb(ime_language_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.language_set = callback_func; + g_event_callback.language_set_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_imdata_set_cb(ime_imdata_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.imdata_set = callback_func; + g_event_callback.imdata_set_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_imdata_requested_cb(ime_imdata_requested_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.imdata_requested = callback_func; + g_event_callback.imdata_requested_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_layout_set_cb(ime_layout_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.layout_set = callback_func; + g_event_callback.layout_set_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_return_key_type_set_cb(ime_return_key_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) return retVal; + + g_event_callback.return_key_type_set = callback_func; + g_event_callback.return_key_type_set_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_return_key_state_set_cb(ime_return_key_state_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.return_key_state_set = callback_func; + g_event_callback.return_key_state_set_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_geometry_requested_cb(ime_geometry_requested_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.geometry_requested = callback_func; + g_event_callback.geometry_requested_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_process_key_event_cb(ime_process_key_event_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.process_key_event = callback_func; + g_event_callback.process_key_event_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_process_key_event_with_keycode_cb(ime_process_key_event_with_keycode_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.process_key_event_with_keycode = callback_func; + g_event_callback.process_key_event_with_keycode_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_display_language_changed_cb(ime_display_language_changed_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.display_language_changed = callback_func; + g_event_callback.display_language_changed_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_rotation_degree_changed_cb(ime_rotation_degree_changed_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.rotation_degree_changed = callback_func; + g_event_callback.rotation_degree_changed_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_accessibility_state_changed_cb(ime_accessibility_state_changed_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.accessibility_state_changed = callback_func; + g_event_callback.accessibility_state_changed_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_option_window_created_cb(ime_option_window_created_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.option_window_created = callback_func; + g_event_callback.option_window_created_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_option_window_destroyed_cb(ime_option_window_destroyed_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.option_window_destroyed = callback_func; + g_event_callback.option_window_destroyed_user_data = user_data; + + return IME_ERROR_NONE; +} + +//LCOV_EXCL_START +EXPORT_API int ime_event_set_caps_mode_changed_cb(ime_caps_mode_changed_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.caps_mode_changed = callback_func; + g_event_callback.caps_mode_changed_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_candidate_show_cb(ime_candidate_show_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.candidate_show = callback_func; + g_event_callback.candidate_show_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_candidate_hide_cb(ime_candidate_hide_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.candidate_hide = callback_func; + g_event_callback.candidate_hide_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_lookup_table_changed_cb(ime_lookup_table_changed_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.lookup_table_changed = callback_func; + g_event_callback.lookup_table_changed_user_data = user_data; + + return IME_ERROR_NONE; +} +//LCOV_EXCL_STOP + +EXPORT_API int ime_send_key_event(ime_key_code_e keycode, ime_key_mask_e keymask, bool forward_key) +{ + 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; + + if (forward_key) + g_core.forward_key_event(-1, NULL, (sclu32)keycode, (sclu16)keymask); + else + g_core.send_key_event(-1, NULL, (sclu32)keycode, (sclu16)keymask); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_commit_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.commit_string(-1, NULL, str); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_show_preedit_string(void) +{ + 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.show_preedit_string(-1, NULL); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_hide_preedit_string(void) +{ + 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.hide_preedit_string(-1, NULL); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_update_preedit_string(const char *str, Eina_List *attrs) +{ + 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; + + scim::AttributeList attrv; + void *data = NULL; + ime_preedit_attribute *attr = NULL; + + if (attrs) { + EINA_LIST_FREE(attrs, data) { + attr = (ime_preedit_attribute *)data; + if (attr) { + attrv.push_back(scim::Attribute(attr->start, attr->length, (scim::AttributeType)attr->type, attr->value)); + free(attr); + } + } + } + + g_core.update_preedit_string(-1, NULL, str, attrv); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_request_surrounding_text(int maxlen_before, int maxlen_after) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!g_event_callback.surrounding_text_updated) { + LOGW("IME_ERROR_NO_CALLBACK_FUNCTION"); + return IME_ERROR_NO_CALLBACK_FUNCTION; + } + + 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.get_surrounding_text(NULL, maxlen_before, maxlen_after); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_delete_surrounding_text(int offset, int len) +{ + 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.delete_surrounding_text(offset, len); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_get_surrounding_text(int maxlen_before, int maxlen_after, char **text, int *cursor_pos) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!text || !cursor_pos) { + 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; + + int cursor = 0; + + int ret = g_core.get_surrounding_text(maxlen_before, maxlen_after, text, cursor); + if (ret == -1) { + LOGW("IME_ERROR_OUR_OF_MEMORY"); + return IME_ERROR_OUT_OF_MEMORY; + } + + if (cursor_pos) + *cursor_pos = cursor; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_set_selection(int start, int end) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (start < 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_selection(start, end); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_get_selected_text(char **text) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!text) { + 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.get_selection_text(text); + + return IME_ERROR_NONE; +} + +EXPORT_API Evas_Object* ime_get_main_window(void) +{ + ime_error_e retVal = IME_ERROR_NONE; + + Evas_Object *win = NULL; + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) { + LOGE("_check_privilege returned %d.", retVal); + set_last_result(retVal); + return NULL; + } + + if (!g_running) { + set_last_result(IME_ERROR_NOT_RUNNING); + LOGW("IME_ERROR_NOT_RUNNING"); + return NULL; + } + + win = static_cast(g_core.get_main_window()); + if (win) { + set_last_result(IME_ERROR_NONE); + } else { + set_last_result(IME_ERROR_OPERATION_FAILED); + LOGW("IME_ERROR_OPERATION_FAILED"); + } + + return win; +} + +EXPORT_API int ime_set_size(int portrait_width, int portrait_height, int landscape_width, int landscape_height) +{ + ime_error_e retVal = IME_ERROR_NONE; + + SclSize portrait_size, landscape_size; + + if (portrait_width < 1 || portrait_height < 1 || landscape_width < 1 || landscape_height < 1) { + 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; + + portrait_size.width = portrait_width; + portrait_size.height = portrait_height; + + landscape_size.width = landscape_width; + landscape_size.height = landscape_height; + + g_core.set_keyboard_size_hints(portrait_size, landscape_size); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_create_option_window(void) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!g_event_callback.option_window_created || !g_event_callback.option_window_destroyed) { + LOGW("ime_create_option_window_cb() and ime_destroy_option_window_cb() callback functions are not set."); + return IME_ERROR_NO_CALLBACK_FUNCTION; + } + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (g_core.create_option_window()) { + return IME_ERROR_NONE; + } else { + LOGW("IME_ERROR_OPERATION_FAILED"); + return IME_ERROR_OPERATION_FAILED; + } +} + +EXPORT_API int ime_destroy_option_window(Evas_Object *window) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!g_event_callback.option_window_created || !g_event_callback.option_window_destroyed) { + LOGW("ime_create_option_window_cb() and ime_destroy_option_window_cb() callback functions are not set."); + return IME_ERROR_NO_CALLBACK_FUNCTION; + } + + if (!window) { + LOGW("Window pointer is null."); + 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.destroy_option_window(window); + + return IME_ERROR_NONE; +} + +//LCOV_EXCL_START +EXPORT_API int ime_set_imengine(const char *engine_id) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!engine_id) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_core.set_keyboard_ise_by_uuid(engine_id); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_flush_imengine(void) +{ + 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.flush_keyboard_ise(); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_reset_imengine(void) +{ + 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.reset_keyboard_ise(); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_update_input_context(unsigned int type, unsigned int value) +{ + 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_input_context(type, value); + + return IME_ERROR_NONE; +} +//LCOV_EXCL_STOP + +EXPORT_API int ime_request_hide(void) +{ + 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.request_ise_hide(); + + return IME_ERROR_NONE; +} + +//LCOV_EXCL_START +EXPORT_API int ime_initialize(void) +{ + ime_error_e retVal = IME_ERROR_NONE; + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_core.init(); + g_running = false; + + return retVal; +} + +EXPORT_API int ime_prepare(void) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (g_running) { + LOGE("inputmethod main loop is already running."); + return IME_ERROR_OPERATION_FAILED; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_core.prepare(); + + g_running = true; + + return retVal; +} + +EXPORT_API int ime_finalize(void) +{ + ime_error_e retVal = IME_ERROR_NONE; + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_core.fini(); + g_running = false; + memset(&g_basic_callback, 0, sizeof(ime_callback_s)); + memset(&g_event_callback, 0, sizeof(ime_event_callback_s)); + g_user_data = NULL; + + return retVal; +} + +EXPORT_API int ime_select_candidate(unsigned int index) +{ + 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.select_candidate(index); + + return IME_ERROR_NONE; +} +//LCOV_EXCL_STOP + +EXPORT_API int ime_send_private_command(const char *command) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!command) { + 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.send_private_command(command); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_commit_content(const char *content, const char *description, const char *mime_type) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!content || !description || !mime_type) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + 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.commit_content(content, description, mime_type); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_context_get_layout(ime_context_h context, Ecore_IMF_Input_Panel_Layout *layout) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!context || !layout) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + *layout = context->layout; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_context_get_layout_variation(ime_context_h context, ime_layout_variation_e *layout_variation) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!context || !layout_variation) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + *layout_variation = static_cast(context->layout_variation); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_context_get_cursor_position(ime_context_h context, int *cursor_pos) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!context || !cursor_pos) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + *cursor_pos = context->cursor_pos; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_context_get_autocapital_type(ime_context_h context, Ecore_IMF_Autocapital_Type *autocapital_type) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!context || !autocapital_type) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + *autocapital_type = context->autocapital_type; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_context_get_return_key_type(ime_context_h context, Ecore_IMF_Input_Panel_Return_Key_Type *return_key_type) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!context || !return_key_type) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + *return_key_type = context->return_key_type; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_context_get_return_key_state(ime_context_h context, bool *return_key_state) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!context || !return_key_state) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + *return_key_state = static_cast(context->return_key_disabled); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_context_get_prediction_mode(ime_context_h context, bool *prediction_mode) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!context || !prediction_mode) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + *prediction_mode = static_cast(context->prediction_allow); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_context_get_password_mode(ime_context_h context, bool *password_mode) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!context || !password_mode) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + *password_mode = static_cast(context->password_mode); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_context_get_input_hint(ime_context_h context, Ecore_IMF_Input_Hints *input_hint) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!context || !input_hint) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + *input_hint = context->input_hint; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_context_get_bidi_direction(ime_context_h context, Ecore_IMF_BiDi_Direction *bidi) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!context || !bidi) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + *bidi = context->bidi_direction; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_context_get_language(ime_context_h context, Ecore_IMF_Input_Panel_Lang *language) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!context || !language) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + *language = context->language; + + return IME_ERROR_NONE; +} + +//LCOV_EXCL_START +EXPORT_API int ime_context_get_caps_mode(ime_context_h context, bool *caps_mode) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!context || !caps_mode) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + *caps_mode = static_cast(context->caps_mode); + + return IME_ERROR_NONE; +} +//LCOV_EXCL_STOP + +EXPORT_API int ime_device_info_get_name(ime_device_info_h dev_info, char **dev_name) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!dev_info || !dev_name) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + if (!dev_info->dev_name) + *dev_name = strdup(""); + else + *dev_name = strdup(dev_info->dev_name); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_device_info_get_class(ime_device_info_h dev_info, Ecore_IMF_Device_Class *dev_class) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!dev_info || !dev_class) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + *dev_class = dev_info->dev_class; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_device_info_get_subclass(ime_device_info_h dev_info, Ecore_IMF_Device_Subclass *dev_subclass) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!dev_info || !dev_subclass) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + *dev_subclass = dev_info->dev_subclass; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_process_input_device_event_cb(ime_process_input_device_event_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.process_input_device_event = callback_func; + g_event_callback.process_input_device_event_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_unset_process_input_device_event_cb(void) +{ + ime_error_e retVal = IME_ERROR_NONE; + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.process_input_device_event = NULL; + g_event_callback.process_input_device_event_user_data = NULL; + + return IME_ERROR_NONE; +} + +/* Functions for Rotary input device event */ +EXPORT_API int ime_input_device_rotary_get_direction(ime_input_device_event_h event_handle, ime_input_device_rotary_direction_e *direction) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (!event_handle || !direction) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + ime_device_event_s *device_event = static_cast(event_handle); + if (device_event->device_type != IME_INPUT_DEVICE_TYPE_ROTARY) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + if (!g_running) { + LOGW("IME_ERROR_OPERATION_FAILED"); + return IME_ERROR_OPERATION_FAILED; + } + + Ecore_Event_Detent_Rotate *rotary_device_event = + static_cast(device_event->event_data); + if (rotary_device_event) { + if (rotary_device_event->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) { + *direction = IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE; + } else if (rotary_device_event->direction == ECORE_DETENT_DIRECTION_COUNTER_CLOCKWISE) { + *direction = IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE; + } + } + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_prediction_hint_set_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) return retVal; + + g_event_callback.prediction_hint_set = callback_func; + g_event_callback.prediction_hint_set_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_set_mime_type_set_request_cb(ime_mime_type_set_request_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.mime_type_set = callback_func; + g_event_callback.mime_type_set_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_set_floating_mode(bool floating_mode) +{ + 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.set_floating_mode(floating_mode); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_set_floating_drag_start(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.set_floating_drag_enabled(true); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_set_floating_drag_end(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.set_floating_drag_enabled(false); + + return IME_ERROR_NONE; +} + +//LCOV_EXCL_START +EXPORT_API int ime_set_window_creation_defer_flag(bool flag) +{ + ime_error_e retVal = IME_ERROR_NONE; + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_core.set_window_creation_defer_flag(flag); + + return IME_ERROR_NONE; +} +//LCOV_EXCL_STOP + +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; +} + +//LCOV_EXCL_START +EXPORT_API int ime_event_set_optimization_hint_set_cb(ime_optimization_hint_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; + } + + LOGD(""); + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + LOGD(""); + g_event_callback.optimization_hint_set = callback_func; + g_event_callback.optimization_hint_set_user_data = user_data; + + return IME_ERROR_NONE; +} +//LCOV_EXCL_STOP + +EXPORT_API int ime_update_input_panel_event(ime_event_type_e type, unsigned int value) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (type < IME_EVENT_TYPE_LANGUAGE || type > IME_EVENT_TYPE_GEOMETRY) { + 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_input_context((sclu32)type, value); + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_set_candidate_visibility_state(bool visible) +{ + 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; + + if (visible) + g_core.show_candidate_string(); + else + g_core.hide_candidate_string(); + + return IME_ERROR_NONE; +} diff --git a/inputmethod/src/privilege_checker.cpp b/inputmethod/src/privilege_checker.cpp new file mode 100644 index 0000000..ba71cfc --- /dev/null +++ b/inputmethod/src/privilege_checker.cpp @@ -0,0 +1,75 @@ +#include "privilege_checker_private.h" + +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "INPUTMETHOD" + +namespace +{ + +cynara *p_cynara = NULL; + +} + +bool +inputmethod_cynara_initialize(void) +{ + int ret = cynara_initialize(&p_cynara, NULL); + if (ret != CYNARA_API_SUCCESS) + LOGW("Failed to call cynara_initialize (). ret : %d.", ret); + + return ret == CYNARA_API_SUCCESS; +} + +void +inputmethod_cynara_finish(void) +{ + if (p_cynara) + cynara_finish(p_cynara); + + p_cynara = NULL; +} + +bool +check_privilege(const char *uid, const char *privilege) +{ + FILE *fp = NULL; + char label_path[1024] = "/proc/self/attr/current"; + char smack_label[1024] = {'\0', }; + + if (!p_cynara) { + return false; + } + + fp = fopen(label_path, "r"); + if (fp != NULL) { + if (fread(smack_label, 1, sizeof(smack_label) - 1, fp) <= 0) + LOGW("Error : fread"); + + fclose(fp); + } + + pid_t pid = getpid(); + char *session = cynara_session_from_pid(pid); + int ret = cynara_check(p_cynara, smack_label, session, uid, privilege); + if (session) + free(session); + + if (ret != CYNARA_API_ACCESS_ALLOWED) { + LOGW("Access denied. The result of cynara_check() : %d.", ret); + return false; + } + return true; +} + diff --git a/packaging/capi-ui-inputmethod.spec b/packaging/capi-ui-inputmethod.spec index b0afb60..ce10fe1 100644 --- a/packaging/capi-ui-inputmethod.spec +++ b/packaging/capi-ui-inputmethod.spec @@ -21,7 +21,6 @@ Requires(postun): /sbin/ldconfig %description Input Method Library - %package devel Summary: Input Method Library (Development) Group: Development/Libraries @@ -30,6 +29,22 @@ Requires: %{name} = %{version}-%{release} %description devel Input Method Library (Development) +%package -n capi-ui-remote-input +Summary: Remote Input Library +Group: Graphics & UI Framework/Input +Requires: %{name} = %{version}-%{release} + +%description -n capi-ui-remote-input +Remote Input Library + +%package -n capi-ui-remote-input-devel +Summary: Remote Input Library (Development) +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description -n capi-ui-remote-input-devel +Remote Input Library (Development) + %if 0%{?gcov:1} %package gcov Summary: Input Method (gcov) @@ -89,9 +104,19 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj %files devel %{_includedir}/inputmethod*.h -%{_libdir}/pkgconfig/*.pc +%{_libdir}/pkgconfig/capi-ui-inputmethod.pc %{_libdir}/libcapi-ui-inputmethod.so +%files -n capi-ui-remote-input +%manifest capi-ui-inputmethod.manifest +%{_libdir}/libcapi-ui-remote-input.so.* +%license LICENSE + +%files -n capi-ui-remote-input-devel +%{_includedir}/remote_input*.h +%{_libdir}/pkgconfig/capi-ui-remote-input.pc +%{_libdir}/libcapi-ui-remote-input.so + %if 0%{?gcov:1} %files gcov %{_datadir}/gcov/obj/* diff --git a/remote_input/include/remote_input.h b/remote_input/include/remote_input.h new file mode 100644 index 0000000..98eb12c --- /dev/null +++ b/remote_input/include/remote_input.h @@ -0,0 +1,492 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_UIX_REMOTE_INPUT_H__ +#define __TIZEN_UIX_REMOTE_INPUT_H__ + + +/** + * @file remote_input.h + * @brief This file contains remote input APIs and related enumeration. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_UIX_INPUTMETHOD_MODULE + * @{ + */ + + +/** + * @platform + * @brief Enumeration for remote input function error. + * @since_tizen 5.5 + */ +typedef enum { + REMOTE_INPUT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + REMOTE_INPUT_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + REMOTE_INPUT_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + REMOTE_INPUT_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of Memory */ + REMOTE_INPUT_OPERATION_FAILED, /**< Operation failed */ +} remote_input_error_e; + +/** + * @platform + * @brief Enumeration for key types. + * @since_tizen 5.5 + * @see remote_input_send_key_event() + */ +typedef enum { + REMOTE_INPUT_KEY_ENTER = 0, /**< Enter key */ + REMOTE_INPUT_KEY_SPACE, /**< Space key */ + REMOTE_INPUT_KEY_BACKSPACE, /**< Backspace key */ + REMOTE_INPUT_KEY_ESC, /**< Escape key */ + REMOTE_INPUT_KEY_UP, /**< Up key */ + REMOTE_INPUT_KEY_DOWN, /**< Down key */ + REMOTE_INPUT_KEY_LEFT, /**< LEFT key */ + REMOTE_INPUT_KEY_RIGHT, /**< Right key */ + REMOTE_INPUT_KEY_PAGE_UP, /**< Page up key */ + REMOTE_INPUT_KEY_PAGE_DOWN, /**< Page down key */ + REMOTE_INPUT_KEY_SELECT, /**< Select key */ + REMOTE_INPUT_KEY_CANCEL, /**< Cancel key */ +} remote_input_key_type_e; + +/** + * @platform + * @brief Enumeration for input resources. + * @since_tizen 5.5 + * @see remote_input_resource_changed_cb() + */ +typedef enum { + REMOTE_INPUT_RESOURCE_LOCAL = 0, /**< Input event from IME, H/W keyboard */ + REMOTE_INPUT_RESOURCE_REMOTE, /**< Input event from remote input API */ +} remote_input_resource_e; + +/** + * @platform + * @brief Handle of the remote input. + * @since_tizen 5.5 + */ +typedef struct remote_input_s *remote_input_h; + +/** + * @platform + * @brief Called when an associated text field has focus. + * @since_tizen 5.5 + * @param[in] user_data User data to be passed to the callback function + * @pre The callback can be registered using remote_input_focus_in_callback_set() function. + * @see remote_input_focus_in_callback_set() + * @see remote_input_focus_in_callback_unset() + */ +typedef void (*remote_input_focus_in_cb)(void *user_data); + +/** + * @platform + * @brief Called when an associated text field loses focus. + * @since_tizen 5.5 + * @param[in] user_data User data to be passed to the callback function + * @pre The callback can be registered using remote_input_focus_out_callback_set() function. + * @see remote_input_focus_out_callback_set() + * @see remote_input_focus_out_callback_unset() + */ +typedef void (*remote_input_focus_out_cb)(void *user_data); + +/** + * @platform + * @brief Called when an associated text field requests the input panel to set its attributes. + * @since_tizen 5.5 + * @remarks This callback will be called after remote_input_focus_in_cb(). + * It can be called again when the associated text field's attributes are changed. + * Remote IME application should configure its input panel with various attributes. + * @param[in] user_data User data to be passed to the callback function + * @pre The callback can be registered using remote_input_metadata_updated_callback_set() function. + * @see remote_input_metadata_updated_callback_set() + * @see remote_input_metadata_updated_callback_unset() + * @see remote_input_get_input_hint() + * @see remote_input_get_layout() + * @see remote_input_get_layout_variation() + * @see remote_input_get_autocapital_type() + * @see remote_input_get_return_key_state() + * @see remote_input_get_return_key_type() + */ +typedef void (*remote_input_metadata_updated_cb)(void *user_data); + +/** + * @platform + * @brief Called when an associated text field responds to a request with the surrounding text. + * @since_tizen 5.5 + * @remarks This callback will be called after remote_input_metadata_updated_cb(). + * It can be called again when the text or the cursor position in the associated text field is changed. + * @a text can be used only in the callback. To use outside, make a copy. + * @param[in] text The UTF-8 string requested + * @param[in] cursor_pos The cursor position + * @param[in] user_data User data to be passed to the callback function + * @pre The callback can be registered using remote_input_text_updated_callback_set() function. + * @see remote_input_text_updated_callback_set() + * @see remote_input_text_updated_callback_unset() + */ +typedef void (*remote_input_text_updated_cb)(const char *text, int cursor_pos, void *user_data); + +/** + * @platform + * @brief Called when the input resource is changed. + * @since_tizen 5.5 + * @param[in] resource The input resource + * @param[in] user_data User data to be passed to the callback function + * @pre The callback can be registered using remote_input_resource_changed_callback_set() function. + * @see remote_input_resource_changed_callback_set() + * @see remote_input_resource_changed_callback_unset() + */ +typedef void (*remote_input_resource_changed_cb)(remote_input_resource_e resource, void *user_data); + +/** + * @platform + * @brief Creates a remote input handle. + * @since_tizen 5.5 + * @privlevel platform + * @privilege %http://tizen.org/privilege/remoteinput + * @remarks If the function succeeds, @a remote_handle must be released with remote_input_destroy(). + * @param[out] remote_handle The remote input handle + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @retval #REMOTE_INPUT_PERMISSION_DENIED Permission denied + * @retval #REMOTE_INPUT_OUT_OF_MEMORY Out of memory + * @retval #REMOTE_INPUT_OPERATION_FAILED Operation failure + * @see remote_input_destroy() + */ +int remote_input_create(remote_input_h *remote_handle); + +/** + * @platform + * @brief Destroys a remote input handle. + * @since_tizen 5.5 + * @param[in] remote_handle The remote input handle + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @retval #REMOTE_INPUT_OPERATION_FAILED Operation failed + * @see remote_input_create() + */ +int remote_input_destroy(remote_input_h remote_handle); + +/** + * @platform + * @brief Sets a callback function to be called when an associated text field has focus. + * @since_tizen 5.5 + * @param[in] remote_handle The remote input handle + * @param[in] callback The callback function to register + * @param[in] user_data User data to be passed to the callback function + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @see remote_input_focus_in_callback_unset() + */ +int remote_input_focus_in_callback_set(remote_input_h remote_handle, remote_input_focus_in_cb callback, void *user_data); + +/** + * @platform + * @brief Unsets the callback function. + * @since_tizen 5.5 + * @param[in] remote_handle The remote input handle + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @see remote_input_focus_in_callback_set() + */ +int remote_input_focus_in_callback_unset(remote_input_h remote_handle); + +/** + * @platform + * @brief Sets a callback function to be called when an associated text field loses focus. + * @since_tizen 5.5 + * @param[in] remote_handle The remote input handle + * @param[in] callback The callback function to register + * @param[in] user_data User data to be passed to the callback function + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @see remote_input_focus_out_callback_unset() + */ +int remote_input_focus_out_callback_set(remote_input_h remote_handle, remote_input_focus_out_cb callback, void *user_data); + +/** + * @platform + * @brief Unsets the callback function. + * @since_tizen 5.5 + * @param[in] remote_handle The remote input handle + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @see remote_input_focus_out_callback_set() + */ +int remote_input_focus_out_callback_unset(remote_input_h remote_handle); + +/** + * @platform + * @brief Sets a callback function to be called when an associated text field requests the input panel to set its attributes. + * @since_tizen 5.5 + * @param[in] remote_handle The remote input handle + * @param[in] callback The callback function to register + * @param[in] user_data User data to be passed to the callback function + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @see remote_input_metadata_updated_callback_unset() + */ +int remote_input_metadata_updated_callback_set(remote_input_h remote_handle, remote_input_metadata_updated_cb callback, void *user_data); + +/** + * @platform + * @brief Unsets the callback function. + * @since_tizen 5.5 + * @param[in] remote_handle The remote input handle + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @see remote_input_metadata_updated_callback_set() + */ +int remote_input_metadata_updated_callback_unset(remote_input_h remote_handle); + +/** + * @platform + * @brief Sets a callback function to be called when an associated text field responds to a request with the surrounding text. + * @since_tizen 5.5 + * @param[in] remote_handle The remote input handle + * @param[in] callback The callback function to register + * @param[in] user_data User data to be passed to the callback function + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @see remote_inputl_text_updated_callback_unset() + */ +int remote_input_text_updated_callback_set(remote_input_h remote_handle, remote_input_text_updated_cb callback, void *user_data); + +/** + * @platform + * @brief Unsets the callback function. + * @since_tizen 5.5 + * @param[in] remote_handle The remote input handle + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @see remote_inputl_text_updated_callback_set() + */ +int remote_input_text_updated_callback_unset(remote_input_h remote_handle); + +/** + * @platform + * @brief Sets a callback function to be called when the input resource is changed. + * @since_tizen 5.5 + * @param[in] remote_handle The remote input handle + * @param[in] callback The callback function to register + * @param[in] user_data User data to be passed to the callback function + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @see remote_input_resource_changed_callback_unset() + */ +int remote_input_resource_changed_callback_set(remote_input_h remote_handle, remote_input_resource_changed_cb callback, void *user_data); + +/** + * @platform + * @brief Unsets the callback function. + * @since_tizen 5.5 + * @param[in] remote_handle The remote input handle + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @see remote_input_resource_changed_callback_set() + */ +int remote_input_resource_changed_callback_unset(remote_input_h remote_handle); + +/** + * @platform + * @brief Gets the input hint information. + * @details Each edit field has various attributes for input panel. + * This function can be called to get the input hint information in remote_input_metadata_updated_cb() callback function. + * @since_tizen 5.5 + * @remarks @a input_hint is a bit-wise value which recommends the input panel provide an auto completion and so on + * if it is capable of supporting such features. + * @param[in] remote_handle The remote input handle + * @param[out] input_hint Input hint information + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @post Remote input panel UI should be drawn or operated by this information accordingly. + * @see remote_input_metadata_updated_cb() + */ +int remote_input_get_input_hint(remote_input_h remote_handle, Ecore_IMF_Input_Hints *input_hint); + +/** + * @platform + * @brief Gets the layout information. + * @details Each edit field has various attributes for input panel. + * This function can be called to get the layout information in remote_input_metadata_updated_cb() callback function. + * @since_tizen 5.5 + * @param[in] remote_handle The remote input handle + * @param[out] layout Layout information + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @post Remote input panel UI should be drawn or operated by this information accordingly. + * @see remote_input_metadata_updated_cb() + */ +int remote_input_get_layout(remote_input_h remote_handle, Ecore_IMF_Input_Panel_Layout *layout); + +/** + * @platform + * @brief Gets the layout variation information. + * @details Each edit field has various attributes for input panel. + * This function can be called to get the layout variation information in remote_input_metadata_updated_cb() callback function. + * @since_tizen 5.5 + * @param[in] remote_handle The remote input handle + * @param[out] variation The layout variation + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @post Remote input panel UI should be drawn or operated by this information accordingly. + * @see remote_input_metadata_updated_cb() + */ +int remote_input_get_layout_variation(remote_input_h remote_handle, int *variation); + +/** + * @platform + * @brief Gets the autocapital type information. + * @details Each edit field has various attributes for input panel. + * This function can be called to get the autocapital type information in remote_input_metadata_updated_cb() callback function. + * @since_tizen 5.5 + * @param[in] remote_handle The remote input handle + * @param[out] autocapital_type autocapital_type Autocapital type information + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @post Remote input panel UI should be drawn or operated by this information accordingly. + * @see remote_input_metadata_updated_cb() + */ +int remote_input_get_autocapital_type(remote_input_h remote_handle, Ecore_IMF_Autocapital_Type *autocapital_type); + +/** + * @platform + * @brief Gets the return key state information. + * @details Each edit field has various attributes for input panel. + * This function can be called to get the return key state information in remote_input_metadata_updated_cb() callback function. + * @since_tizen 5.5 + * @param[in] remote_handle The remote input handle + * @param[out] return_key_state The return key state information \n @c true to enable return key button, @c false to disable return key button + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @post Remote input panel UI should be drawn or operated by this information accordingly. + * @see remote_input_metadata_updated_cb() + */ +int remote_input_get_return_key_state(remote_input_h remote_handle, bool *return_key_state); + +/** + * @platform + * @brief Gets the return key label type information. + * @details Each edit field has various attributes for input panel. + * This function can be called to get the return key label type information in remote_input_metadata_updated_cb() callback function. + * @since_tizen 5.5 + * @param[in] remote_handle The remote input handle + * @param[out] return_key_type The return key label type information + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @post Remote input panel UI should be drawn or operated by this information accordingly. + * @see remote_input_metadata_updated_cb() + */ +int remote_input_get_return_key_type(remote_input_h remote_handle, Ecore_IMF_Input_Panel_Return_Key_Type *return_key_type); + +/** + * @platform + * @brief Sends a key event to the associated text field. + * @since_tizen 5.5 + * @remarks This function must be used if an associated text field has focus. + * Otherwise, #REMOTE_INPUT_OPERATION_FAILED will be returned. + * @param[in] remote_handle The remote input handle + * @param[in] key The key type + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @retval #REMOTE_INPUT_OPERATION_FAILED Operation failure + */ +int remote_input_send_key_event(remote_input_h remote_handle, remote_input_key_type_e key); + +/** + * @platform + * @brief Sends a commit string to the associated text field. + * @since_tizen 5.5 + * @remarks This function must be used if an associated text field has focus. + * Otherwise, #REMOTE_INPUT_OPERATION_FAILED will be returned. + * @param[in] remote_handle The remote input handle + * @param[in] text The UTF-8 string to be committed + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @retval #REMOTE_INPUT_OPERATION_FAILED Operation failure + */ +int remote_input_send_commit_string(remote_input_h remote_handle, const char *text); + +/** + * @platform + * @brief Updates a preedit string to the associated text field. + * @since_tizen 5.5 + * @remarks This function must be used if an associated text field has focus. + * Otherwise, #REMOTE_INPUT_OPERATION_FAILED will be returned. + * @param[in] remote_handle The remote input handle + * @param[in] text The UTF-8 string to be committed + * @param[in] cursor_pos The cursor position; -1 means at the end of line + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @retval #REMOTE_INPUT_OPERATION_FAILED Operation failure + */ +int remote_input_update_preedit_string(remote_input_h remote_handle, const char *text, int cursor_pos); + +/** + * @platform + * @brief Requests to delete surrounding text. + * @since_tizen 5.5 + * @remarks This function must be used if an associated text field has focus. + * Otherwise, #REMOTE_INPUT_OPERATION_FAILED will be returned. + * @param[in] remote_handle The remote input handle + * @param[in] offset The offset value from the cursor position + * @param[in] len The length of the text to delete + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_INPUT_ERROR_NONE Successful + * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter + * @retval #REMOTE_INPUT_OPERATION_FAILED Operation failure + */ +int remote_input_delete_surrounding_text(remote_input_h remote_handle, int offset, int len); + + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_UIX_REMOTE_INPUT_H__ */ + diff --git a/remote_input/include/remote_input_private.h b/remote_input/include/remote_input_private.h new file mode 100644 index 0000000..0c369eb --- /dev/null +++ b/remote_input/include/remote_input_private.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_UIX_REMOTE_INPUT_PRIVATE_H__ +#define __TIZEN_UIX_REMOTE_INPUT_PRIVATE_H__ + +#include +#include +#include + +struct remote_input_s { + remote_control_client *remote_client; + Ecore_IMF_Input_Hints hint; + Ecore_IMF_Input_Panel_Layout layout; + int variation; + Ecore_IMF_Autocapital_Type autocapital_type; + bool return_key_disabled; + Ecore_IMF_Input_Panel_Return_Key_Type return_key_type; + remote_input_metadata_updated_cb metadata_updated_cb; + void *metadata_updated_cb_user_data; + remote_input_text_updated_cb text_updated_cb; + void *text_updated_cb_user_data; + remote_input_resource_changed_cb resource_changed_cb; + void *resource_changed_cb_user_data; +}; + +#endif /* __TIZEN_UIX_REMOTE_INPUT_PRIVATE_H__ */ + diff --git a/remote_input/src/remote_input.cpp b/remote_input/src/remote_input.cpp new file mode 100644 index 0000000..8713e76 --- /dev/null +++ b/remote_input/src/remote_input.cpp @@ -0,0 +1,418 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include "privilege_checker_private.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "REMOTE_INPUT" + +#define REMOTE_PRIVILEGE "http://tizen.org/privilege/remoteinput" + +static remote_input_error_e _remote_check_privilege() { + char uid[16]; + remote_input_error_e ret = REMOTE_INPUT_ERROR_NONE; + + if (inputmethod_cynara_initialize() == false) { + LOGE("cynara_initialize () == false"); + return REMOTE_INPUT_PERMISSION_DENIED; + } + + snprintf(uid, 16, "%d", getuid()); + if (check_privilege(uid, REMOTE_PRIVILEGE) == false) { + LOGE("check_privilege(uid, REMOTE_PRIVILEGE) == false. uid : %s", uid); + ret = REMOTE_INPUT_PERMISSION_DENIED; + } + + inputmethod_cynara_finish(); + + return ret; +} + +static void _metadata_updated_cb(void *user_data, remote_control_entry_metadata_s *data) +{ + remote_input_h remote_handle = (remote_input_h)user_data; + + if (remote_handle == NULL) { + LOGE("remote handle is not available"); + return; + } + + remote_handle->hint = data->hint; + remote_handle->layout = data->layout; + remote_handle->variation = data->variation; + remote_handle->autocapital_type = data->autocapital_type; + remote_handle->return_key_disabled = data->return_key_disabled; + remote_handle->return_key_type = data->return_key_type; + + if (remote_handle->metadata_updated_cb) { + remote_handle->metadata_updated_cb(remote_handle->metadata_updated_cb_user_data); + } +} + +static void _text_updated_cb(void *user_data, const char *text, int cursor_pos) +{ + remote_input_h remote_handle = (remote_input_h)user_data; + + if (remote_handle == NULL) { + LOGE("remote handle is not available"); + return; + } + + if (remote_handle->text_updated_cb) { + remote_handle->text_updated_cb(text, cursor_pos, remote_handle->text_updated_cb_user_data); + } +} + +static void _resource_updated_cb(void *user_data, remote_control_input_resource resource) +{ + remote_input_h remote_handle = (remote_input_h)user_data; + + if (remote_handle == NULL) { + LOGE("remote handle is not available"); + return; + } + + if (remote_handle->resource_changed_cb) { + remote_handle->resource_changed_cb(resource == REMOTE_CONTROL_INPUT_RESOURCE_LOCAL ? REMOTE_INPUT_RESOURCE_LOCAL : REMOTE_INPUT_RESOURCE_REMOTE, + remote_handle->resource_changed_cb_user_data); + } +} + +EXPORT_API int remote_input_create(remote_input_h *remote_handle) +{ + remote_input_error_e ret = REMOTE_INPUT_ERROR_NONE; + + if (!remote_handle) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + ret = _remote_check_privilege(); + if (ret != REMOTE_INPUT_ERROR_NONE) { + LOGE("REMOTE_INPUT_PERMISSION_DENIED"); + return ret; + } + + struct remote_input_s *remote_input = (remote_input_h)calloc(1, sizeof(struct remote_input_s)); + if (!remote_input) { + LOGE("REMOTE_INPUT_OUT_OF_MEMORY"); + return REMOTE_INPUT_OUT_OF_MEMORY; + } + + remote_input->remote_client = remote_control_connect(); + if (!remote_input->remote_client) { + LOGE("REMOTE_INPUT_OPERATION_FAILED"); + free(remote_input); + remote_input = NULL; + return REMOTE_INPUT_OPERATION_FAILED; + } + + *remote_handle = (remote_input_h)remote_input; + + return ret; +} + +EXPORT_API int remote_input_destroy(remote_input_h remote_handle) +{ + if (!remote_handle || !remote_handle->remote_client) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + if (remote_control_disconnect(remote_handle->remote_client) != REMOTE_CONTROL_ERROR_NONE) { + LOGE("REMOTE_INPUT_OPERATION_FAILED"); + return REMOTE_INPUT_OPERATION_FAILED; + } else { + remote_handle->remote_client = NULL; + } + + free(remote_handle); + remote_handle = NULL; + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_focus_in_callback_set(remote_input_h remote_handle, remote_input_focus_in_cb callback, void *user_data) +{ + if (!remote_handle || !remote_handle->remote_client || !callback) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + remote_control_focus_in_callback_set(remote_handle->remote_client, callback, user_data); + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_focus_in_callback_unset(remote_input_h remote_handle) +{ + if (!remote_handle || !remote_handle->remote_client) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + remote_control_focus_in_callback_unset(remote_handle->remote_client); + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_focus_out_callback_set(remote_input_h remote_handle, remote_input_focus_out_cb callback, void *user_data) +{ + if (!remote_handle || !remote_handle->remote_client || !callback) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + remote_control_focus_out_callback_set(remote_handle->remote_client, callback, user_data); + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_focus_out_callback_unset(remote_input_h remote_handle) +{ + if (!remote_handle || !remote_handle->remote_client) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + remote_control_focus_out_callback_unset(remote_handle->remote_client); + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_metadata_updated_callback_set(remote_input_h remote_handle, remote_input_metadata_updated_cb callback, void *user_data) +{ + if (!remote_handle || !remote_handle->remote_client || !callback) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + remote_control_entry_metadata_callback_set(remote_handle->remote_client, _metadata_updated_cb, (void *)remote_handle); + remote_handle->metadata_updated_cb = callback; + remote_handle->metadata_updated_cb_user_data = user_data; + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_metadata_updated_callback_unset(remote_input_h remote_handle) +{ + if (!remote_handle || !remote_handle->remote_client) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + remote_control_entry_metadata_callback_unset(remote_handle->remote_client); + remote_handle->metadata_updated_cb = NULL; + remote_handle->metadata_updated_cb_user_data = NULL; + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_text_updated_callback_set(remote_input_h remote_handle, remote_input_text_updated_cb callback, void *user_data) +{ + if (!remote_handle || !remote_handle->remote_client || !callback) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + remote_control_text_updated_callback_set(remote_handle->remote_client, _text_updated_cb, (void *)remote_handle); + remote_handle->text_updated_cb = callback; + remote_handle->text_updated_cb_user_data = user_data; + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_text_updated_callback_unset(remote_input_h remote_handle) +{ + if (!remote_handle || !remote_handle->remote_client) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + remote_control_text_updated_callback_unset(remote_handle->remote_client); + remote_handle->text_updated_cb = NULL; + remote_handle->text_updated_cb_user_data = NULL; + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_resource_changed_callback_set(remote_input_h remote_handle, remote_input_resource_changed_cb callback, void *user_data) +{ + if (!remote_handle || !remote_handle->remote_client || !callback) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + remote_control_input_resource_changed_callback_set(remote_handle->remote_client, _resource_updated_cb, (void *)remote_handle); + remote_handle->resource_changed_cb = callback; + remote_handle->resource_changed_cb_user_data = user_data; + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_resource_changed_callback_unset(remote_input_h remote_handle) +{ + if (!remote_handle || !remote_handle->remote_client) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + remote_control_input_resource_changed_callback_unset(remote_handle->remote_client); + remote_handle->resource_changed_cb = NULL; + remote_handle->resource_changed_cb_user_data = NULL; + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_get_input_hint(remote_input_h remote_handle, Ecore_IMF_Input_Hints *input_hint) +{ + if (!remote_handle || !input_hint) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + *input_hint = remote_handle->hint; + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_get_layout(remote_input_h remote_handle, Ecore_IMF_Input_Panel_Layout *layout) +{ + if (!remote_handle || !layout) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + *layout = remote_handle->layout; + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_get_layout_variation(remote_input_h remote_handle, int *variation) +{ + if (!remote_handle || !variation) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + *variation = remote_handle->variation; + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_get_autocapital_type(remote_input_h remote_handle, Ecore_IMF_Autocapital_Type *autocapital_type) +{ + if (!remote_handle || !autocapital_type) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + *autocapital_type = remote_handle->autocapital_type; + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_get_return_key_state(remote_input_h remote_handle, bool *return_key_state) +{ + if (!remote_handle || !return_key_state) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + *return_key_state = remote_handle->return_key_disabled; + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_get_return_key_type(remote_input_h remote_handle, Ecore_IMF_Input_Panel_Return_Key_Type *return_key_type) +{ + if (!remote_handle || !return_key_type) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + *return_key_type = remote_handle->return_key_type; + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_send_key_event(remote_input_h remote_handle, remote_input_key_type_e key) +{ + if (!remote_handle || key > REMOTE_INPUT_KEY_CANCEL) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + if (remote_control_send_key_event(remote_handle->remote_client, (remote_control_key_type_e)key) != REMOTE_CONTROL_ERROR_NONE) { + LOGE("REMOTE_INPUT_OPERATION_FAILED"); + return REMOTE_INPUT_OPERATION_FAILED; + } + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_send_commit_string(remote_input_h remote_handle, const char *text) +{ + if (!remote_handle || !text) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + if (remote_control_send_commit_string(remote_handle->remote_client, text) != REMOTE_CONTROL_ERROR_NONE) { + LOGE("REMOTE_INPUT_OPERATION_FAILED"); + return REMOTE_INPUT_OPERATION_FAILED; + } + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_update_preedit_string(remote_input_h remote_handle, const char *text, int cursor_pos) +{ + if (!remote_handle || !text || cursor_pos < -1) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + if (remote_control_update_preedit_string(remote_handle->remote_client, text, NULL, cursor_pos) != REMOTE_CONTROL_ERROR_NONE) { + LOGE("REMOTE_INPUT_OPERATION_FAILED"); + return REMOTE_INPUT_OPERATION_FAILED; + } + + return REMOTE_INPUT_ERROR_NONE; +} + +EXPORT_API int remote_input_delete_surrounding_text(remote_input_h remote_handle, int offset, int len) +{ + if (!remote_handle || len <= 0) { + LOGE("REMOTE_INPUT_INVALID_PARAMETER"); + return REMOTE_INPUT_INVALID_PARAMETER; + } + + if (remote_control_delete_surrounding_text(remote_handle->remote_client, offset, len) != REMOTE_CONTROL_ERROR_NONE) { + LOGE("REMOTE_INPUT_OPERATION_FAILED"); + return REMOTE_INPUT_OPERATION_FAILED; + } + + return REMOTE_INPUT_ERROR_NONE; +} \ No newline at end of file diff --git a/src/inputmethod.cpp b/src/inputmethod.cpp deleted file mode 100644 index bf98918..0000000 --- a/src/inputmethod.cpp +++ /dev/null @@ -1,2153 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "inputmethod_private.h" -#include -#include "inputmethod_internal.h" - -using namespace std; - -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "INPUTMETHOD" - -using namespace scl; - -class CCoreEventCallback : public ISCLCoreEventCallback -{ - void on_init(); - void on_run(int argc, char **argv); - void on_exit(); - void on_update_cursor_position(sclint ic, const sclchar *ic_uuid, sclint cursor_pos); - void on_update_surrounding_text(sclint ic, const sclchar *text, sclint cursor); - void on_focus_out(sclint ic, const sclchar *ic_uuid); - void on_focus_in(sclint ic, const sclchar *ic_uuid); - void on_ise_show(sclint ic, const int degree, Ise_Context &context); - void on_ise_hide(sclint ic, const sclchar *ic_uuid); - void on_get_geometry(sclu32 *pos_x, sclu32 *pos_y, sclu32 *width, sclu32 *height); - void on_set_language(Ecore_IMF_Input_Panel_Lang language); - void on_set_imdata(sclchar *buf, sclu32 len); - void on_get_imdata(sclchar **buf, sclu32 *len); - void on_get_language_locale(sclint ic, sclchar **locale); - void on_set_return_key_type(Ecore_IMF_Input_Panel_Return_Key_Type type); - void on_set_return_key_disable(sclu32 disabled); - void on_set_layout(sclu32 layout); - void on_reset_input_context(sclint ic, const sclchar *uuid); - void on_process_key_event(scim::KeyEvent &key, sclu32 *ret); - void on_process_key_event_with_keycode(scim::KeyEvent &key, sclu32 *ret, sclu32 keycode); - void on_set_display_language(const sclchar *language); - void on_set_rotation_degree(sclint degree); - void on_set_accessibility_state(sclboolean state); - void on_create_option_window(sclwindow window, SCLOptionWindowType type); - void on_destroy_option_window(sclwindow window); - void on_check_option_window_availability(sclboolean *ret); - void on_set_caps_mode(sclu32 mode); - void on_candidate_show(sclint ic, const sclchar *ic_uuid); - 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); - 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); -}; - -typedef struct -{ - ime_focus_in_cb focus_in; /**< Called when an edit field has focus */ - ime_focus_out_cb focus_out; /**< Called when an edit field loses focus */ - ime_surrounding_text_updated_cb surrounding_text_updated; /**< Called when an edit field responds to a request with the surrounding text */ - ime_input_context_reset_cb input_context_reset; /**< Called to reset the input context of an edit field */ - ime_cursor_position_updated_cb cursor_position_updated; /**< Called when the position of the cursor in an edit field changes */ - ime_language_requested_cb language_requested; /**< Called when an edit field requests the language from the input panel */ - ime_language_set_cb language_set; /**< Called to set the preferred language to the input panel */ - ime_imdata_set_cb imdata_set; /**< Called to set the application specific data to deliver to the input panel */ - ime_imdata_requested_cb imdata_requested; /**< Called when an associated text input UI control requests the application specific data from the input panel */ - ime_layout_set_cb layout_set; /**< Called when an edit field requests the input panel to set its layout */ - ime_return_key_type_set_cb return_key_type_set; /**< Called when an edit field requests the input panel to set the "return" key label */ - ime_return_key_state_set_cb return_key_state_set; /**< Called when an edit field requests the input panel to enable or disable the "return" key state */ - ime_geometry_requested_cb geometry_requested; /**< Called when an edit field requests the position and size from the input panel */ - ime_process_key_event_cb process_key_event; /**< Called when the key event is received from the external keyboard devices */ - ime_process_key_event_with_keycode_cb process_key_event_with_keycode; /**< Called when the key event is received from the external keyboard devices */ - ime_display_language_changed_cb display_language_changed; /**< Called when the system display language is changed */ - ime_rotation_degree_changed_cb rotation_degree_changed; /**< Called when the device is rotated */ - ime_accessibility_state_changed_cb accessibility_state_changed; /**< Called when Accessibility in Settings application is on or off */ - ime_option_window_created_cb option_window_created; /**< Called to create the option window */ - ime_option_window_destroyed_cb option_window_destroyed; /**< Called to destroy the option window */ - ime_caps_mode_changed_cb caps_mode_changed; - ime_candidate_show_cb candidate_show; - 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; - 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; - void *focus_in_user_data; - void *focus_out_user_data; - void *surrounding_text_updated_user_data; - void *input_context_reset_user_data; - void *cursor_position_updated_user_data; - void *language_requested_user_data; - void *language_set_user_data; - void *imdata_set_user_data; - void *imdata_requested_user_data; - void *layout_set_user_data; - void *return_key_type_set_user_data; - void *return_key_state_set_user_data; - void *geometry_requested_user_data; - void *process_key_event_user_data; - void *process_key_event_with_keycode_user_data; - void *display_language_changed_user_data; - void *rotation_degree_changed_user_data; - void *accessibility_state_changed_user_data; - void *option_window_created_user_data; - void *option_window_destroyed_user_data; - void *caps_mode_changed_user_data; - void *candidate_show_user_data; - void *candidate_hide_user_data; - 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; - void *prediction_hint_data_set_user_data; - void *optimization_hint_set_user_data; -} ime_event_callback_s; - -typedef struct { - ime_input_device_type_e device_type; - void *event_data; -} ime_device_event_s; - -static ime_callback_s g_basic_callback = {NULL}; -static ime_event_callback_s g_event_callback = {NULL}; -static void *g_user_data = NULL; -static bool g_running = false; - -static CCoreEventCallback g_core_event_callback; -CSCLCore g_core(&g_core_event_callback); - -extern "C" { - extern void ime_app_main(int argc, char **argv); -} - -//LCOV_EXCL_START -void CCoreEventCallback::on_init() -{ - if (g_basic_callback.create) { - g_basic_callback.create(g_user_data); - } -} - -void CCoreEventCallback::on_run(int argc, char **argv) -{ - LOGD("on_run"); - ime_app_main(argc, argv); -} - -void CCoreEventCallback::on_exit() -{ - LOGD("on_exit"); - if (g_basic_callback.terminate) { - g_basic_callback.terminate(g_user_data); - } -} - -void CCoreEventCallback::on_update_cursor_position(sclint ic, const sclchar *ic_uuid, sclint cursor_pos) -{ - if (g_event_callback.cursor_position_updated) { - g_event_callback.cursor_position_updated(cursor_pos, g_event_callback.cursor_position_updated_user_data); - } -} - -void CCoreEventCallback::on_update_surrounding_text(sclint ic, const sclchar *text, sclint cursor) -{ - if (g_event_callback.surrounding_text_updated) { - g_event_callback.surrounding_text_updated(ic, text, cursor, g_event_callback.surrounding_text_updated_user_data); - } -} - -void CCoreEventCallback::on_focus_out(sclint ic, const sclchar *ic_uuid) -{ - if (g_event_callback.focus_out) { - g_event_callback.focus_out(ic, g_event_callback.focus_out_user_data); - } -} - -void CCoreEventCallback::on_focus_in(sclint ic, const sclchar *ic_uuid) -{ - if (g_event_callback.focus_in) { - g_event_callback.focus_in(ic, g_event_callback.focus_in_user_data); - } -} - -void CCoreEventCallback::on_ise_show(sclint ic, const int degree, Ise_Context &context) -{ - if (g_basic_callback.show) { - struct _ime_context input_context; - - memset(&input_context, 0, sizeof(struct _ime_context)); - input_context.layout = context.layout; - input_context.layout_variation = context.layout_variation; - input_context.cursor_pos = context.cursor_pos; - input_context.autocapital_type = context.autocapital_type; - input_context.return_key_type = context.return_key_type; - input_context.return_key_disabled = context.return_key_disabled; - input_context.prediction_allow = context.prediction_allow; - input_context.password_mode = context.password_mode; - input_context.imdata_size = context.imdata_size; - input_context.input_hint = context.input_hint; - input_context.bidi_direction = context.bidi_direction; - input_context.language = context.language; - input_context.client_window = context.client_window; - input_context.caps_mode = context.caps_mode; - - g_basic_callback.show(ic, static_cast(&input_context), g_user_data); - } -} - -void CCoreEventCallback::on_ise_hide(sclint ic, const sclchar *ic_uuid) -{ - if (g_basic_callback.hide) { - g_basic_callback.hide(ic, g_user_data); - } -} - -void CCoreEventCallback::on_get_geometry(sclu32 *pos_x, sclu32 *pos_y, sclu32 *width, sclu32 *height) -{ - int geometry_pos_x = 0; - int geometry_pos_y = 0; - int geometry_width = 0; - int geometry_height = 0; - - if (g_event_callback.geometry_requested) { - g_event_callback.geometry_requested(g_event_callback.geometry_requested_user_data, &geometry_pos_x, &geometry_pos_y, &geometry_width, &geometry_height); - } - - if (pos_x) - *pos_x = geometry_pos_x; - - if (pos_y) - *pos_y = geometry_pos_y; - - if (width) - *width = geometry_width; - - if (height) - *height = geometry_height; -} - -void CCoreEventCallback::on_set_language(Ecore_IMF_Input_Panel_Lang language) -{ - if (g_event_callback.language_set) { - g_event_callback.language_set(language, g_event_callback.language_set_user_data); - } -} - -void CCoreEventCallback::on_set_imdata(sclchar *buf, sclu32 len) -{ - if (g_event_callback.imdata_set) { - g_event_callback.imdata_set((void *)buf, len, g_event_callback.imdata_set_user_data); - } -} - -void CCoreEventCallback::on_get_imdata(sclchar **buf, sclu32 *len) -{ - if (g_event_callback.imdata_requested) { - g_event_callback.imdata_requested(g_event_callback.imdata_set_user_data, (void **)buf, len); - } -} - -void CCoreEventCallback::on_get_language_locale(sclint ic, sclchar **locale) -{ - if (g_event_callback.language_requested) { - g_event_callback.language_requested(g_event_callback.language_requested_user_data, locale); - } -} - -void CCoreEventCallback::on_set_return_key_type(Ecore_IMF_Input_Panel_Return_Key_Type type) -{ - if (g_event_callback.return_key_type_set) { - g_event_callback.return_key_type_set(type, g_event_callback.return_key_type_set_user_data); - } -} - -void CCoreEventCallback::on_set_return_key_disable(sclu32 disabled) -{ - bool return_key_disabled = !!disabled; - - if (g_event_callback.return_key_state_set) { - g_event_callback.return_key_state_set(return_key_disabled, g_event_callback.return_key_state_set_user_data); - } -} - -void CCoreEventCallback::on_set_layout(sclu32 layout) -{ - if (g_event_callback.layout_set) { - g_event_callback.layout_set(static_cast(layout), g_event_callback.layout_set_user_data); - } -} - -void CCoreEventCallback::on_reset_input_context(sclint ic, const sclchar *uuid) -{ - if (g_event_callback.input_context_reset) { - g_event_callback.input_context_reset(g_event_callback.input_context_reset_user_data); - } -} - -void CCoreEventCallback::on_process_key_event(scim::KeyEvent &key, sclu32 *ret) -{ - if (g_event_callback.process_key_event) { - struct _ime_device_info dev_info = {key.dev_name.c_str(), - static_cast(key.dev_class), static_cast(key.dev_subclass)}; - bool processed = g_event_callback.process_key_event(static_cast(key.code), static_cast(key.mask), - static_cast(&dev_info), g_event_callback.process_key_event_user_data); - - if (ret) { - if (processed) - *ret = 1; - else - *ret = 0; - } - } else { - if (ret) { - *ret = 0; - } - } -} - -void CCoreEventCallback::on_process_key_event_with_keycode(scim::KeyEvent &key, sclu32 *ret, sclu32 keycode) -{ - if (g_event_callback.process_key_event_with_keycode) { - struct _ime_device_info dev_info = {key.dev_name.c_str(), - static_cast(key.dev_class), static_cast(key.dev_subclass)}; - bool processed = g_event_callback.process_key_event_with_keycode(keycode, static_cast(key.code), static_cast(key.mask), - static_cast(&dev_info), g_event_callback.process_key_event_user_data); - - if (ret) { - if (processed) - *ret = 1; - else - *ret = 0; - } - } else { - if (ret) { - *ret = 0; - } - } -} - -void CCoreEventCallback::on_set_display_language(const sclchar *language) -{ - if (g_event_callback.display_language_changed) { - g_event_callback.display_language_changed(language, g_event_callback.display_language_changed_user_data); - } -} - -void CCoreEventCallback::on_set_rotation_degree(sclint degree) -{ - if (g_event_callback.rotation_degree_changed) { - g_event_callback.rotation_degree_changed(degree, g_event_callback.rotation_degree_changed_user_data); - } -} - -void CCoreEventCallback::on_set_accessibility_state(sclboolean state) -{ - if (g_event_callback.accessibility_state_changed) { - g_event_callback.accessibility_state_changed(state, g_event_callback.accessibility_state_changed_user_data); - } -} - -void CCoreEventCallback::on_create_option_window(sclwindow window, SCLOptionWindowType type) -{ - if (g_event_callback.option_window_created) { - g_event_callback.option_window_created(static_cast(window), static_cast(type), g_event_callback.option_window_created_user_data); - } -} - -void CCoreEventCallback::on_destroy_option_window(sclwindow window) -{ - if (g_event_callback.option_window_destroyed) { - g_event_callback.option_window_destroyed(static_cast(window), g_event_callback.option_window_destroyed_user_data); - } -} - -void CCoreEventCallback::on_check_option_window_availability(sclboolean *ret) -{ - if (ret) { - if (g_event_callback.option_window_created) // Instead of each 3rd party keyboard, inputmethod will reply the availability of the option (setting). - *ret = true; - else - *ret = false; - } -} - -void CCoreEventCallback::on_set_caps_mode(sclu32 mode) -{ - if (g_event_callback.caps_mode_changed) { - g_event_callback.caps_mode_changed(mode, g_event_callback.caps_mode_changed_user_data); - } -} - -void CCoreEventCallback::on_candidate_show(sclint ic, const sclchar *ic_uuid) -{ - if (g_event_callback.candidate_show) { - g_event_callback.candidate_show(ic, g_event_callback.candidate_show_user_data); - } -} - -void CCoreEventCallback::on_candidate_hide(sclint ic, const sclchar *ic_uuid) -{ - if (g_event_callback.candidate_hide) { - g_event_callback.candidate_hide(ic, g_event_callback.candidate_hide_user_data); - } -} - -void CCoreEventCallback::on_update_lookup_table(SclCandidateTable &table) -{ - Eina_List *string_list = NULL; - - if (g_event_callback.lookup_table_changed) { - vector::iterator iter = table.candidate.begin(); - for (; iter != table.candidate.end(); ++iter) { - string_list = eina_list_append(string_list, iter->c_str()); - } - - g_event_callback.lookup_table_changed(string_list, g_event_callback.lookup_table_changed_user_data); - } -} - -void CCoreEventCallback::on_process_input_device_event(sclu32 &type, sclchar *data, size_t &len, sclu32 *ret) -{ - typedef struct { - int ecore_event_id; - ime_input_device_type_e device_type; - } ime_device_type_conv_table; - - ime_device_type_conv_table conv_table[] = { - { ECORE_EVENT_DETENT_ROTATE , IME_INPUT_DEVICE_TYPE_ROTARY }, - }; - - ime_input_device_type_e device_type = IME_INPUT_DEVICE_TYPE_UNKNOWN; - for (unsigned int loop = 0; loop < sizeof(conv_table) / sizeof(ime_device_type_conv_table); loop++) { - if ((unsigned int)(conv_table[loop].ecore_event_id) == type) { - device_type = conv_table[loop].device_type; - } - } - - if (g_event_callback.process_input_device_event) { - ime_device_event_s device_event; - device_event.device_type = device_type; - device_event.event_data = static_cast(data); - void *input_data = static_cast(&device_event); - void *user_data = g_event_callback.process_input_device_event_user_data; - - g_event_callback.process_input_device_event(device_type, input_data, user_data); - - if (ret) { - *ret = 1; - } - } else { - if (ret) { - *ret = 0; - } - } -} - -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); - } -} - -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); - } -} - -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); - } -} - -void CCoreEventCallback::on_set_optimization_hint(sclu32 hint) -{ - if (g_event_callback.optimization_hint_set) { - g_event_callback.optimization_hint_set((ime_optimization_hint_e)hint, g_event_callback.optimization_hint_set_user_data); - } -} -//LCOV_EXCL_STOP - -ime_error_e _check_privilege() -{ - char uid[16]; - ime_error_e ret = IME_ERROR_NONE; - - if (inputmethod_cynara_initialize() == false) { - LOGE("inputmethod_cynara_initialize () == false"); - return IME_ERROR_PERMISSION_DENIED; - } - - snprintf(uid, 16, "%d", getuid()); - if (check_privilege(uid, IME_PRIVILEGE) == false) { - LOGE("check_privilege(uid, IME_PRIVILEGE) == false. uid : %s", uid); - ret = IME_ERROR_PERMISSION_DENIED; - } - - inputmethod_cynara_finish(); - - return ret; -} - -//LCOV_EXCL_START -bool g_from_dotnet = false; -EXPORT_API int ime_set_dotnet_flag(bool set) -{ - ime_error_e retVal = IME_ERROR_NONE; - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - g_from_dotnet = set; - - return retVal; -} -//LCOV_EXCL_STOP - -EXPORT_API int ime_run(ime_callback_s *basic_cb, void *user_data) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (g_running) { - LOGE("inputmethod main loop is already running."); - return IME_ERROR_OPERATION_FAILED; - } - - if (!basic_cb) { - LOGE("basic callbacks pointer is null."); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - g_basic_callback = *basic_cb; - - if (!g_basic_callback.create || !g_basic_callback.terminate || - !g_basic_callback.show || !g_basic_callback.hide) { - LOGE("mandatory callback funtions are not set"); - memset(&g_basic_callback, 0, sizeof(ime_callback_s)); - memset(&g_event_callback, 0, sizeof(ime_event_callback_s)); - return IME_ERROR_NO_CALLBACK_FUNCTION; - } - - g_user_data = user_data; - g_running = true; - - if (g_from_dotnet) { - LOGD("ime_run is called from dotnet"); - return IME_ERROR_NONE; - } - - try { - g_core.run(); - } catch (...) { - LOGW("exception is thrown from g_core.run()\n"); - } - - memset(&g_basic_callback, 0, sizeof(ime_callback_s)); - memset(&g_event_callback, 0, sizeof(ime_event_callback_s)); - g_user_data = NULL; - g_running = false; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_focus_in_cb(ime_focus_in_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.focus_in = callback_func; - g_event_callback.focus_in_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_focus_out_cb(ime_focus_out_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.focus_out = callback_func; - g_event_callback.focus_out_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_surrounding_text_updated_cb(ime_surrounding_text_updated_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.surrounding_text_updated = callback_func; - g_event_callback.surrounding_text_updated_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_input_context_reset_cb(ime_input_context_reset_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.input_context_reset = callback_func; - g_event_callback.input_context_reset_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_cursor_position_updated_cb(ime_cursor_position_updated_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.cursor_position_updated = callback_func; - g_event_callback.cursor_position_updated_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_language_requested_cb(ime_language_requested_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.language_requested = callback_func; - g_event_callback.language_requested_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_language_set_cb(ime_language_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.language_set = callback_func; - g_event_callback.language_set_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_imdata_set_cb(ime_imdata_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.imdata_set = callback_func; - g_event_callback.imdata_set_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_imdata_requested_cb(ime_imdata_requested_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.imdata_requested = callback_func; - g_event_callback.imdata_requested_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_layout_set_cb(ime_layout_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.layout_set = callback_func; - g_event_callback.layout_set_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_return_key_type_set_cb(ime_return_key_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) return retVal; - - g_event_callback.return_key_type_set = callback_func; - g_event_callback.return_key_type_set_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_return_key_state_set_cb(ime_return_key_state_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.return_key_state_set = callback_func; - g_event_callback.return_key_state_set_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_geometry_requested_cb(ime_geometry_requested_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.geometry_requested = callback_func; - g_event_callback.geometry_requested_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_process_key_event_cb(ime_process_key_event_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.process_key_event = callback_func; - g_event_callback.process_key_event_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_process_key_event_with_keycode_cb(ime_process_key_event_with_keycode_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.process_key_event_with_keycode = callback_func; - g_event_callback.process_key_event_with_keycode_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_display_language_changed_cb(ime_display_language_changed_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.display_language_changed = callback_func; - g_event_callback.display_language_changed_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_rotation_degree_changed_cb(ime_rotation_degree_changed_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.rotation_degree_changed = callback_func; - g_event_callback.rotation_degree_changed_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_accessibility_state_changed_cb(ime_accessibility_state_changed_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.accessibility_state_changed = callback_func; - g_event_callback.accessibility_state_changed_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_option_window_created_cb(ime_option_window_created_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.option_window_created = callback_func; - g_event_callback.option_window_created_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_option_window_destroyed_cb(ime_option_window_destroyed_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.option_window_destroyed = callback_func; - g_event_callback.option_window_destroyed_user_data = user_data; - - return IME_ERROR_NONE; -} - -//LCOV_EXCL_START -EXPORT_API int ime_event_set_caps_mode_changed_cb(ime_caps_mode_changed_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.caps_mode_changed = callback_func; - g_event_callback.caps_mode_changed_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_candidate_show_cb(ime_candidate_show_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.candidate_show = callback_func; - g_event_callback.candidate_show_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_candidate_hide_cb(ime_candidate_hide_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.candidate_hide = callback_func; - g_event_callback.candidate_hide_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_lookup_table_changed_cb(ime_lookup_table_changed_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.lookup_table_changed = callback_func; - g_event_callback.lookup_table_changed_user_data = user_data; - - return IME_ERROR_NONE; -} -//LCOV_EXCL_STOP - -EXPORT_API int ime_send_key_event(ime_key_code_e keycode, ime_key_mask_e keymask, bool forward_key) -{ - 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; - - if (forward_key) - g_core.forward_key_event(-1, NULL, (sclu32)keycode, (sclu16)keymask); - else - g_core.send_key_event(-1, NULL, (sclu32)keycode, (sclu16)keymask); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_commit_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.commit_string(-1, NULL, str); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_show_preedit_string(void) -{ - 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.show_preedit_string(-1, NULL); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_hide_preedit_string(void) -{ - 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.hide_preedit_string(-1, NULL); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_update_preedit_string(const char *str, Eina_List *attrs) -{ - 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; - - scim::AttributeList attrv; - void *data = NULL; - ime_preedit_attribute *attr = NULL; - - if (attrs) { - EINA_LIST_FREE(attrs, data) { - attr = (ime_preedit_attribute *)data; - if (attr) { - attrv.push_back(scim::Attribute(attr->start, attr->length, (scim::AttributeType)attr->type, attr->value)); - free(attr); - } - } - } - - g_core.update_preedit_string(-1, NULL, str, attrv); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_request_surrounding_text(int maxlen_before, int maxlen_after) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!g_event_callback.surrounding_text_updated) { - LOGW("IME_ERROR_NO_CALLBACK_FUNCTION"); - return IME_ERROR_NO_CALLBACK_FUNCTION; - } - - 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.get_surrounding_text(NULL, maxlen_before, maxlen_after); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_delete_surrounding_text(int offset, int len) -{ - 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.delete_surrounding_text(offset, len); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_get_surrounding_text(int maxlen_before, int maxlen_after, char **text, int *cursor_pos) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!text || !cursor_pos) { - 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; - - int cursor = 0; - - int ret = g_core.get_surrounding_text(maxlen_before, maxlen_after, text, cursor); - if (ret == -1) { - LOGW("IME_ERROR_OUR_OF_MEMORY"); - return IME_ERROR_OUT_OF_MEMORY; - } - - if (cursor_pos) - *cursor_pos = cursor; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_set_selection(int start, int end) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (start < 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_selection(start, end); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_get_selected_text(char **text) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!text) { - 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.get_selection_text(text); - - return IME_ERROR_NONE; -} - -EXPORT_API Evas_Object* ime_get_main_window(void) -{ - ime_error_e retVal = IME_ERROR_NONE; - - Evas_Object *win = NULL; - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) { - LOGE("_check_privilege returned %d.", retVal); - set_last_result(retVal); - return NULL; - } - - if (!g_running) { - set_last_result(IME_ERROR_NOT_RUNNING); - LOGW("IME_ERROR_NOT_RUNNING"); - return NULL; - } - - win = static_cast(g_core.get_main_window()); - if (win) { - set_last_result(IME_ERROR_NONE); - } else { - set_last_result(IME_ERROR_OPERATION_FAILED); - LOGW("IME_ERROR_OPERATION_FAILED"); - } - - return win; -} - -EXPORT_API int ime_set_size(int portrait_width, int portrait_height, int landscape_width, int landscape_height) -{ - ime_error_e retVal = IME_ERROR_NONE; - - SclSize portrait_size, landscape_size; - - if (portrait_width < 1 || portrait_height < 1 || landscape_width < 1 || landscape_height < 1) { - 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; - - portrait_size.width = portrait_width; - portrait_size.height = portrait_height; - - landscape_size.width = landscape_width; - landscape_size.height = landscape_height; - - g_core.set_keyboard_size_hints(portrait_size, landscape_size); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_create_option_window(void) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!g_event_callback.option_window_created || !g_event_callback.option_window_destroyed) { - LOGW("ime_create_option_window_cb() and ime_destroy_option_window_cb() callback functions are not set."); - return IME_ERROR_NO_CALLBACK_FUNCTION; - } - - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (g_core.create_option_window()) { - return IME_ERROR_NONE; - } else { - LOGW("IME_ERROR_OPERATION_FAILED"); - return IME_ERROR_OPERATION_FAILED; - } -} - -EXPORT_API int ime_destroy_option_window(Evas_Object *window) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!g_event_callback.option_window_created || !g_event_callback.option_window_destroyed) { - LOGW("ime_create_option_window_cb() and ime_destroy_option_window_cb() callback functions are not set."); - return IME_ERROR_NO_CALLBACK_FUNCTION; - } - - if (!window) { - LOGW("Window pointer is null."); - 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.destroy_option_window(window); - - return IME_ERROR_NONE; -} - -//LCOV_EXCL_START -EXPORT_API int ime_set_imengine(const char *engine_id) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!engine_id) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - g_core.set_keyboard_ise_by_uuid(engine_id); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_flush_imengine(void) -{ - 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.flush_keyboard_ise(); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_reset_imengine(void) -{ - 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.reset_keyboard_ise(); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_update_input_context(unsigned int type, unsigned int value) -{ - 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_input_context(type, value); - - return IME_ERROR_NONE; -} -//LCOV_EXCL_STOP - -EXPORT_API int ime_request_hide(void) -{ - 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.request_ise_hide(); - - return IME_ERROR_NONE; -} - -//LCOV_EXCL_START -EXPORT_API int ime_initialize(void) -{ - ime_error_e retVal = IME_ERROR_NONE; - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - g_core.init(); - g_running = false; - - return retVal; -} - -EXPORT_API int ime_prepare(void) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (g_running) { - LOGE("inputmethod main loop is already running."); - return IME_ERROR_OPERATION_FAILED; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - g_core.prepare(); - - g_running = true; - - return retVal; -} - -EXPORT_API int ime_finalize(void) -{ - ime_error_e retVal = IME_ERROR_NONE; - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - g_core.fini(); - g_running = false; - memset(&g_basic_callback, 0, sizeof(ime_callback_s)); - memset(&g_event_callback, 0, sizeof(ime_event_callback_s)); - g_user_data = NULL; - - return retVal; -} - -EXPORT_API int ime_select_candidate(unsigned int index) -{ - 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.select_candidate(index); - - return IME_ERROR_NONE; -} -//LCOV_EXCL_STOP - -EXPORT_API int ime_send_private_command(const char *command) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!command) { - 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.send_private_command(command); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_commit_content(const char *content, const char *description, const char *mime_type) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!content || !description || !mime_type) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - 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.commit_content(content, description, mime_type); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_context_get_layout(ime_context_h context, Ecore_IMF_Input_Panel_Layout *layout) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!context || !layout) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - - *layout = context->layout; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_context_get_layout_variation(ime_context_h context, ime_layout_variation_e *layout_variation) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!context || !layout_variation) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - - *layout_variation = static_cast(context->layout_variation); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_context_get_cursor_position(ime_context_h context, int *cursor_pos) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!context || !cursor_pos) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - - *cursor_pos = context->cursor_pos; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_context_get_autocapital_type(ime_context_h context, Ecore_IMF_Autocapital_Type *autocapital_type) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!context || !autocapital_type) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - - *autocapital_type = context->autocapital_type; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_context_get_return_key_type(ime_context_h context, Ecore_IMF_Input_Panel_Return_Key_Type *return_key_type) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!context || !return_key_type) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - - *return_key_type = context->return_key_type; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_context_get_return_key_state(ime_context_h context, bool *return_key_state) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!context || !return_key_state) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - - *return_key_state = static_cast(context->return_key_disabled); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_context_get_prediction_mode(ime_context_h context, bool *prediction_mode) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!context || !prediction_mode) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - - *prediction_mode = static_cast(context->prediction_allow); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_context_get_password_mode(ime_context_h context, bool *password_mode) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!context || !password_mode) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - - *password_mode = static_cast(context->password_mode); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_context_get_input_hint(ime_context_h context, Ecore_IMF_Input_Hints *input_hint) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!context || !input_hint) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - - *input_hint = context->input_hint; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_context_get_bidi_direction(ime_context_h context, Ecore_IMF_BiDi_Direction *bidi) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!context || !bidi) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - - *bidi = context->bidi_direction; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_context_get_language(ime_context_h context, Ecore_IMF_Input_Panel_Lang *language) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!context || !language) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - - *language = context->language; - - return IME_ERROR_NONE; -} - -//LCOV_EXCL_START -EXPORT_API int ime_context_get_caps_mode(ime_context_h context, bool *caps_mode) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!context || !caps_mode) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - - *caps_mode = static_cast(context->caps_mode); - - return IME_ERROR_NONE; -} -//LCOV_EXCL_STOP - -EXPORT_API int ime_device_info_get_name(ime_device_info_h dev_info, char **dev_name) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!dev_info || !dev_name) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - - if (!dev_info->dev_name) - *dev_name = strdup(""); - else - *dev_name = strdup(dev_info->dev_name); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_device_info_get_class(ime_device_info_h dev_info, Ecore_IMF_Device_Class *dev_class) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!dev_info || !dev_class) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - - *dev_class = dev_info->dev_class; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_device_info_get_subclass(ime_device_info_h dev_info, Ecore_IMF_Device_Subclass *dev_subclass) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!dev_info || !dev_subclass) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (!g_running) { - LOGW("IME_ERROR_NOT_RUNNING"); - return IME_ERROR_NOT_RUNNING; - } - - *dev_subclass = dev_info->dev_subclass; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_process_input_device_event_cb(ime_process_input_device_event_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.process_input_device_event = callback_func; - g_event_callback.process_input_device_event_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_unset_process_input_device_event_cb(void) -{ - ime_error_e retVal = IME_ERROR_NONE; - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - g_event_callback.process_input_device_event = NULL; - g_event_callback.process_input_device_event_user_data = NULL; - - return IME_ERROR_NONE; -} - -/* Functions for Rotary input device event */ -EXPORT_API int ime_input_device_rotary_get_direction(ime_input_device_event_h event_handle, ime_input_device_rotary_direction_e *direction) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (!event_handle || !direction) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - ime_device_event_s *device_event = static_cast(event_handle); - if (device_event->device_type != IME_INPUT_DEVICE_TYPE_ROTARY) { - LOGW("IME_ERROR_INVALID_PARAMETER"); - return IME_ERROR_INVALID_PARAMETER; - } - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - if (!g_running) { - LOGW("IME_ERROR_OPERATION_FAILED"); - return IME_ERROR_OPERATION_FAILED; - } - - Ecore_Event_Detent_Rotate *rotary_device_event = - static_cast(device_event->event_data); - if (rotary_device_event) { - if (rotary_device_event->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) { - *direction = IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE; - } else if (rotary_device_event->direction == ECORE_DETENT_DIRECTION_COUNTER_CLOCKWISE) { - *direction = IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE; - } - } - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_prediction_hint_set_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) return retVal; - - g_event_callback.prediction_hint_set = callback_func; - g_event_callback.prediction_hint_set_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_event_set_mime_type_set_request_cb(ime_mime_type_set_request_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.mime_type_set = callback_func; - g_event_callback.mime_type_set_user_data = user_data; - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_set_floating_mode(bool floating_mode) -{ - 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.set_floating_mode(floating_mode); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_set_floating_drag_start(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.set_floating_drag_enabled(true); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_set_floating_drag_end(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.set_floating_drag_enabled(false); - - return IME_ERROR_NONE; -} - -//LCOV_EXCL_START -EXPORT_API int ime_set_window_creation_defer_flag(bool flag) -{ - ime_error_e retVal = IME_ERROR_NONE; - - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - g_core.set_window_creation_defer_flag(flag); - - return IME_ERROR_NONE; -} -//LCOV_EXCL_STOP - -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; -} - -//LCOV_EXCL_START -EXPORT_API int ime_event_set_optimization_hint_set_cb(ime_optimization_hint_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; - } - - LOGD(""); - retVal = _check_privilege(); - if (retVal != IME_ERROR_NONE) return retVal; - - LOGD(""); - g_event_callback.optimization_hint_set = callback_func; - g_event_callback.optimization_hint_set_user_data = user_data; - - return IME_ERROR_NONE; -} -//LCOV_EXCL_STOP - -EXPORT_API int ime_update_input_panel_event(ime_event_type_e type, unsigned int value) -{ - ime_error_e retVal = IME_ERROR_NONE; - - if (type < IME_EVENT_TYPE_LANGUAGE || type > IME_EVENT_TYPE_GEOMETRY) { - 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_input_context((sclu32)type, value); - - return IME_ERROR_NONE; -} - -EXPORT_API int ime_set_candidate_visibility_state(bool visible) -{ - 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; - - if (visible) - g_core.show_candidate_string(); - else - g_core.hide_candidate_string(); - - return IME_ERROR_NONE; -} diff --git a/src/privilege_checker.cpp b/src/privilege_checker.cpp deleted file mode 100644 index ba71cfc..0000000 --- a/src/privilege_checker.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "privilege_checker_private.h" - -#include -#include -#include -#include -#include - -#include -#include -#include - -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "INPUTMETHOD" - -namespace -{ - -cynara *p_cynara = NULL; - -} - -bool -inputmethod_cynara_initialize(void) -{ - int ret = cynara_initialize(&p_cynara, NULL); - if (ret != CYNARA_API_SUCCESS) - LOGW("Failed to call cynara_initialize (). ret : %d.", ret); - - return ret == CYNARA_API_SUCCESS; -} - -void -inputmethod_cynara_finish(void) -{ - if (p_cynara) - cynara_finish(p_cynara); - - p_cynara = NULL; -} - -bool -check_privilege(const char *uid, const char *privilege) -{ - FILE *fp = NULL; - char label_path[1024] = "/proc/self/attr/current"; - char smack_label[1024] = {'\0', }; - - if (!p_cynara) { - return false; - } - - fp = fopen(label_path, "r"); - if (fp != NULL) { - if (fread(smack_label, 1, sizeof(smack_label) - 1, fp) <= 0) - LOGW("Error : fread"); - - fclose(fp); - } - - pid_t pid = getpid(); - char *session = cynara_session_from_pid(pid); - int ret = cynara_check(p_cynara, smack_label, session, uid, privilege); - if (session) - free(session); - - if (ret != CYNARA_API_ACCESS_ALLOWED) { - LOGW("Access denied. The result of cynara_check() : %d.", ret); - return false; - } - return true; -} -