1100ae2f9Sopenharmony_ci/*
2100ae2f9Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
3100ae2f9Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4100ae2f9Sopenharmony_ci * you may not use this file except in compliance with the License.
5100ae2f9Sopenharmony_ci * You may obtain a copy of the License at
6100ae2f9Sopenharmony_ci *
7100ae2f9Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8100ae2f9Sopenharmony_ci *
9100ae2f9Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10100ae2f9Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11100ae2f9Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12100ae2f9Sopenharmony_ci * See the License for the specific language governing permissions and
13100ae2f9Sopenharmony_ci * limitations under the License.
14100ae2f9Sopenharmony_ci */
15100ae2f9Sopenharmony_ci
16100ae2f9Sopenharmony_ci#ifndef COMMON_EVENT_MANAGER_FFI_H
17100ae2f9Sopenharmony_ci#define COMMON_EVENT_MANAGER_FFI_H
18100ae2f9Sopenharmony_ci
19100ae2f9Sopenharmony_ci#include "ffi_remote_data.h"
20100ae2f9Sopenharmony_ci#include "cj_common_ffi.h"
21100ae2f9Sopenharmony_ci#include "emitter_common.h"
22100ae2f9Sopenharmony_ci
23100ae2f9Sopenharmony_ciusing CEventData = OHOS::EventsEmitter::CEventData;
24100ae2f9Sopenharmony_ci
25100ae2f9Sopenharmony_ciextern "C" {
26100ae2f9Sopenharmony_ci    struct CEventCallback {
27100ae2f9Sopenharmony_ci        char* name;
28100ae2f9Sopenharmony_ci        void (*callbackRef)(const CEventData data);
29100ae2f9Sopenharmony_ci    };
30100ae2f9Sopenharmony_ci
31100ae2f9Sopenharmony_ci    // CommonEventManager ffi apis
32100ae2f9Sopenharmony_ci    FFI_EXPORT int32_t CJ_OnWithId(uint32_t eventId, CEventCallback callbackInfo);
33100ae2f9Sopenharmony_ci    FFI_EXPORT int32_t CJ_OnWithStringId(char* eventId, CEventCallback callbackInfo);
34100ae2f9Sopenharmony_ci    FFI_EXPORT int32_t CJ_OnceWithId(uint32_t eventId, CEventCallback callbackInfo);
35100ae2f9Sopenharmony_ci    FFI_EXPORT int32_t CJ_OnceWithStringId(char* eventId, CEventCallback callbackInfo);
36100ae2f9Sopenharmony_ci    FFI_EXPORT void CJ_OffWithId(uint32_t eventId);
37100ae2f9Sopenharmony_ci    FFI_EXPORT void CJ_OffWithString(char* eventId);
38100ae2f9Sopenharmony_ci    FFI_EXPORT int32_t CJ_OffWithIdCallback(uint32_t eventId, CEventCallback callbackInfo);
39100ae2f9Sopenharmony_ci    FFI_EXPORT int32_t CJ_OffWithStringCallback(char* eventId, CEventCallback callbackInfo);
40100ae2f9Sopenharmony_ci    FFI_EXPORT void CJ_EmitWithId(uint32_t eventId, uint32_t priority, CEventData data);
41100ae2f9Sopenharmony_ci    FFI_EXPORT void CJ_EmitWithString(char* eventId, uint32_t priority, CEventData data);
42100ae2f9Sopenharmony_ci    FFI_EXPORT uint32_t CJ_GetListenerCountById(uint32_t eventId);
43100ae2f9Sopenharmony_ci    FFI_EXPORT uint32_t CJ_GetListenerCountByString(char* eventId);
44100ae2f9Sopenharmony_ci}
45100ae2f9Sopenharmony_ci
46100ae2f9Sopenharmony_ci
47100ae2f9Sopenharmony_ci#endif