• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 BUS_CENTER_EVENT_H
17 #define BUS_CENTER_EVENT_H
18 
19 #include "softbus_bus_center.h"
20 #include "bus_center_info_key.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 typedef enum {
27     /* event from system monitor */
28     LNN_EVENT_IP_ADDR_CHANGED,
29     LNN_EVENT_WIFI_STATE_CHANGED,
30     LNN_EVENT_BT_STATE_CHANGED,
31     LNN_EVENT_BT_ACL_STATE_CHANGED,
32     LNN_EVENT_WLAN_PARAM,
33     LNN_EVENT_SCREEN_STATE_CHANGED,
34     LNN_EVENT_SCREEN_LOCK_CHANGED,
35     LNN_EVENT_ACCOUNT_CHANGED,
36     LNN_EVENT_DIF_ACCOUNT_DEV_CHANGED,
37     LNN_EVENT_USER_STATE_CHANGED,
38     LNN_EVENT_NIGHT_MODE_CHANGED,
39     LNN_EVENT_OOBE_STATE_CHANGED,
40     LNN_EVENT_HOME_GROUP_CHANGED,
41     LNN_EVENT_USER_SWITCHED,
42     /* event from internal lnn */
43     LNN_EVENT_NODE_ONLINE_STATE_CHANGED,
44     LNN_EVENT_NODE_MIGRATE,
45     LNN_EVENT_RELATION_CHANGED,
46     LNN_EVENT_NODE_MASTER_STATE_CHANGED,
47     LNN_EVENT_NODE_ADDR_CHANGED,
48     LNN_EVENT_NETWORK_STATE_CHANGED,
49     LNN_EVENT_SINGLE_NETWORK_OFFLINE,
50     LNN_EVENT_NODE_HB_REPEAT_CYCLE,
51     LNN_EVENT_NETWORKID_CHANGED,
52     LNN_EVENT_LP_EVENT_REPORT,
53     LNN_EVENT_LANE_VAP_CHANGE,
54     LNN_EVENT_DATA_SHARE_STATE_CHANGE,
55     LNN_EVENT_NODE_NET_TYPE,
56     LNN_EVENT_DEVICE_INFO_CHANGED,
57     LNN_EVENT_NET_LINK_STATE_CHANGE,
58     /* event from sa monitor */
59     LNN_EVENT_WIFI_SERVICE_START,
60     LNN_EVENT_TYPE_MAX,
61 } LnnEventType;
62 
63 typedef struct {
64     LnnEventType event;
65 } LnnEventBasicInfo;
66 
67 typedef struct {
68     LnnEventBasicInfo basic;
69     char ifName[NET_IF_NAME_LEN];
70 } LnnMonitorAddressChangedEvent;
71 
72 typedef enum {
73     SOFTBUS_WIFI_CONNECTED,
74     SOFTBUS_WIFI_DISCONNECTED,
75     SOFTBUS_WIFI_DISABLING,
76     SOFTBUS_WIFI_DISABLED,
77     SOFTBUS_WIFI_ENABLING,
78     SOFTBUS_WIFI_ENABLED,
79     SOFTBUS_AP_DISABLED,
80     SOFTBUS_AP_ENABLED,
81     SOFTBUS_WIFI_OBTAINING_IPADDR,
82     SOFTBUS_WIFI_SEMI_ACTIVE,
83     SOFTBUS_WIFI_UNKNOWN,
84 } SoftBusWifiState;
85 
86 typedef enum {
87     SOFTBUS_SCREEN_ON,
88     SOFTBUS_SCREEN_OFF,
89     SOFTBUS_SCREEN_UNKNOWN,
90 } SoftBusScreenState;
91 
92 typedef enum {
93     SOFTBUS_BLE_TURN_ON,
94     SOFTBUS_BLE_TURN_OFF,
95     SOFTBUS_BR_TURN_ON,
96     SOFTBUS_BR_TURN_OFF,
97     SOFTBUS_BT_UNKNOWN,
98 } SoftBusBtState;
99 
100 typedef enum {
101     SOFTBUS_SCREEN_LOCK,
102     SOFTBUS_USER_UNLOCK,
103     SOFTBUS_SCREEN_UNLOCK,
104     SOFTBUS_SCREEN_LOCK_UNKNOWN,
105 } SoftBusScreenLockState;
106 
107 typedef enum {
108     SOFTBUS_ACCOUNT_LOG_IN,
109     SOFTBUS_ACCOUNT_LOG_OUT,
110     SOFTBUS_ACCOUNT_UNKNOWN,
111 } SoftBusAccountState;
112 
113 typedef enum {
114     SOFTBUS_USER_SWITCHED,
115     SOFTBUS_USER_SWITCH_UNKNOWN,
116 } SoftBusUserSwitchState;
117 
118 typedef enum {
119     SOFTBUS_DATA_SHARE_READY,
120     SOFTBUS_DATA_SHARE_UNKNOWN,
121 } SoftBusDataShareState;
122 
123 typedef enum {
124     SOFTBUS_DIF_ACCOUNT_DEV_CHANGE,
125     SOFTBUS_DIF_ACCOUNT_UNKNOWN,
126 } SoftBusDifferentAccountState;
127 
128 typedef enum {
129     SOFTBUS_USER_FOREGROUND,
130     SOFTBUS_USER_BACKGROUND,
131     SOFTBUS_USER_UNKNOWN,
132 } SoftBusUserState;
133 
134 typedef enum {
135     SOFTBUS_NIGHT_MODE_ON,
136     SOFTBUS_NIGHT_MODE_OFF,
137     SOFTBUS_NIGHT_MODE_UNKNOWN,
138 } SoftBusNightModeState;
139 
140 typedef enum {
141     SOFTBUS_OOBE_RUNNING,
142     SOFTBUS_OOBE_END,
143     SOFTBUS_FACK_OOBE_END,
144     SOFTBUS_OOBE_UNKNOWN,
145 } SoftBusOOBEState;
146 
147 typedef enum {
148     SOFTBUS_HOME_GROUP_CHANGE = 0X1,
149     SOFTBUS_HOME_GROUP_JOIN,
150     SOFTBUS_HOME_GROUP_LEAVE,
151     SOFTBUS_HOME_GROUP_UNKNOWN,
152 } SoftBusHomeGroupState;
153 
154 typedef enum {
155     SOFTBUS_BR_ACL_CONNECTED,
156     SOFTBUS_BR_ACL_DISCONNECTED,
157 } SoftBusBtAclState;
158 
159 typedef enum {
160     SOFTBUS_WIFI_NETWORKD_ENABLE,
161     SOFTBUS_WIFI_NETWORKD_DISABLE,
162     SOFTBUS_BLE_NETWORKD_ENABLE,
163     SOFTBUS_BLE_NETWORKD_DISABLE,
164     SOFTBUS_NETWORKD_UNKNOWN,
165 } SoftBusNetworkState;
166 
167 typedef enum {
168     SOFTBUS_LOCAL_DEVICE_INFO_ACOUNT_CHANGED,
169     SOFTBUS_LOCAL_DEVICE_INFO_NAME_CHANGED,
170     SOFTBUS_LOCAL_DEVICE_INFO_UNKNOWN,
171 } SoftBusDeviceInfoState;
172 
173 typedef enum {
174     SOFTBUS_MSDP_MOVEMENT_AND_STATIONARY,
175     SOFTBUS_LP_EVENT_UNKNOWN,
176 } SoftBusLpEventType;
177 
178 typedef enum {
179     SOFTBUS_NETMANAGER_IFNAME_START,
180     SOFTBUS_NETMANAGER_IFNAME_ADDED,
181     SOFTBUS_NETMANAGER_IFNAME_REMOVED,
182     SOFTBUS_NETMANAGER_IFNAME_LINK_UP,
183     SOFTBUS_NETMANAGER_IFNAME_IP_UPDATED,
184     SOFTBUS_NETMANAGER_IFNAME_UNKNOWN,
185 } NetManagerIfNameState;
186 
187 typedef struct {
188     LnnEventBasicInfo basic;
189     uint8_t status;
190 } LnnMonitorWlanStateChangedEvent;
191 
192 typedef struct {
193     LnnEventBasicInfo basic;
194     uint8_t status;
195 } LnnMonitorScreenStateChangedEvent;
196 
197 typedef struct {
198     LnnEventBasicInfo basic;
199     uint8_t status;
200 } LnnMonitorHbStateChangedEvent;
201 
202 typedef struct {
203     LnnEventBasicInfo basic;
204     uint8_t status;
205     char btMac[BT_MAC_LEN];
206 } LnnMonitorBtAclStateChangedEvent;
207 
208 typedef struct {
209     LnnEventBasicInfo basic;
210     bool isOnline;
211     const char *networkId;
212     const char *uuid;
213     const char *udid;
214 } LnnOnlineStateEventInfo;
215 
216 typedef struct {
217     LnnEventBasicInfo basic;
218     ConnectionAddrType type;
219     uint8_t relation;
220     bool isJoin;
221     const char *udid;
222 } LnnRelationChanedEventInfo;
223 
224 typedef struct {
225     LnnEventBasicInfo basic;
226     int32_t weight;
227     bool isMasterNode;
228     const char* masterNodeUDID;
229 } LnnMasterNodeChangedEvent;
230 
231 typedef struct {
232     LnnEventBasicInfo basic;
233     char addr[SHORT_ADDRESS_MAX_LEN];
234     char networkId[NETWORK_ID_BUF_LEN];
235     bool delFlag;
236     bool isLocal;
237 } LnnNodeAddrChangedEvent;
238 
239 typedef struct {
240     LnnEventBasicInfo basic;
241     ConnectionAddrType type;
242     const char *networkId;
243     const char *uuid;
244     const char *udid;
245 } LnnSingleNetworkOffLineEvent;
246 
247 typedef struct {
248     LnnEventBasicInfo basic;
249     char networkId[NETWORK_ID_BUF_LEN];
250 } LnnNetworkIdChangedEvent;
251 
252 typedef struct {
253     LnnEventBasicInfo basic;
254     SoftBusLpEventType type;
255 } LnnLpReportEvent;
256 
257 typedef struct {
258     LnnEventBasicInfo basic;
259     int32_t vapPreferChannel;
260 } LnnLaneVapChangeEvent;
261 
262 typedef struct {
263     LnnEventBasicInfo basic;
264     ConnectionAddrType addrType;
265     const char *networkId;
266 } LnnNodeNetTypeInfo;
267 
268 typedef struct {
269     LnnEventBasicInfo basic;
270     uint8_t status;
271 } LnnDeviceInfoChangeEvent;
272 
273 typedef struct {
274     LnnEventBasicInfo basic;
275     uint8_t status;
276     char ifName[NET_IF_NAME_LEN];
277 } LnnMonitorNetlinkStateInfo;
278 
279 typedef void (*LnnEventHandler)(const LnnEventBasicInfo *info);
280 
281 int32_t LnnInitBusCenterEvent(void);
282 void LnnDeinitBusCenterEvent(void);
283 
284 int32_t LnnRegisterEventHandler(LnnEventType event, LnnEventHandler handler);
285 void LnnUnregisterEventHandler(LnnEventType event, LnnEventHandler handler);
286 
287 void LnnNotifyJoinResult(ConnectionAddr *addr,
288     const char *networkId, int32_t retCode);
289 void LnnNotifyLeaveResult(const char *networkId, int32_t retCode);
290 
291 void LnnNotifyOnlineState(bool isOnline, NodeBasicInfo *info);
292 void LnnNotifyBasicInfoChanged(NodeBasicInfo *info, NodeBasicInfoType type);
293 void LnnNotifyNodeStatusChanged(NodeStatus *info, NodeStatusType type);
294 void LnnNotifyLocalNetworkIdChanged(void);
295 void LnnNotifyDeviceTrustedChange(int32_t type, const char *msg, uint32_t msgLen);
296 void LnnNotifyHichainProofException(
297     const char *proofInfo, uint32_t proofLen, uint16_t deviceTypeId, int32_t errCode);
298 void LnnNotifyMigrate(bool isOnline, NodeBasicInfo *info);
299 
300 void LnnNotifyWlanStateChangeEvent(void *state);
301 void LnnNotifyScreenStateChangeEvent(SoftBusScreenState state);
302 void LnnNotifyDifferentAccountChangeEvent(void *state);
303 void LnnNotifyBtStateChangeEvent(void *state);
304 void LnnNotifyScreenLockStateChangeEvent(SoftBusScreenLockState state);
305 void LnnNotifyAccountStateChangeEvent(SoftBusAccountState state);
306 void LnnNotifyUserStateChangeEvent(SoftBusUserState state);
307 void LnnNotifyHomeGroupChangeEvent(SoftBusHomeGroupState state);
308 void LnnNotifyNightModeStateChangeEvent(void *state);
309 void LnnNotifyOOBEStateChangeEvent(SoftBusOOBEState state);
310 void LnnNotifyBtAclStateChangeEvent(const char *btMac, SoftBusBtAclState state);
311 void LnnNotifyAddressChangedEvent(const char* ifName);
312 void LnnNotifyLnnRelationChanged(const char *udid, ConnectionAddrType type, uint8_t relation, bool isJoin);
313 void LnnNotifyDeviceVerified(const char *udid);
314 
315 void LnnNotifyTimeSyncResult(const char *pkgName, int32_t pid, const TimeSyncResultInfo *info, int32_t retCode);
316 
317 void LnnNotifyMasterNodeChanged(bool isMaster, const char* masterNodeUdid, int32_t weight);
318 
319 void LnnNotifyNodeAddressChanged(const char *addr, const char *networkId, bool isLocal);
320 
321 void LnnNotifyNetworkStateChanged(SoftBusNetworkState state);
322 
323 void LnnNotifySingleOffLineEvent(const ConnectionAddr *addr, NodeBasicInfo *basicInfo);
324 
325 void LnnNotifyNetworkIdChangeEvent(const char *networkId);
326 
327 void LnnNotifyLpReportEvent(SoftBusLpEventType type);
328 
329 void LnnNotifyHBRepeat(void);
330 
331 void LnnNotifyUserSwitchEvent(SoftBusUserSwitchState state);
332 
333 void LnnNotifyDataShareStateChangeEvent(SoftBusDataShareState state);
334 
335 void LnnNotifyVapInfoChangeEvent(int32_t preferChannel);
336 
337 void LnnNotifyStateForSession(char *udid, int32_t retCode);
338 
339 void LnnNotifyOnlineNetType(const char *networkId, ConnectionAddrType addrType);
340 
341 void LnnNotifyDeviceInfoChanged(SoftBusDeviceInfoState state);
342 
343 void LnnNotifyNetlinkStateChangeEvent(NetManagerIfNameState state, const char *ifName);
344 
345 void LnnNotifyWifiServiceStart(void *para);
346 
347 #ifdef __cplusplus
348 }
349 #endif
350 #endif
351