• 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_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     std::function<void(bool, const std::string &)> OnP2pPeerJoinOrLeaveEvent;
34     /* Report the latest services discovery information. */
35     std::function<void(const std::vector<WifiP2pServiceInfo> &)> OnP2pServicesChangedEvent;
36     /* The event of connection status change. */
37     std::function<void(const WifiP2pLinkedInfo &)> OnP2pConnectionChangedEvent;
38     /* The event of this device configure has change */
39     std::function<void(const WifiP2pDevice &)> OnP2pThisDeviceChangedEvent;
40     /* The event of discovery status change */
41     std::function<void(bool)> OnP2pDiscoveryChangedEvent;
42     /* The event of groups configure has change */
43     std::function<void()> OnP2pGroupsChangedEvent;
44     /* The result returned by the asynchronous interface */
45     std::function<void(P2pActionCallback, ErrCode)> OnP2pActionResultEvent;
46     /* The event of config change */
47     std::function<void(CfgType, char*, int)> OnConfigChangedEvent;
48     /* The event of gc join */
49     std::function<void(const GcInfo &)> OnP2pGcJoinGroupEvent;
50     /* The event of gc leave */
51     std::function<void(const GcInfo &)> OnP2pGcLeaveGroupEvent;
52     std::function<void(P2pServicerProtocolType, const std::vector<unsigned char> &, const WifiP2pDevice &)>
53         OnP2pServiceAvailable;
54     std::function<void(const std::string &, const std::string &, const WifiP2pDevice &)> OnP2pDnsSdServiceAvailable;
55     std::function<void(const std::string &, const std::map<std::string, std::string> &, const WifiP2pDevice &)>
56         OnP2pDnsSdTxtRecordAvailable;
57     std::function<void(const std::vector<std::string> &, const WifiP2pDevice &)> OnP2pUpnpServiceAvailable;
58     std::function<void(const std::string &)> OnP2pPrivatePeersChangedEvent;
59 };
60 }  // namespace Wifi
61 }  // namespace OHOS
62 #endif  // OHOS_IP2P_SERVICE_CALLBACK_H