• 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 
16 #ifndef INTERFACE_PROFILE_PBAP_PCE_H
17 #define INTERFACE_PROFILE_PBAP_PCE_H
18 
19 #include "interface_profile.h"
20 #include "pbap_pce_parameter.h"
21 namespace OHOS {
22 namespace bluetooth {
23 /**
24  * @brief obsever for pbap client
25  * when pbap client occur event, call these
26  * @since 6
27  */
28 class IPbapPceObserver {
29 public:
30     /**
31      * @brief  ConnectionState Changed
32      *
33      * @param  device     bluetooth address
34      * @param  state      changed status
35      * @since 6
36      */
37     virtual void OnServiceConnectionStateChanged(const RawAddress &device, int state) = 0;
38 
39     /**
40      * @brief connect password input call back
41      * @details when connect password input call  it
42      * @param device remote device
43      * @param description description bytes
44      * @param charset description bytes's chartset
45      * @param fullAccess fullAccess
46      * @since 6
47      */
48     virtual void OnServicePasswordRequired(
49         const RawAddress &device, const std::vector<uint8_t> &description,
50         uint8_t charset, bool fullAccess = true) = 0;
51     /**
52      * @brief Called OnActionCompleted
53      *
54      * @param device remote device
55      * @param respCode Response code
56      * @param actionType phonebook action type
57      * @param result phonebook action response result
58      * @since 6
59      */
60     virtual void OnActionCompleted(
61         const RawAddress &device, int respCode, int actionType, const IPbapPhoneBookData &result) = 0;
62 
63     /**
64      * @brief constructor
65      * @details constructor
66      * @return
67      * @since 6
68      */
IPbapPceObserver()69     IPbapPceObserver()
70     {}
71 
72     /**
73      * @brief deconstructor
74      * @details deconstructor
75      * @return
76      * @since 6
77      */
~IPbapPceObserver()78     virtual ~IPbapPceObserver(){};
79 };
80 
81 /**
82  * @brief pbap pce service
83  * pbap pce service
84  */
85 class IProfilePbapPce : public IProfile {
86 public:
87     /**
88      * @brief register observer
89      * @details register observer for the service of phone book client
90      * @param observer reference to a PbapClientObserver
91      * @return void
92      * @since 6
93      */
94     virtual void RegisterObserver(IPbapPceObserver &observer) = 0;
95 
96     /**
97      * @brief deregister observer
98      * @details deregister observer for the service of phone book client
99      * @param observer reference to a PbapClientObserver
100      * @return void
101      * @since 6
102      */
103     virtual void DeregisterObserver(IPbapPceObserver &observer) = 0;
104 
105     /**
106      * @brief get the remote devices
107      * @details get the remote device with the specified states
108      * @param states states
109      * @return std::vector remote devices
110      * @since 6
111      */
112     virtual std::vector<RawAddress> GetDevicesByStates(const std::vector<int> &states) = 0;
113 
114     /**
115      * @brief get the state of device
116      * @details get the state with the specified remote device
117      * @param device  remote device
118      * @return int @c not -1 state of the specified remote device
119      *             @c -1 device is not exist
120      * @since 6
121      */
122     virtual int GetDeviceState(const RawAddress &device) = 0;
123 
124     /**
125      * @brief set the strategy of device
126      * @details set the strategy with the specified remote device
127      * @param device  remote device
128      * @param strategy  specified strategy
129      * @return int @c 0  success
130      *             @c other failure
131      * @since 6
132      */
133     virtual int SetConnectionStrategy(const RawAddress &device, int strategy) = 0;
134 
135     /**
136      * @brief get the strategy of device
137      * @details get the strategy with the specified remote device
138      * @param device  remote device
139      * @return int @c  strategy
140      * @since 6
141      */
142     virtual int GetConnectionStrategy(const RawAddress &device) = 0;
143 
144     /**
145      * @brief Set device's password. please call after OnServicePasswordRequired event.
146      *
147      * @param device device
148      * @param password device's password
149      * @return int @c 0 ok
150      *             @c -1 fail
151      * @since 6
152      */
153     virtual int SetDevicePassword(
154         const RawAddress &device, const std::string &password, const std::string &userId = "") = 0;
155 
156     /**
157      * @brief Pull phone book. please call after Connected.
158      *
159      * @param device device
160      * @param param app parameter
161      * @return int @c 0 ok
162      *             @c -1 fail
163      * @since 6
164      */
165     virtual int PullPhoneBook(const RawAddress &device, const IPbapPullPhoneBookParam &param) = 0;
166 
167     /**
168      * @brief Set phone book. please call after Connected.
169      *
170      * @param device device
171      * @param path path of phone book
172      * @param flag
173      *        @c PBAP_FLAG_GO_TO_ROOT and empty name--to root;
174      *        @c PBAP_FLAG_GO_DOWN --go down;
175      *        @c PBAP_FLAG_GO_UP --go up
176      * @return int @c 0 ok
177      *             @c -1 fail
178      * @since 6
179      */
180     virtual int SetPhoneBook(const RawAddress &device, const std::u16string &name, int flag) = 0;
181 
182     /**
183      * @brief Pull vCard listing. please call after Connected.
184      *
185      * @param device device
186      * @param param app parameter
187      * @return int @c 0 ok
188      *             @c -1 fail
189      * @since 6
190      */
191     virtual int PullvCardListing(const RawAddress &device, const IPbapPullvCardListingParam &param) = 0;
192 
193     /**
194      * @brief Pull vCard entry. please call after Connected.
195      *
196      * @param device device
197      * @param param app parameter
198      * @return int @c 0 ok
199      *             @c -1 fail
200      * @since 6
201      */
202     virtual int PullvCardEntry(const RawAddress &device, const IPbapPullvCardEntryParam &param) = 0;
203     /**
204      * @brief is downloading.
205      *
206      * @param device device
207      * @return int @c 0 ok
208      *             @c -1 fail
209      * @since 6
210      */
211 
212     virtual bool IsDownloading(const RawAddress &device) = 0;
213 
214     /**
215      * @brief abort downloading.
216      *
217      * @param device device
218      * @return int @c 0 ok
219      *             @c -1 fail
220      * @since 6
221      */
222     virtual int AbortDownloading(const RawAddress &device) = 0;
223 };
224 }  // namespace bluetooth
225 }  // namespace OHOS
226 
227 #endif  // INTERFACE_PROFILE_PBAP_PCE_H