Add internal interfaces for supporting uix-inputmethod 93/135693/2
authorJi-hoon Lee <dalton.lee@samsung.com>
Fri, 12 May 2017 08:28:40 +0000 (17:28 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Mon, 26 Jun 2017 07:51:21 +0000 (16:51 +0900)
Change-Id: I740735100dd45137eae36c9ad125f0c1749b89f1

include/inputmethod_internal.h
src/inputmethod.cpp

index 7668d5384eedc75d2f6982f48de9ea1e8e0f1192..3fc03e882bd9b58b1f42c58964b979d73bfc4850 100644 (file)
@@ -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
index 4f0b7546e97c604055925724daf8972228392f7b..5b4f39a2de836a78024ea57f95d684d76dad9c26 100644 (file)
@@ -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;