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_I_WIFI_P2P_CALLBACK_H
16 #define OHOS_I_WIFI_P2P_CALLBACK_H
17 
18 #include <string>
19 #include <iremote_stub.h>
20 #include "define.h"
21 #include "message_option.h"
22 #include "message_parcel.h"
23 #include "wifi_errcode.h"
24 #include "wifi_hid2d_msg.h"
25 #include "wifi_p2p_msg.h"
26 
27 namespace OHOS {
28 namespace Wifi {
29 class IWifiP2pCallback : public IRemoteBroker {
30 public:
31     /**
32      * @Description Deal p2p state change message.
33      *
34      * @param state - P2P_STATE_IDLE/P2P_STATE_STARTED/P2P_STATE_CLOSED
35      */
36     virtual void OnP2pStateChanged(int state) = 0;
37 
38     /**
39      * @Description Persistent Group Changed Resources
40      *
41      */
42     virtual void OnP2pPersistentGroupsChanged(void) = 0;
43 
44     /**
45      * @Description The device is changed.
46      *
47      * @param device - WifiP2pDevice object
48      */
49     virtual void OnP2pThisDeviceChanged(const WifiP2pDevice &device) = 0;
50 
51     /**
52      * @Description If the discover P2P device information is updated, all the
53      *        latest WifiP2P devices are reported.
54      *
55      * @param device - std::vector<WifiP2pDevice> object
56      */
57     virtual void OnP2pPeersChanged(const std::vector<WifiP2pDevice> &device) = 0;
58 
59     /**
60      * @Description If the discover P2P device information is updated, all the
61      *        latest WifiP2P private devices are reported.
62      *
63      * @param priWfdInfo - std::string &priWfdInfo object
64      */
65     virtual void OnP2pPrivatePeersChanged(const std::string &priWfdInfo) = 0;
66 
67     /**
68      * @Description This event is triggered when the discovered services are updated.
69      *
70      * @param srvInfo - std::vector<WifiP2pServiceInfo> object
71      */
72     virtual void OnP2pServicesChanged(const std::vector<WifiP2pServiceInfo> &srvInfo) = 0;
73 
74     /**
75      * @Description Connection status change.
76      *
77      * @param info - WifiP2pLinkedInfo object
78      */
79     virtual void OnP2pConnectionChanged(const WifiP2pLinkedInfo &info) = 0;
80 
81     /**
82      * @Description Discover status change.
83      *
84      * @param isChange - true : change, false : not change
85      */
86     virtual void OnP2pDiscoveryChanged(bool isChange) = 0;
87 
88     /**
89      * @Description P2p callback result.
90      *
91      * @param action - DiscoverDevices/StopDiscoverDevices/DiscoverServices/StopDiscoverServices
92      *                 /PutLocalP2pService/StartP2pListen/StopP2pListen/CreateGroup/RemoveGroup
93      *                 /DeleteGroup/P2pConnect/P2pCancelConnect/RemoveGroupClient
94      * @param code   - Return code
95      */
96     virtual void OnP2pActionResult(P2pActionCallback action, ErrCode code) = 0;
97 
98     /**
99      * @Description Config changed callback.
100      *
101      * @param type - Config type
102      * @param data - Config data
103      * @param len  - Config data length
104      */
105     virtual void OnConfigChanged(CfgType type, char* data, int dataLen) = 0;
106 
107     /**
108      * @Description Gc connect to go and obtained ip.
109      *
110      * @param info - GcInfo object
111      */
112     virtual void OnP2pGcJoinGroup(const GcInfo &info) = 0;
113 
114     /**
115      * @Description Gc disconnect from group.
116      *
117      * @param info - GcInfo object
118      */
119     virtual void OnP2pGcLeaveGroup(const GcInfo &info) = 0;
120 
121 public:
122     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.wifi.IWifiP2pCallback");
123 };
124 }  // namespace Wifi
125 }  // namespace OHOS
126 #endif