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_IP2P_SERVICE_CALLBACK_H
16 #define OHOS_IP2P_SERVICE_CALLBACK_H
17 
18 #include <functional>
19 #include "wifi_errcode.h"
20 #include "wifi_p2p_msg.h"
21 #include "wifi_hid2d_msg.h"
22 
23 namespace OHOS {
24 namespace Wifi {
25 /* The callbacks of P2P service provided */
26 struct IP2pServiceCallbacks {
27     /* The name of module. */
28     std::string callbackModuleName;
29     /* The event of status change. */
30     std::function<void(P2pState)> OnP2pStateChangedEvent;
31     /* Report the latest devices discovery information. */
32     std::function<void(const std::vector<WifiP2pDevice> &)> OnP2pPeersChangedEvent;
33     /* Report the latest services discovery information. */
34     std::function<void(const std::vector<WifiP2pServiceInfo> &)> OnP2pServicesChangedEvent;
35     /* The event of connection status change. */
36     std::function<void(const WifiP2pLinkedInfo &)> OnP2pConnectionChangedEvent;
37     /* The event of this device configure has change */
38     std::function<void(const WifiP2pDevice &)> OnP2pThisDeviceChangedEvent;
39     /* The event of discovery status change */
40     std::function<void(bool)> OnP2pDiscoveryChangedEvent;
41     /* The event of groups configure has change */
42     std::function<void()> OnP2pGroupsChangedEvent;
43     /* The result returned by the asynchronous interface */
44     std::function<void(P2pActionCallback, ErrCode)> OnP2pActionResultEvent;
45     /* The event of config change */
46     std::function<void(CfgType, char*, int)> OnConfigChangedEvent;
47     /* The event of gc join */
48     std::function<void(const GcInfo &)> OnP2pGcJoinGroupEvent;
49     /* The event of gc leave */
50     std::function<void(const GcInfo &)> OnP2pGcLeaveGroupEvent;
51     std::function<void(P2pServicerProtocolType, const std::vector<unsigned char> &, const WifiP2pDevice &)>
52         OnP2pServiceAvailable;
53     std::function<void(const std::string &, const std::string &, const WifiP2pDevice &)> OnP2pDnsSdServiceAvailable;
54     std::function<void(const std::string &, const std::map<std::string, std::string> &, const WifiP2pDevice &)>
55         OnP2pDnsSdTxtRecordAvailable;
56     std::function<void(const std::vector<std::string> &, const WifiP2pDevice &)> OnP2pUpnpServiceAvailable;
57     std::function<void(const std::string &)> OnP2pPrivatePeersChangedEvent;
58 };
59 }  // namespace Wifi
60 }  // namespace OHOS
61 #endif  // OHOS_IP2P_SERVICE_CALLBACK_H