• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 #include "bluetooth_pbap_pce_parameter.h"
17 
18 namespace OHOS {
19 namespace Bluetooth {
20 // BluetoothIPbapPullPhoneBookParam
BluetoothIPbapPullPhoneBookParam(const bluetooth::IPbapPullPhoneBookParam & other)21 BluetoothIPbapPullPhoneBookParam::BluetoothIPbapPullPhoneBookParam(const bluetooth::IPbapPullPhoneBookParam &other)
22 {
23     SetName(other.GetName());
24     SetPropertySelector(other.GetPropertySelector());
25     SetFormat(other.GetFormat());
26     SetMaxListCount(other.GetMaxListCount());
27     SetListStartOffset(other.GetListStartOffset());
28     SetResetNewMissedCalls(other.GetResetNewMissedCalls());
29     SetvCardSelector(other.GetvCardSelector());
30     SetvCardSelectorOp(other.GetvCardSelectorOp());
31     SetSpecifiedBitset(other.GetSpecifiedBitset());
32 }
33 
BluetoothIPbapPullPhoneBookParam(const BluetoothIPbapPullPhoneBookParam & other)34 BluetoothIPbapPullPhoneBookParam::BluetoothIPbapPullPhoneBookParam(const BluetoothIPbapPullPhoneBookParam &other)
35 {
36     SetName(other.GetName());
37     SetPropertySelector(other.GetPropertySelector());
38     SetFormat(other.GetFormat());
39     SetMaxListCount(other.GetMaxListCount());
40     SetListStartOffset(other.GetListStartOffset());
41     SetResetNewMissedCalls(other.GetResetNewMissedCalls());
42     SetvCardSelector(other.GetvCardSelector());
43     SetvCardSelectorOp(other.GetvCardSelectorOp());
44     SetSpecifiedBitset(other.GetSpecifiedBitset());
45 }
46 
Marshalling(Parcel & parcel) const47 bool BluetoothIPbapPullPhoneBookParam::Marshalling(Parcel &parcel) const
48 {
49     bool status = false;
50     status = parcel.WriteString16(GetName());
51     if (!status) {
52         return status;
53     }
54     status = parcel.WriteInt64(GetPropertySelector());
55     if (!status) {
56         return status;
57     }
58     status = parcel.WriteInt32(GetFormat());
59     if (!status) {
60         return status;
61     }
62     status = parcel.WriteInt32(GetMaxListCount());
63     if (!status) {
64         return status;
65     }
66     status = parcel.WriteInt32(GetListStartOffset());
67     if (!status) {
68         return status;
69     }
70     status = parcel.WriteInt32(GetResetNewMissedCalls());
71     if (!status) {
72         return status;
73     }
74     status = parcel.WriteInt64(GetvCardSelector());
75     if (!status) {
76         return status;
77     }
78     status = parcel.WriteInt32(GetvCardSelectorOp());
79     if (!status) {
80         return status;
81     }
82     status = parcel.WriteInt64(GetSpecifiedBitset());
83 
84     return status;
85 }
86 
WriteToParcel(Parcel & parcel)87 bool BluetoothIPbapPullPhoneBookParam::WriteToParcel(Parcel &parcel)
88 {
89     return Marshalling(parcel);
90 }
91 
ReadFromParcel(Parcel & parcel)92 bool BluetoothIPbapPullPhoneBookParam::ReadFromParcel(Parcel &parcel)
93 {
94     bool status = false;
95     std::u16string valString16;
96     int64_t val64 = 0;
97     int val = 0;
98     status = parcel.ReadString16(valString16);
99     if (!status) {
100         return status;
101     }
102     SetName(valString16);
103     status = parcel.ReadInt64(val64);
104     if (!status) {
105         return status;
106     }
107     SetPropertySelector(val64);
108     status = parcel.ReadInt32(val);
109     if (!status) {
110         return status;
111     }
112     SetFormat(val);
113     status = parcel.ReadInt32(val);
114     if (!status) {
115         return status;
116     }
117     SetMaxListCount(val);
118     status = parcel.ReadInt32(val);
119     if (!status) {
120         return status;
121     }
122     SetListStartOffset(val);
123     status = parcel.ReadInt32(val);
124     if (!status) {
125         return status;
126     }
127     SetResetNewMissedCalls(val);
128     status = parcel.ReadInt64(val64);
129     if (!status) {
130         return status;
131     }
132     SetvCardSelector(val64);
133     status = parcel.ReadInt32(val);
134     if (!status) {
135         return status;
136     }
137     SetvCardSelectorOp(val);
138     status = parcel.ReadInt64(val64);
139     if (!status) {
140         return status;
141     }
142     SetSpecifiedBitset(val64);
143 
144     return status;
145 }
146 
Unmarshalling(Parcel & parcel)147 BluetoothIPbapPullPhoneBookParam *BluetoothIPbapPullPhoneBookParam::Unmarshalling(Parcel &parcel)
148 {
149     BluetoothIPbapPullPhoneBookParam *pullPhoneBookParam = new BluetoothIPbapPullPhoneBookParam();
150     if (pullPhoneBookParam != nullptr && !pullPhoneBookParam->ReadFromParcel(parcel)) {
151         delete pullPhoneBookParam;
152         pullPhoneBookParam = nullptr;
153     }
154     return pullPhoneBookParam;
155 }
156 
157 // BluetoothIPbapPullvCardListingParam
BluetoothIPbapPullvCardListingParam(const bluetooth::IPbapPullvCardListingParam & other)158 BluetoothIPbapPullvCardListingParam::BluetoothIPbapPullvCardListingParam(
159     const bluetooth::IPbapPullvCardListingParam &other)
160 {
161     SetName(other.GetName());
162     SetOrder(other.GetOrder());
163     SetSearchValue(other.GetSearchValue());
164     SetSearchProperty(other.GetSearchProperty());
165     SetMaxListCount(other.GetMaxListCount());
166     SetListStartOffset(other.GetListStartOffset());
167     SetResetNewMissedCalls(other.GetResetNewMissedCalls());
168     SetvCardSelector(other.GetvCardSelector());
169     SetvCardSelectorOp(other.GetvCardSelectorOp());
170     SetSpecifiedBitset(other.GetSpecifiedBitset());
171 }
172 
BluetoothIPbapPullvCardListingParam(const BluetoothIPbapPullvCardListingParam & other)173 BluetoothIPbapPullvCardListingParam::BluetoothIPbapPullvCardListingParam(
174     const BluetoothIPbapPullvCardListingParam &other)
175 {
176     SetName(other.GetName());
177     SetOrder(other.GetOrder());
178     SetSearchValue(other.GetSearchValue());
179     SetSearchProperty(other.GetSearchProperty());
180     SetMaxListCount(other.GetMaxListCount());
181     SetListStartOffset(other.GetListStartOffset());
182     SetResetNewMissedCalls(other.GetResetNewMissedCalls());
183     SetvCardSelector(other.GetvCardSelector());
184     SetvCardSelectorOp(other.GetvCardSelectorOp());
185     SetSpecifiedBitset(other.GetSpecifiedBitset());
186 }
187 
Marshalling(Parcel & parcel) const188 bool BluetoothIPbapPullvCardListingParam::Marshalling(Parcel &parcel) const
189 {
190     bool status = false;
191     status = parcel.WriteString16(GetName());
192     if (!status) {
193         return status;
194     }
195     status = parcel.WriteInt32(GetOrder());
196     if (!status) {
197         return status;
198     }
199     status = parcel.WriteString(GetSearchValue());
200     if (!status) {
201         return status;
202     }
203     status = parcel.WriteInt32(GetSearchProperty());
204     if (!status) {
205         return status;
206     }
207     status = parcel.WriteInt32(GetMaxListCount());
208     if (!status) {
209         return status;
210     }
211     status = parcel.WriteInt32(GetListStartOffset());
212     if (!status) {
213         return status;
214     }
215     status = parcel.WriteInt32(GetResetNewMissedCalls());
216     if (!status) {
217         return status;
218     }
219     status = parcel.WriteInt64(GetvCardSelector());
220     if (!status) {
221         return status;
222     }
223     status = parcel.WriteInt32(GetvCardSelectorOp());
224     if (!status) {
225         return status;
226     }
227     status = parcel.WriteInt64(GetSpecifiedBitset());
228 
229     return status;
230 }
231 
WriteToParcel(Parcel & parcel)232 bool BluetoothIPbapPullvCardListingParam::WriteToParcel(Parcel &parcel)
233 {
234     return Marshalling(parcel);
235 }
236 
ReadFromParcel(Parcel & parcel)237 bool BluetoothIPbapPullvCardListingParam::ReadFromParcel(Parcel &parcel)
238 {
239     std::u16string valString16;
240     std::string valString;
241     int64_t val64 = 0;
242     int val = 0;
243     if (!parcel.ReadString16(valString16)) {
244         return false;
245     }
246     SetName(valString16);
247     if (!parcel.ReadInt32(val)) {
248         return false;
249     }
250     SetOrder(val);
251     if (!parcel.ReadString(valString)) {
252         return false;
253     }
254     SetSearchValue(valString);
255     if (!parcel.ReadInt32(val)) {
256         return false;
257     }
258     SetSearchProperty(val);
259     if (!parcel.ReadInt32(val)) {
260         return false;
261     }
262     SetMaxListCount(val);
263     if (!parcel.ReadInt32(val)) {
264         return false;
265     }
266     SetListStartOffset(val);
267     if (!parcel.ReadInt32(val)) {
268         return false;
269     }
270     SetResetNewMissedCalls(val);
271     if (!parcel.ReadInt64(val64)) {
272         return false;
273     }
274     SetvCardSelector(val64);
275     if (!parcel.ReadInt32(val)) {
276         return false;
277     }
278     SetvCardSelectorOp(val);
279     if (!parcel.ReadInt64(val64)) {
280         return false;
281     }
282     SetSpecifiedBitset(val64);
283 
284     return true;
285 }
286 
Unmarshalling(Parcel & parcel)287 BluetoothIPbapPullvCardListingParam *BluetoothIPbapPullvCardListingParam::Unmarshalling(Parcel &parcel)
288 {
289     BluetoothIPbapPullvCardListingParam *pullvCardListingParam = new BluetoothIPbapPullvCardListingParam();
290     if (pullvCardListingParam != nullptr && !pullvCardListingParam->ReadFromParcel(parcel)) {
291         delete pullvCardListingParam;
292         pullvCardListingParam = nullptr;
293     }
294     return pullvCardListingParam;
295 }
296 
297 // BluetoothIPbapPullvCardEntryParam
BluetoothIPbapPullvCardEntryParam(const bluetooth::IPbapPullvCardEntryParam & other)298 BluetoothIPbapPullvCardEntryParam::BluetoothIPbapPullvCardEntryParam(
299     const bluetooth::IPbapPullvCardEntryParam &other)
300 {
301     SetName(other.GetName());
302     SetPropertySelector(other.GetPropertySelector());
303     SetFormat(other.GetFormat());
304     SetSpecifiedBitset(other.GetSpecifiedBitset());
305 }
306 
BluetoothIPbapPullvCardEntryParam(const BluetoothIPbapPullvCardEntryParam & other)307 BluetoothIPbapPullvCardEntryParam::BluetoothIPbapPullvCardEntryParam(const BluetoothIPbapPullvCardEntryParam &other)
308 {
309     SetName(other.GetName());
310     SetPropertySelector(other.GetPropertySelector());
311     SetFormat(other.GetFormat());
312     SetSpecifiedBitset(other.GetSpecifiedBitset());
313 }
314 
Marshalling(Parcel & parcel) const315 bool BluetoothIPbapPullvCardEntryParam::Marshalling(Parcel &parcel) const
316 {
317     bool status = false;
318     status = parcel.WriteString16(GetName());
319     if (!status) {
320         return status;
321     }
322     status = parcel.WriteInt64(GetPropertySelector());
323     if (!status) {
324         return status;
325     }
326     status = parcel.WriteInt32(GetFormat());
327     if (!status) {
328         return status;
329     }
330     status = parcel.WriteInt64(GetSpecifiedBitset());
331 
332     return status;
333 }
334 
WriteToParcel(Parcel & parcel)335 bool BluetoothIPbapPullvCardEntryParam::WriteToParcel(Parcel &parcel)
336 {
337     return Marshalling(parcel);
338 }
339 
ReadFromParcel(Parcel & parcel)340 bool BluetoothIPbapPullvCardEntryParam::ReadFromParcel(Parcel &parcel)
341 {
342     bool status = false;
343     std::u16string valString16;
344     int64_t val64 = 0;
345     int val = 0;
346     status = parcel.ReadString16(valString16);
347     if (!status) {
348         return status;
349     }
350     SetName(valString16);
351     status = parcel.ReadInt64(val64);
352     if (!status) {
353         return status;
354     }
355     SetPropertySelector(val64);
356     status = parcel.ReadInt32(val);
357     if (!status) {
358         return status;
359     }
360     SetFormat(val);
361     status = parcel.ReadInt64(val64);
362     if (!status) {
363         return status;
364     }
365     SetSpecifiedBitset(val64);
366     return status;
367 }
368 
Unmarshalling(Parcel & parcel)369 BluetoothIPbapPullvCardEntryParam *BluetoothIPbapPullvCardEntryParam::Unmarshalling(Parcel &parcel)
370 {
371     BluetoothIPbapPullvCardEntryParam *pullvCardEntryParam = new BluetoothIPbapPullvCardEntryParam();
372     if (pullvCardEntryParam != nullptr && !pullvCardEntryParam->ReadFromParcel(parcel)) {
373         delete pullvCardEntryParam;
374         pullvCardEntryParam = nullptr;
375     }
376     return pullvCardEntryParam;
377 }
378 
379 // BluetoothIPbapPhoneBookData functions
BluetoothIPbapPhoneBookData(const bluetooth::IPbapPhoneBookData & other)380 BluetoothIPbapPhoneBookData::BluetoothIPbapPhoneBookData(const bluetooth::IPbapPhoneBookData &other)
381 {
382     phoneBookSize_ = other.phoneBookSize_;
383     primaryFolderVersion_ = other.primaryFolderVersion_;
384     secondaryFolderVersion_ = other.secondaryFolderVersion_;
385     databaseIdentifier_ = other.databaseIdentifier_;
386     deviceAddr_ = other.deviceAddr_;
387     vcardPath_ = other.vcardPath_;
388     vcardFileName_ = other.vcardFileName_;
389     resultLoaded_ = other.resultLoaded_;
390     result_ = other.result_;
391 }
392 
BluetoothIPbapPhoneBookData(const BluetoothIPbapPhoneBookData & other)393 BluetoothIPbapPhoneBookData::BluetoothIPbapPhoneBookData(const BluetoothIPbapPhoneBookData &other)
394 {
395     phoneBookSize_ = other.phoneBookSize_;
396     primaryFolderVersion_ = other.primaryFolderVersion_;
397     secondaryFolderVersion_ = other.secondaryFolderVersion_;
398     databaseIdentifier_ = other.databaseIdentifier_;
399     deviceAddr_ = other.deviceAddr_;
400     vcardPath_ = other.vcardPath_;
401     vcardFileName_ = other.vcardFileName_;
402     resultLoaded_ = other.resultLoaded_;
403     result_ = other.result_;
404 }
405 
Marshalling(Parcel & parcel) const406 bool BluetoothIPbapPhoneBookData::Marshalling(Parcel &parcel) const
407 {
408     bool status = false;
409     status = parcel.WriteUint16(phoneBookSize_);
410     if (!status) {
411         return status;
412     }
413 
414     status = parcel.WriteUInt8Vector(primaryFolderVersion_);
415     if (!status) {
416         return status;
417     }
418 
419     status = parcel.WriteUInt8Vector(secondaryFolderVersion_);
420     if (!status) {
421         return status;
422     }
423 
424     status = parcel.WriteUInt8Vector(databaseIdentifier_);
425     if (!status) {
426         return status;
427     }
428 
429     status = parcel.WriteString(deviceAddr_);
430     if (!status) {
431         return status;
432     }
433 
434     status = parcel.WriteString(vcardPath_);
435     if (!status) {
436         return status;
437     }
438 
439     status = parcel.WriteString(vcardFileName_);
440     if (!status) {
441         return status;
442     }
443 
444     status = parcel.WriteUint16(resultLoaded_);
445     if (!status) {
446         return status;
447     }
448 
449     status = parcel.WriteUInt8Vector(result_);
450     return status;
451 }
452 
WriteToParcel(Parcel & parcel)453 bool BluetoothIPbapPhoneBookData::WriteToParcel(Parcel &parcel)
454 {
455     return Marshalling(parcel);
456 }
457 
ReadFromParcel(Parcel & parcel)458 bool BluetoothIPbapPhoneBookData::ReadFromParcel(Parcel &parcel)
459 {
460     bool status = false;
461     status = parcel.ReadUint16(phoneBookSize_);
462     if (!status) {
463         return status;
464     }
465 
466     status = parcel.ReadUInt8Vector(&primaryFolderVersion_);
467     if (!status) {
468         return status;
469     }
470 
471     status = parcel.ReadUInt8Vector(&secondaryFolderVersion_);
472     if (!status) {
473         return status;
474     }
475 
476     status = parcel.ReadUInt8Vector(&databaseIdentifier_);
477     if (!status) {
478         return status;
479     }
480 
481     status = parcel.ReadString(deviceAddr_);
482     if (!status) {
483         return status;
484     }
485     status = parcel.ReadString(vcardPath_);
486     if (!status) {
487         return status;
488     }
489     status = parcel.ReadString(vcardFileName_);
490     if (!status) {
491         return status;
492     }
493     status = parcel.ReadUint16(resultLoaded_);
494     if (!status) {
495         return status;
496     }
497 
498     status = parcel.ReadUInt8Vector(&result_);
499     return status;
500 }
501 
Unmarshalling(Parcel & parcel)502 BluetoothIPbapPhoneBookData *BluetoothIPbapPhoneBookData::Unmarshalling(Parcel &parcel)
503 {
504     BluetoothIPbapPhoneBookData *phoneBookData = new BluetoothIPbapPhoneBookData();
505     if (phoneBookData != nullptr && !phoneBookData->ReadFromParcel(parcel)) {
506         delete phoneBookData;
507         phoneBookData = nullptr;
508     }
509     return phoneBookData;
510 }
511 }  // namespace Bluetooth
512 }  // namespace OHOS
513