mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-27 00:41:04 +00:00
输入法 ffi 桥接层代码函数名变更
Signed-off-by: PipiSummer <xiatian44@huawei.com> Change-Id: I2e570c8f48fa8cdd8d7e7bf2b6d0719815b6b82b
This commit is contained in:
parent
7b03e79976
commit
0d071e18ff
70
.vscode/settings.json
vendored
70
.vscode/settings.json
vendored
@ -1,70 +0,0 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"algorithm": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"bitset": "cpp",
|
||||
"cctype": "cpp",
|
||||
"chrono": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"codecvt": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"csignal": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"deque": "cpp",
|
||||
"list": "cpp",
|
||||
"map": "cpp",
|
||||
"set": "cpp",
|
||||
"string": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"random": "cpp",
|
||||
"ratio": "cpp",
|
||||
"regex": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"fstream": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"numbers": "cpp",
|
||||
"ostream": "cpp",
|
||||
"ranges": "cpp",
|
||||
"semaphore": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"thread": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"variant": "cpp"
|
||||
}
|
||||
}
|
2
BUILD.gn
2
BUILD.gn
@ -21,11 +21,11 @@ group("imf_packages") {
|
||||
"etc/init:inputmethodservice.cfg",
|
||||
"etc/para:inputmethod.para",
|
||||
"etc/para:inputmethod_para",
|
||||
"frameworks/cj:cj_inputmethod_ffi",
|
||||
"frameworks/js/napi/inputmethodability:inputmethodengine",
|
||||
"frameworks/js/napi/inputmethodclient:inputmethod",
|
||||
"frameworks/js/napi/inputmethodlist:inputmethodlist",
|
||||
"frameworks/js/napi/keyboardpanelmanager:keyboardpanelmanager",
|
||||
"frameworks/cj:cj_inputmethod_ffi",
|
||||
"interfaces/inner_api/inputmethod_ability:inputmethod_ability",
|
||||
"interfaces/inner_api/inputmethod_controller:inputmethod_client",
|
||||
"profile:inputmethod_inputmethod_sa_profiles",
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2022-2023 Huawei Device Co., Ltd.
|
||||
# Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
# 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
|
||||
@ -42,17 +42,17 @@ ohos_shared_library("cj_inputmethod_ffi") {
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
"src/cj_input_method_controller.cpp",
|
||||
"src/cj_input_method_textchanged_listener.cpp",
|
||||
"src/input_method_ffi.cpp",
|
||||
"src/setting_listeners.cpp",
|
||||
"src/utils.cpp",
|
||||
"src/cj_input_method_controller.cpp",
|
||||
"src/cj_input_method_textchanged_listener.cpp"
|
||||
]
|
||||
|
||||
configs = [ ":imf_config" ]
|
||||
|
||||
deps = [
|
||||
"${inputmethod_path}/frameworks/js/napi/common:inputmethod_js_common",
|
||||
"${inputmethod_path}/common:inputmethod_common",
|
||||
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client",
|
||||
]
|
||||
|
||||
|
@ -60,15 +60,27 @@ private:
|
||||
static constexpr int32_t MAX_TIMEOUT = 2500;
|
||||
void RegisterListener(int8_t type, int64_t id);
|
||||
void UnRegisterListener(int8_t type);
|
||||
void InitInsertText(int64_t id);
|
||||
void InitDeleteRight(int64_t id);
|
||||
void InitDeleteLeft(int64_t id);
|
||||
void InitSendKeyboardStatus(int64_t id);
|
||||
void InitSendFunctionKey(int64_t id);
|
||||
void InitMoveCursor(int64_t id);
|
||||
void InitHandleExtendAction(int64_t id);
|
||||
void InitGetLeftText(int64_t id);
|
||||
void InitGetRightText(int64_t id);
|
||||
void InitSelectByRange(int64_t id);
|
||||
void InitSelectByMovement(int64_t id);
|
||||
void InitGetTextIndexAtCursor(int64_t id);
|
||||
std::recursive_mutex mutex_;
|
||||
std::function<void(int32_t start, int32_t end)> onSelectByRange;
|
||||
std::function<void(Range)> onSelectByRange;
|
||||
std::function<void(int32_t)> onSelectByMovement;
|
||||
std::function<void(const char* text)> insertText;
|
||||
std::function<void(int32_t length)> deleteRight;
|
||||
std::function<void(int32_t length)> deleteLeft;
|
||||
std::function<void(int64_t status)> sendKeyboardStatus;
|
||||
std::function<void(int64_t functionKey)> sendFunctionKey;
|
||||
std::function<void(int64_t direction)> moveCursor;
|
||||
std::function<void(int32_t status)> sendKeyboardStatus;
|
||||
std::function<void(int32_t functionKey)> sendFunctionKey;
|
||||
std::function<void(int32_t direction)> moveCursor;
|
||||
std::function<void(int32_t action)> handleExtendAction;
|
||||
std::function<char*(int32_t number)> getLeftText;
|
||||
std::function<char*(int32_t number)> getRightText;
|
||||
|
@ -19,34 +19,35 @@
|
||||
#include "input_method_ffi_structs.h"
|
||||
|
||||
extern "C" {
|
||||
FFI_EXPORT int32_t CJ_GetDefaultInputMethod(CInputMethodProperty &props);
|
||||
FFI_EXPORT int32_t CJ_GetCurrentInputMethod(CInputMethodProperty &props);
|
||||
FFI_EXPORT int32_t CJ_SwitchInputMethod(bool &result, CInputMethodProperty props);
|
||||
FFI_EXPORT int32_t CJ_SwitchCurrentInputMethodSubtype(bool &result, CInputMethodSubtype target);
|
||||
FFI_EXPORT int32_t CJ_GetCurrentInputMethodSubtype(CInputMethodSubtype &props);
|
||||
FFI_EXPORT int32_t CJ_SwitchCurrentInputMethodAndSubtype(bool &result, CInputMethodProperty target, CInputMethodSubtype subtype);
|
||||
FFI_EXPORT int32_t CJ_GetSystemInputMethodConfigAbility(CElementName &elem);
|
||||
FFI_EXPORT RetInputMethodSubtype CJ_ListInputMethodSubtype(CInputMethodProperty props);
|
||||
FFI_EXPORT RetInputMethodSubtype CJ_ListCurrentInputMethodSubtype();
|
||||
FFI_EXPORT RetInputMethodProperty CJ_GetInputMethods(bool enable);
|
||||
FFI_EXPORT RetInputMethodProperty CJ_GetAllInputMethods();
|
||||
FFI_EXPORT int32_t CJ_InputMethodSettingOn(uint32_t type, void (*func)(CInputMethodProperty, CInputMethodSubtype));
|
||||
FFI_EXPORT int32_t CJ_InputMethodSettingOff(uint32_t type);
|
||||
FFI_EXPORT int32_t CJ_ShowOptionalInputMethods(bool& result);
|
||||
FFI_EXPORT int32_t CJ_InputMethodControllerOn(int8_t type, int64_t id);
|
||||
FFI_EXPORT int32_t CJ_InputMethodControllerOff(int8_t type);
|
||||
FFI_EXPORT int32_t FfiInputMethodGetDefaultInputMethod(CInputMethodProperty &props);
|
||||
FFI_EXPORT int32_t FfiInputMethodGetCurrentInputMethod(CInputMethodProperty &props);
|
||||
FFI_EXPORT int32_t FfiInputMethodSwitchInputMethod(bool &result, CInputMethodProperty props);
|
||||
FFI_EXPORT int32_t FfiInputMethodSwitchCurrentInputMethodSubtype(bool &result, CInputMethodSubtype target);
|
||||
FFI_EXPORT int32_t FfiInputMethodGetCurrentInputMethodSubtype(CInputMethodSubtype &props);
|
||||
FFI_EXPORT int32_t FfiInputMethodSwitchCurrentInputMethodAndSubtype(bool &result, CInputMethodProperty target,
|
||||
CInputMethodSubtype subtype);
|
||||
FFI_EXPORT int32_t FfiInputMethodGetSystemInputMethodConfigAbility(CElementName &elem);
|
||||
FFI_EXPORT RetInputMethodSubtype FfiInputMethodSettingListInputMethodSubtype(CInputMethodProperty props);
|
||||
FFI_EXPORT RetInputMethodSubtype FfiInputMethodSettingListCurrentInputMethodSubtype();
|
||||
FFI_EXPORT RetInputMethodProperty FfiInputMethodSettingGetInputMethods(bool enable);
|
||||
FFI_EXPORT RetInputMethodProperty FfiInputMethodSettingGetAllInputMethods();
|
||||
FFI_EXPORT int32_t FfiInputMethodSettingOn(uint32_t type, void (*func)(CInputMethodProperty, CInputMethodSubtype));
|
||||
FFI_EXPORT int32_t FfiInputMethodSettingOff(uint32_t type);
|
||||
FFI_EXPORT int32_t FfiInputMethodSettingShowOptionalInputMethods(bool& result);
|
||||
FFI_EXPORT int32_t FfiInputMethodControllerOn(int8_t type, int64_t id);
|
||||
FFI_EXPORT int32_t FfiInputMethodControllerOff(int8_t type);
|
||||
|
||||
FFI_EXPORT int32_t OHOSFfiAttach(bool showKeyboard, CTextConfig txtCfg);
|
||||
FFI_EXPORT int32_t OHOSFfiDetach();
|
||||
FFI_EXPORT int32_t OHOSFfiShowTextInput();
|
||||
FFI_EXPORT int32_t OHOSFfiHideTextInput();
|
||||
FFI_EXPORT int32_t OHOSFfiSetCallingWindow(uint32_t windowId);
|
||||
FFI_EXPORT int32_t OHOSFfiUpdateCursor(CCursorInfo cursor);
|
||||
FFI_EXPORT int32_t OHOSFfiChangeSelection(char *text, int32_t start, int32_t end);
|
||||
FFI_EXPORT int32_t OHOSFfiUpdateAttribute(CInputAttribute inputAttribute);
|
||||
FFI_EXPORT int32_t OHOSFfiShowSoftKeyboard();
|
||||
FFI_EXPORT int32_t OHOSFfiHideSoftKeyboard();
|
||||
FFI_EXPORT int32_t OHOSFfiStopInputSession();
|
||||
FFI_EXPORT int32_t FfiInputMethodControllerAttach(bool showKeyboard, CTextConfig txtCfg);
|
||||
FFI_EXPORT int32_t FfiInputMethodControllerDetach();
|
||||
FFI_EXPORT int32_t FfiInputMethodControllerShowTextInput();
|
||||
FFI_EXPORT int32_t FfiInputMethodControllerHideTextInput();
|
||||
FFI_EXPORT int32_t FfiInputMethodControllerSetCallingWindow(uint32_t windowId);
|
||||
FFI_EXPORT int32_t FfiInputMethodControllerUpdateCursor(CCursorInfo cursor);
|
||||
FFI_EXPORT int32_t FfiInputMethodControllerChangeSelection(char *text, int32_t start, int32_t end);
|
||||
FFI_EXPORT int32_t FfiInputMethodControllerUpdateAttribute(CInputAttribute inputAttribute);
|
||||
FFI_EXPORT int32_t FfiInputMethodControllerShowSoftKeyboard();
|
||||
FFI_EXPORT int32_t FfiInputMethodControllerHideSoftKeyboard();
|
||||
FFI_EXPORT int32_t FfiInputMethodControllerStopInputSession();
|
||||
}
|
||||
|
||||
#endif // INPUT_METHOD_FFI_H
|
@ -39,6 +39,7 @@ const int8_t GET_LEFT_TEXT = 7;
|
||||
const int8_t GET_RIGHT_TEXT = 8;
|
||||
const int8_t GET_TEXT_INDEX = 9;
|
||||
const int8_t SELECT_BY_MOVEMENT = 10;
|
||||
const int8_t SELECT_BY_RANGE = 11;
|
||||
|
||||
std::shared_ptr<CjInputMethodController> CjInputMethodController::GetInstance()
|
||||
{
|
||||
@ -56,7 +57,7 @@ std::shared_ptr<CjInputMethodController> CjInputMethodController::GetInstance()
|
||||
int32_t CjInputMethodController::Attach(const CTextConfig &txtCfg, bool showKeyboard)
|
||||
{
|
||||
auto textListener = CjInputMethodTextChangedListener::GetInstance();
|
||||
if (!textListener) {
|
||||
if (textListener == nullptr) {
|
||||
IMSA_HILOGE("failed to create CjInputMethodTextChangedListener!");
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
@ -79,7 +80,7 @@ int32_t CjInputMethodController::Attach(const CTextConfig &txtCfg, bool showKeyb
|
||||
};
|
||||
|
||||
auto controller = InputMethodController::GetInstance();
|
||||
if (!controller) {
|
||||
if (controller == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
return controller->Attach(textListener, showKeyboard, textCfg);
|
||||
@ -88,7 +89,7 @@ int32_t CjInputMethodController::Attach(const CTextConfig &txtCfg, bool showKeyb
|
||||
int32_t CjInputMethodController::Detach()
|
||||
{
|
||||
auto controller = InputMethodController::GetInstance();
|
||||
if (!controller) {
|
||||
if (controller == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
return controller->Close();
|
||||
@ -97,7 +98,7 @@ int32_t CjInputMethodController::Detach()
|
||||
int32_t CjInputMethodController::ShowTextInput()
|
||||
{
|
||||
auto controller = InputMethodController::GetInstance();
|
||||
if (!controller) {
|
||||
if (controller == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
return controller->ShowTextInput();
|
||||
@ -106,7 +107,7 @@ int32_t CjInputMethodController::ShowTextInput()
|
||||
int32_t CjInputMethodController::HideTextInput()
|
||||
{
|
||||
auto controller = InputMethodController::GetInstance();
|
||||
if (!controller) {
|
||||
if (controller == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
return controller->HideTextInput();
|
||||
@ -115,7 +116,7 @@ int32_t CjInputMethodController::HideTextInput()
|
||||
int32_t CjInputMethodController::SetCallingWindow(uint32_t windowId)
|
||||
{
|
||||
auto controller = InputMethodController::GetInstance();
|
||||
if (!controller) {
|
||||
if (controller == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
return controller->SetCallingWindow(windowId);
|
||||
@ -124,7 +125,7 @@ int32_t CjInputMethodController::SetCallingWindow(uint32_t windowId)
|
||||
int32_t CjInputMethodController::UpdateCursor(const CCursorInfo &cursor)
|
||||
{
|
||||
auto controller = InputMethodController::GetInstance();
|
||||
if (!controller) {
|
||||
if (controller == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
CursorInfo cursorInfo = {
|
||||
@ -139,7 +140,7 @@ int32_t CjInputMethodController::UpdateCursor(const CCursorInfo &cursor)
|
||||
int32_t CjInputMethodController::ChangeSelection(const std::string &text, int32_t start, int32_t end)
|
||||
{
|
||||
auto controller = InputMethodController::GetInstance();
|
||||
if (!controller) {
|
||||
if (controller == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
|
||||
@ -150,7 +151,7 @@ int32_t CjInputMethodController::ChangeSelection(const std::string &text, int32_
|
||||
int32_t CjInputMethodController::UpdateAttribute(const CInputAttribute &inputAttribute)
|
||||
{
|
||||
auto controller = InputMethodController::GetInstance();
|
||||
if (!controller) {
|
||||
if (controller == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
Configuration config = Configuration();
|
||||
@ -162,7 +163,7 @@ int32_t CjInputMethodController::UpdateAttribute(const CInputAttribute &inputAtt
|
||||
int32_t CjInputMethodController::ShowSoftKeyboard()
|
||||
{
|
||||
auto controller = InputMethodController::GetInstance();
|
||||
if (!controller) {
|
||||
if (controller == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
return controller->ShowSoftKeyboard();
|
||||
@ -171,7 +172,7 @@ int32_t CjInputMethodController::ShowSoftKeyboard()
|
||||
int32_t CjInputMethodController::HideSoftKeyboard()
|
||||
{
|
||||
auto controller = InputMethodController::GetInstance();
|
||||
if (!controller) {
|
||||
if (controller == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
return controller->HideSoftKeyboard();
|
||||
@ -180,7 +181,7 @@ int32_t CjInputMethodController::HideSoftKeyboard()
|
||||
int32_t CjInputMethodController::StopInputSession()
|
||||
{
|
||||
auto controller = InputMethodController::GetInstance();
|
||||
if (!controller) {
|
||||
if (controller == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
return controller->StopInputSession();
|
||||
@ -190,90 +191,44 @@ void CjInputMethodController::RegisterListener(int8_t type, int64_t id)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
switch (type) {
|
||||
case INSERT_TEXT: {
|
||||
auto callback = reinterpret_cast<void(*)(const char*)>(id);
|
||||
insertText = [lambda = CJLambda::Create(callback)](const char* text) -> void {
|
||||
lambda(text);
|
||||
};
|
||||
case INSERT_TEXT:
|
||||
InitInsertText(id);
|
||||
break;
|
||||
}
|
||||
case DELETE_LEFT: {
|
||||
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||
deleteLeft = [lambda = CJLambda::Create(callback)](int32_t length) -> void {
|
||||
lambda(length);
|
||||
};
|
||||
case DELETE_LEFT:
|
||||
InitDeleteRight(id);
|
||||
break;
|
||||
}
|
||||
case DELETE_RIGHT: {
|
||||
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||
deleteRight = [lambda = CJLambda::Create(callback)](int32_t length) -> void {
|
||||
lambda(length);
|
||||
};
|
||||
case DELETE_RIGHT:
|
||||
InitDeleteLeft(id);
|
||||
break;
|
||||
}
|
||||
case SEND_KEYBOARD_STATUS: {
|
||||
auto callback = reinterpret_cast<void(*)(int64_t)>(id);
|
||||
sendKeyboardStatus = [lambda = CJLambda::Create(callback)](int64_t status) -> void {
|
||||
lambda(status);
|
||||
};
|
||||
case SEND_KEYBOARD_STATUS:
|
||||
InitSendKeyboardStatus(id);
|
||||
break;
|
||||
}
|
||||
case SEND_FUNCTION_KEY: {
|
||||
auto callback = reinterpret_cast<void(*)(int64_t)>(id);
|
||||
sendFunctionKey = [lambda = CJLambda::Create(callback)](int64_t functionKey) -> void {
|
||||
lambda(functionKey);
|
||||
};
|
||||
case SEND_FUNCTION_KEY:
|
||||
InitSendFunctionKey(id);
|
||||
break;
|
||||
}
|
||||
case MOVE_CURSOR: {
|
||||
auto callback = reinterpret_cast<void(*)(int64_t)>(id);
|
||||
moveCursor = [lambda = CJLambda::Create(callback)](int64_t direction) -> void {
|
||||
lambda(direction);
|
||||
};
|
||||
case MOVE_CURSOR:
|
||||
InitMoveCursor(id);
|
||||
break;
|
||||
}
|
||||
case HANDLE_EXTEND_ACTION: {
|
||||
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||
handleExtendAction = [lambda = CJLambda::Create(callback)](int32_t action) -> void {
|
||||
lambda(action);
|
||||
};
|
||||
case HANDLE_EXTEND_ACTION:
|
||||
InitHandleExtendAction(id);
|
||||
break;
|
||||
}
|
||||
case GET_LEFT_TEXT: {
|
||||
auto callback = reinterpret_cast<char*(*)(int32_t)>(id);
|
||||
getLeftText = [lambda = CJLambda::Create(callback)](int32_t number) -> char* {
|
||||
return lambda(number);
|
||||
};
|
||||
case GET_LEFT_TEXT:
|
||||
InitGetLeftText(id);
|
||||
break;
|
||||
}
|
||||
case GET_RIGHT_TEXT: {
|
||||
auto callback = reinterpret_cast<char*(*)(int32_t)>(id);
|
||||
getRightText = [lambda = CJLambda::Create(callback)](int32_t number) -> char* {
|
||||
return lambda(number);
|
||||
};
|
||||
case GET_RIGHT_TEXT:
|
||||
InitGetRightText(id);
|
||||
break;
|
||||
}
|
||||
case GET_TEXT_INDEX: {
|
||||
auto callback = reinterpret_cast<int32_t(*)()>(id);
|
||||
getTextIndexAtCursor = [lambda = CJLambda::Create(callback)](void) -> int32_t {
|
||||
return lambda();
|
||||
};
|
||||
case GET_TEXT_INDEX:
|
||||
InitGetTextIndexAtCursor(id);
|
||||
break;
|
||||
}
|
||||
case SELECT_BY_MOVEMENT: {
|
||||
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||
onSelectByMovement = [lambda = CJLambda::Create(callback)](int32_t direction) -> void {
|
||||
lambda(direction);
|
||||
};
|
||||
case SELECT_BY_MOVEMENT:
|
||||
InitSelectByMovement(id);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
auto callback = reinterpret_cast<void(*)(int32_t, int32_t)>(id);
|
||||
onSelectByRange = [lambda = CJLambda::Create(callback)](int32_t start, int32_t end) -> void {
|
||||
lambda(start, end);
|
||||
};
|
||||
case SELECT_BY_RANGE:
|
||||
InitSelectByRange(id);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -314,16 +269,18 @@ void CjInputMethodController::UnRegisterListener(int8_t type)
|
||||
case SELECT_BY_MOVEMENT:
|
||||
onSelectByMovement = nullptr;
|
||||
break;
|
||||
default:
|
||||
case SELECT_BY_RANGE:
|
||||
onSelectByRange = nullptr;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t CjInputMethodController::Subscribe(int8_t type, int64_t id)
|
||||
{
|
||||
auto controller = CjInputMethodController::GetInstance();
|
||||
if (!controller) {
|
||||
if (controller == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
controller->RegisterListener(type, id);
|
||||
@ -333,7 +290,7 @@ int32_t CjInputMethodController::Subscribe(int8_t type, int64_t id)
|
||||
int32_t CjInputMethodController::Unsubscribe(int8_t type)
|
||||
{
|
||||
auto controller = CjInputMethodController::GetInstance();
|
||||
if (!controller) {
|
||||
if (controller == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
controller->UnRegisterListener(type);
|
||||
@ -342,21 +299,22 @@ int32_t CjInputMethodController::Unsubscribe(int8_t type)
|
||||
|
||||
void CjInputMethodController::OnSelectByRange(int32_t start, int32_t end)
|
||||
{
|
||||
if (onSelelctByRange == nullptr) {
|
||||
IMSA_HILOGI("onSelelctByRange null");
|
||||
if (onSelectByRange == nullptr) {
|
||||
IMSA_HILOGD("onSelelctByRange null");
|
||||
return;
|
||||
}
|
||||
IMSA_HILOGI("onSelelctByRange runs");
|
||||
return onSelectByRange(start, end);
|
||||
IMSA_HILOGD("onSelelctByRange runs");
|
||||
Range range = { .start = start, .end = end };
|
||||
return onSelectByRange(range);
|
||||
}
|
||||
|
||||
void CjInputMethodController::OnSelectByMovement(int32_t direction)
|
||||
{
|
||||
if (onSelectByMovement == nullptr) {
|
||||
IMSA_HILOGI("onSelectByMovement null");
|
||||
IMSA_HILOGD("onSelectByMovement null");
|
||||
return;
|
||||
}
|
||||
IMSA_HILOGI("onSelectByMovement runs");
|
||||
IMSA_HILOGD("onSelectByMovement runs");
|
||||
return onSelectByMovement(direction);
|
||||
}
|
||||
|
||||
@ -368,10 +326,11 @@ void CjInputMethodController::InsertText(const std::u16string &text)
|
||||
return;
|
||||
}
|
||||
if (insertText == nullptr) {
|
||||
IMSA_HILOGI("insertText null");
|
||||
IMSA_HILOGD("insertText null");
|
||||
free(insertTxt);
|
||||
return;
|
||||
}
|
||||
IMSA_HILOGI("insertText runs");
|
||||
IMSA_HILOGD("insertText runs");
|
||||
insertText(insertTxt);
|
||||
free(insertTxt);
|
||||
return;
|
||||
@ -380,10 +339,10 @@ void CjInputMethodController::InsertText(const std::u16string &text)
|
||||
void CjInputMethodController::DeleteRight(int32_t length)
|
||||
{
|
||||
if (deleteRight == nullptr) {
|
||||
IMSA_HILOGI("deleteRight null");
|
||||
IMSA_HILOGD("deleteRight null");
|
||||
return;
|
||||
}
|
||||
IMSA_HILOGI("deleteRight runs");
|
||||
IMSA_HILOGD("deleteRight runs");
|
||||
deleteRight(length);
|
||||
return;
|
||||
}
|
||||
@ -391,10 +350,10 @@ void CjInputMethodController::DeleteRight(int32_t length)
|
||||
void CjInputMethodController::DeleteLeft(int32_t length)
|
||||
{
|
||||
if (deleteLeft == nullptr) {
|
||||
IMSA_HILOGI("deleteLeft null");
|
||||
IMSA_HILOGD("deleteLeft null");
|
||||
return;
|
||||
}
|
||||
IMSA_HILOGI("deleteLeft runs");
|
||||
IMSA_HILOGD("deleteLeft runs");
|
||||
deleteLeft(length);
|
||||
return;
|
||||
}
|
||||
@ -402,11 +361,11 @@ void CjInputMethodController::DeleteLeft(int32_t length)
|
||||
void CjInputMethodController::SendKeyboardStatus(const KeyboardStatus &status)
|
||||
{
|
||||
if (sendKeyboardStatus == nullptr) {
|
||||
IMSA_HILOGI("sendKeyboardStatus null");
|
||||
IMSA_HILOGD("sendKeyboardStatus null");
|
||||
return;
|
||||
}
|
||||
IMSA_HILOGI("sendKeyboardStatus runs");
|
||||
auto statusNum = static_cast<int64_t>(status);
|
||||
IMSA_HILOGD("sendKeyboardStatus runs");
|
||||
auto statusNum = static_cast<int32_t>(status);
|
||||
sendKeyboardStatus(statusNum);
|
||||
return;
|
||||
}
|
||||
@ -414,11 +373,11 @@ void CjInputMethodController::SendKeyboardStatus(const KeyboardStatus &status)
|
||||
void CjInputMethodController::SendFunctionKey(const FunctionKey &functionKey)
|
||||
{
|
||||
if (sendFunctionKey == nullptr) {
|
||||
IMSA_HILOGI("sendFunctionKey null");
|
||||
IMSA_HILOGD("sendFunctionKey null");
|
||||
return;
|
||||
}
|
||||
IMSA_HILOGI("sendFunctionKey runs");
|
||||
auto type = static_cast<int64_t>(functionKey.GetEnterKeyType());
|
||||
IMSA_HILOGD("sendFunctionKey runs");
|
||||
auto type = static_cast<int32_t>(functionKey.GetEnterKeyType());
|
||||
sendFunctionKey(type);
|
||||
return;
|
||||
}
|
||||
@ -426,11 +385,11 @@ void CjInputMethodController::SendFunctionKey(const FunctionKey &functionKey)
|
||||
void CjInputMethodController::MoveCursor(const Direction direction)
|
||||
{
|
||||
if (moveCursor == nullptr) {
|
||||
IMSA_HILOGI("moveCursor null");
|
||||
IMSA_HILOGD("moveCursor null");
|
||||
return;
|
||||
}
|
||||
IMSA_HILOGI("moveCursor runs");
|
||||
auto dir = static_cast<int64_t>(direction);
|
||||
IMSA_HILOGD("moveCursor runs");
|
||||
auto dir = static_cast<int32_t>(direction);
|
||||
moveCursor(dir);
|
||||
return;
|
||||
}
|
||||
@ -438,10 +397,10 @@ void CjInputMethodController::MoveCursor(const Direction direction)
|
||||
void CjInputMethodController::HandleExtendAction(int32_t action)
|
||||
{
|
||||
if (handleExtendAction == nullptr) {
|
||||
IMSA_HILOGI("handleExtendAction null");
|
||||
IMSA_HILOGD("handleExtendAction null");
|
||||
return;
|
||||
}
|
||||
IMSA_HILOGI("handleExtendAction runs");
|
||||
IMSA_HILOGD("handleExtendAction runs");
|
||||
handleExtendAction(action);
|
||||
return;
|
||||
}
|
||||
@ -449,10 +408,10 @@ void CjInputMethodController::HandleExtendAction(int32_t action)
|
||||
std::u16string CjInputMethodController::GetLeftText(int32_t number)
|
||||
{
|
||||
if (getLeftText == nullptr) {
|
||||
IMSA_HILOGI("getLeftText null");
|
||||
IMSA_HILOGD("getLeftText null");
|
||||
return u"";
|
||||
}
|
||||
IMSA_HILOGI("getLeftText runs");
|
||||
IMSA_HILOGD("getLeftText runs");
|
||||
char *text = getLeftText(number);
|
||||
auto ret = Str8ToStr16(std::string(text));
|
||||
free(text);
|
||||
@ -462,10 +421,10 @@ std::u16string CjInputMethodController::GetLeftText(int32_t number)
|
||||
std::u16string CjInputMethodController::GetRightText(int32_t number)
|
||||
{
|
||||
if (getRightText == nullptr) {
|
||||
IMSA_HILOGI("getRightText null");
|
||||
IMSA_HILOGD("getRightText null");
|
||||
return u"";
|
||||
}
|
||||
IMSA_HILOGI("getRightText runs");
|
||||
IMSA_HILOGD("getRightText runs");
|
||||
char *text = getRightText(number);
|
||||
auto ret = Str8ToStr16(std::string(text));
|
||||
free(text);
|
||||
@ -475,11 +434,108 @@ std::u16string CjInputMethodController::GetRightText(int32_t number)
|
||||
int32_t CjInputMethodController::GetTextIndexAtCursor()
|
||||
{
|
||||
if (getTextIndexAtCursor == nullptr) {
|
||||
IMSA_HILOGI("getTextIndexAtCursor null");
|
||||
IMSA_HILOGD("getTextIndexAtCursor null");
|
||||
return -1;
|
||||
}
|
||||
IMSA_HILOGI("getTextIndexAtCursor runs");
|
||||
IMSA_HILOGD("getTextIndexAtCursor runs");
|
||||
return getTextIndexAtCursor();
|
||||
}
|
||||
|
||||
void CjInputMethodController::InitInsertText(int64_t id)
|
||||
{
|
||||
auto callback = reinterpret_cast<void(*)(const char*)>(id);
|
||||
insertText = [lambda = CJLambda::Create(callback)](const char* text) -> void {
|
||||
lambda(text);
|
||||
};
|
||||
}
|
||||
|
||||
void CjInputMethodController::InitDeleteRight(int64_t id)
|
||||
{
|
||||
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||
deleteLeft = [lambda = CJLambda::Create(callback)](int32_t length) -> void {
|
||||
lambda(length);
|
||||
};
|
||||
}
|
||||
|
||||
void CjInputMethodController::InitDeleteLeft(int64_t id)
|
||||
{
|
||||
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||
deleteRight = [lambda = CJLambda::Create(callback)](int32_t length) -> void {
|
||||
lambda(length);
|
||||
};
|
||||
}
|
||||
|
||||
void CjInputMethodController::InitSendKeyboardStatus(int64_t id)
|
||||
{
|
||||
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||
sendKeyboardStatus = [lambda = CJLambda::Create(callback)](int32_t status) -> void {
|
||||
lambda(status);
|
||||
};
|
||||
}
|
||||
|
||||
void CjInputMethodController::InitSendFunctionKey(int64_t id)
|
||||
{
|
||||
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||
sendFunctionKey = [lambda = CJLambda::Create(callback)](int32_t functionKey) -> void {
|
||||
lambda(functionKey);
|
||||
};
|
||||
}
|
||||
|
||||
void CjInputMethodController::InitMoveCursor(int64_t id)
|
||||
{
|
||||
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||
moveCursor = [lambda = CJLambda::Create(callback)](int32_t direction) -> void {
|
||||
lambda(direction);
|
||||
};
|
||||
}
|
||||
|
||||
void CjInputMethodController::InitHandleExtendAction(int64_t id)
|
||||
{
|
||||
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||
handleExtendAction = [lambda = CJLambda::Create(callback)](int32_t action) -> void {
|
||||
lambda(action);
|
||||
};
|
||||
}
|
||||
|
||||
void CjInputMethodController::InitGetLeftText(int64_t id)
|
||||
{
|
||||
auto callback = reinterpret_cast<char*(*)(int32_t)>(id);
|
||||
getLeftText = [lambda = CJLambda::Create(callback)](int32_t number) -> char* {
|
||||
return lambda(number);
|
||||
};
|
||||
}
|
||||
|
||||
void CjInputMethodController::InitGetRightText(int64_t id)
|
||||
{
|
||||
auto callback = reinterpret_cast<char*(*)(int32_t)>(id);
|
||||
getRightText = [lambda = CJLambda::Create(callback)](int32_t number) -> char* {
|
||||
return lambda(number);
|
||||
};
|
||||
}
|
||||
|
||||
void CjInputMethodController::InitGetTextIndexAtCursor(int64_t id)
|
||||
{
|
||||
auto callback = reinterpret_cast<int32_t(*)()>(id);
|
||||
getTextIndexAtCursor = [lambda = CJLambda::Create(callback)](void) -> int32_t {
|
||||
return lambda();
|
||||
};
|
||||
}
|
||||
|
||||
void CjInputMethodController::InitSelectByMovement(int64_t id)
|
||||
{
|
||||
auto callback = reinterpret_cast<void(*)(int32_t)>(id);
|
||||
onSelectByMovement = [lambda = CJLambda::Create(callback)](int32_t direction) -> void {
|
||||
lambda(direction);
|
||||
};
|
||||
}
|
||||
|
||||
void CjInputMethodController::InitSelectByRange(int64_t id)
|
||||
{
|
||||
auto callback = reinterpret_cast<void(*)(Range)>(id);
|
||||
onSelectByRange = [lambda = CJLambda::Create(callback)](Range range) -> void {
|
||||
lambda(range);
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
|
@ -1,14 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* 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.
|
||||
*/
|
@ -22,16 +22,17 @@
|
||||
#include "global.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace OHOS::MiscServices
|
||||
{
|
||||
extern "C"
|
||||
{
|
||||
int32_t CJ_GetDefaultInputMethod(CInputMethodProperty &props)
|
||||
namespace OHOS::MiscServices {
|
||||
extern "C" {
|
||||
int32_t FfiInputMethodGetDefaultInputMethod(CInputMethodProperty &props)
|
||||
{
|
||||
auto ctrl = InputMethodController::GetInstance();
|
||||
if (ctrl == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
std::shared_ptr<Property> property;
|
||||
int32_t ret = InputMethodController::GetInstance()->GetDefaultInputMethod(property);
|
||||
if (property == nullptr)
|
||||
{
|
||||
int32_t ret = ctrl->GetDefaultInputMethod(property);
|
||||
if (property == nullptr) {
|
||||
IMSA_HILOGE("default input method is nullptr!");
|
||||
return ret;
|
||||
}
|
||||
@ -39,67 +40,90 @@ namespace OHOS::MiscServices
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t CJ_GetCurrentInputMethod(CInputMethodProperty &props)
|
||||
{
|
||||
std::shared_ptr<Property> property = InputMethodController::GetInstance()->GetCurrentInputMethod();
|
||||
if (property == nullptr)
|
||||
int32_t FfiInputMethodGetCurrentInputMethod(CInputMethodProperty &props)
|
||||
{
|
||||
auto ctrl = InputMethodController::GetInstance();
|
||||
if (ctrl == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
std::shared_ptr<Property> property = ctrl->GetCurrentInputMethod();
|
||||
if (property == nullptr) {
|
||||
IMSA_HILOGE("current input method is nullptr!");
|
||||
return 0;
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
Utils::InputMethodProperty2C(props, *property);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t CJ_SwitchInputMethod(bool &result, CInputMethodProperty props)
|
||||
int32_t FfiInputMethodSwitchInputMethod(bool &result, CInputMethodProperty props)
|
||||
{
|
||||
InputMethodSyncTrace tracer("CJInputMethod_SwitchInputMethod");
|
||||
auto ctrl = InputMethodController::GetInstance();
|
||||
if (ctrl == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
int32_t errCode =
|
||||
InputMethodController::GetInstance()->SwitchInputMethod(SwitchTrigger::CURRENT_IME, std::string(props.name), std::string(props.id));
|
||||
if (errCode == ErrorCode::NO_ERROR)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
return errCode;
|
||||
}
|
||||
|
||||
int32_t CJ_SwitchCurrentInputMethodSubtype(bool &result, CInputMethodSubtype target)
|
||||
{
|
||||
InputMethodSyncTrace tracer("CJInputMethod_SwitchCurrentInputMethodSubtype");
|
||||
int32_t errCode = InputMethodController::GetInstance()->SwitchInputMethod(
|
||||
SwitchTrigger::CURRENT_IME, std::string(target.name), std::string(target.id));
|
||||
ctrl->SwitchInputMethod(SwitchTrigger::CURRENT_IME, std::string(props.name), std::string(props.id));
|
||||
if (errCode == ErrorCode::NO_ERROR) {
|
||||
result = true;
|
||||
}
|
||||
return errCode;
|
||||
}
|
||||
|
||||
int32_t CJ_GetCurrentInputMethodSubtype(CInputMethodSubtype &props)
|
||||
int32_t FfiInputMethodSwitchCurrentInputMethodSubtype(bool &result, CInputMethodSubtype target)
|
||||
{
|
||||
std::shared_ptr<SubProperty> subProperty = InputMethodController::GetInstance()->GetCurrentInputMethodSubtype();
|
||||
InputMethodSyncTrace tracer("CJInputMethod_SwitchCurrentInputMethodSubtype");
|
||||
auto ctrl = InputMethodController::GetInstance();
|
||||
if (ctrl == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
int32_t errCode =
|
||||
ctrl->SwitchInputMethod(SwitchTrigger::CURRENT_IME, std::string(target.name), std::string(target.id));
|
||||
if (errCode == ErrorCode::NO_ERROR) {
|
||||
result = true;
|
||||
}
|
||||
return errCode;
|
||||
}
|
||||
|
||||
int32_t FfiInputMethodGetCurrentInputMethodSubtype(CInputMethodSubtype &props)
|
||||
{
|
||||
auto ctrl = InputMethodController::GetInstance();
|
||||
if (ctrl == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
std::shared_ptr<SubProperty> subProperty = ctrl->GetCurrentInputMethodSubtype();
|
||||
if (subProperty == nullptr) {
|
||||
IMSA_HILOGE("current input method subtype is nullptr!");
|
||||
return -1;
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
Utils::InputMethodSubProperty2C(props, *subProperty);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t CJ_SwitchCurrentInputMethodAndSubtype(bool &result, CInputMethodProperty target, CInputMethodSubtype subtype)
|
||||
int32_t FfiInputMethodSwitchCurrentInputMethodAndSubtype(bool &result,
|
||||
CInputMethodProperty target, CInputMethodSubtype subtype)
|
||||
{
|
||||
InputMethodSyncTrace tracer("CJInputMethod_SwitchCurrentInputMethodAndSubtype");
|
||||
int32_t errCode =
|
||||
InputMethodController::GetInstance()->SwitchInputMethod(SwitchTrigger::CURRENT_IME, std::string(subtype.name), std::string(subtype.id));
|
||||
auto ctrl = InputMethodController::GetInstance();
|
||||
if (ctrl == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
int32_t errCode = ctrl->SwitchInputMethod(SwitchTrigger::CURRENT_IME,
|
||||
std::string(subtype.name), std::string(subtype.id));
|
||||
if (errCode == ErrorCode::NO_ERROR) {
|
||||
result = true;
|
||||
}
|
||||
return errCode;
|
||||
}
|
||||
|
||||
int32_t CJ_GetSystemInputMethodConfigAbility(CElementName &elem)
|
||||
int32_t FfiInputMethodGetSystemInputMethodConfigAbility(CElementName &elem)
|
||||
{
|
||||
OHOS::AppExecFwk::ElementName inputMethodConfig;
|
||||
int32_t ret = InputMethodController::GetInstance()->GetInputMethodConfig(inputMethodConfig);
|
||||
auto ctrl = InputMethodController::GetInstance();
|
||||
if (ctrl == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
int32_t ret = ctrl->GetInputMethodConfig(inputMethodConfig);
|
||||
if (ret == ErrorCode::NO_ERROR) {
|
||||
elem.deviceId = Utils::MallocCString(inputMethodConfig.GetDeviceID());
|
||||
elem.bundleName = Utils::MallocCString(inputMethodConfig.GetBundleName());
|
||||
@ -109,14 +133,18 @@ namespace OHOS::MiscServices
|
||||
return ret;
|
||||
}
|
||||
|
||||
RetInputMethodSubtype CJ_ListInputMethodSubtype(CInputMethodProperty props)
|
||||
RetInputMethodSubtype FfiInputMethodSettingListInputMethodSubtype(CInputMethodProperty props)
|
||||
{
|
||||
IMSA_HILOGD("run in ListInputMethodSubtype");
|
||||
RetInputMethodSubtype ret{};
|
||||
Property property = Utils::C2InputMethodProperty(props);
|
||||
std::vector<SubProperty> subProps;
|
||||
int32_t errCode =
|
||||
InputMethodController::GetInstance()->ListInputMethodSubtype(property, subProps);
|
||||
auto ctrl = InputMethodController::GetInstance();
|
||||
if (ctrl == nullptr) {
|
||||
ret.code = ERR_NO_MEMORY;
|
||||
return ret;
|
||||
}
|
||||
int32_t errCode = ctrl->ListInputMethodSubtype(property, subProps);
|
||||
ret.code = errCode;
|
||||
if (errCode != ErrorCode::NO_ERROR) {
|
||||
return ret;
|
||||
@ -138,12 +166,17 @@ namespace OHOS::MiscServices
|
||||
return ret;
|
||||
}
|
||||
|
||||
RetInputMethodSubtype CJ_ListCurrentInputMethodSubtype()
|
||||
RetInputMethodSubtype FfiInputMethodSettingListCurrentInputMethodSubtype()
|
||||
{
|
||||
IMSA_HILOGD("run in ListCurrentInputMethodSubtype");
|
||||
RetInputMethodSubtype ret{};
|
||||
std::vector<SubProperty> subProps;
|
||||
int32_t errCode = InputMethodController::GetInstance()->ListCurrentInputMethodSubtype(subProps);
|
||||
auto ctrl = InputMethodController::GetInstance();
|
||||
if (ctrl == nullptr) {
|
||||
ret.code = ERR_NO_MEMORY;
|
||||
return ret;
|
||||
}
|
||||
int32_t errCode = ctrl->ListCurrentInputMethodSubtype(subProps);
|
||||
ret.code = errCode;
|
||||
if (errCode != ErrorCode::NO_ERROR) {
|
||||
return ret;
|
||||
@ -165,12 +198,17 @@ namespace OHOS::MiscServices
|
||||
return ret;
|
||||
}
|
||||
|
||||
RetInputMethodProperty CJ_GetInputMethods(bool enable)
|
||||
RetInputMethodProperty FfiInputMethodSettingGetInputMethods(bool enable)
|
||||
{
|
||||
IMSA_HILOGD("run in");
|
||||
RetInputMethodProperty ret{};
|
||||
std::vector<Property> properties;
|
||||
int32_t errCode = InputMethodController::GetInstance()->ListInputMethod(enable, properties);
|
||||
auto ctrl = InputMethodController::GetInstance();
|
||||
if (ctrl == nullptr) {
|
||||
ret.code = ERR_NO_MEMORY;
|
||||
return ret;
|
||||
}
|
||||
int32_t errCode = ctrl->ListInputMethod(enable, properties);
|
||||
ret.code = errCode;
|
||||
if (errCode != ErrorCode::NO_ERROR) {
|
||||
return ret;
|
||||
@ -191,12 +229,17 @@ namespace OHOS::MiscServices
|
||||
return ret;
|
||||
}
|
||||
|
||||
RetInputMethodProperty CJ_GetAllInputMethods()
|
||||
RetInputMethodProperty FfiInputMethodSettingGetAllInputMethods()
|
||||
{
|
||||
IMSA_HILOGD("run in");
|
||||
RetInputMethodProperty ret{};
|
||||
std::vector<Property> properties;
|
||||
int32_t errCode = InputMethodController::GetInstance()->ListInputMethod(properties);
|
||||
auto ctrl = InputMethodController::GetInstance();
|
||||
if (ctrl == nullptr) {
|
||||
ret.code = ERR_NO_MEMORY;
|
||||
return ret;
|
||||
}
|
||||
int32_t errCode = ctrl->ListInputMethod(properties);
|
||||
ret.code = errCode;
|
||||
if (errCode != ErrorCode::NO_ERROR) {
|
||||
return ret;
|
||||
@ -217,20 +260,32 @@ namespace OHOS::MiscServices
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t CJ_InputMethodSettingOn(uint32_t type, void (*func)(CInputMethodProperty, CInputMethodSubtype))
|
||||
int32_t FfiInputMethodSettingOn(uint32_t type, void (*func)(CInputMethodProperty, CInputMethodSubtype))
|
||||
{
|
||||
return CJGetInputMethodSetting::GetIMSInstance()->Subscribe(type, func);
|
||||
auto setting = CJGetInputMethodSetting::GetIMSInstance();
|
||||
if (setting == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
return setting->Subscribe(type, func);
|
||||
}
|
||||
|
||||
int32_t CJ_InputMethodSettingOff(uint32_t type)
|
||||
int32_t FfiInputMethodSettingOff(uint32_t type)
|
||||
{
|
||||
return CJGetInputMethodSetting::GetIMSInstance()->UnSubscribe(type);
|
||||
auto setting = CJGetInputMethodSetting::GetIMSInstance();
|
||||
if (setting == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
return setting->UnSubscribe(type);
|
||||
}
|
||||
|
||||
int32_t CJ_ShowOptionalInputMethods(bool& result)
|
||||
int32_t FfiInputMethodSettingShowOptionalInputMethods(bool& result)
|
||||
{
|
||||
IMSA_HILOGD("start JsGetInputMethodSetting.");
|
||||
int32_t errCode = InputMethodController::GetInstance()->DisplayOptionalInputMethod();
|
||||
auto ctrl = InputMethodController::GetInstance();
|
||||
if (ctrl == nullptr) {
|
||||
return ERR_NO_MEMORY;
|
||||
}
|
||||
int32_t errCode = ctrl->DisplayOptionalInputMethod();
|
||||
if (errCode == ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGI("exec DisplayOptionalInputMethod success");
|
||||
result = true;
|
||||
@ -238,67 +293,67 @@ namespace OHOS::MiscServices
|
||||
return errCode;
|
||||
}
|
||||
|
||||
int32_t CJ_InputMethodControllerOn(int8_t type, int64_t id)
|
||||
int32_t FfiInputMethodControllerOn(int8_t type, int64_t id)
|
||||
{
|
||||
return CjInputMethodController::Subscribe(type, id);
|
||||
}
|
||||
|
||||
int32_t CJ_InputMethodControllerOff(int8_t type)
|
||||
int32_t FfiInputMethodControllerOff(int8_t type)
|
||||
{
|
||||
return CjInputMethodController::Unsubscribe(type);
|
||||
}
|
||||
|
||||
int32_t OHOSFfiAttach(bool showKeyboard, CTextConfig txtCfg)
|
||||
int32_t FfiInputMethodControllerAttach(bool showKeyboard, CTextConfig txtCfg)
|
||||
{
|
||||
return CjInputMethodController::Attach(txtCfg, showKeyboard);
|
||||
}
|
||||
|
||||
int32_t OHOSFfiDetach()
|
||||
int32_t FfiInputMethodControllerDetach()
|
||||
{
|
||||
return CjInputMethodController::Detach();
|
||||
}
|
||||
|
||||
int32_t OHOSFfiShowTextInput()
|
||||
int32_t FfiInputMethodControllerShowTextInput()
|
||||
{
|
||||
return CjInputMethodController::ShowTextInput();
|
||||
}
|
||||
|
||||
int32_t OHOSFfiHideTextInput()
|
||||
int32_t FfiInputMethodControllerHideTextInput()
|
||||
{
|
||||
return CjInputMethodController::HideTextInput();
|
||||
}
|
||||
|
||||
int32_t OHOSFfiSetCallingWindow(uint32_t windowId)
|
||||
int32_t FfiInputMethodControllerSetCallingWindow(uint32_t windowId)
|
||||
{
|
||||
return CjInputMethodController::SetCallingWindow(windowId);
|
||||
}
|
||||
|
||||
int32_t OHOSFfiUpdateCursor(CCursorInfo cursor)
|
||||
int32_t FfiInputMethodControllerUpdateCursor(CCursorInfo cursor)
|
||||
{
|
||||
return CjInputMethodController::UpdateCursor(cursor);
|
||||
}
|
||||
|
||||
int32_t OHOSFfiChangeSelection(char *text, int32_t start, int32_t end)
|
||||
int32_t FfiInputMethodControllerChangeSelection(char *text, int32_t start, int32_t end)
|
||||
{
|
||||
return CjInputMethodController::ChangeSelection(std::string(text), start, end);
|
||||
}
|
||||
|
||||
int32_t OHOSFfiUpdateAttribute(CInputAttribute inputAttribute)
|
||||
int32_t FfiInputMethodControllerUpdateAttribute(CInputAttribute inputAttribute)
|
||||
{
|
||||
return CjInputMethodController::UpdateAttribute(inputAttribute);
|
||||
}
|
||||
|
||||
int32_t OHOSFfiShowSoftKeyboard()
|
||||
int32_t FfiInputMethodControllerShowSoftKeyboard()
|
||||
{
|
||||
return CjInputMethodController::ShowSoftKeyboard();
|
||||
}
|
||||
|
||||
int32_t OHOSFfiHideSoftKeyboard()
|
||||
int32_t FfiInputMethodControllerHideSoftKeyboard()
|
||||
{
|
||||
return CjInputMethodController::HideSoftKeyboard();
|
||||
}
|
||||
|
||||
int32_t OHOSFfiStopInputSession()
|
||||
int32_t FfiInputMethodControllerStopInputSession()
|
||||
{
|
||||
return CjInputMethodController::StopInputSession();
|
||||
}
|
||||
|
@ -17,14 +17,12 @@
|
||||
namespace OHOS::MiscServices {
|
||||
char* Utils::MallocCString(const std::string &origin)
|
||||
{
|
||||
if (origin.empty())
|
||||
{
|
||||
if (origin.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto len = origin.length() + 1;
|
||||
char *res = static_cast<char *>(malloc(sizeof(char) * len));
|
||||
if (res == nullptr)
|
||||
{
|
||||
if (res == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::char_traits<char>::copy(res, origin.c_str(), len);
|
||||
|
Loading…
Reference in New Issue
Block a user