From 309308469304fb046cb679bbbb8a9aca15d86414 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Fri, 12 May 2017 17:28:40 +0900 Subject: [PATCH] Add internal interfaces for supporting uix-inputmethod Change-Id: I740735100dd45137eae36c9ad125f0c1749b89f1 --- include/inputmethod_internal.h | 49 +++++++++++++++++++++++++++++++++++++++ src/inputmethod.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) diff --git a/include/inputmethod_internal.h b/include/inputmethod_internal.h index 7668d53..3fc03e8 100644 --- a/include/inputmethod_internal.h +++ b/include/inputmethod_internal.h @@ -274,6 +274,55 @@ EXPORT_API int ime_update_input_context(unsigned int type, unsigned int value); */ EXPORT_API int ime_request_hide(); +/** + * @brief Explicitly request IME to initialize + * + * @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 + */ +EXPORT_API int ime_initialize(); + +/** + * @brief Request 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 + */ +EXPORT_API int ime_prepare(); + +/** + * @brief Explicitly request IME to finalize + * + * @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 + */ +EXPORT_API int ime_finalize(); + #ifdef __cplusplus } #endif diff --git a/src/inputmethod.cpp b/src/inputmethod.cpp index 4f0b754..5b4f39a 100644 --- a/src/inputmethod.cpp +++ b/src/inputmethod.cpp @@ -1467,6 +1467,58 @@ int ime_request_hide() return IME_ERROR_NONE; } +int ime_initialize() +{ + ime_error_e retVal = IME_ERROR_NONE; + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) { + LOGE("_check_privilege returned %d.", retVal); + return retVal; + } + + g_core.init(); + + return retVal; +} + +int ime_prepare() +{ + 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) { + LOGE("_check_privilege returned %d.", retVal); + return retVal; + } + + g_core.prepare(); + + g_running = true; + + return retVal; +} + +int ime_finalize() +{ + ime_error_e retVal = IME_ERROR_NONE; + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) { + LOGE("_check_privilege returned %d.", retVal); + return retVal; + } + + g_core.fini(); + + return retVal; +} + int ime_select_candidate(unsigned int index) { ime_error_e retVal = IME_ERROR_NONE; -- 2.7.4