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)21BluetoothIPbapPullPhoneBookParam::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)34BluetoothIPbapPullPhoneBookParam::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) const47bool 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)87bool BluetoothIPbapPullPhoneBookParam::writeToParcel(Parcel &parcel) 88 { 89 return Marshalling(parcel); 90 } 91 readFromParcel(Parcel & parcel)92bool BluetoothIPbapPullPhoneBookParam::readFromParcel(Parcel &parcel) 93 { 94 bool status = false; 95 std::u16string tmpString16; 96 int64_t tmp64 = 0; 97 int tmp = 0; 98 status = parcel.ReadString16(tmpString16); 99 if (!status) { 100 return status; 101 } 102 SetName(tmpString16); 103 status = parcel.ReadInt64(tmp64); 104 if (!status) { 105 return status; 106 } 107 SetPropertySelector(tmp64); 108 status = parcel.ReadInt32(tmp); 109 if (!status) { 110 return status; 111 } 112 SetFormat(tmp); 113 status = parcel.ReadInt32(tmp); 114 if (!status) { 115 return status; 116 } 117 SetMaxListCount(tmp); 118 status = parcel.ReadInt32(tmp); 119 if (!status) { 120 return status; 121 } 122 SetListStartOffset(tmp); 123 status = parcel.ReadInt32(tmp); 124 if (!status) { 125 return status; 126 } 127 SetResetNewMissedCalls(tmp); 128 status = parcel.ReadInt64(tmp64); 129 if (!status) { 130 return status; 131 } 132 SetvCardSelector(tmp64); 133 status = parcel.ReadInt32(tmp); 134 if (!status) { 135 return status; 136 } 137 SetvCardSelectorOp(tmp); 138 status = parcel.ReadInt64(tmp64); 139 if (!status) { 140 return status; 141 } 142 SetSpecifiedBitset(tmp64); 143 144 return status; 145 } 146 Unmarshalling(Parcel & parcel)147BluetoothIPbapPullPhoneBookParam *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 155 return pullPhoneBookParam; 156 } 157 158 // BluetoothIPbapPullvCardListingParam BluetoothIPbapPullvCardListingParam(const::bluetooth::IPbapPullvCardListingParam & other)159BluetoothIPbapPullvCardListingParam::BluetoothIPbapPullvCardListingParam( 160 const ::bluetooth::IPbapPullvCardListingParam &other) 161 { 162 SetName(other.GetName()); 163 SetOrder(other.GetOrder()); 164 SetSearchValue(other.GetSearchValue()); 165 SetSearchProperty(other.GetSearchProperty()); 166 SetMaxListCount(other.GetMaxListCount()); 167 SetListStartOffset(other.GetListStartOffset()); 168 SetResetNewMissedCalls(other.GetResetNewMissedCalls()); 169 SetvCardSelector(other.GetvCardSelector()); 170 SetvCardSelectorOp(other.GetvCardSelectorOp()); 171 SetSpecifiedBitset(other.GetSpecifiedBitset()); 172 } 173 BluetoothIPbapPullvCardListingParam(const BluetoothIPbapPullvCardListingParam & other)174BluetoothIPbapPullvCardListingParam::BluetoothIPbapPullvCardListingParam( 175 const BluetoothIPbapPullvCardListingParam &other) 176 { 177 SetName(other.GetName()); 178 SetOrder(other.GetOrder()); 179 SetSearchValue(other.GetSearchValue()); 180 SetSearchProperty(other.GetSearchProperty()); 181 SetMaxListCount(other.GetMaxListCount()); 182 SetListStartOffset(other.GetListStartOffset()); 183 SetResetNewMissedCalls(other.GetResetNewMissedCalls()); 184 SetvCardSelector(other.GetvCardSelector()); 185 SetvCardSelectorOp(other.GetvCardSelectorOp()); 186 SetSpecifiedBitset(other.GetSpecifiedBitset()); 187 } 188 Marshalling(Parcel & parcel) const189bool BluetoothIPbapPullvCardListingParam::Marshalling(Parcel &parcel) const 190 { 191 bool status = false; 192 status = parcel.WriteString16(GetName()); 193 if (!status) { 194 return status; 195 } 196 status = parcel.WriteInt32(GetOrder()); 197 if (!status) { 198 return status; 199 } 200 status = parcel.WriteString(GetSearchValue()); 201 if (!status) { 202 return status; 203 } 204 status = parcel.WriteInt32(GetSearchProperty()); 205 if (!status) { 206 return status; 207 } 208 status = parcel.WriteInt32(GetMaxListCount()); 209 if (!status) { 210 return status; 211 } 212 status = parcel.WriteInt32(GetListStartOffset()); 213 if (!status) { 214 return status; 215 } 216 status = parcel.WriteInt32(GetResetNewMissedCalls()); 217 if (!status) { 218 return status; 219 } 220 status = parcel.WriteInt64(GetvCardSelector()); 221 if (!status) { 222 return status; 223 } 224 status = parcel.WriteInt32(GetvCardSelectorOp()); 225 if (!status) { 226 return status; 227 } 228 status = parcel.WriteInt64(GetSpecifiedBitset()); 229 230 return status; 231 } 232 writeToParcel(Parcel & parcel)233bool BluetoothIPbapPullvCardListingParam::writeToParcel(Parcel &parcel) 234 { 235 return Marshalling(parcel); 236 } 237 readFromParcel(Parcel & parcel)238bool BluetoothIPbapPullvCardListingParam::readFromParcel(Parcel &parcel) 239 { 240 bool status = false; 241 std::u16string tmpString16; 242 std::string tmpString; 243 int64_t tmp64 = 0; 244 int tmp = 0; 245 status = parcel.ReadString16(tmpString16); 246 if (!status) { 247 return status; 248 } 249 SetName(tmpString16); 250 status = parcel.ReadInt32(tmp); 251 if (!status) { 252 return status; 253 } 254 SetOrder(tmp); 255 status = parcel.ReadString(tmpString); 256 if (!status) { 257 return status; 258 } 259 SetSearchValue(tmpString); 260 status = parcel.ReadInt32(tmp); 261 if (!status) { 262 return status; 263 } 264 SetSearchProperty(tmp); 265 status = parcel.ReadInt32(tmp); 266 if (!status) { 267 return status; 268 } 269 SetMaxListCount(tmp); 270 status = parcel.ReadInt32(tmp); 271 if (!status) { 272 return status; 273 } 274 SetListStartOffset(tmp); 275 status = parcel.ReadInt32(tmp); 276 if (!status) { 277 return status; 278 } 279 SetResetNewMissedCalls(tmp); 280 status = parcel.ReadInt64(tmp64); 281 if (!status) { 282 return status; 283 } 284 SetvCardSelector(tmp64); 285 status = parcel.ReadInt32(tmp); 286 if (!status) { 287 return status; 288 } 289 SetvCardSelectorOp(tmp); 290 status = parcel.ReadInt64(tmp64); 291 if (!status) { 292 return status; 293 } 294 SetSpecifiedBitset(tmp64); 295 296 return status; 297 } 298 Unmarshalling(Parcel & parcel)299BluetoothIPbapPullvCardListingParam *BluetoothIPbapPullvCardListingParam::Unmarshalling(Parcel &parcel) 300 { 301 BluetoothIPbapPullvCardListingParam *pullvCardListingParam = new BluetoothIPbapPullvCardListingParam(); 302 if (pullvCardListingParam != nullptr && !pullvCardListingParam->readFromParcel(parcel)) { 303 delete pullvCardListingParam; 304 pullvCardListingParam = nullptr; 305 } 306 307 return pullvCardListingParam; 308 } 309 310 // BluetoothIPbapPullvCardEntryParam BluetoothIPbapPullvCardEntryParam(const::bluetooth::IPbapPullvCardEntryParam & other)311BluetoothIPbapPullvCardEntryParam::BluetoothIPbapPullvCardEntryParam( 312 const ::bluetooth::IPbapPullvCardEntryParam &other) 313 { 314 SetName(other.GetName()); 315 SetPropertySelector(other.GetPropertySelector()); 316 SetFormat(other.GetFormat()); 317 SetSpecifiedBitset(other.GetSpecifiedBitset()); 318 } 319 BluetoothIPbapPullvCardEntryParam(const BluetoothIPbapPullvCardEntryParam & other)320BluetoothIPbapPullvCardEntryParam::BluetoothIPbapPullvCardEntryParam(const BluetoothIPbapPullvCardEntryParam &other) 321 { 322 SetName(other.GetName()); 323 SetPropertySelector(other.GetPropertySelector()); 324 SetFormat(other.GetFormat()); 325 SetSpecifiedBitset(other.GetSpecifiedBitset()); 326 } 327 Marshalling(Parcel & parcel) const328bool BluetoothIPbapPullvCardEntryParam::Marshalling(Parcel &parcel) const 329 { 330 bool status = false; 331 status = parcel.WriteString16(GetName()); 332 if (!status) { 333 return status; 334 } 335 status = parcel.WriteInt64(GetPropertySelector()); 336 if (!status) { 337 return status; 338 } 339 status = parcel.WriteInt32(GetFormat()); 340 if (!status) { 341 return status; 342 } 343 status = parcel.WriteInt64(GetSpecifiedBitset()); 344 345 return status; 346 } 347 writeToParcel(Parcel & parcel)348bool BluetoothIPbapPullvCardEntryParam::writeToParcel(Parcel &parcel) 349 { 350 return Marshalling(parcel); 351 } 352 readFromParcel(Parcel & parcel)353bool BluetoothIPbapPullvCardEntryParam::readFromParcel(Parcel &parcel) 354 { 355 bool status = false; 356 std::u16string tmpString16; 357 int64_t tmp64 = 0; 358 int tmp = 0; 359 status = parcel.ReadString16(tmpString16); 360 if (!status) { 361 return status; 362 } 363 SetName(tmpString16); 364 status = parcel.ReadInt64(tmp64); 365 if (!status) { 366 return status; 367 } 368 SetPropertySelector(tmp64); 369 status = parcel.ReadInt32(tmp); 370 if (!status) { 371 return status; 372 } 373 SetFormat(tmp); 374 status = parcel.ReadInt64(tmp64); 375 if (!status) { 376 return status; 377 } 378 SetSpecifiedBitset(tmp64); 379 return status; 380 } 381 Unmarshalling(Parcel & parcel)382BluetoothIPbapPullvCardEntryParam *BluetoothIPbapPullvCardEntryParam::Unmarshalling(Parcel &parcel) 383 { 384 BluetoothIPbapPullvCardEntryParam *pullvCardEntryParam = new BluetoothIPbapPullvCardEntryParam(); 385 if (pullvCardEntryParam != nullptr && !pullvCardEntryParam->readFromParcel(parcel)) { 386 delete pullvCardEntryParam; 387 pullvCardEntryParam = nullptr; 388 } 389 390 return pullvCardEntryParam; 391 } 392 393 // BluetoothIPbapPhoneBookData functions BluetoothIPbapPhoneBookData(const::bluetooth::IPbapPhoneBookData & other)394BluetoothIPbapPhoneBookData::BluetoothIPbapPhoneBookData(const ::bluetooth::IPbapPhoneBookData &other) 395 { 396 phoneBookSize_ = other.phoneBookSize_; 397 primaryFolderVersion_ = other.primaryFolderVersion_; 398 secondaryFolderVersion_ = other.secondaryFolderVersion_; 399 databaseIdentifier_ = other.databaseIdentifier_; 400 deviceAddr_ = other.deviceAddr_; 401 vcardPath_ = other.vcardPath_; 402 vcardFileName_ = other.vcardFileName_; 403 resultLoaded_ = other.resultLoaded_; 404 result_ = other.result_; 405 } 406 BluetoothIPbapPhoneBookData(const BluetoothIPbapPhoneBookData & other)407BluetoothIPbapPhoneBookData::BluetoothIPbapPhoneBookData(const BluetoothIPbapPhoneBookData &other) 408 { 409 phoneBookSize_ = other.phoneBookSize_; 410 primaryFolderVersion_ = other.primaryFolderVersion_; 411 secondaryFolderVersion_ = other.secondaryFolderVersion_; 412 databaseIdentifier_ = other.databaseIdentifier_; 413 deviceAddr_ = other.deviceAddr_; 414 vcardPath_ = other.vcardPath_; 415 vcardFileName_ = other.vcardFileName_; 416 resultLoaded_ = other.resultLoaded_; 417 result_ = other.result_; 418 } 419 Marshalling(Parcel & parcel) const420bool BluetoothIPbapPhoneBookData::Marshalling(Parcel &parcel) const 421 { 422 bool status = false; 423 status = parcel.WriteInt32(phoneBookSize_); 424 if (!status) { 425 return status; 426 } 427 428 status = parcel.WriteUInt8Vector(primaryFolderVersion_); 429 if (!status) { 430 return status; 431 } 432 433 status = parcel.WriteUInt8Vector(secondaryFolderVersion_); 434 if (!status) { 435 return status; 436 } 437 438 status = parcel.WriteUInt8Vector(databaseIdentifier_); 439 if (!status) { 440 return status; 441 } 442 443 status = parcel.WriteString(deviceAddr_); 444 if (!status) { 445 return status; 446 } 447 448 status = parcel.WriteString(vcardPath_); 449 if (!status) { 450 return status; 451 } 452 453 status = parcel.WriteString(vcardFileName_); 454 if (!status) { 455 return status; 456 } 457 458 status = parcel.WriteInt32(resultLoaded_); 459 if (!status) { 460 return status; 461 } 462 463 status = parcel.WriteUInt8Vector(result_); 464 return status; 465 } 466 writeToParcel(Parcel & parcel)467bool BluetoothIPbapPhoneBookData::writeToParcel(Parcel &parcel) 468 { 469 return Marshalling(parcel); 470 } 471 readFromParcel(Parcel & parcel)472bool BluetoothIPbapPhoneBookData::readFromParcel(Parcel &parcel) 473 { 474 bool status = false; 475 int32_t tmp = 0; 476 status = parcel.ReadInt32(tmp); 477 if (!status) { 478 return status; 479 } 480 phoneBookSize_ = tmp; 481 482 status = parcel.ReadUInt8Vector(&primaryFolderVersion_); 483 if (!status) { 484 return status; 485 } 486 487 status = parcel.ReadUInt8Vector(&secondaryFolderVersion_); 488 if (!status) { 489 return status; 490 } 491 492 status = parcel.ReadUInt8Vector(&databaseIdentifier_); 493 if (!status) { 494 return status; 495 } 496 497 status = parcel.ReadString(deviceAddr_); 498 if (!status) { 499 return status; 500 } 501 status = parcel.ReadString(vcardPath_); 502 if (!status) { 503 return status; 504 } 505 status = parcel.ReadString(vcardFileName_); 506 if (!status) { 507 return status; 508 } 509 status = parcel.ReadInt32(tmp); 510 if (!status) { 511 return status; 512 } 513 resultLoaded_ = tmp; 514 515 int size = 0; 516 status = parcel.ReadInt32(tmp); 517 if (!status) { 518 return status; 519 } 520 size = tmp; 521 522 status = parcel.ReadUInt8Vector(&result_); 523 return status; 524 } 525 Unmarshalling(Parcel & parcel)526BluetoothIPbapPhoneBookData *BluetoothIPbapPhoneBookData::Unmarshalling(Parcel &parcel) 527 { 528 BluetoothIPbapPhoneBookData *phoneBookData = new BluetoothIPbapPhoneBookData(); 529 if (phoneBookData != nullptr && !phoneBookData->readFromParcel(parcel)) { 530 delete phoneBookData; 531 phoneBookData = nullptr; 532 } 533 534 return phoneBookData; 535 } 536 } // namespace Bluetooth 537 } // namespace OHOS 538