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_SERVICE_REQUEST_LIST_H
16 #define OHOS_WIFI_P2P_SERVICE_REQUEST_LIST_H
17 
18 #include "wifi_p2p_msg.h"
19 #include "wifi_msg.h"
20 
21 namespace OHOS {
22 namespace Wifi {
23 class WifiP2pServiceRequestList {
24 public:
25     /**
26      * @Description Construct a new WifiP2pServiceRequestList object.
27      *
28      */
29     WifiP2pServiceRequestList();
30 
31     /**
32      * @Description Default destructor.
33      *
34      */
35     virtual ~WifiP2pServiceRequestList() = default;
36 
37     /**
38      * @Description Add service discovery request.
39      *
40      * @param req service discovery request
41      * @return true adding succeeded
42      * @return false adding failed
43      */
44     virtual bool AddServiceRequest(const WifiP2pServiceRequest &req);
45 
46     /**
47      * @Description Deleting service discovery request.
48      *
49      * @param req service discovery request
50      * @return true deleted successfully
51      * @return false deletion failed
52      */
53     virtual bool RemoveServiceRequest(const WifiP2pServiceRequest &req);
54 
55     /**
56      * @Description Clear the list of service discovery requests.
57      *
58      * @return true deleted successfully
59      * @return false deletion failed
60      */
61     virtual bool ClearServiceRequest();
62 
63     /**
64      * @Description Obtains the list of all service discovery requests.
65      *
66      * @param srvReqList a list of saving service discovery requests
67      * @return true deleted successfully
68      * @return false deletion failed
69      */
70     virtual const std::vector<WifiP2pServiceRequest> &GetServiceRequestList() const;
71 
72     /**
73      * @Description Set the update indicate.
74      *
75      * @param setUpdateIndic number of the update indicate
76      */
77     virtual void SetUpdateIndic(unsigned short setUpdateIndic);
78 
79     /**
80      * @Description Get the update indicate.
81      *
82      * @return unsigned short number of the update indicate
83      */
84     virtual unsigned short GetUpdateIndic() const;
85 
86     /**
87      * @Description Set the operating frequency.
88      *
89      * @param setFrequency number of frequency
90      */
91     virtual void SetFrequency(int setFrequency);
92 
93     /**
94      * @Description Get the operating frequency.
95      *
96      * @return int number of frequency
97      */
98     virtual int GetFrequency() const;
99 
100     /**
101      * @Description Set the dialog ID.
102      *
103      * @param setDialogToken number of the dialog ID
104      */
105     virtual void SetDialogToken(int setDialogToken);
106 
107     /**
108      * @Description Get the dialog ID.
109      *
110      * @return int number of the dialog ID
111      */
112     virtual int GetDialogToken() const;
113 
114     /**
115      * @Description Obtains the TLVs of the list combination.
116      * @return - std::vector<unsigned char>
117      */
118     virtual std::vector<unsigned char> GetTlvs() const;
119 
120     /**
121      * @Description Set the p2pDevice member.
122      *
123      * @param device device object to be set
124      */
125     virtual void SetDevice(const WifiP2pDevice &device);
126 
127     /**
128      * @Description Get the p2pDevice member instance.
129      *
130      * @return const WifiP2pDevice& p2pDevice
131      */
132     virtual const WifiP2pDevice &GetDevice() const;
133     /**
134      * @Description Parses the TLVS package of the service request and saves the data to the srvReqList table.
135      *
136      * @param tlvs TLVS data packet
137      * @return true parsing succeeded
138      * @return false parsing failed
139      */
140     virtual bool ParseTlvs2ReqList(const std::vector<unsigned char> &tlvs);
141 
142 private:
143     unsigned short updateIndic;                       /* update counter ID */
144     int frequency;                                    /* operating frequency */
145     int dialogToken;                                  /* dialog ID */
146     WifiP2pDevice p2pDevice;                             /* source (or target) device */
147     std::vector<WifiP2pServiceRequest> srvReqList;    /* received (or sent) a list of requests */
148 };
149 }  // namespace Wifi
150 }  // namespace OHOS
151 
152 #endif  /* OHOS_WIFI_P2P_SERVICE_REQUEST_LIST_H */
153