• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef CJ_INPUT_METHOD_UTILS_H
17 #define CJ_INPUT_METHOD_UTILS_H
18 
19 #include <cstdint>
20 #include <memory>
21 #include <string>
22 #include "cj_ffi/cj_common_ffi.h"
23 #include "input_method_ffi_structs.h"
24 #include "input_method_property.h"
25 #include "global.h"
26 #include <map>
27 
28 namespace OHOS::MiscServices {
29 enum IMFErrorCode : int32_t {
30     EXCEPTION_PERMISSION = 201,
31     EXCEPTION_SYSTEM_PERMISSION = 202,
32     EXCEPTION_PARAMCHECK = 401,
33     EXCEPTION_UNSUPPORTED = 801,
34     EXCEPTION_PACKAGEMANAGER = 12800001,
35     EXCEPTION_IMENGINE = 12800002,
36     EXCEPTION_IMCLIENT = 12800003,
37     EXCEPTION_IME = 12800004,
38     EXCEPTION_CONFPERSIST = 12800005,
39     EXCEPTION_CONTROLLER = 12800006,
40     EXCEPTION_SETTINGS = 12800007,
41     EXCEPTION_IMMS = 12800008,
42     EXCEPTION_DETACHED = 12800009,
43     EXCEPTION_DEFAULTIME = 12800010,
44     EXCEPTION_TEXT_PREVIEW_NOT_SUPPORTED = 12800011,
45     EXCEPTION_PANEL_NOT_FOUND = 12800012,
46     EXCEPTION_WINDOW_MANAGER = 12800013,
47     EXCEPTION_BASIC_MODE = 12800014,
48     EXCEPTION_REQUEST_NOT_ACCEPT = 12800015,
49     EXCEPTION_EDITABLE = 12800016,
50     EXCEPTION_INVALID_PANEL_TYPE_FLAG = 12800017,
51     EXCEPTION_IME_NOT_FOUND = 12800018,
52     EXCEPTION_OPERATE_DEFAULTIME = 12800019,
53     EXCEPTION_INVALID_IMMERSIVE_EFFECT = 12800020,
54     EXCEPTION_PRECONDITION_REQUIRED = 12800021,
55 };
56 
57 class FFI_EXPORT Utils {
58 public:
59     static constexpr int32_t ERR_NO_MEMORY = -2;
60     static const std::map<int32_t, IMFErrorCode> ERROR_CODE_MAP;
61     static char* MallocCString(const std::string &origin);
62     static void InputMethodProperty2C(CInputMethodProperty *props, const Property &property);
63     static Property C2InputMethodProperty(CInputMethodProperty props);
64     static void InputMethodSubProperty2C(CInputMethodSubtype *props, const SubProperty &property);
65     static int32_t ConvertErrorCode(int32_t code);
66 };
67 }
68 #endif