• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 "native_interface_xcomponent.h"
17 
18 #include "frameworks/core/components/xcomponent/native_interface_xcomponent_impl.h"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
OH_NativeXComponent_GetXComponentId(OH_NativeXComponent * component,char * id,uint64_t * size)24 int32_t OH_NativeXComponent_GetXComponentId(OH_NativeXComponent* component, char* id, uint64_t* size)
25 {
26     if ((component == nullptr) || (id == nullptr) || (size == nullptr)) {
27         return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
28     }
29     if (((*size) == 0) || ((*size) > (OH_XCOMPONENT_ID_LEN_MAX + 1))) {
30         LOGE("The referenced value of 'size' should be in the range (0, OH_XCOMPONENT_ID_LEN_MAX + 1]");
31         return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
32     }
33     return component->GetXComponentId(id, size);
34 }
35 
OH_NativeXComponent_GetXComponentSize(OH_NativeXComponent * component,const void * window,uint64_t * width,uint64_t * height)36 int32_t OH_NativeXComponent_GetXComponentSize(
37     OH_NativeXComponent* component, const void* window, uint64_t* width, uint64_t* height)
38 {
39     if ((component == nullptr) || (window == nullptr) || (width == nullptr) || (height == nullptr)) {
40         return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
41     }
42     return component->GetXComponentSize(window, width, height);
43 }
44 
OH_NativeXComponent_GetXComponentOffset(OH_NativeXComponent * component,const void * window,double * x,double * y)45 int32_t OH_NativeXComponent_GetXComponentOffset(
46     OH_NativeXComponent* component, const void* window, double* x, double* y)
47 {
48     if ((component == nullptr) || (window == nullptr) || (x == nullptr) || (y == nullptr)) {
49         return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
50     }
51     return component->GetXComponentOffset(window, x, y);
52 }
53 
OH_NativeXComponent_GetTouchEvent(OH_NativeXComponent * component,const void * window,OH_NativeXComponent_TouchEvent * touchEvent)54 int32_t OH_NativeXComponent_GetTouchEvent(
55     OH_NativeXComponent* component, const void* window, OH_NativeXComponent_TouchEvent* touchEvent)
56 {
57     if ((component == nullptr) || (window == nullptr) || (touchEvent == nullptr)) {
58         return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
59     }
60     return component->GetTouchEvent(window, touchEvent);
61 }
62 
OH_NativeXComponent_RegisterCallback(OH_NativeXComponent * component,OH_NativeXComponent_Callback * callback)63 int32_t OH_NativeXComponent_RegisterCallback(OH_NativeXComponent* component, OH_NativeXComponent_Callback* callback)
64 {
65     if ((component == nullptr) || (callback == nullptr)) {
66         return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
67     }
68     return component->RegisterCallback(callback);
69 }
70 
71 #ifdef __cplusplus
72 };
73 #endif
74