• 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 #include "global.h"
17 #include "native_inputmethod_types.h"
18 using namespace OHOS::MiscServices;
OH_MessageHandlerProxy_Create(void)19 InputMethod_MessageHandlerProxy *OH_MessageHandlerProxy_Create(void)
20 {
21     return new (std::nothrow) InputMethod_MessageHandlerProxy();
22 }
23 
OH_MessageHandlerProxy_Destroy(InputMethod_MessageHandlerProxy * proxy)24 void OH_MessageHandlerProxy_Destroy(InputMethod_MessageHandlerProxy *proxy)
25 {
26     if (proxy == nullptr) {
27         IMSA_HILOGE("proxy is nullptr");
28         return;
29     }
30     delete proxy;
31 }
32 
OH_MessageHandlerProxy_SetOnTerminatedFunc(InputMethod_MessageHandlerProxy * proxy,OH_MessageHandlerProxy_OnTerminatedFunc onTerminatedFunc)33 InputMethod_ErrorCode OH_MessageHandlerProxy_SetOnTerminatedFunc(
34     InputMethod_MessageHandlerProxy *proxy, OH_MessageHandlerProxy_OnTerminatedFunc onTerminatedFunc)
35 {
36     if (proxy == nullptr) {
37         IMSA_HILOGE("proxy is nullptr");
38         return IME_ERR_NULL_POINTER;
39     }
40 
41     if (onTerminatedFunc == nullptr) {
42         IMSA_HILOGE("onTerminatedFunc is nullptr");
43         return IME_ERR_NULL_POINTER;
44     }
45 
46     proxy->onTerminatedFunc = onTerminatedFunc;
47     return IME_ERR_OK;
48 }
49 
OH_MessageHandlerProxy_GetOnTerminatedFunc(InputMethod_MessageHandlerProxy * proxy,OH_MessageHandlerProxy_OnTerminatedFunc * onTerminatedFunc)50 InputMethod_ErrorCode OH_MessageHandlerProxy_GetOnTerminatedFunc(
51     InputMethod_MessageHandlerProxy *proxy, OH_MessageHandlerProxy_OnTerminatedFunc *onTerminatedFunc)
52 {
53     if (proxy == nullptr) {
54         IMSA_HILOGE("proxy is nullptr");
55         return IME_ERR_NULL_POINTER;
56     }
57     if (onTerminatedFunc == nullptr) {
58         IMSA_HILOGE("onTerminatedFunc is nullptr");
59         return IME_ERR_NULL_POINTER;
60     }
61     *onTerminatedFunc = proxy->onTerminatedFunc;
62     return IME_ERR_OK;
63 }
64 
OH_MessageHandlerProxy_SetOnMessageFunc(InputMethod_MessageHandlerProxy * proxy,OH_MessageHandlerProxy_OnMessageFunc onMessageFunc)65 InputMethod_ErrorCode OH_MessageHandlerProxy_SetOnMessageFunc(
66     InputMethod_MessageHandlerProxy *proxy, OH_MessageHandlerProxy_OnMessageFunc onMessageFunc)
67 {
68     if (proxy == nullptr) {
69         IMSA_HILOGE("proxy is nullptr");
70         return IME_ERR_NULL_POINTER;
71     }
72 
73     if (onMessageFunc == nullptr) {
74         IMSA_HILOGE("onMessageFunc is nullptr");
75         return IME_ERR_NULL_POINTER;
76     }
77 
78     proxy->onMessageFunc = onMessageFunc;
79     return IME_ERR_OK;
80 }
81 
OH_MessageHandlerProxy_GetOnMessageFunc(InputMethod_MessageHandlerProxy * proxy,OH_MessageHandlerProxy_OnMessageFunc * onMessageFunc)82 InputMethod_ErrorCode OH_MessageHandlerProxy_GetOnMessageFunc(
83     InputMethod_MessageHandlerProxy *proxy, OH_MessageHandlerProxy_OnMessageFunc *onMessageFunc)
84 {
85     if (proxy == nullptr) {
86         IMSA_HILOGE("proxy is nullptr");
87         return IME_ERR_NULL_POINTER;
88     }
89     if (onMessageFunc == nullptr) {
90         IMSA_HILOGE("onMessageFunc is nullptr");
91         return IME_ERR_NULL_POINTER;
92     }
93     *onMessageFunc = proxy->onMessageFunc;
94     return IME_ERR_OK;
95 }