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 "scanner_info.h" 17 18 namespace OHOS::Scan { 19 20 21 //tcp ScanDeviceInfoTCP()22ScanDeviceInfoTCP::ScanDeviceInfoTCP() 23 { 24 deviceName=""; 25 uuid=""; 26 model=""; 27 manufacturer=""; 28 deviceType=""; 29 port=""; 30 addr=""; 31 button=""; 32 feeder=""; 33 deviceState = 0; 34 } 35 ScanDeviceInfoTCP(const ScanDeviceInfoTCP & right)36ScanDeviceInfoTCP::ScanDeviceInfoTCP(const ScanDeviceInfoTCP &right) 37 { 38 deviceName = right.deviceName; 39 uuid = right.uuid; 40 model = right.model; 41 manufacturer = right.manufacturer; 42 deviceType = right.deviceType; 43 port = right.port; 44 addr = right.addr; 45 button = right.button; 46 feeder = right.feeder; 47 deviceState = right.deviceState; 48 } 49 operator =(const ScanDeviceInfoTCP & right)50ScanDeviceInfoTCP &ScanDeviceInfoTCP::operator=(const ScanDeviceInfoTCP &right) 51 { 52 if (this != &right) { 53 deviceName = right.deviceName; 54 uuid = right.uuid; 55 model = right.model; 56 manufacturer = right.manufacturer; 57 deviceType = right.deviceType; 58 port = right.port; 59 addr = right.addr; 60 button = right.button; 61 feeder = right.feeder; 62 deviceState = right.deviceState; 63 } 64 return *this; 65 } 66 SetDeviceName(const std::string & deviceName_)67void ScanDeviceInfoTCP::SetDeviceName(const std::string& deviceName_) 68 { 69 deviceName = deviceName_; 70 } 71 SetUuid(const std::string & uuid_)72void ScanDeviceInfoTCP::SetUuid(const std::string& uuid_) 73 { 74 uuid = uuid_; 75 } 76 SetModel(const std::string & model_)77void ScanDeviceInfoTCP::SetModel(const std::string& model_) 78 { 79 model = model_; 80 } 81 SetManufacturer(const std::string & manufacturer_)82void ScanDeviceInfoTCP::SetManufacturer(const std::string& manufacturer_) 83 { 84 manufacturer = manufacturer_; 85 } 86 SetDeviceType(const std::string & deviceType_)87void ScanDeviceInfoTCP::SetDeviceType(const std::string& deviceType_) 88 { 89 deviceType = deviceType_; 90 } 91 SetPort(const std::string & port_)92void ScanDeviceInfoTCP::SetPort(const std::string& port_) 93 { 94 port = port_; 95 } 96 SetAddr(const std::string & addr_)97void ScanDeviceInfoTCP::SetAddr(const std::string& addr_) 98 { 99 addr = addr_; 100 } 101 SetButton(const std::string & button_)102void ScanDeviceInfoTCP::SetButton(const std::string& button_) 103 { 104 button = button_; 105 } 106 SetFeeder(const std::string & feeder_)107void ScanDeviceInfoTCP::SetFeeder(const std::string& feeder_) 108 { 109 feeder = feeder_; 110 } 111 SetDeviceState(const uint32_t & deviceState_)112void ScanDeviceInfoTCP::SetDeviceState(const uint32_t& deviceState_) 113 { 114 deviceState = deviceState_; 115 } 116 GetDeviceName() const117const std::string& ScanDeviceInfoTCP::GetDeviceName() const 118 { 119 return deviceName; 120 } 121 GetUuid() const122const std::string& ScanDeviceInfoTCP::GetUuid() const 123 { 124 return uuid; 125 } 126 GetModel() const127const std::string& ScanDeviceInfoTCP::GetModel() const 128 { 129 return model; 130 } 131 GetManufacturer() const132const std::string& ScanDeviceInfoTCP::GetManufacturer() const 133 { 134 return manufacturer; 135 } 136 GetDeviceType() const137const std::string& ScanDeviceInfoTCP::GetDeviceType() const 138 { 139 return deviceType; 140 } 141 GetPort() const142const std::string& ScanDeviceInfoTCP::GetPort() const 143 { 144 return port; 145 } 146 GetAddr() const147const std::string& ScanDeviceInfoTCP::GetAddr() const 148 { 149 return addr; 150 } 151 GetButton() const152const std::string& ScanDeviceInfoTCP::GetButton() const 153 { 154 return button; 155 } 156 GetFeeder() const157const std::string& ScanDeviceInfoTCP::GetFeeder() const 158 { 159 return feeder; 160 } 161 GetDeviceState() const162const uint32_t& ScanDeviceInfoTCP::GetDeviceState() const 163 { 164 return deviceState; 165 } 166 ReadFromParcel(Parcel & parcel)167bool ScanDeviceInfoTCP::ReadFromParcel(Parcel &parcel) 168 { 169 SetDeviceName(parcel.ReadString()); 170 SetUuid(parcel.ReadString()); 171 SetModel(parcel.ReadString()); 172 SetManufacturer(parcel.ReadString()); 173 SetDeviceType(parcel.ReadString()); 174 SetPort(parcel.ReadString()); 175 SetAddr(parcel.ReadString()); 176 SetButton(parcel.ReadString()); 177 SetFeeder(parcel.ReadString()); 178 return true; 179 } 180 Marshalling(Parcel & parcel) const181bool ScanDeviceInfoTCP::Marshalling(Parcel &parcel) const 182 { 183 parcel.WriteString(GetDeviceName()); 184 parcel.WriteString(GetUuid()); 185 parcel.WriteString(GetModel()); 186 parcel.WriteString(GetManufacturer()); 187 parcel.WriteString(GetDeviceType()); 188 parcel.WriteString(GetPort()); 189 parcel.WriteString(GetAddr()); 190 parcel.WriteString(GetButton()); 191 parcel.WriteString(GetFeeder()); 192 return true; 193 } 194 Unmarshalling(Parcel & parcel)195std::shared_ptr<ScanDeviceInfoTCP> ScanDeviceInfoTCP::Unmarshalling(Parcel &parcel) 196 { 197 auto nativeObj = std::make_shared<ScanDeviceInfoTCP>(); 198 if (!nativeObj->ReadFromParcel(parcel)) { 199 SCAN_HILOGE("Failed to unmarshalling scaner info"); 200 return nullptr; 201 } 202 return nativeObj; 203 } 204 205 ScanDeviceInfo()206ScanDeviceInfo::ScanDeviceInfo() 207 { 208 deviceId = ""; 209 manufacturer = ""; 210 model = ""; 211 deviceType = ""; 212 deviceState = 0; 213 discoverMode = ""; 214 serialNumber = ""; 215 deviceName = ""; 216 uniqueId = ""; 217 uuid = ""; 218 } 219 ScanDeviceInfo(const ScanDeviceInfo & right)220ScanDeviceInfo::ScanDeviceInfo(const ScanDeviceInfo &right) 221 { 222 deviceId = right.deviceId; 223 manufacturer = right.manufacturer; 224 model = right.model; 225 deviceType = right.deviceType; 226 deviceState = right.deviceState; 227 discoverMode = right.discoverMode; 228 serialNumber = right.serialNumber; 229 deviceName = right.deviceName; 230 uniqueId = right.uniqueId; 231 uuid = right.uuid; 232 } 233 operator =(const ScanDeviceInfo & right)234ScanDeviceInfo &ScanDeviceInfo::operator=(const ScanDeviceInfo &right) 235 { 236 if (this != &right) { 237 deviceId = right.deviceId; 238 manufacturer = right.manufacturer; 239 model = right.model; 240 deviceType = right.deviceType; 241 deviceState = right.deviceState; 242 discoverMode = right.discoverMode; 243 serialNumber = right.serialNumber; 244 deviceName = right.deviceName; 245 uniqueId = right.uniqueId; 246 uuid = right.uuid; 247 } 248 return *this; 249 } 250 251 SetDeviceId(const std::string & newScannerId)252void ScanDeviceInfo::SetDeviceId(const std::string& newScannerId) 253 { 254 deviceId = newScannerId; 255 } 256 GetDeviceId() const257const std::string& ScanDeviceInfo::GetDeviceId() const 258 { 259 return deviceId; 260 } 261 SetManufacturer(const std::string & newManufacturer)262void ScanDeviceInfo::SetManufacturer(const std::string& newManufacturer) 263 { 264 manufacturer = newManufacturer; 265 } 266 GetManufacturer() const267const std::string& ScanDeviceInfo::GetManufacturer() const 268 { 269 return manufacturer; 270 } 271 SetModel(const std::string & newModel)272void ScanDeviceInfo::SetModel(const std::string& newModel) 273 { 274 model = newModel; 275 } 276 GetModel() const277const std::string& ScanDeviceInfo::GetModel() const 278 { 279 return model; 280 } 281 SetDeviceType(const std::string & newDeviceType)282void ScanDeviceInfo::SetDeviceType(const std::string& newDeviceType) 283 { 284 deviceType = newDeviceType; 285 } 286 GetDeviceType() const287const std::string& ScanDeviceInfo::GetDeviceType() const 288 { 289 return deviceType; 290 } 291 SetDeviceState(const uint32_t & newDeviceState)292void ScanDeviceInfo::SetDeviceState(const uint32_t& newDeviceState) 293 { 294 deviceState = newDeviceState; 295 } 296 GetDeviceState() const297const uint32_t& ScanDeviceInfo::GetDeviceState() const 298 { 299 return deviceState; 300 } 301 SetDiscoverMode(const std::string & newDiscoverMode)302void ScanDeviceInfo::SetDiscoverMode(const std::string& newDiscoverMode) 303 { 304 discoverMode = newDiscoverMode; 305 } 306 GetDiscoverMode() const307const std::string& ScanDeviceInfo::GetDiscoverMode() const 308 { 309 return discoverMode; 310 } 311 SetSerialNumber(const std::string & newSerialNumber)312void ScanDeviceInfo::SetSerialNumber(const std::string& newSerialNumber) 313 { 314 serialNumber = newSerialNumber; 315 } 316 GetSerialNumber() const317const std::string& ScanDeviceInfo::GetSerialNumber() const 318 { 319 return serialNumber; 320 } 321 SetDeviceName(const std::string & newDeviceName)322void ScanDeviceInfo::SetDeviceName(const std::string& newDeviceName) 323 { 324 deviceName = newDeviceName; 325 } 326 GetDeviceName() const327const std::string& ScanDeviceInfo::GetDeviceName() const 328 { 329 return deviceName; 330 } 331 SetUniqueId(const std::string & uniqueId)332void ScanDeviceInfo::SetUniqueId(const std::string& uniqueId) 333 { 334 this->uniqueId = uniqueId; 335 } 336 GetUniqueId() const337const std::string& ScanDeviceInfo::GetUniqueId() const 338 { 339 return uniqueId; 340 } 341 SetUuid(const std::string & uuid)342void ScanDeviceInfo::SetUuid(const std::string& uuid) 343 { 344 this->uuid = uuid; 345 } 346 GetUuid() const347const std::string& ScanDeviceInfo::GetUuid() const 348 { 349 return uuid; 350 } 351 ReadFromParcel(Parcel & parcel)352bool ScanDeviceInfo::ReadFromParcel(Parcel &parcel) 353 { 354 SetDeviceId(parcel.ReadString()); 355 SetManufacturer(parcel.ReadString()); 356 SetModel(parcel.ReadString()); 357 SetDeviceType(parcel.ReadString()); 358 SetDiscoverMode(parcel.ReadString()); 359 SetSerialNumber(parcel.ReadString()); 360 SetDeviceName(parcel.ReadString()); 361 SetUniqueId(parcel.ReadString()); 362 return true; 363 } 364 Marshalling(Parcel & parcel) const365bool ScanDeviceInfo::Marshalling(Parcel &parcel) const 366 { 367 parcel.WriteString(deviceId); 368 parcel.WriteString(manufacturer); 369 parcel.WriteString(model); 370 parcel.WriteString(deviceType); 371 parcel.WriteString(discoverMode); 372 parcel.WriteString(serialNumber); 373 parcel.WriteString(deviceName); 374 parcel.WriteString(uniqueId); 375 return true; 376 } 377 Unmarshalling(Parcel & parcel)378std::shared_ptr<ScanDeviceInfo> ScanDeviceInfo::Unmarshalling(Parcel &parcel) 379 { 380 auto nativeObj = std::make_shared<ScanDeviceInfo>(); 381 if (!nativeObj->ReadFromParcel(parcel)) { 382 SCAN_HILOGE("Failed to unmarshalling scaner info"); 383 return nullptr; 384 } 385 return nativeObj; 386 } 387 388 // ScanDeviceInfoSync 389 ScanDeviceInfoSync()390ScanDeviceInfoSync::ScanDeviceInfoSync() 391 { 392 deviceId = ""; 393 discoverMode = ""; 394 serialNumber = ""; 395 syncMode = ""; 396 deviceState = 0; 397 oldDeviceId = ""; 398 } 399 ScanDeviceInfoSync(const ScanDeviceInfoSync & right)400ScanDeviceInfoSync::ScanDeviceInfoSync(const ScanDeviceInfoSync &right) 401 { 402 deviceId = right.deviceId; 403 discoverMode = right.discoverMode; 404 serialNumber = right.serialNumber; 405 syncMode = right.syncMode; 406 deviceState = right.deviceState; 407 oldDeviceId = right.oldDeviceId; 408 } 409 operator =(const ScanDeviceInfoSync & right)410ScanDeviceInfoSync &ScanDeviceInfoSync::operator=(const ScanDeviceInfoSync &right) 411 { 412 if (this != &right) { 413 deviceId = right.deviceId; 414 discoverMode = right.discoverMode; 415 serialNumber = right.serialNumber; 416 syncMode = right.syncMode; 417 deviceState = right.deviceState; 418 oldDeviceId = right.oldDeviceId; 419 } 420 return *this; 421 } 422 423 SetDeviceId(const std::string & newScannerId)424void ScanDeviceInfoSync::SetDeviceId(const std::string& newScannerId) 425 { 426 deviceId = newScannerId; 427 } 428 GetDeviceId() const429const std::string& ScanDeviceInfoSync::GetDeviceId() const 430 { 431 return deviceId; 432 } 433 SetDiscoverMode(const std::string & newDiscoverMode)434void ScanDeviceInfoSync::SetDiscoverMode(const std::string& newDiscoverMode) 435 { 436 discoverMode = newDiscoverMode; 437 } 438 GetDiscoverMode() const439const std::string& ScanDeviceInfoSync::GetDiscoverMode() const 440 { 441 return discoverMode; 442 } 443 SetSerialNumber(const std::string & newSerialNumber)444void ScanDeviceInfoSync::SetSerialNumber(const std::string& newSerialNumber) 445 { 446 serialNumber = newSerialNumber; 447 } 448 GetSerialNumber() const449const std::string& ScanDeviceInfoSync::GetSerialNumber() const 450 { 451 return serialNumber; 452 } 453 SetSyncMode(const std::string & newSyncMode)454void ScanDeviceInfoSync::SetSyncMode(const std::string& newSyncMode) 455 { 456 syncMode = newSyncMode; 457 } 458 GetSyncMode() const459const std::string& ScanDeviceInfoSync::GetSyncMode() const 460 { 461 return syncMode; 462 } 463 SetDeviceState(const uint32_t & newDeviceState)464void ScanDeviceInfoSync::SetDeviceState(const uint32_t& newDeviceState) 465 { 466 deviceState = newDeviceState; 467 } 468 GetDeviceState() const469const uint32_t& ScanDeviceInfoSync::GetDeviceState() const 470 { 471 return deviceState; 472 } 473 SetOldDeviceId(const std::string & oldDeviceId)474void ScanDeviceInfoSync::SetOldDeviceId(const std::string& oldDeviceId) 475 { 476 this->oldDeviceId = oldDeviceId; 477 } 478 GetOldDeviceId() const479const std::string& ScanDeviceInfoSync::GetOldDeviceId() const 480 { 481 return oldDeviceId; 482 } 483 SetUniqueId(const std::string & uniqueId)484void ScanDeviceInfoSync::SetUniqueId(const std::string& uniqueId) 485 { 486 this->uniqueId = uniqueId; 487 } 488 GetUniqueId() const489const std::string& ScanDeviceInfoSync::GetUniqueId() const 490 { 491 return uniqueId; 492 } 493 ReadFromParcel(Parcel & parcel)494void ScanDeviceInfoSync::ReadFromParcel(Parcel &parcel) 495 { 496 SetDeviceId(parcel.ReadString()); 497 SetDiscoverMode(parcel.ReadString()); 498 SetSerialNumber(parcel.ReadString()); 499 SetSyncMode(parcel.ReadString()); 500 SetOldDeviceId(parcel.ReadString()); 501 } 502 Marshalling(Parcel & parcel) const503bool ScanDeviceInfoSync::Marshalling(Parcel &parcel) const 504 { 505 parcel.WriteString(deviceId); 506 parcel.WriteString(discoverMode); 507 parcel.WriteString(serialNumber); 508 parcel.WriteString(syncMode); 509 parcel.WriteString(oldDeviceId); 510 return true; 511 } 512 Unmarshalling(Parcel & parcel)513std::shared_ptr<ScanDeviceInfoSync> ScanDeviceInfoSync::Unmarshalling(Parcel &parcel) 514 { 515 auto nativeObj = std::make_shared<ScanDeviceInfoSync>(); 516 nativeObj->ReadFromParcel(parcel); 517 return nativeObj; 518 } 519 520 } // namespace OHOS::Scan 521