• 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 EVENT_CONTEXT_H
17 #define EVENT_CONTEXT_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "napi/native_api.h"
23 #include "napi/native_node_api.h"
24 
25 namespace OHOS {
26 namespace NetManagerStandard {
27 // net policy
28 const std::string NET_UID_POLICY_CHANGE = "netUidPolicyChange";
29 const std::string NET_CELLULAR_POLICY_CHANGE = "netCellularPolicyChange";
30 const std::string NET_STRATEGY_SWITCH_CHANGE = "netStrategySwitchChange";
31 // net status
32 const std::string NET_AVAILABLE_CHANGE = "netAvailable";
33 const std::string NET_BLOCK_STATUS_CHANGE = "netBlockStatusChange";
34 const std::string NET_CAPABILITIES_CHANGE = "netCapabilitiesChange";
35 const std::string NET_CONNECTION_CHANGE = "netConnectionPropertiesChange";
36 const std::string NET_LOST_CHANGE = "netLost";
37 const std::string NET_UNAVAILABLE_CHANGE = "netUnavailable";
38 const std::string NET_STATS_CHANGE = "netStatsChange";
39 constexpr int32_t EVENT_CONTENT_MAX_BYTE = 64;
40 
41 enum {
42     EVENT_NET_UNKNOW_CHANGE = -1,
43     EVENT_NET_UID_POLICY_CHANGE = 21,
44     EVENT_NET_CELLULAR_POLICY_CHANGE = 22,
45     EVENT_NET_STRATEGY_SWITCH_CHANGE = 23,
46     EVENT_NET_AVAILABLE_CHANGE = 31,
47     EVENT_NET_CAPABILITIES_CHANGE = 32,
48     EVENT_NET_CONNECTION_CHANGE = 33,
49     EVENT_NET_LOST_CHANGE = 34,
50     EVENT_NET_STATS_CHANGE = 35,
51     EVENT_NET_BLOCK_STATUS_CHANGE = 36,
52     EVENT_NET_UNAVAILABLE_CHANGE = 37,
53 };
54 
55 // event listener context
56 struct EventListener {
EventListenerEventListener57     EventListener() {}
58     int32_t eventId = 0;
59     napi_env env = nullptr;
60     napi_ref callbackRef = nullptr;
61 };
62 } // namespace NetManagerStandard
63 } // namespace OHOS
64 #endif // EVENT_CONTEXT_H
65