• 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 #ifndef WEBVIEW_MESSAGE_FFI_H
17 #define WEBVIEW_MESSAGE_FFI_H
18 
19 #include <cstdint>
20 #include "ffi_remote_data.h"
21 #include "webview_utils.h"
22 #include "cj_common_ffi.h"
23 
24 extern "C" {
25     // WebMessagePort
26     FFI_EXPORT void FfiOHOSWebMessagePortPostMessageEvent(int64_t msgPortId, char* stringValue, int32_t *errCode);
27     FFI_EXPORT void FfiOHOSWebMessagePortPostMessageEventArr(int64_t msgPortId, CArrUI8 arrBuf, int32_t *errCode);
28     FFI_EXPORT void FfiOHOSWebMessagePortPostMessageEventExt(int64_t msgPortId, int64_t msgExtId, int32_t *errCode);
29     FFI_EXPORT bool FfiOHOSWebMessagePortIsExtentionType(int64_t msgPortId);
30     FFI_EXPORT void FfiOHOSWebMessagePortOnMessageEvent(int64_t msgPortId,
31         void (*callback)(OHOS::Webview::RetWebMessage), int32_t *errCode);
32     FFI_EXPORT void FfiOHOSWebMessagePortOnMessageEventExt(int64_t msgPortId,
33         void (*callback)(int64_t), int32_t *errCode);
34     FFI_EXPORT void FfiOHOSWebMessagePortClose(int64_t msgPortId, int32_t *errCode);
35 
36     // WebMessageExt
37     FFI_EXPORT int64_t FfiOHOSWebMessageExtImplConstructor();
38     FFI_EXPORT int32_t FfiOHOSWebMessageExtImplGetType(int64_t msgExtId, int32_t *errCode);
39     FFI_EXPORT char* FfiOHOSWebMessageExtImplGetString(int64_t msgExtId, int32_t *errCode);
40     FFI_EXPORT OHOS::Webview::RetNumber FfiOHOSWebMessageExtImplGetNumber(int64_t msgExtId, int32_t *errCode);
41     FFI_EXPORT bool FfiOHOSWebMessageExtImplGetBoolean(int64_t msgExtId, int32_t *errCode);
42     FFI_EXPORT CArrUI8 FfiOHOSWebMessageExtImplGetArrayBuffer(int64_t msgExtId, int32_t *errCode);
43     FFI_EXPORT OHOS::Webview::CArrValue FfiOHOSWebMessageExtImplGetArray(int64_t msgExtId, int32_t *errCode);
44     FFI_EXPORT OHOS::Webview::CError FfiOHOSWebMessageExtImplGetError(int64_t msgExtId, int32_t *errCode);
45     FFI_EXPORT void FfiOHOSWebMessageExtImplSetType(int64_t msgExtId, int32_t type, int32_t *errCode);
46     FFI_EXPORT void FfiOHOSWebMessageExtImplSetString(int64_t msgExtId, char* message, int32_t *errCode);
47     FFI_EXPORT void FfiOHOSWebMessageExtImplSetNumber(int64_t msgExtId, double value, int32_t *errCode);
48     FFI_EXPORT void FfiOHOSWebMessageExtImplSetBoolean(int64_t msgExtId, bool value, int32_t *errCode);
49     FFI_EXPORT void FfiOHOSWebMessageExtImplSetArrayBuffer(int64_t msgExtId,
50         CArrUI8 value, int32_t *errCode);
51     FFI_EXPORT void FfiOHOSWebMessageExtImplSetArrayString(int64_t msgExtId,
52         CArrString value, int32_t *errCode);
53     FFI_EXPORT void FfiOHOSWebMessageExtImplSetArrayInt(int64_t msgExtId,
54         CArrI64 value, int32_t *errCode);
55     FFI_EXPORT void FfiOHOSWebMessageExtImplSetArrayDouble(int64_t msgExtId,
56         OHOS::Webview::CArrDouble value, int32_t *errCode);
57     FFI_EXPORT void FfiOHOSWebMessageExtImplSetArrayBoolean(int64_t msgExtId,
58         OHOS::Webview::CArrBool value, int32_t *errCode);
59     FFI_EXPORT void FfiOHOSWebMessageExtImplSetError(int64_t msgExtId,
60         OHOS::Webview::CError value, int32_t *errCode);
61 
62     // WebJsMessageExtImpl
63     FFI_EXPORT int32_t FfiOHOSJsMessageExtImplGetType(int64_t jsExtId, int32_t *errCode);
64     FFI_EXPORT char* FfiOHOSJsMessageExtImplGetString(int64_t jsExtId, int32_t *errCode);
65     FFI_EXPORT OHOS::Webview::RetNumber FfiOHOSJsMessageExtImplGetNumber(int64_t jsExtId, int32_t *errCode);
66     FFI_EXPORT bool FfiOHOSJsMessageExtImplGetBoolean(int64_t jsExtId, int32_t *errCode);
67     FFI_EXPORT CArrUI8 FfiOHOSJsMessageExtImplGetArrayBuffer(int64_t jsExtId, int32_t *errCode);
68     FFI_EXPORT OHOS::Webview::CArrValue FfiOHOSJsMessageExtImplGetArray(int64_t jsExtId, int32_t *errCode);
69 }
70 #endif // WEBVIEW_MESSAGE_FFI_H