• 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 #ifndef OHOS_INPUTMETHOD_INPUTMETHOD_PROXY_CAPI_H
16 #define OHOS_INPUTMETHOD_INPUTMETHOD_PROXY_CAPI_H
17 /**
18  * @addtogroup InputMethod
19  * @{
20  *
21  * @brief InputMethod provides functions to use input methods and develop input methods.
22  *
23  * @since 12
24  */
25 
26 /**
27  * @file inputmethod_inputmethod_proxy_capi.h
28  *
29  * @brief Provides functions to use input methods.
30  *
31  * @library libohinputmethod.so
32  * @kit IMEKit
33  * @syscap SystemCapability.MiscServices.InputMethodFramework
34  * @since 12
35  * @version 1.0
36  */
37 #include <stddef.h>
38 
39 #include "inputmethod_types_capi.h"
40 #include "inputmethod_attach_options_capi.h"
41 #include "inputmethod_cursor_info_capi.h"
42 #include "inputmethod_private_command_capi.h"
43 #include "inputmethod_message_handler_proxy_capi.h"
44 #ifdef __cplusplus
45 extern "C"{
46 #endif /* __cplusplus */
47 /**
48  * @brief Define the InputMethod_InputMethodProxy structure type.
49  *
50  * Provides methods for controlling input method.
51  *
52  * @since 12
53  */
54 typedef struct InputMethod_InputMethodProxy InputMethod_InputMethodProxy;
55 
56 /**
57  * @brief Show keyboard.
58  *
59  * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance.
60  *     The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}.
61  * @return Returns a specific error code.
62  *     {@link IME_ERR_OK} - success.
63  *     {@link IME_ERR_IMCLIENT} - input method client error.
64  *     {@link IME_ERR_IMMS} - input method manager service error.
65  *     {@link IME_ERR_DETACHED} - input method client detached.
66  *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
67  * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
68  * @since 12
69  */
70 InputMethod_ErrorCode OH_InputMethodProxy_ShowKeyboard(InputMethod_InputMethodProxy *inputMethodProxy);
71 /**
72  * @brief ShowTextInput.
73  *
74  * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance.
75  *     The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}.
76  * @param options Represents a pointer to an {@link InputMethod_AttachOptions} instance which will be get value from.
77  * @return Returns a specific error code.
78  *     {@link IME_ERR_OK} - success.
79  *     {@link IME_ERR_IMCLIENT} - input method client error.
80  *     {@link IME_ERR_IMMS} - input method manager service error.
81  *     {@link IME_ERR_DETACHED} - input method client detached.
82  *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
83  * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
84  * @since 16
85  */
86 InputMethod_ErrorCode OH_InputMethodProxy_ShowTextInput(
87     InputMethod_InputMethodProxy *inputMethodProxy, InputMethod_AttachOptions *options);
88 /**
89  * @brief Hide keyboard.
90  *
91  * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance.
92  *     The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}.
93  * @return Returns a specific error code.
94  *     {@link IME_ERR_OK} - success.
95  *     {@link IME_ERR_IMCLIENT} - input method client error.
96  *     {@link IME_ERR_IMMS} - input method manager service error.
97  *     {@link IME_ERR_DETACHED} - input method client detached.
98  *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
99  * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
100  * @since 12
101  */
102 InputMethod_ErrorCode OH_InputMethodProxy_HideKeyboard(InputMethod_InputMethodProxy *inputMethodProxy);
103 
104 /**
105  * @brief Notify selection change.
106  *
107  * Notify selection change when text or cursor position or selected text changed.
108  *
109  * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance.
110  *     The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}.
111  * @param text The whole input text.
112  * @param length The length of text. Max length is 8K.
113  * @param start The start position of selected text.
114  * @param end The end position of selected text.
115  * @return Returns a specific error code.
116  *     {@link IME_ERR_OK} - success.
117  *     {@link IME_ERR_PARAMCHECK} - parameter check failed.
118  *     {@link IME_ERR_IMCLIENT} - input method client error.
119  *     {@link IME_ERR_IMMS} - input method manager service error.
120  *     {@link IME_ERR_DETACHED} - input method client detached.
121  *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
122  * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
123  * @since 12
124  */
125 InputMethod_ErrorCode OH_InputMethodProxy_NotifySelectionChange(
126     InputMethod_InputMethodProxy *inputMethodProxy, char16_t text[], size_t length, int start, int end);
127 
128 /**
129  * @brief Notify text editor configuration change.
130  *
131  * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance.
132  *     The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}.
133  * @param enterKey The enter key type.
134  * @param textType The text input type.
135  * @return Returns a specific error code.
136  *     {@link IME_ERR_OK} - success.
137  *     {@link IME_ERR_PARAMCHECK} - parameter check failed.
138  *     {@link IME_ERR_IMCLIENT} - input method client error.
139  *     {@link IME_ERR_IMMS} - input method manager service error.
140  *     {@link IME_ERR_DETACHED} - input method client detached.
141  *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
142  * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
143  * @since 12
144  */
145 InputMethod_ErrorCode OH_InputMethodProxy_NotifyConfigurationChange(InputMethod_InputMethodProxy *inputMethodProxy,
146     InputMethod_EnterKeyType enterKey, InputMethod_TextInputType textType);
147 
148 /**
149  * @brief Notify cursor update.
150  *
151  * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance.
152  *     The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}.
153  * @param cursorInfo Represents a pointer to an {@link InputMethod_CursorInfo} instance.
154  *     The cursor information.
155  * @return Returns a specific error code.
156  *     {@link IME_ERR_OK} - success.
157  *     {@link IME_ERR_PARAMCHECK} - parameter check failed.
158  *     {@link IME_ERR_IMCLIENT} - input method client error.
159  *     {@link IME_ERR_IMMS} - input method manager service error.
160  *     {@link IME_ERR_DETACHED} - input method client detached.
161  *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
162  * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
163  * @since 12
164  */
165 InputMethod_ErrorCode OH_InputMethodProxy_NotifyCursorUpdate(
166     InputMethod_InputMethodProxy *inputMethodProxy, InputMethod_CursorInfo *cursorInfo);
167 
168 /**
169  * @brief Send private command.
170  *
171  * @param inputMethodProxy Represents a pointer to an {@link OH_InputMethod_InputMethodProxy} instance.
172  *     The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}.
173  * @param privateCommand The private commands, which is defined in {@link InputMethod_PrivateCommand}. Max size 32KB.
174  * @param size The size of privateCommand. Max is 5.
175  * @return Returns a specific error code.
176  *     {@link IME_ERR_OK} - success.
177  *     {@link IME_ERR_PARAMCHECK} - parameter check failed.
178  *     {@link IME_ERR_IMCLIENT} - input method client error.
179  *     {@link IME_ERR_IMMS} - input method manager service error.
180  *     {@link IME_ERR_DETACHED} - input method client detached.
181  *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
182  * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
183  * @since 12
184  */
185 InputMethod_ErrorCode OH_InputMethodProxy_SendPrivateCommand(
186     InputMethod_InputMethodProxy *inputMethodProxy, InputMethod_PrivateCommand *privateCommand[], size_t size);
187 
188 /**
189  * @brief Send private command.
190  *
191  * @param inputMethodProxy Represents a pointer to an {@link OH_InputMethod_InputMethodProxy} instance.
192  *     The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}.
193  * @param msgId The ArrayBuffer.msgId, which is defined in {@link InputMethod_PrivateCommand}. Max size 256B.
194  * @param msgIdLength The size of ArrayBuffer.msgId. Max is 256B.
195  * @param msgParam The private commands, which is defined in {@link InputMethod_PrivateCommand}. Max size 128KB.
196  * @param msgParamLength The size of ArrayBuffer.msgParam. Max is 128KB.
197  * @param size The size of privateCommand. Max is 5.
198  * @return Returns a specific error code.
199  *     {@link IME_ERR_OK} - success.
200  *     {@link IME_ERR_PARAMCHECK} - parameter check failed.
201  *     {@link IME_ERR_IMCLIENT} - input method client error.
202  *     {@link IME_ERR_IMMS} - input method manager service error.
203  *     {@link IME_ERR_DETACHED} - input method client detached.
204  *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
205  * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
206  * @since 16
207  */
208 InputMethod_ErrorCode OH_InputMethodProxy_SendMessage(InputMethod_InputMethodProxy *inputMethodProxy,
209     const char16_t *msgId, size_t msgIdLength, const uint8_t *msgParam, size_t msgParamLength);
210 
211 /**
212  * @brief Register message handler.
213  *
214  * @param inputMethodProxy Represents a pointer to an {@link OH_InputMethod_InputMethodProxy} instance.
215  *     The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}.
216  * @param messageHandler Represents a pointer to an {@link InputMethod_MessageHandlerProxy} instance.
217  *     The caller needs to manage the lifecycle of messageHandler.
218  * @return Returns a specific error code.
219  *     {@link IME_ERR_OK} - success.
220  *     {@link IME_ERR_PARAMCHECK} - parameter check failed.
221  *     {@link IME_ERR_IMCLIENT} - input method client error.
222  *     {@link IME_ERR_IMMS} - input method manager service error.
223  *     {@link IME_ERR_DETACHED} - input method client detached.
224  *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
225  * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
226  * @since 16
227  */
228 InputMethod_ErrorCode OH_InputMethodProxy_RecvMessage(
229     InputMethod_InputMethodProxy *inputMethodProxy, InputMethod_MessageHandlerProxy *messageHandler);
230 #ifdef __cplusplus
231 }
232 #endif /* __cplusplus */
233 /** @} */
234 #endif // INPUTMETHOD_INPUTMETHOD_PROXY_CAP_H