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 COMMON_EVENT_MANAGER_FFI_H
17 #define COMMON_EVENT_MANAGER_FFI_H
18 
19 #include "ffi_remote_data.h"
20 #include "cj_common_ffi.h"
21 #include "emitter_common.h"
22 
23 using CEventData = OHOS::EventsEmitter::CEventData;
24 
25 extern "C" {
26     struct CEventCallback {
27         char* name;
28         void (*callbackRef)(const CEventData data);
29     };
30 
31     // CommonEventManager ffi apis
32     FFI_EXPORT int32_t CJ_OnWithId(uint32_t eventId, CEventCallback callbackInfo);
33     FFI_EXPORT int32_t CJ_OnWithStringId(char* eventId, CEventCallback callbackInfo);
34     FFI_EXPORT int32_t CJ_OnceWithId(uint32_t eventId, CEventCallback callbackInfo);
35     FFI_EXPORT int32_t CJ_OnceWithStringId(char* eventId, CEventCallback callbackInfo);
36     FFI_EXPORT void CJ_OffWithId(uint32_t eventId);
37     FFI_EXPORT void CJ_OffWithString(char* eventId);
38     FFI_EXPORT int32_t CJ_OffWithIdCallback(uint32_t eventId, CEventCallback callbackInfo);
39     FFI_EXPORT int32_t CJ_OffWithStringCallback(char* eventId, CEventCallback callbackInfo);
40     FFI_EXPORT void CJ_EmitWithId(uint32_t eventId, uint32_t priority, CEventData data);
41     FFI_EXPORT void CJ_EmitWithString(char* eventId, uint32_t priority, CEventData data);
42     FFI_EXPORT uint32_t CJ_GetListenerCountById(uint32_t eventId);
43     FFI_EXPORT uint32_t CJ_GetListenerCountByString(char* eventId);
44 }
45 
46 
47 #endif