Add APIs for only internal use 41/112941/4
authorJihoon Kim <jihoon48.kim@samsung.com>
Fri, 3 Feb 2017 09:58:38 +0000 (18:58 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 6 Feb 2017 01:32:44 +0000 (10:32 +0900)
Change-Id: Iec3eefdae5dab5116cde525fd17fc1df4603df83
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
include/inputmethod_internal.h [new file with mode: 0644]
src/inputmethod.cpp

diff --git a/include/inputmethod_internal.h b/include/inputmethod_internal.h
new file mode 100644 (file)
index 0000000..910562a
--- /dev/null
@@ -0,0 +1,252 @@
+/*
+ * 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 <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @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
+ *
+ * @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 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()
+ */
+EXPORT_API int ime_event_set_caps_mode_changed_cb(ime_caps_mode_changed_cb callback_func, 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()
+ */
+EXPORT_API int ime_event_set_candidate_show_cb(ime_candidate_show_cb callback_func, void *user_data);
+
+EXPORT_API 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()
+ */
+EXPORT_API int ime_event_set_lookup_table_changed_cb(ime_lookup_table_changed_cb callback_func, void *user_data);
+
+/**
+ * @brief Set 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_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
+ */
+EXPORT_API int ime_set_imengine(const char *engine_id);
+
+/**
+ * @brief Flush 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
+ */
+EXPORT_API int ime_flush_imengine();
+
+/**
+ * @brief Reset 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
+ */
+EXPORT_API int ime_reset_imengine();
+
+/**
+ * @brief Send 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
+ */
+EXPORT_API int ime_select_candidate(unsigned int index);
+
+/**
+ * @brief Send 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
+ */
+EXPORT_API int ime_update_input_context(unsigned int type, unsigned int value);
+
+/**
+ * @brief Send the request to hide IME.
+ *
+ * @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
+ */
+EXPORT_API int ime_request_hide();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_UIX_INPUTMETHOD_INTERNAL_H__ */
+
index 88c4393..3c39f31 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <vector>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -23,6 +24,9 @@
 #include <privilege_checker_private.h>
 #include "inputmethod_private.h"
 #include <inputmethod.h>
+#include "inputmethod_internal.h"
+
+using namespace std;
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -58,6 +62,10 @@ class CCoreEventCallback : public ISCLCoreEventCallback
     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);
 #ifdef TIZEN_WEARABLE
     void on_process_input_device_event(sclu32 &type, sclchar *data, size_t &len, sclu32 *ret);
 #endif
@@ -84,6 +92,10 @@ typedef struct
     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;
 #ifdef TIZEN_WEARABLE
     ime_process_input_device_event_cb process_input_device_event;   /**< Called when the event is received from the unconventional input devices */
 #endif
@@ -106,6 +118,10 @@ typedef struct
     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;
 #ifdef TIZEN_WEARABLE
     void *process_input_device_event_user_data;
 #endif
@@ -358,6 +374,41 @@ void CCoreEventCallback::on_check_option_window_availability(sclboolean *ret)
     }
 }
 
+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<string>::iterator iter = table.candidate.begin();
+        for (; iter != table.candidate.end(); ++iter) {
+            string_list = eina_list_append(string_list, strdup(iter->c_str()));
+        }
+
+        g_event_callback.lookup_table_changed(string_list, g_event_callback.lookup_table_changed_user_data);
+    }
+}
+
 #ifdef TIZEN_WEARABLE
 void CCoreEventCallback::on_process_input_device_event(sclu32 &type, sclchar *data, size_t &len, sclu32 *ret)
 {
@@ -955,6 +1006,90 @@ int ime_event_set_option_window_destroyed_cb(ime_option_window_destroyed_cb call
     return IME_ERROR_NONE;
 }
 
+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) {
+        LOGE("_check_privilege returned %d.", retVal);
+        return retVal;
+    }
+
+    g_event_callback.caps_mode_changed = callback_func;
+    g_event_callback.caps_mode_changed_user_data = user_data;
+
+    return IME_ERROR_NONE;
+}
+
+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) {
+        LOGE("_check_privilege returned %d.", retVal);
+        return retVal;
+    }
+
+    g_event_callback.candidate_show = callback_func;
+    g_event_callback.candidate_show_user_data = user_data;
+
+    return IME_ERROR_NONE;
+}
+
+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) {
+        LOGE("_check_privilege returned %d.", retVal);
+        return retVal;
+    }
+
+    g_event_callback.candidate_hide = callback_func;
+    g_event_callback.candidate_hide_user_data = user_data;
+
+    return IME_ERROR_NONE;
+}
+
+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) {
+        LOGE("_check_privilege returned %d.", retVal);
+        return retVal;
+    }
+
+    g_event_callback.lookup_table_changed = callback_func;
+    g_event_callback.lookup_table_changed_user_data = user_data;
+
+    return IME_ERROR_NONE;
+}
+
 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;
@@ -1312,6 +1447,126 @@ int ime_destroy_option_window(Evas_Object *window)
     return IME_ERROR_NONE;
 }
 
+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) {
+        LOGE("_check_privilege returned %d.", retVal);
+        return retVal;
+    }
+
+    g_core.set_keyboard_ise_by_uuid(engine_id);
+
+    return IME_ERROR_NONE;
+}
+
+int ime_flush_imengine()
+{
+    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) {
+        LOGE("_check_privilege returned %d.", retVal);
+        return retVal;
+    }
+
+    g_core.flush_keyboard_ise();
+
+    return IME_ERROR_NONE;
+}
+
+int ime_reset_imengine()
+{
+    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) {
+        LOGE("_check_privilege returned %d.", retVal);
+        return retVal;
+    }
+
+    g_core.reset_keyboard_ise();
+
+    return IME_ERROR_NONE;
+}
+
+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) {
+        LOGE("_check_privilege returned %d.", retVal);
+        return retVal;
+    }
+
+    g_core.update_input_context(type, value);
+
+    return IME_ERROR_NONE;
+}
+
+int ime_request_hide()
+{
+    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) {
+        LOGE("_check_privilege returned %d.", retVal);
+        return retVal;
+    }
+
+    g_core.request_ise_hide();
+
+    return IME_ERROR_NONE;
+}
+
+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) {
+        LOGE("_check_privilege returned %d.", retVal);
+        return retVal;
+    }
+
+    g_core.select_candidate(index);
+
+    return IME_ERROR_NONE;
+}
+
 int ime_context_get_layout(ime_context_h context, Ecore_IMF_Input_Panel_Layout *layout)
 {
     ime_error_e retVal = IME_ERROR_NONE;