122736c2fSopenharmony_ci/* 222736c2fSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 322736c2fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 422736c2fSopenharmony_ci * you may not use this file except in compliance with the License. 522736c2fSopenharmony_ci * You may obtain a copy of the License at 622736c2fSopenharmony_ci * 722736c2fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 822736c2fSopenharmony_ci * 922736c2fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1022736c2fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1122736c2fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1222736c2fSopenharmony_ci * See the License for the specific language governing permissions and 1322736c2fSopenharmony_ci * limitations under the License. 1422736c2fSopenharmony_ci */ 1522736c2fSopenharmony_ci#include "native_inputmethod_utils.h" 1622736c2fSopenharmony_ci#include <map> 1722736c2fSopenharmony_ci 1822736c2fSopenharmony_ci#include "global.h" 1922736c2fSopenharmony_ciusing namespace OHOS::MiscServices; 2022736c2fSopenharmony_cistatic const std::map<int32_t, InputMethod_ErrorCode> ERROR_CODE_MAP = { 2122736c2fSopenharmony_ci { ErrorCode::NO_ERROR, IME_ERR_OK }, 2222736c2fSopenharmony_ci { ErrorCode::ERROR_CONTROLLER_INVOKING_FAILED, IME_ERR_CONTROLLER }, 2322736c2fSopenharmony_ci { ErrorCode::ERROR_REMOTE_CLIENT_DIED, IME_ERR_IMCLIENT }, 2422736c2fSopenharmony_ci { ErrorCode::ERROR_CLIENT_NOT_FOUND, IME_ERR_IMCLIENT }, 2522736c2fSopenharmony_ci { ErrorCode::ERROR_CLIENT_NULL_POINTER, IME_ERR_IMCLIENT }, 2622736c2fSopenharmony_ci { ErrorCode::ERROR_CLIENT_NOT_FOCUSED, IME_ERR_IMCLIENT }, 2722736c2fSopenharmony_ci { ErrorCode::ERROR_CLIENT_NOT_EDITABLE, IME_ERR_IMCLIENT }, 2822736c2fSopenharmony_ci { ErrorCode::ERROR_CLIENT_NOT_BOUND, IME_ERR_DETACHED }, 2922736c2fSopenharmony_ci { ErrorCode::ERROR_CLIENT_ADD_FAILED, IME_ERR_IMCLIENT }, 3022736c2fSopenharmony_ci { ErrorCode::ERROR_NULL_POINTER, IME_ERR_IMMS }, 3122736c2fSopenharmony_ci { ErrorCode::ERROR_BAD_PARAMETERS, IME_ERR_IMMS }, 3222736c2fSopenharmony_ci { ErrorCode::ERROR_SERVICE_START_FAILED, IME_ERR_IMMS }, 3322736c2fSopenharmony_ci { ErrorCode::ERROR_IME_START_FAILED, IME_ERR_IMMS }, 3422736c2fSopenharmony_ci { ErrorCode::ERROR_KBD_SHOW_FAILED, IME_ERR_IMMS }, 3522736c2fSopenharmony_ci { ErrorCode::ERROR_KBD_HIDE_FAILED, IME_ERR_IMMS }, 3622736c2fSopenharmony_ci { ErrorCode::ERROR_IME_NOT_STARTED, IME_ERR_IMMS }, 3722736c2fSopenharmony_ci { ErrorCode::ERROR_EX_NULL_POINTER, IME_ERR_IMMS }, 3822736c2fSopenharmony_ci { ErrorCode::ERROR_PACKAGE_MANAGER, IME_ERR_PACKAGEMANAGER }, 3922736c2fSopenharmony_ci { ErrorCode::ERROR_EX_UNSUPPORTED_OPERATION, IME_ERR_IMMS }, 4022736c2fSopenharmony_ci { ErrorCode::ERROR_EX_SERVICE_SPECIFIC, IME_ERR_IMMS }, 4122736c2fSopenharmony_ci { ErrorCode::ERROR_EX_PARCELABLE, IME_ERR_IMMS }, 4222736c2fSopenharmony_ci { ErrorCode::ERROR_EX_ILLEGAL_ARGUMENT, IME_ERR_IMMS }, 4322736c2fSopenharmony_ci { ErrorCode::ERROR_EX_ILLEGAL_STATE, IME_ERR_IMMS }, 4422736c2fSopenharmony_ci { ErrorCode::ERROR_IME_START_INPUT_FAILED, IME_ERR_IMMS }, 4522736c2fSopenharmony_ci { ErrorCode::ERROR_IME, IME_ERR_IMENGINE }, 4622736c2fSopenharmony_ci { ErrorCode::ERROR_PARAMETER_CHECK_FAILED, IME_ERR_PARAMCHECK }, 4722736c2fSopenharmony_ci { ErrorCode::ERROR_ENABLE_IME, IME_ERR_IMMS }, 4822736c2fSopenharmony_ci { ErrorCode::ERROR_NOT_CURRENT_IME, IME_ERR_IMMS }, 4922736c2fSopenharmony_ci { ErrorCode::ERROR_GET_TEXT_CONFIG, IME_ERR_IMCLIENT }, 5022736c2fSopenharmony_ci { ErrorCode::ERROR_INVALID_PRIVATE_COMMAND_SIZE, IME_ERR_PARAMCHECK }, 5122736c2fSopenharmony_ci { ErrorCode::ERROR_TEXT_LISTENER_ERROR, IME_ERR_IMCLIENT }, 5222736c2fSopenharmony_ci { ErrorCode::ERROR_INVALID_RANGE, IME_ERR_PARAMCHECK }, 5322736c2fSopenharmony_ci}; 5422736c2fSopenharmony_ci 5522736c2fSopenharmony_ciInputMethod_ErrorCode ErrorCodeConvert(int32_t code) 5622736c2fSopenharmony_ci{ 5722736c2fSopenharmony_ci IMSA_HILOGD("Convert start."); 5822736c2fSopenharmony_ci auto iter = ERROR_CODE_MAP.find(code); 5922736c2fSopenharmony_ci if (iter != ERROR_CODE_MAP.end()) { 6022736c2fSopenharmony_ci IMSA_HILOGE("ErrorCode: %{public}d", iter->second); 6122736c2fSopenharmony_ci return iter->second; 6222736c2fSopenharmony_ci } 6322736c2fSopenharmony_ci IMSA_HILOGD("Convert end."); 6422736c2fSopenharmony_ci return IME_ERR_UNDEFINED; 6522736c2fSopenharmony_ci}