• 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_MESSAGE_HANDLER_PROXY_CAPI_H
16 #define OHOS_INPUTMETHOD_MESSAGE_HANDLER_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_text_editor_proxy_capi.h
28  *
29  * @brief Provides functions for getting requests and notifications from input method.
30  *
31  * @library libohinputmethod.so
32  * @kit IMEKit
33  * @syscap SystemCapability.MiscServices.InputMethodFramework
34  * @since 16
35  * @version 1.0
36  */
37 #include <stddef.h>
38 
39 #include "inputmethod_text_config_capi.h"
40 #include "inputmethod_types_capi.h"
41 #ifdef __cplusplus
42 extern "C" {
43 #endif /* __cplusplus */
44 /**
45  * @brief Define the InputMethod_MessageHandlerProxy structure type.
46  *
47  * Provides methods for getting requests and notifications from input method.\n
48  * When input method sends request or notification to editor, the methods will be called.\n
49  *
50  * @since 16
51  */
52 typedef struct InputMethod_MessageHandlerProxy InputMethod_MessageHandlerProxy;
53 
54 /**
55  * @brief Called when input method sending private command.
56  *
57  * You need to implement this function, set it to {@link InputMethod_MessageHandlerProxy} through {@link
58  * OH_TextEditorProxy_SetOnTerminatedFunc}, and use {@link OH_InputMethodProxy_RecvMessage} to complete the
59  * registration.\n
60  *
61  * @param messageHandlerProxy Represents a pointer to an
62  *                            {@link InputMethod_MessageHandlerProxy} instance which will be set in.
63  * @return Returns the result of handling private command.
64  * @since 16
65  */
66 typedef int32_t (*OH_MessageHandlerProxy_OnTerminatedFunc)(InputMethod_MessageHandlerProxy *messageHandlerProxy);
67 
68 /**
69  * @brief Called when input method finishing preview text.
70  *
71  * You need to implement this function, set it to {@link InputMethod_MessageHandlerProxy} through {@link
72  * OH_TextEditorProxy_SetOnMessageFunc}, and use {@link OH_InputMethodProxy_RecvMessage} to complete the
73  * registration.\n
74  *
75  * @param messageHandlerProxy Represents a pointer to an
76  *                            {@link InputMethod_MessageHandlerProxy} instance which will be set in.
77  * @param msgId ArrayBuffer.msgId from input method.
78  * @param msgIdLength Size of ArrayBuffer.msgId.
79  * @param msgParam ArrayBuffer.msgParam from input method.
80  * @param msgParamLength Size of ArrayBuffer.msgParam.
81  * @since 16
82  */
83 typedef int32_t (*OH_MessageHandlerProxy_OnMessageFunc)(InputMethod_MessageHandlerProxy *messageHandlerProxy,
84     const char16_t msgId[], size_t msgIdLength, const uint8_t *msgParam, size_t msgParamLength);
85 
86 /**
87  * @brief Create a new {@link InputMethod_MessageHandlerProxy} instance.
88  *
89  * @return If the creation succeeds, a pointer to the newly created {@link InputMethod_MessageHandlerProxy}
90  * instance is returned. If the creation fails, NULL is returned, possible cause is insufficient memory.
91  * @since 12
92  */
93 InputMethod_MessageHandlerProxy *OH_MessageHandlerProxy_Create(void);
94 
95 /**
96  * @brief Destroy a {@link InputMethod_MessageHandlerProxy} instance.
97  *
98  * @param proxy The {@link InputMethod_MessageHandlerProxy} instance to be destroyed.
99  * @since 16
100  */
101 void OH_MessageHandlerProxy_Destroy(InputMethod_MessageHandlerProxy *proxy);
102 
103 /**
104  * @brief Set function {@link OH_MessageHandlerProxy_OnTerminatedFunc} into {@link InputMethod_MessageHandlerProxy}.
105  *
106  * @param proxy Represents a pointer to an
107  *              {@link InputMethod_MessageHandlerProxy} instance which will be set function in.
108  * @param onTerminatedFunc Represents function {@link OH_MessageHandlerProxy_SetOnTerminatedFunc} which
109  * will be set.
110  * @return Returns a specific error code.
111  *     {@link IME_ERR_OK} - success.
112  *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
113  * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
114  * @since 16
115  */
116 InputMethod_ErrorCode OH_MessageHandlerProxy_SetOnTerminatedFunc(
117     InputMethod_MessageHandlerProxy *proxy, OH_MessageHandlerProxy_OnTerminatedFunc onTerminatedFunc);
118 
119 /**
120  * @brief Get function {@link OH_MessageHandlerProxy_OnTerminatedFunc} from {@link InputMethod_MessageHandlerProxy}.
121  *
122  * @param proxy Represents a pointer to an
123  *              {@link InputMethod_MessageHandlerProxy} instance which will be get function from.
124  * @param onTerminatedFunc Represents function {@link OH_MessageHandlerProxy_GetOnTerminatedFunc} which
125  * will be get.
126  * @return Returns a specific error code.
127  *     {@link IME_ERR_OK} - success.
128  *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
129  * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
130  * @since 16
131  */
132 InputMethod_ErrorCode OH_MessageHandlerProxy_GetOnTerminatedFunc(
133     InputMethod_MessageHandlerProxy *proxy, OH_MessageHandlerProxy_OnTerminatedFunc *onTerminatedFunc);
134 
135 /**
136  * @brief Set function {@link OH_MessageHandlerProxy_OnMessageFunc} into {@link InputMethod_MessageHandlerProxy}.
137  *
138  * @param proxy Represents a pointer to an
139  *              {@link InputMethod_MessageHandlerProxy} instance which will be set function in.
140  * @param onMessageFunc Represents function {@link OH_MessageHandlerProxy_SetOnMessageFunc} which
141  * will be set.
142  * @return Returns a specific error code.
143  *     {@link IME_ERR_OK} - success.
144  *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
145  * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
146  * @since 16
147  */
148 InputMethod_ErrorCode OH_MessageHandlerProxy_SetOnMessageFunc(
149     InputMethod_MessageHandlerProxy *proxy, OH_MessageHandlerProxy_OnMessageFunc onMessageFunc);
150 
151 /**
152  * @brief Get function {@link OH_MessageHandlerProxy_OnMessageFunc} from {@link InputMethod_MessageHandlerProxy}.
153  *
154  * @param proxy Represents a pointer to an {@link InputMethod_MessageHandlerProxy} instance which will be get function
155  * from.
156  * @param onMessageFunc Represents function {@link OH_MessageHandlerProxy_GetOnMessageFunc} which
157  * will be get.
158  * @return Returns a specific error code.
159  *     {@link IME_ERR_OK} - success.
160  *     {@link IME_ERR_NULL_POINTER} - unexpected null pointer.
161  * Specific error codes can be referenced {@link InputMethod_ErrorCode}.
162  * @since 16
163  */
164 InputMethod_ErrorCode OH_MessageHandlerProxy_GetOnMessageFunc(
165     InputMethod_MessageHandlerProxy *proxy, OH_MessageHandlerProxy_OnMessageFunc *onMessageFunc);
166 #ifdef __cplusplus
167 }
168 #endif /* __cplusplus */
169 /** @} */
170 #endif // OHOS_INPUTMETHOD_MESSAGE_HANDLER_PROXY_CAPI_H