• 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 #ifndef OHOS_WIFI_P2P_CALLBACK_PROXY_H
16 #define OHOS_WIFI_P2P_CALLBACK_PROXY_H
17 
18 #include "i_wifi_p2p_callback.h"
19 #include "iremote_proxy.h"
20 
21 namespace OHOS {
22 namespace Wifi {
23 class WifiP2pCallbackProxy : public IRemoteProxy<IWifiP2pCallback> {
24 public:
25     explicit WifiP2pCallbackProxy(const sptr<IRemoteObject> &impl);
26     virtual ~WifiP2pCallbackProxy();
27 
28     /**
29      * @Description Deal p2p state change message
30      *
31      * @param state - P2P_STATE_IDLE/P2P_STATE_STARTED/P2P_STATE_CLOSED
32      */
33     void OnP2pStateChanged(int state) override;
34 
35     /**
36      * @Description Persistent Group Changed Resources
37      *
38      */
39     void OnP2pPersistentGroupsChanged() override;
40 
41     /**
42      * @Description The device is changed.
43      *
44      * @param device - WifiP2pDevice object
45      */
46     void OnP2pThisDeviceChanged(const WifiP2pDevice &device) override;
47 
48     /**
49      * @Description If the discover P2P device information is updated, all the
50      *        latest WifiP2P devices are reported.
51      *
52      * @param device - std::vector<WifiP2pDevice> object
53      */
54     void OnP2pPeersChanged(const std::vector<WifiP2pDevice> &device) override;
55 
56     /**
57      * @Description If the discover P2P device information is updated, all the
58      *        latest WifiP2P devices are reported.
59      *
60      * @param priWfdInfo - std::string &priWfdInfo object
61      */
62     void OnP2pPrivatePeersChanged(const std::string &priWfdInfo) override;
63 
64     /**
65      * @Description This event is triggered when the discovered services are updated.
66      *
67      * @param srvInfo - std::vector<WifiP2pServiceInfo> object
68      */
69     void OnP2pServicesChanged(const std::vector<WifiP2pServiceInfo> &srvInfo) override;
70 
71     /**
72      * @Description Connection status change
73      *
74      * @param info - WifiP2pLinkedInfo object
75      */
76     void OnP2pConnectionChanged(const WifiP2pLinkedInfo &info) override;
77 
78     /**
79      * @Description Discover status change
80      *
81      * @param isChange - true : change, false : not change
82      */
83     void OnP2pDiscoveryChanged(bool isChange) override;
84 
85     /**
86      * @Description P2p callback result
87      *
88      * @param action - DiscoverDevices/StopDiscoverDevices/DiscoverServices/StopDiscoverServices
89      *                 /PutLocalP2pService/StartP2pListen/StopP2pListen/CreateGroup/RemoveGroup
90      *                 /DeleteGroup/P2pConnect/P2pCancelConnect
91      * @param code   - Return code
92      */
93     void OnP2pActionResult(P2pActionCallback action, ErrCode code) override;
94 
95     /**
96      * @Description Config changed callback.
97      *
98      * @param type - Config type
99      * @param cfgData - Config data
100      * @param dataLen  - Config data length
101      */
102     void OnConfigChanged(CfgType type, char* cfgData, int dataLen) override;
103 
104     /**
105      * @Description The go dhcp server send ack to gc event.
106      *
107      * @param info - WifiP2pLinkedInfo object
108      */
109     void OnP2pGcJoinGroup(const OHOS::Wifi::GcInfo &info) override;
110 
111     /**
112      * @Description The go dhcp server send ack to gc event.
113      *
114      * @param info - WifiP2pLinkedInfo object
115      */
116     void OnP2pGcLeaveGroup(const OHOS::Wifi::GcInfo &info) override;
117 
118     /**
119      * @Description p2p chr error code report.
120      *
121      * @param errCode - p2p chr error code
122      */
123     void OnP2pChrErrCodeReport(const int errCode) override;
124 
125 private:
126     void WriteWifiP2pDeviceData(MessageParcel &data, const WifiP2pDevice &device);
127 
128 private:
129     static inline BrokerDelegator<WifiP2pCallbackProxy> delegator;
130 };
131 }  // namespace Wifi
132 }  // namespace OHOS
133 #endif