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 #include "napi/native_api.h"
16 #include "inputmethod/inputmethod_attach_options_capi.h"
17 #include "inputmethod/inputmethod_controller_capi.h"
18 #include "inputmethod/inputmethod_cursor_info_capi.h"
19 #include "inputmethod/inputmethod_inputmethod_proxy_capi.h"
20 #include "inputmethod/inputmethod_private_command_capi.h"
21 #include "inputmethod/inputmethod_text_avoid_info_capi.h"
22 #include "inputmethod/inputmethod_text_config_capi.h"
23 #include "inputmethod/inputmethod_text_editor_proxy_capi.h"
24 #include "inputmethod/inputmethod_types_capi.h"
25 #include "native_common.h"
26 #include "hilog/log.h"
27 #include "codecvt"
28 #include "locale"
29
30 InputMethod_TextEditorProxy *g_txtEditProxy = nullptr;
31 InputMethod_InputMethodProxy *g_inputMethodProxy = nullptr;
32 InputMethod_PrivateCommand *g_privateCommand = nullptr;
33 InputMethod_CursorInfo *g_cursorInfo = nullptr;
34 InputMethod_TextAvoidInfo *g_textAvoidInfo = nullptr;
35 InputMethod_AttachOptions *g_options = nullptr;
36
GetTextConfigFunc(InputMethod_TextEditorProxy * textEditorProxy,InputMethod_TextConfig * config)37 void GetTextConfigFunc(InputMethod_TextEditorProxy *textEditorProxy, InputMethod_TextConfig *config)
38 {
39 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>GetTextConfigFunc successful.");
40 }
41
InsertTextFunc(InputMethod_TextEditorProxy * textEditorProxy,const char16_t * text,size_t length)42 void InsertTextFunc(InputMethod_TextEditorProxy *textEditorProxy, const char16_t *text, size_t length)
43 {
44 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>InsertTextFunc successful.");
45 }
46
DeleteForwardFunc(InputMethod_TextEditorProxy * textEditorProxy,int32_t length)47 void DeleteForwardFunc(InputMethod_TextEditorProxy *textEditorProxy, int32_t length)
48 {
49 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>DeleteForwardFunc successful.");
50 }
51
DeleteBackwardFunc(InputMethod_TextEditorProxy * textEditorProxy,int32_t length)52 void DeleteBackwardFunc(InputMethod_TextEditorProxy *textEditorProxy, int32_t length)
53 {
54 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>DeleteBackwardFunc successful.");
55 }
56
SendKeyboardStatusFunc(InputMethod_TextEditorProxy * textEditorProxy,InputMethod_KeyboardStatus keyboardStatus)57 void SendKeyboardStatusFunc(InputMethod_TextEditorProxy *textEditorProxy, InputMethod_KeyboardStatus keyboardStatus)
58 {
59 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>SendKeyboardStatusFunc successful.");
60 }
61
SendEnterKeyFunc(InputMethod_TextEditorProxy * textEditorProxy,InputMethod_EnterKeyType enterKeyType)62 void SendEnterKeyFunc(InputMethod_TextEditorProxy *textEditorProxy, InputMethod_EnterKeyType enterKeyType)
63 {
64 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>SendEnterKeyFunc successful.");
65 }
66
MoveCursorFunc(InputMethod_TextEditorProxy * textEditorProxy,InputMethod_Direction direction)67 void MoveCursorFunc(InputMethod_TextEditorProxy *textEditorProxy, InputMethod_Direction direction)
68 {
69 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>MoveCursorFunc successful.");
70 }
71
HandleSetSelectionFunc(InputMethod_TextEditorProxy * textEditorProxy,int32_t start,int32_t end)72 void HandleSetSelectionFunc(InputMethod_TextEditorProxy *textEditorProxy, int32_t start, int32_t end)
73 {
74 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>HandleSetSelectionFunc successful.");
75 }
76
HandleExtendActionFunc(InputMethod_TextEditorProxy * textEditorProxy,InputMethod_ExtendAction action)77 void HandleExtendActionFunc(InputMethod_TextEditorProxy *textEditorProxy, InputMethod_ExtendAction action)
78 {
79 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>HandleExtendActionFunc successful.");
80 }
81
GetLeftTextOfCursorFunc(InputMethod_TextEditorProxy * textEditorProxy,int32_t number,char16_t text[],size_t * length)82 void GetLeftTextOfCursorFunc(InputMethod_TextEditorProxy *textEditorProxy, int32_t number, char16_t text[],
83 size_t *length)
84 {
85 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>GetLeftTextOfCursorFunc successful.");
86 }
87
GetRightTextOfCursorFunc(InputMethod_TextEditorProxy * textEditorProxy,int32_t number,char16_t text[],size_t * length)88 void GetRightTextOfCursorFunc(InputMethod_TextEditorProxy *textEditorProxy, int32_t number, char16_t text[],
89 size_t *length)
90 {
91 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>GetRightTextOfCursorFunc successful.");
92 }
93
GetTextIndexAtCursorFunc(InputMethod_TextEditorProxy * textEditorProxy)94 int32_t GetTextIndexAtCursorFunc(InputMethod_TextEditorProxy *textEditorProxy)
95 {
96 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>GetTextIndexAtCursorFunc successful.");
97 return 0;
98 }
99
ReceivePrivateCommandFunc(InputMethod_TextEditorProxy * textEditorProxy,InputMethod_PrivateCommand * privateCommand[],size_t size)100 int32_t ReceivePrivateCommandFunc(InputMethod_TextEditorProxy *textEditorProxy,
101 InputMethod_PrivateCommand *privateCommand[], size_t size)
102 {
103 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>ReceivePrivateCommandFunc successful.");
104 return 0;
105 }
106
SetPreviewTextFunc(InputMethod_TextEditorProxy * textEditorProxy,const char16_t text[],size_t length,int32_t start,int32_t end)107 int32_t SetPreviewTextFunc(InputMethod_TextEditorProxy *textEditorProxy, const char16_t text[], size_t length,
108 int32_t start, int32_t end)
109 {
110 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>SetPreviewTextFunc successful.");
111 return 0;
112 }
113
FinishTextPreviewFunc(InputMethod_TextEditorProxy * textEditorProxy)114 void FinishTextPreviewFunc(InputMethod_TextEditorProxy *textEditorProxy)
115 {
116 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>FinishTextPreviewFunc successful.");
117 }
118
TextEditorProxy_Create()119 void TextEditorProxy_Create()
120 {
121 if (g_txtEditProxy == nullptr) {
122 g_txtEditProxy = OH_TextEditorProxy_Create();
123 OH_TextEditorProxy_SetGetTextConfigFunc(g_txtEditProxy, GetTextConfigFunc);
124 OH_TextEditorProxy_SetInsertTextFunc(g_txtEditProxy, InsertTextFunc);
125 OH_TextEditorProxy_SetDeleteForwardFunc(g_txtEditProxy, DeleteForwardFunc);
126 OH_TextEditorProxy_SetDeleteBackwardFunc(g_txtEditProxy, DeleteBackwardFunc);
127 OH_TextEditorProxy_SetSendKeyboardStatusFunc(g_txtEditProxy, SendKeyboardStatusFunc);
128 OH_TextEditorProxy_SetSendEnterKeyFunc(g_txtEditProxy, SendEnterKeyFunc);
129 OH_TextEditorProxy_SetMoveCursorFunc(g_txtEditProxy, MoveCursorFunc);
130 OH_TextEditorProxy_SetHandleSetSelectionFunc(g_txtEditProxy, HandleSetSelectionFunc);
131 OH_TextEditorProxy_SetHandleExtendActionFunc(g_txtEditProxy, HandleExtendActionFunc);
132 OH_TextEditorProxy_SetGetLeftTextOfCursorFunc(g_txtEditProxy, GetLeftTextOfCursorFunc);
133 OH_TextEditorProxy_SetGetRightTextOfCursorFunc(g_txtEditProxy, GetRightTextOfCursorFunc);
134 OH_TextEditorProxy_SetGetTextIndexAtCursorFunc(g_txtEditProxy, GetTextIndexAtCursorFunc);
135 OH_TextEditorProxy_SetReceivePrivateCommandFunc(g_txtEditProxy, ReceivePrivateCommandFunc);
136 OH_TextEditorProxy_SetSetPreviewTextFunc(g_txtEditProxy, SetPreviewTextFunc);
137 OH_TextEditorProxy_SetFinishTextPreviewFunc(g_txtEditProxy, FinishTextPreviewFunc);
138 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>TextEditorProxy_Create successful.");
139 }
140 }
141
AttachOptions_Create(bool showKeyboard)142 void AttachOptions_Create(bool showKeyboard)
143 {
144 g_options = OH_AttachOptions_Create(showKeyboard);
145 }
AttachOptions_CreateWithRequestKeyboardReason(bool showKeyboard,InputMethod_RequestKeyboardReason requestKeyboardReason)146 void AttachOptions_CreateWithRequestKeyboardReason(bool showKeyboard,
147 InputMethod_RequestKeyboardReason requestKeyboardReason)
148 {
149 g_options = OH_AttachOptions_CreateWithRequestKeyboardReason(showKeyboard, requestKeyboardReason);
150 }
151
SUB_IMF_NDK_AttachOptions_Create_0100(napi_env env,napi_callback_info info)152 static napi_value SUB_IMF_NDK_AttachOptions_Create_0100(napi_env env, napi_callback_info info)
153 {
154 g_options = OH_AttachOptions_Create(true);
155 bool showKeyboard = false;
156 InputMethod_ErrorCode returnValue = OH_AttachOptions_IsShowKeyboard(g_options, &showKeyboard);
157 OH_AttachOptions_Destroy(g_options);
158
159 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
160 napi_value result = nullptr;
161 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
162 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_AttachOptions_IsShowKeyboard successful.");
163 return result;
164 }
165 napi_value result = nullptr;
166 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
167 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_AttachOptions_IsShowKeyboard fail.");
168 return result;
169 }
170
SUB_IMF_NDK_AttachOptions_CreateWithRequestKeyboardReason_NONE(napi_env env,napi_callback_info info)171 static napi_value SUB_IMF_NDK_AttachOptions_CreateWithRequestKeyboardReason_NONE(napi_env env, napi_callback_info info)
172 {
173 g_options = OH_AttachOptions_CreateWithRequestKeyboardReason(
174 true,
175 InputMethod_RequestKeyboardReason::IME_REQUEST_REASON_NONE);
176 bool showKeyboard = false;
177 int requestKeyboardReason = 0;
178 InputMethod_ErrorCode returnValue = OH_AttachOptions_IsShowKeyboard(g_options, &showKeyboard);
179 InputMethod_ErrorCode returnValueReason =
180 OH_AttachOptions_GetRequestKeyboardReason(g_options, &requestKeyboardReason);
181 OH_AttachOptions_Destroy(g_options);
182 if (returnValueReason == InputMethod_ErrorCode::IME_ERR_OK) {
183 napi_value result = nullptr;
184 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
185 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_AttachOptions_GetRequestKeyboardReason successful.");
186 return result;
187 }
188 napi_value result = nullptr;
189 NAPI_CALL(env, napi_create_int32(env, returnValueReason, &result));
190 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_AttachOptions_GetRequestKeyboardReason fail.");
191 return result;
192 }
193
SUB_IMF_NDK_AttachOptions_CreateWithRequestKeyboardReason_MOUSE(napi_env env,napi_callback_info info)194 static napi_value SUB_IMF_NDK_AttachOptions_CreateWithRequestKeyboardReason_MOUSE(napi_env env, napi_callback_info info)
195 {
196 g_options = OH_AttachOptions_CreateWithRequestKeyboardReason(
197 true,
198 InputMethod_RequestKeyboardReason::IME_REQUEST_REASON_MOUSE);
199 bool showKeyboard = false;
200 int requestKeyboardReason = 0;
201 InputMethod_ErrorCode returnValue = OH_AttachOptions_IsShowKeyboard(g_options, &showKeyboard);
202 InputMethod_ErrorCode returnValueReason =
203 OH_AttachOptions_GetRequestKeyboardReason(g_options, &requestKeyboardReason);
204 OH_AttachOptions_Destroy(g_options);
205 if (returnValueReason == InputMethod_ErrorCode::IME_ERR_OK) {
206 napi_value result = nullptr;
207 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
208 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_AttachOptions_GetRequestKeyboardReason successful.");
209 return result;
210 }
211 napi_value result = nullptr;
212 NAPI_CALL(env, napi_create_int32(env, returnValueReason, &result));
213 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_AttachOptions_GetRequestKeyboardReason fail.");
214 return result;
215 }
216
SUB_IMF_NDK_AttachOptions_CreateWithRequestKeyboardReason_TOUCH(napi_env env,napi_callback_info info)217 static napi_value SUB_IMF_NDK_AttachOptions_CreateWithRequestKeyboardReason_TOUCH(napi_env env, napi_callback_info info)
218 {
219 g_options = OH_AttachOptions_CreateWithRequestKeyboardReason(
220 true,
221 InputMethod_RequestKeyboardReason::IME_REQUEST_REASON_TOUCH);
222 bool showKeyboard = false;
223 int requestKeyboardReason = 0;
224 InputMethod_ErrorCode returnValue = OH_AttachOptions_IsShowKeyboard(g_options, &showKeyboard);
225 InputMethod_ErrorCode returnValueReason =
226 OH_AttachOptions_GetRequestKeyboardReason(g_options, &requestKeyboardReason);
227 OH_AttachOptions_Destroy(g_options);
228 if (returnValueReason == InputMethod_ErrorCode::IME_ERR_OK) {
229 napi_value result = nullptr;
230 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
231 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_AttachOptions_GetRequestKeyboardReason successful.");
232 return result;
233 }
234 napi_value result = nullptr;
235 NAPI_CALL(env, napi_create_int32(env, returnValueReason, &result));
236 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_AttachOptions_GetRequestKeyboardReason fail.");
237 return result;
238 }
239
SUB_IMF_NDK_AttachOptions_CreateWithRequestKeyboardReason_OTHER(napi_env env,napi_callback_info info)240 static napi_value SUB_IMF_NDK_AttachOptions_CreateWithRequestKeyboardReason_OTHER(napi_env env, napi_callback_info info)
241 {
242 g_options = OH_AttachOptions_CreateWithRequestKeyboardReason(
243 true,
244 InputMethod_RequestKeyboardReason::IME_REQUEST_REASON_OTHER);
245 bool showKeyboard = false;
246 int requestKeyboardReason = 0;
247 InputMethod_ErrorCode returnValue = OH_AttachOptions_IsShowKeyboard(g_options, &showKeyboard);
248 InputMethod_ErrorCode returnValueReason =
249 OH_AttachOptions_GetRequestKeyboardReason(g_options, &requestKeyboardReason);
250 OH_AttachOptions_Destroy(g_options);
251 if (returnValueReason == InputMethod_ErrorCode::IME_ERR_OK) {
252 napi_value result = nullptr;
253 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
254 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_AttachOptions_GetRequestKeyboardReason successful.");
255 return result;
256 }
257 napi_value result = nullptr;
258 NAPI_CALL(env, napi_create_int32(env, returnValueReason, &result));
259 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_AttachOptions_GetRequestKeyboardReason fail.");
260 return result;
261 }
262
SUB_IMF_NDK_InputMethodController_Attach_0100(napi_env env,napi_callback_info info)263 static napi_value SUB_IMF_NDK_InputMethodController_Attach_0100(napi_env env, napi_callback_info info)
264 {
265 TextEditorProxy_Create();
266 AttachOptions_Create(false);
267 InputMethod_ErrorCode returnValue = OH_InputMethodController_Attach(g_txtEditProxy, g_options, &g_inputMethodProxy);
268 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
269 napi_value result = nullptr;
270 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
271 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodController_Attach successful.");
272 return result;
273 }
274 napi_value result = nullptr;
275 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
276 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodController_Attach fail.");
277 return result;
278 }
279
SUB_IMF_NDK_InputMethodController_Attach_MOUSE(napi_env env,napi_callback_info info)280 static napi_value SUB_IMF_NDK_InputMethodController_Attach_MOUSE(napi_env env, napi_callback_info info)
281 {
282 TextEditorProxy_Create();
283 OH_AttachOptions_CreateWithRequestKeyboardReason(true, InputMethod_RequestKeyboardReason::IME_REQUEST_REASON_MOUSE);
284 InputMethod_ErrorCode returnValue = OH_InputMethodController_Attach(g_txtEditProxy, g_options, &g_inputMethodProxy);
285 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
286 napi_value result = nullptr;
287 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
288 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodController_Attach successful.");
289 return result;
290 }
291 napi_value result = nullptr;
292 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
293 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodController_Attach fail.");
294 return result;
295 }
296
SUB_IMF_NDK_InputMethodController_Attach_TOUCH(napi_env env,napi_callback_info info)297 static napi_value SUB_IMF_NDK_InputMethodController_Attach_TOUCH(napi_env env, napi_callback_info info)
298 {
299 TextEditorProxy_Create();
300 OH_AttachOptions_CreateWithRequestKeyboardReason(true, InputMethod_RequestKeyboardReason::IME_REQUEST_REASON_TOUCH);
301 InputMethod_ErrorCode returnValue = OH_InputMethodController_Attach(g_txtEditProxy, g_options, &g_inputMethodProxy);
302 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
303 napi_value result = nullptr;
304 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
305 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodController_Attach successful.");
306 return result;
307 }
308 napi_value result = nullptr;
309 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
310 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodController_Attach fail.");
311 return result;
312 }
313
SUB_IMF_NDK_InputMethodController_Attach_NONE(napi_env env,napi_callback_info info)314 static napi_value SUB_IMF_NDK_InputMethodController_Attach_NONE(napi_env env, napi_callback_info info)
315 {
316 TextEditorProxy_Create();
317 OH_AttachOptions_CreateWithRequestKeyboardReason(true, InputMethod_RequestKeyboardReason::IME_REQUEST_REASON_OTHER);
318 InputMethod_ErrorCode returnValue = OH_InputMethodController_Attach(g_txtEditProxy, g_options, &g_inputMethodProxy);
319 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
320 napi_value result = nullptr;
321 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
322 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodController_Attach successful.");
323 return result;
324 }
325 napi_value result = nullptr;
326 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
327 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodController_Attach fail.");
328 return result;
329 }
330
SUB_IMF_NDK_InputMethodController_Detach_0100(napi_env env,napi_callback_info info)331 static napi_value SUB_IMF_NDK_InputMethodController_Detach_0100(napi_env env, napi_callback_info info)
332 {
333 TextEditorProxy_Create();
334 AttachOptions_Create(false);
335 OH_InputMethodController_Attach(g_txtEditProxy, g_options, &g_inputMethodProxy);
336 InputMethod_ErrorCode returnValue = OH_InputMethodController_Detach(g_inputMethodProxy);
337 OH_TextEditorProxy_Destroy(g_txtEditProxy);
338 g_txtEditProxy = nullptr;
339 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
340 napi_value result = nullptr;
341 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
342 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodController_Detach successful.");
343 return result;
344 }
345 napi_value result = nullptr;
346 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
347 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodController_Detach fail.");
348 return result;
349 }
350
SUB_IMF_NDK_InputMethodProxy_ShowKeyboard_0100(napi_env env,napi_callback_info info)351 static napi_value SUB_IMF_NDK_InputMethodProxy_ShowKeyboard_0100(napi_env env, napi_callback_info info)
352 {
353 TextEditorProxy_Create();
354 AttachOptions_Create(false);
355 OH_InputMethodController_Attach(g_txtEditProxy, g_options, &g_inputMethodProxy);
356 InputMethod_ErrorCode returnValue = OH_InputMethodProxy_ShowKeyboard(g_inputMethodProxy);
357 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
358 napi_value result = nullptr;
359 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
360 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_ShowKeyboard successful.");
361 return result;
362 }
363 napi_value result = nullptr;
364 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
365 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_ShowKeyboard fail.");
366 return result;
367 }
368
SUB_IMF_NDK_InputMethodProxy_ShowTextInput_NONE(napi_env env,napi_callback_info info)369 static napi_value SUB_IMF_NDK_InputMethodProxy_ShowTextInput_NONE(napi_env env, napi_callback_info info)
370 {
371 OH_AttachOptions_CreateWithRequestKeyboardReason(true, InputMethod_RequestKeyboardReason::IME_REQUEST_REASON_NONE);
372 InputMethod_ErrorCode returnValue = OH_InputMethodProxy_ShowTextInput(g_inputMethodProxy, g_options);
373 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
374 napi_value result = nullptr;
375 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
376 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_ShowTextInput successful.");
377 return result;
378 }
379 napi_value result = nullptr;
380 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
381 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_ShowTextInput fail.");
382 return result;
383 }
384
SUB_IMF_NDK_InputMethodProxy_ShowTextInput_MOUSE(napi_env env,napi_callback_info info)385 static napi_value SUB_IMF_NDK_InputMethodProxy_ShowTextInput_MOUSE(napi_env env, napi_callback_info info)
386 {
387 OH_AttachOptions_CreateWithRequestKeyboardReason(true, InputMethod_RequestKeyboardReason::IME_REQUEST_REASON_MOUSE);
388 InputMethod_ErrorCode returnValue = OH_InputMethodProxy_ShowTextInput(g_inputMethodProxy, g_options);
389 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
390 napi_value result = nullptr;
391 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
392 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_ShowTextInput successful.");
393 return result;
394 }
395 napi_value result = nullptr;
396 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
397 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_ShowTextInput fail.");
398 return result;
399 }
400
SUB_IMF_NDK_InputMethodProxy_ShowTextInput_TOUCH(napi_env env,napi_callback_info info)401 static napi_value SUB_IMF_NDK_InputMethodProxy_ShowTextInput_TOUCH(napi_env env, napi_callback_info info)
402 {
403 OH_AttachOptions_CreateWithRequestKeyboardReason(true, InputMethod_RequestKeyboardReason::IME_REQUEST_REASON_TOUCH);
404 InputMethod_ErrorCode returnValue = OH_InputMethodProxy_ShowTextInput(g_inputMethodProxy, g_options);
405 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
406 napi_value result = nullptr;
407 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
408 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_ShowTextInput successful.");
409 return result;
410 }
411 napi_value result = nullptr;
412 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
413 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_ShowTextInput fail.");
414 return result;
415 }
416
SUB_IMF_NDK_InputMethodProxy_ShowTextInput_OTHER(napi_env env,napi_callback_info info)417 static napi_value SUB_IMF_NDK_InputMethodProxy_ShowTextInput_OTHER(napi_env env, napi_callback_info info)
418 {
419 OH_AttachOptions_CreateWithRequestKeyboardReason(true, InputMethod_RequestKeyboardReason::IME_REQUEST_REASON_OTHER);
420 InputMethod_ErrorCode returnValue = OH_InputMethodProxy_ShowTextInput(g_inputMethodProxy, g_options);
421 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
422 napi_value result = nullptr;
423 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
424 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_ShowTextInput successful.");
425 return result;
426 }
427 napi_value result = nullptr;
428 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
429 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_ShowTextInput fail.");
430 return result;
431 }
432
SUB_IMF_NDK_InputMethodProxy_HideKeyboard_0100(napi_env env,napi_callback_info info)433 static napi_value SUB_IMF_NDK_InputMethodProxy_HideKeyboard_0100(napi_env env, napi_callback_info info)
434 {
435 TextEditorProxy_Create();
436 AttachOptions_Create(true);
437 OH_InputMethodController_Attach(g_txtEditProxy, g_options, &g_inputMethodProxy);
438 InputMethod_ErrorCode returnValue = OH_InputMethodProxy_HideKeyboard(g_inputMethodProxy);
439 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
440 napi_value result = nullptr;
441 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
442 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_HideKeyboard successful.");
443 return result;
444 }
445 napi_value result = nullptr;
446 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
447 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_HideKeyboard fail.");
448 return result;
449 }
450
SUB_IMF_NDK_InputMethodProxy_NotifySelectionChange_0100(napi_env env,napi_callback_info info)451 static napi_value SUB_IMF_NDK_InputMethodProxy_NotifySelectionChange_0100(napi_env env, napi_callback_info info)
452 {
453 TextEditorProxy_Create();
454 AttachOptions_Create(true);
455 OH_InputMethodController_Attach(g_txtEditProxy, g_options, &g_inputMethodProxy);
456 char16_t text[] = u"TestValue";
457 InputMethod_ErrorCode returnValue = OH_InputMethodProxy_NotifySelectionChange(g_inputMethodProxy, text, 9, 1, 3);
458 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
459 napi_value result = nullptr;
460 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
461 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_NotifySelectionChange successful.");
462 return result;
463 }
464 napi_value result = nullptr;
465 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
466 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_NotifySelectionChange fail.");
467 return result;
468 }
469
SUB_IMF_NDK_InputMethodProxy_NotifyConfigurationChange_0100(napi_env env,napi_callback_info info)470 static napi_value SUB_IMF_NDK_InputMethodProxy_NotifyConfigurationChange_0100(napi_env env, napi_callback_info info)
471 {
472 TextEditorProxy_Create();
473 AttachOptions_Create(true);
474 OH_InputMethodController_Attach(g_txtEditProxy, g_options, &g_inputMethodProxy);
475 InputMethod_ErrorCode returnValue =
476 OH_InputMethodProxy_NotifyConfigurationChange(g_inputMethodProxy, IME_ENTER_KEY_SEND, IME_TEXT_INPUT_TYPE_TEXT);
477 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
478 napi_value result = nullptr;
479 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
480 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_NotifyConfigurationChange successful.");
481 return result;
482 }
483 napi_value result = nullptr;
484 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
485 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_NotifyConfigurationChange fail.");
486 return result;
487 }
488
SUB_IMF_NDK_InputMethodProxy_NotifyCursorUpdate_0100(napi_env env,napi_callback_info info)489 static napi_value SUB_IMF_NDK_InputMethodProxy_NotifyCursorUpdate_0100(napi_env env, napi_callback_info info)
490 {
491 TextEditorProxy_Create();
492 AttachOptions_Create(true);
493 OH_InputMethodController_Attach(g_txtEditProxy, g_options, &g_inputMethodProxy);
494 InputMethod_CursorInfo *cursorInfo = OH_CursorInfo_Create(100, 200, 300, 400);
495 InputMethod_ErrorCode returnValue = OH_InputMethodProxy_NotifyCursorUpdate(g_inputMethodProxy, cursorInfo);
496 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
497 napi_value result = nullptr;
498 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
499 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "",
500 "NDKTest====>SUB_IMF_NDK_InputMethodProxy_NotifyConfigurationChange_0100 successful.");
501 return result;
502 }
503 napi_value result = nullptr;
504 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
505 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "",
506 "NDKTest====>SUB_IMF_NDK_InputMethodProxy_NotifyConfigurationChange_0100 fail.");
507 return result;
508 }
509
SUB_IMF_NDK_InputMethodProxy_SendPrivateCommand_0100(napi_env env,napi_callback_info info)510 static napi_value SUB_IMF_NDK_InputMethodProxy_SendPrivateCommand_0100(napi_env env, napi_callback_info info)
511 {
512 TextEditorProxy_Create();
513 AttachOptions_Create(true);
514 OH_InputMethodController_Attach(g_txtEditProxy, g_options, &g_inputMethodProxy);
515 std::string keyStr1 = "testKey_1";
516 std::string valStr1 = "testValue_2";
517 InputMethod_PrivateCommand *keyCommand1 = nullptr;
518 keyCommand1 = OH_PrivateCommand_Create(const_cast<char *>(keyStr1.c_str()), keyStr1.length());
519 OH_PrivateCommand_SetStrValue(keyCommand1, const_cast<char *>(valStr1.c_str()), valStr1.length());
520 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_PrivateCommand_SetStrValue successful.");
521
522 std::string keyStr2 = "testKey_2";
523 bool valStr2 = true;
524 InputMethod_PrivateCommand *keyCommand2 = nullptr;
525 keyCommand2 = OH_PrivateCommand_Create(const_cast<char *>(keyStr2.c_str()), keyStr2.length());
526 OH_PrivateCommand_SetBoolValue(keyCommand2, valStr2);
527 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_PrivateCommand_SetBoolValue successful.");
528
529 std::string keyStr3 = "testKey_3";
530 int32_t valStr3 = 123456789;
531 InputMethod_PrivateCommand *keyCommand3 = nullptr;
532 keyCommand3 = OH_PrivateCommand_Create(const_cast<char *>(keyStr3.c_str()), keyStr3.length());
533 OH_PrivateCommand_SetIntValue(keyCommand3, valStr3);
534 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_PrivateCommand_SetIntValue successful.");
535
536 InputMethod_PrivateCommand *privateCommand[] = {keyCommand1, keyCommand2, keyCommand3};
537 InputMethod_ErrorCode returnValue = OH_InputMethodProxy_SendPrivateCommand(g_inputMethodProxy, privateCommand, 3);
538 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
539 napi_value result = nullptr;
540 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
541 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_SendPrivateCommand successful.");
542 return result;
543 }
544 OH_PrivateCommand_Destroy(*privateCommand);
545 napi_value result = nullptr;
546 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
547 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_SendPrivateCommand fail.");
548 return result;
549 }
550
SUB_IMF_NDK_PrivateCommand_SetKey_0100(napi_env env,napi_callback_info info)551 static napi_value SUB_IMF_NDK_PrivateCommand_SetKey_0100(napi_env env, napi_callback_info info)
552 {
553 std::string key = "key";
554 auto privateCommand = OH_PrivateCommand_Create(const_cast<char *>(key.c_str()), key.length());
555
556 std::string newKey = "newKey";
557 InputMethod_ErrorCode returnValue =
558 OH_PrivateCommand_SetKey(privateCommand, const_cast<char *>(newKey.c_str()), newKey.length());
559 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
560 napi_value result = nullptr;
561 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
562 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_SendPrivateCommand fail.");
563 return result;
564 }
565
566 const char *actStrKey = nullptr;
567 size_t actStrKeyLength = 0;
568 returnValue = OH_PrivateCommand_GetKey(privateCommand, &actStrKey, &actStrKeyLength);
569 if (actStrKey != newKey) {
570 napi_value result = nullptr;
571 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
572 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_PrivateCommand_GetKey fail.");
573 return result;
574 }
575
576 returnValue = OH_PrivateCommand_SetBoolValue(privateCommand, true);
577 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
578 napi_value result = nullptr;
579 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
580 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_PrivateCommand_SetBoolValue successful.");
581 return result;
582 }
583
584 bool actBoolValue = false;
585 returnValue = OH_PrivateCommand_GetBoolValue(privateCommand, &actBoolValue);
586 if (actBoolValue != true) {
587 napi_value result = nullptr;
588 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
589 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_PrivateCommand_GetBoolValue fail.");
590 return result;
591 }
592
593 returnValue = OH_PrivateCommand_SetIntValue(privateCommand, 0);
594 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
595 napi_value result = nullptr;
596 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
597 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_PrivateCommand_SetIntValue successful.");
598 return result;
599 }
600
601 int32_t actIntValue = 5;
602 returnValue = OH_PrivateCommand_GetIntValue(privateCommand, &actIntValue);
603 if (actIntValue != 0) {
604 napi_value result = nullptr;
605 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
606 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_PrivateCommand_GetIntValue fail.");
607 return result;
608 }
609
610 std::string extStrValue = "testString";
611 returnValue =
612 OH_PrivateCommand_SetStrValue(privateCommand, const_cast<char *>(extStrValue.c_str()), extStrValue.length());
613 if (returnValue == InputMethod_ErrorCode::IME_ERR_OK) {
614 napi_value result = nullptr;
615 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
616 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_PrivateCommand_SetStrValue successful.");
617 return result;
618 }
619
620 const char *actStrValue = nullptr;
621 size_t actStrValueLength = 0;
622 returnValue = OH_PrivateCommand_GetStrValue(privateCommand, &actStrValue, &actStrValueLength);
623 if (actStrValue != extStrValue) {
624 napi_value result = nullptr;
625 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
626 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>NDKTest====>OH_PrivateCommand_GetStrValue fail.");
627 return result;
628 }
629
630 InputMethod_CommandValueType valueType = IME_COMMAND_VALUE_TYPE_INT32;
631 OH_PrivateCommand_GetValueType(privateCommand, &valueType);
632 if (valueType != IME_COMMAND_VALUE_TYPE_STRING) {
633 napi_value result = nullptr;
634 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
635 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_PrivateCommand_GetBoolValue fail.");
636 return result;
637 }
638
639 napi_value result = nullptr;
640 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
641 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_PrivateCommand_GetValueType fail.");
642 return result;
643 }
644
SUB_IMF_NDK_TextAvoidInfo_Create_0100(napi_env env,napi_callback_info info)645 static napi_value SUB_IMF_NDK_TextAvoidInfo_Create_0100(napi_env env, napi_callback_info info)
646 {
647 double expPositionY = 20;
648 double expHeight = 20;
649 g_textAvoidInfo = OH_TextAvoidInfo_Create(expPositionY, expHeight);
650 double actPositionY = 0.0;
651 double actHeight = 0.0;
652 InputMethod_ErrorCode returnValue = OH_TextAvoidInfo_SetPositionY(g_textAvoidInfo, expPositionY);
653 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
654 napi_value result = nullptr;
655 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
656 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextAvoidInfo_SetPositionY fail.");
657 return result;
658 }
659
660 returnValue = OH_TextAvoidInfo_SetHeight(g_textAvoidInfo, expHeight);
661 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
662 napi_value result = nullptr;
663 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
664 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextAvoidInfo_SetHeight fail.");
665 return result;
666 }
667
668 returnValue = OH_TextAvoidInfo_GetPositionY(g_textAvoidInfo, &actPositionY);
669 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
670 napi_value result = nullptr;
671 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
672 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextAvoidInfo_GetPositionY fail.");
673 return result;
674 }
675 if (actPositionY != expPositionY) {
676 napi_value result = nullptr;
677 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
678 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>NDKTest====>expect != actual fail.");
679 return result;
680 }
681
682 returnValue = OH_TextAvoidInfo_GetHeight(g_textAvoidInfo, &actHeight);
683 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
684 napi_value result = nullptr;
685 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
686 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextAvoidInfo_GetHeight fail.");
687 return result;
688 }
689 if (actHeight != expHeight) {
690 napi_value result = nullptr;
691 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
692 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>NDKTest====>expect != actual fail.");
693 return result;
694 }
695
696 OH_TextAvoidInfo_Destroy(g_textAvoidInfo);
697
698 napi_value result = nullptr;
699 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
700 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>SUB_IMF_NDK_TextAvoidInfo_Create_0100 successful.");
701 return result;
702 }
703
SUB_IMF_NDK_TextConfig_Create_0100(napi_env env,napi_callback_info info)704 static napi_value SUB_IMF_NDK_TextConfig_Create_0100(napi_env env, napi_callback_info info)
705 {
706 InputMethod_TextConfig *config = OH_TextConfig_Create();
707 InputMethod_TextInputType expInputType = IME_TEXT_INPUT_TYPE_NUMBER_DECIMAL;
708 InputMethod_TextInputType actInputType = IME_TEXT_INPUT_TYPE_NONE;
709 InputMethod_EnterKeyType expEnterKeyType = IME_ENTER_KEY_UNSPECIFIED;
710 InputMethod_EnterKeyType actEnterKeyType = IME_ENTER_KEY_NONE;
711
712 InputMethod_ErrorCode returnValue = OH_TextConfig_SetInputType(config, expInputType);
713 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
714 napi_value result = nullptr;
715 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
716 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextConfig_SetInputType fail.");
717 return result;
718 }
719 returnValue = OH_TextConfig_GetInputType(config, &actInputType);
720 if (actInputType != expInputType) {
721 napi_value result = nullptr;
722 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
723 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextConfig_GetInputType fail.");
724 return result;
725 }
726
727 returnValue = OH_TextConfig_SetEnterKeyType(config, expEnterKeyType);
728 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
729 napi_value result = nullptr;
730 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
731 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextConfig_SetEnterKeyType fail.");
732 return result;
733 }
734 returnValue = OH_TextConfig_GetEnterKeyType(config, &actEnterKeyType);
735 if (actEnterKeyType != expEnterKeyType) {
736 napi_value result = nullptr;
737 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
738 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>expect != actual fail.");
739 return result;
740 }
741
742 returnValue = OH_TextConfig_SetPreviewTextSupport(config, true);
743 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
744 napi_value result = nullptr;
745 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
746 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextConfig_SetPreviewTextSupport fail.");
747 return result;
748 }
749 bool isPreviewTextSupported = false;
750 returnValue = OH_TextConfig_IsPreviewTextSupported(config, &isPreviewTextSupported);
751 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
752 napi_value result = nullptr;
753 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
754 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextConfig_IsPreviewTextSupported fail.");
755 return result;
756 }
757 if (isPreviewTextSupported != true) {
758 napi_value result = nullptr;
759 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
760 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_SendPrivateCommand fail.");
761 return result;
762 }
763
764 int32_t expStart = 1;
765 int32_t expEnd = 2;
766 returnValue = OH_TextConfig_SetSelection(config, expStart, expEnd);
767 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
768 napi_value result = nullptr;
769 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
770 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextConfig_SetSelection fail.");
771 return result;
772 }
773 int32_t actStart = 0;
774 int32_t actEnd = 0;
775 returnValue = OH_TextConfig_GetSelection(config, &actStart, &actEnd);
776 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
777 napi_value result = nullptr;
778 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
779 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextConfig_GetSelection fail.");
780 return result;
781 }
782 if (actStart != expStart or actEnd != expEnd) {
783 napi_value result = nullptr;
784 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
785 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>expect != actual fail.");
786 return result;
787 }
788
789 int32_t expWindowId = 1;
790 returnValue = OH_TextConfig_SetWindowId(config, expWindowId);
791 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
792 napi_value result = nullptr;
793 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
794 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextConfig_SetWindowId fail.");
795 return result;
796 }
797 int32_t actWindowId = 2;
798 returnValue = OH_TextConfig_GetWindowId(config, &actWindowId);
799 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
800 napi_value result = nullptr;
801 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
802 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextConfig_GetWindowId fail.");
803 return result;
804 }
805 if (actWindowId != expWindowId) {
806 napi_value result = nullptr;
807 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
808 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_InputMethodProxy_SendPrivateCommand fail.");
809 return result;
810 }
811
812 InputMethod_CursorInfo *cursorInfo = nullptr;
813 returnValue = OH_TextConfig_GetCursorInfo(config, &cursorInfo);
814 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
815 napi_value result = nullptr;
816 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
817 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextConfig_GetCursorInfo fail.");
818 return result;
819 }
820
821 double expPositionY = 20;
822 double expHeight = 20;
823 g_textAvoidInfo = OH_TextAvoidInfo_Create(expPositionY, expHeight);
824 returnValue = OH_TextConfig_GetTextAvoidInfo(config, &g_textAvoidInfo);
825 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
826 napi_value result = nullptr;
827 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
828 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextConfig_GetCursorInfo fail.");
829 return result;
830 }
831
832 const char16_t *expPlaceholder = u"abcdef";
833 size_t expPlaceholderLength = 3;
834 returnValue = OH_TextConfig_SetPlaceholder(config, expPlaceholder, expPlaceholderLength);
835 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
836 napi_value result = nullptr;
837 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
838 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextConfig_SetPlaceholder fail.");
839 return result;
840 }
841 char16_t actPlaceholder[5];
842 size_t actPlaceholderLength = 4;
843 returnValue = OH_TextConfig_GetPlaceholder(config, actPlaceholder, &actPlaceholderLength);
844 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
845 napi_value result = nullptr;
846 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
847 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextConfig_GetPlaceholder fail.");
848 return result;
849 }
850
851 const char16_t *expAbilityName = u"abcdef";
852 size_t expAbilityNameLength = 3;
853 returnValue = OH_TextConfig_SetAbilityName(config, expAbilityName, expAbilityNameLength);
854 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
855 napi_value result = nullptr;
856 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
857 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextConfig_SetAbilityName fail.");
858 return result;
859 }
860 char16_t actAbilityName[5];
861 size_t actAbilityNameLength = 4;
862 returnValue = OH_TextConfig_GetAbilityName(config, actAbilityName, &actAbilityNameLength);
863 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
864 napi_value result = nullptr;
865 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
866 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextConfig_GetAbilityName fail.");
867 return result;
868 }
869
870 OH_TextConfig_Destroy(config);
871
872 napi_value result = nullptr;
873 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
874 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>SUB_IMF_NDK_TextConfig_Create_0100 successful.");
875 return result;
876 }
877
SUB_IMF_NDK_TextEditorProxy_Get_0100(napi_env env,napi_callback_info info)878 static napi_value SUB_IMF_NDK_TextEditorProxy_Get_0100(napi_env env, napi_callback_info info)
879 {
880 TextEditorProxy_Create();
881 OH_TextEditorProxy_GetTextConfigFunc getTextConfigFunc = nullptr;
882 InputMethod_ErrorCode returnValue = OH_TextEditorProxy_GetGetTextConfigFunc(g_txtEditProxy, &getTextConfigFunc);
883 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
884 napi_value result = nullptr;
885 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
886 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextEditorProxy_GetGetTextConfigFunc fail.");
887 return result;
888 }
889
890 OH_TextEditorProxy_InsertTextFunc insertTextFunc = nullptr;
891 returnValue = OH_TextEditorProxy_GetInsertTextFunc(g_txtEditProxy, &insertTextFunc);
892 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
893 napi_value result = nullptr;
894 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
895 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextEditorProxy_GetInsertTextFunc fail.");
896 return result;
897 }
898
899 OH_TextEditorProxy_DeleteForwardFunc deleteForwardFunc = nullptr;
900 returnValue = OH_TextEditorProxy_GetDeleteForwardFunc(g_txtEditProxy, &deleteForwardFunc);
901 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
902 napi_value result = nullptr;
903 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
904 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextEditorProxy_GetDeleteForwardFunc fail.");
905 return result;
906 }
907
908 OH_TextEditorProxy_DeleteBackwardFunc deleteBackwardFunc = nullptr;
909 returnValue = OH_TextEditorProxy_GetDeleteBackwardFunc(g_txtEditProxy, &deleteBackwardFunc);
910 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
911 napi_value result = nullptr;
912 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
913 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextEditorProxy_GetDeleteBackwardFunc fail.");
914 return result;
915 }
916
917 OH_TextEditorProxy_SendKeyboardStatusFunc sendKeyboardStatusFunc = nullptr;
918 returnValue = OH_TextEditorProxy_GetSendKeyboardStatusFunc(g_txtEditProxy, &sendKeyboardStatusFunc);
919 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
920 napi_value result = nullptr;
921 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
922 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextEditorProxy_GetSendKeyboardStatusFunc fail.");
923 return result;
924 }
925
926 OH_TextEditorProxy_SendEnterKeyFunc sendEnterKeyFunc = nullptr;
927 returnValue = OH_TextEditorProxy_GetSendEnterKeyFunc(g_txtEditProxy, &sendEnterKeyFunc);
928 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
929 napi_value result = nullptr;
930 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
931 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextEditorProxy_GetSendEnterKeyFunc fail.");
932 return result;
933 }
934
935 OH_TextEditorProxy_MoveCursorFunc moveCursorFunc = nullptr;
936 returnValue = OH_TextEditorProxy_GetMoveCursorFunc(g_txtEditProxy, &moveCursorFunc);
937 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
938 napi_value result = nullptr;
939 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
940 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextEditorProxy_GetMoveCursorFunc fail.");
941 return result;
942 }
943
944 OH_TextEditorProxy_HandleSetSelectionFunc handleSetSelectionFunc = nullptr;
945 returnValue = OH_TextEditorProxy_GetHandleSetSelectionFunc(g_txtEditProxy, &handleSetSelectionFunc);
946 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
947 napi_value result = nullptr;
948 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
949 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextEditorProxy_GetHandleSetSelectionFunc fail.");
950 return result;
951 }
952
953 OH_TextEditorProxy_HandleExtendActionFunc handleExtendActionFunc = nullptr;
954 returnValue = OH_TextEditorProxy_GetHandleExtendActionFunc(g_txtEditProxy, &handleExtendActionFunc);
955 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
956 napi_value result = nullptr;
957 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
958 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextEditorProxy_GetHandleExtendActionFunc fail.");
959 return result;
960 }
961
962 OH_TextEditorProxy_GetLeftTextOfCursorFunc getLeftTextOfCursorFunc = nullptr;
963 returnValue = OH_TextEditorProxy_GetGetLeftTextOfCursorFunc(g_txtEditProxy, &getLeftTextOfCursorFunc);
964 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
965 napi_value result = nullptr;
966 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
967 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextEditorProxy_GetGetLeftTextOfCursorFunc fail.");
968 return result;
969 }
970
971 OH_TextEditorProxy_GetRightTextOfCursorFunc getRightTextOfCursorFunc = nullptr;
972 returnValue = OH_TextEditorProxy_GetGetRightTextOfCursorFunc(g_txtEditProxy, &getRightTextOfCursorFunc);
973 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
974 napi_value result = nullptr;
975 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
976 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextEditorProxy_GetGetRightTextOfCursorFunc fail.");
977 return result;
978 }
979
980 OH_TextEditorProxy_GetTextIndexAtCursorFunc getTextIndexAtCursorFunc = nullptr;
981 returnValue = OH_TextEditorProxy_GetGetTextIndexAtCursorFunc(g_txtEditProxy, &getTextIndexAtCursorFunc);
982 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
983 napi_value result = nullptr;
984 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
985 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextEditorProxy_GetGetTextIndexAtCursorFunc fail.");
986 return result;
987 }
988
989 OH_TextEditorProxy_ReceivePrivateCommandFunc receivePrivateCommandFunc = nullptr;
990 returnValue = OH_TextEditorProxy_GetReceivePrivateCommandFunc(g_txtEditProxy, &receivePrivateCommandFunc);
991 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
992 napi_value result = nullptr;
993 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
994 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextEditorProxy_GetReceivePrivateCommandFunc fail.");
995 return result;
996 }
997
998 OH_TextEditorProxy_SetPreviewTextFunc setPreviewTextFunc = nullptr;
999 returnValue = OH_TextEditorProxy_GetSetPreviewTextFunc(g_txtEditProxy, &setPreviewTextFunc);
1000 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
1001 napi_value result = nullptr;
1002 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
1003 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextEditorProxy_GetSetPreviewTextFunc fail.");
1004 return result;
1005 }
1006
1007 OH_TextEditorProxy_FinishTextPreviewFunc finishTextPreviewFunc = nullptr;
1008 returnValue = OH_TextEditorProxy_GetFinishTextPreviewFunc(g_txtEditProxy, &finishTextPreviewFunc);
1009 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
1010 napi_value result = nullptr;
1011 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
1012 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_TextEditorProxy_GetFinishTextPreviewFunc fail.");
1013 return result;
1014 }
1015
1016 napi_value result = nullptr;
1017 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
1018 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>SUB_IMF_NDK_TextEditorProxy_Get_0100 successful.");
1019 return result;
1020 }
1021
SUB_IMF_NDK_CursorInfo_Create_0100(napi_env env,napi_callback_info info)1022 static napi_value SUB_IMF_NDK_CursorInfo_Create_0100(napi_env env, napi_callback_info info)
1023 {
1024 double expLeft = 1.1;
1025 double expTop = 2.2;
1026 double expWidth = 3.3;
1027 double expHeight = 4.4;
1028 auto cursorInfo = OH_CursorInfo_Create(expLeft, expTop, expWidth, expHeight);
1029 double actLeft = 0;
1030 double actTop = 0;
1031 double actWidth = 0;
1032 double actHeight = 0;
1033 InputMethod_ErrorCode returnValue = OH_CursorInfo_SetRect(cursorInfo, actLeft, actTop, actWidth, actHeight);
1034 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
1035 napi_value result = nullptr;
1036 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
1037 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_CursorInfo_SetRect fail.");
1038 return result;
1039 }
1040
1041 returnValue = OH_CursorInfo_GetRect(cursorInfo, &actLeft, &actTop, &actWidth, &actHeight);
1042 if (returnValue != InputMethod_ErrorCode::IME_ERR_OK) {
1043 napi_value result = nullptr;
1044 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
1045 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "", "NDKTest====>OH_CursorInfo_GetRect fail.");
1046 return result;
1047 }
1048 if (actLeft != 0.0 or actTop != 0.0 or actWidth != 0.0 or actHeight != 0.0) {
1049 napi_value result = nullptr;
1050 NAPI_CALL(env, napi_create_int32(env, returnValue, &result));
1051 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "",
1052 "NDKTest====>SUB_IMF_NDK_InputMethodProxy_NotifyConfigurationChange_0100 fail.");
1053 return result;
1054 }
1055 OH_CursorInfo_Destroy(cursorInfo);
1056
1057 napi_value result = nullptr;
1058 NAPI_CALL(env, napi_create_string_utf8(env, "OK", NAPI_AUTO_LENGTH, &result));
1059 OH_LOG_Print(LOG_APP, LOG_INFO, 0, "",
1060 "NDKTest====>SUB_IMF_NDK_InputMethodProxy_NotifyConfigurationChange_0100 successful.");
1061 return result;
1062 }
1063
1064
1065 EXTERN_C_START
Init(napi_env env,napi_value exports)1066 static napi_value Init(napi_env env, napi_value exports)
1067 {
1068 napi_property_descriptor desc[] = {
1069 {"SUB_IMF_NDK_AttachOptions_Create_0100", nullptr, SUB_IMF_NDK_AttachOptions_Create_0100, nullptr, nullptr,
1070 nullptr, napi_default, nullptr},
1071 {"SUB_IMF_NDK_InputMethodController_Attach_0100", nullptr, SUB_IMF_NDK_InputMethodController_Attach_0100,
1072 nullptr, nullptr, nullptr, napi_default, nullptr},
1073 {"SUB_IMF_NDK_InputMethodController_Detach_0100", nullptr, SUB_IMF_NDK_InputMethodController_Detach_0100,
1074 nullptr, nullptr, nullptr, napi_default, nullptr},
1075 {"SUB_IMF_NDK_InputMethodProxy_ShowKeyboard_0100", nullptr, SUB_IMF_NDK_InputMethodProxy_ShowKeyboard_0100,
1076 nullptr, nullptr, nullptr, napi_default, nullptr},
1077 {"SUB_IMF_NDK_InputMethodProxy_HideKeyboard_0100", nullptr, SUB_IMF_NDK_InputMethodProxy_HideKeyboard_0100,
1078 nullptr, nullptr, nullptr, napi_default, nullptr},
1079 {"SUB_IMF_NDK_InputMethodProxy_NotifySelectionChange_0100", nullptr,
1080 SUB_IMF_NDK_InputMethodProxy_NotifySelectionChange_0100, nullptr, nullptr, nullptr, napi_default, nullptr},
1081 {"SUB_IMF_NDK_InputMethodProxy_NotifyConfigurationChange_0100", nullptr,
1082 SUB_IMF_NDK_InputMethodProxy_NotifyConfigurationChange_0100, nullptr, nullptr, nullptr, napi_default, nullptr},
1083 {"SUB_IMF_NDK_InputMethodProxy_NotifyCursorUpdate_0100", nullptr,
1084 SUB_IMF_NDK_InputMethodProxy_NotifyCursorUpdate_0100, nullptr, nullptr, nullptr, napi_default, nullptr},
1085 {"SUB_IMF_NDK_InputMethodProxy_SendPrivateCommand_0100", nullptr,
1086 SUB_IMF_NDK_InputMethodProxy_SendPrivateCommand_0100, nullptr, nullptr, nullptr, napi_default, nullptr},
1087 {"SUB_IMF_NDK_PrivateCommand_SetKey_0100", nullptr, SUB_IMF_NDK_PrivateCommand_SetKey_0100, nullptr, nullptr,
1088 nullptr, napi_default, nullptr},
1089 {"SUB_IMF_NDK_TextAvoidInfo_Create_0100", nullptr, SUB_IMF_NDK_TextAvoidInfo_Create_0100, nullptr, nullptr,
1090 nullptr, napi_default, nullptr},
1091 {"SUB_IMF_NDK_TextConfig_Create_0100", nullptr, SUB_IMF_NDK_TextConfig_Create_0100, nullptr, nullptr, nullptr,
1092 napi_default, nullptr},
1093 {"SUB_IMF_NDK_TextEditorProxy_Get_0100", nullptr, SUB_IMF_NDK_TextEditorProxy_Get_0100, nullptr, nullptr,
1094 nullptr, napi_default, nullptr},
1095 {"SUB_IMF_NDK_CursorInfo_Create_0100", nullptr, SUB_IMF_NDK_CursorInfo_Create_0100, nullptr, nullptr, nullptr,
1096 napi_default, nullptr},
1097 {"SUB_IMF_NDK_InputMethodController_Attach_MOUSE", nullptr,
1098 SUB_IMF_NDK_InputMethodController_Attach_MOUSE, nullptr, nullptr, nullptr, napi_default, nullptr},
1099 {"SUB_IMF_NDK_InputMethodController_Attach_TOUCH", nullptr,
1100 SUB_IMF_NDK_InputMethodController_Attach_TOUCH, nullptr, nullptr, nullptr, napi_default, nullptr},
1101 {"SUB_IMF_NDK_InputMethodController_Attach_NONE", nullptr,
1102 SUB_IMF_NDK_InputMethodController_Attach_NONE, nullptr, nullptr, nullptr, napi_default, nullptr},
1103 {"SUB_IMF_NDK_AttachOptions_CreateWithRequestKeyboardReason_NONE", nullptr,
1104 SUB_IMF_NDK_AttachOptions_CreateWithRequestKeyboardReason_NONE, nullptr, nullptr,
1105 nullptr, napi_default, nullptr},
1106 {"SUB_IMF_NDK_AttachOptions_CreateWithRequestKeyboardReason_MOUSE", nullptr,
1107 SUB_IMF_NDK_AttachOptions_CreateWithRequestKeyboardReason_MOUSE, nullptr, nullptr,
1108 nullptr, napi_default, nullptr},
1109 {"SUB_IMF_NDK_AttachOptions_CreateWithRequestKeyboardReason_TOUCH", nullptr,
1110 SUB_IMF_NDK_AttachOptions_CreateWithRequestKeyboardReason_TOUCH, nullptr, nullptr,
1111 nullptr, napi_default, nullptr},
1112 {"SUB_IMF_NDK_AttachOptions_CreateWithRequestKeyboardReason_OTHER", nullptr,
1113 SUB_IMF_NDK_AttachOptions_CreateWithRequestKeyboardReason_OTHER, nullptr, nullptr,
1114 nullptr, napi_default, nullptr},
1115 {"SUB_IMF_NDK_InputMethodProxy_ShowTextInput_NONE", nullptr,
1116 SUB_IMF_NDK_InputMethodProxy_ShowTextInput_NONE, nullptr, nullptr, nullptr, napi_default, nullptr},
1117 {"SUB_IMF_NDK_InputMethodProxy_ShowTextInput_MOUSE", nullptr,
1118 SUB_IMF_NDK_InputMethodProxy_ShowTextInput_MOUSE, nullptr, nullptr, nullptr, napi_default, nullptr},
1119 {"SUB_IMF_NDK_InputMethodProxy_ShowTextInput_TOUCH", nullptr,
1120 SUB_IMF_NDK_InputMethodProxy_ShowTextInput_TOUCH, nullptr, nullptr, nullptr, napi_default, nullptr},
1121 {"SUB_IMF_NDK_InputMethodProxy_ShowTextInput_OTHER", nullptr,
1122 SUB_IMF_NDK_InputMethodProxy_ShowTextInput_OTHER, nullptr, nullptr, nullptr, napi_default, nullptr}};
1123 napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
1124 return exports;
1125 }
1126 EXTERN_C_END
1127
1128 static napi_module demoModule = {
1129 .nm_version = 1,
1130 .nm_flags = 0,
1131 .nm_filename = nullptr,
1132 .nm_register_func = Init,
1133 .nm_modname = "entry",
1134 .nm_priv = ((void *)0),
1135 .reserved = {0},
1136 };
1137
RegisterEntryModule(void)1138 extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); }
1139