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 OHOS_HIAPPEVENT_COMMON_H
17 #define OHOS_HIAPPEVENT_COMMON_H
18 
19 #include "cj_ffi/cj_common_ffi.h"
20 
21 extern "C" {
22     struct CConfigOption {
23         bool disable = false;
24         const char* maxStorage = nullptr;
25     };
26 
27     struct CParameters {
28         uint8_t valueType = 0;
29         char* key = nullptr;
30         void* value = nullptr;
31         int64_t size = 0;
32     };
33 
34     struct CArrParameters {
35         CParameters* head = nullptr;
36         int64_t size = 0;
37     };
38 
39     struct CAppEventInfo {
40         const char* domain = nullptr;
41         const char* name = nullptr;
42         int event = 0;
43         CArrParameters cArrParamters;
44     };
45 
46     struct CAppEventReportConfig {
47         const char* domain = nullptr;
48         const char* name = nullptr;
49         bool isRealTime = false;
50     };
51 
52     struct CArrAppEventReportConfig {
53         CAppEventReportConfig* head = nullptr;
54         int64_t size = 0;
55     };
56 
57     struct CProcessor {
58         const char* name = nullptr;
59         bool debugMode = false;
60         const char* routeInfo = nullptr;
61         const char* appId = nullptr;
62         bool onStartReport = false;
63         bool onBackgroundReport = false;
64         int64_t periodReport = 0;
65         int64_t batchReport = 0;
66         CArrString userIds;
67         CArrString userProperties;
68         CArrAppEventReportConfig eventConfigs;
69     };
70 
71     struct CAppEventFilter {
72         char* domain = nullptr;
73         CArrUI32 eventTypes;
74         CArrString names;
75     };
76 
77     struct CArrAppEventFilter {
78         CAppEventFilter* head = nullptr;
79         int64_t size = 0;
80     };
81 
82     struct CTriggerCondition {
83         int row = 0;
84         int size = 0;
85         int timeOut = 0;
86     };
87 
88     struct CArrAppEventInfo {
89         CAppEventInfo* head = nullptr;
90         int64_t size = 0;
91     };
92 
93     struct RetAppEventGroup {
94         char* name = nullptr;
95         CArrAppEventInfo appEventInfos;
96     };
97 
98     struct CArrRetAppEventGroup {
99         RetAppEventGroup* head = nullptr;
100         int64_t size = 0;
101     };
102 
103     struct RetAppEventPackage {
104         int packageId;
105         int row;
106         int size;
107         CArrString events;
108     };
109 
110     struct ReTakeNext {
111         int status;
112         RetAppEventPackage event;
113     };
114 
115     struct CWatcher {
116         char* name = nullptr;
117         CTriggerCondition triggerCondition;
118         CArrAppEventFilter appEventFilters;
119         void (*callbackOnTriggerRef)(int, int, int64_t);
120         void (*callbackOnReceiveRef)(char*, CArrRetAppEventGroup);
121     };
122 }
123 
124 #endif