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 #ifndef SCAN_DEVICE_INFO_H 17 #define SCAN_DEVICE_INFO_H 18 #define TDD_ENABLE 1 19 20 #include <map> 21 #include "napi/native_api.h" 22 #include "parcel.h" 23 24 #include "napi_scan_utils.h" 25 26 27 namespace OHOS::Scan { 28 class ScanDeviceInfoTCP final : public Parcelable { 29 public: 30 explicit ScanDeviceInfoTCP(); 31 32 ScanDeviceInfoTCP(const ScanDeviceInfoTCP &right); 33 34 ScanDeviceInfoTCP &operator=(const ScanDeviceInfoTCP &ScanDeviceInfoTCP); 35 36 ~ScanDeviceInfoTCP() = default; 37 38 void SetDeviceName(const std::string &deviceName_); 39 void SetUuid(const std::string &uuid_); 40 void SetModel(const std::string &model_); 41 void SetManufacturer(const std::string &manufacturer_); 42 void SetDeviceType(const std::string &deviceType_); 43 void SetPort(const std::string &port_); 44 void SetAddr(const std::string &addr_); 45 void SetButton(const std::string &button_); 46 void SetFeeder(const std::string &feeder_); 47 void SetDeviceState(const uint32_t &deviceState_); 48 void SetInfoType(const std::string &infoType_); 49 50 [[nodiscard]] const std::string &GetDeviceName() const; 51 [[nodiscard]] const std::string &GetUuid() const; 52 [[nodiscard]] const std::string &GetModel() const; 53 [[nodiscard]] const std::string &GetManufacturer() const; 54 [[nodiscard]] const std::string &GetDeviceType() const; 55 [[nodiscard]] const std::string &GetPort() const; 56 [[nodiscard]] const std::string &GetAddr() const; 57 [[nodiscard]] const std::string &GetButton() const; 58 [[nodiscard]] const std::string &GetFeeder() const; 59 [[nodiscard]] const uint32_t &GetDeviceState() const; 60 [[nodiscard]] const std::string &GetInfoType() const; 61 62 virtual bool Marshalling(Parcel &parcel) const override; 63 64 static std::shared_ptr<ScanDeviceInfoTCP> Unmarshalling(Parcel &parcel); 65 66 #ifndef TDD_ENABLE 67 private: 68 #endif 69 bool ReadFromParcel(Parcel &parcel); 70 71 static bool ValidateProperty(napi_env env, napi_value object); 72 73 #ifndef TDD_ENABLE 74 private: 75 #endif 76 std::string deviceName; 77 std::string uuid; 78 std::string model; 79 std::string manufacturer; 80 std::string deviceType; 81 std::string port; 82 std::string addr; 83 std::string button; 84 std::string feeder; 85 uint32_t deviceState; 86 }; 87 88 class ScanDeviceInfo final : public Parcelable { 89 public: 90 explicit ScanDeviceInfo(); 91 92 ScanDeviceInfo(const ScanDeviceInfo &right); 93 94 ScanDeviceInfo &operator=(const ScanDeviceInfo &ScanDeviceInfo); 95 96 ~ScanDeviceInfo() = default; 97 98 void SetDeviceId(const std::string &newDeviceId); 99 void SetManufacturer(const std::string &newManufacturer); 100 void SetModel(const std::string &newModel); 101 void SetDeviceType(const std::string &newDeviceType); 102 void SetDeviceState(const uint32_t &newDeviceState); 103 void Dump(); 104 void SetDiscoverMode(const std::string &newDiscoverMode); 105 void SetSerialNumber(const std::string &newSerialNumber); 106 void SetDeviceName(const std::string &newDeviceName); 107 void SetUniqueId(const std::string &uniqueId); 108 void SetUuid(const std::string &uuid); 109 110 [[nodiscard]] const std::string &GetDeviceId() const; 111 [[nodiscard]] const std::string &GetManufacturer() const; 112 [[nodiscard]] const std::string &GetModel() const; 113 [[nodiscard]] const std::string &GetDeviceType() const; 114 [[nodiscard]] const uint32_t &GetDeviceState() const; 115 [[nodiscard]] const std::string &GetDiscoverMode() const; 116 [[nodiscard]] const std::string &GetSerialNumber() const; 117 [[nodiscard]] const std::string &GetDeviceName() const; 118 [[nodiscard]] const std::string &GetUniqueId() const; 119 [[nodiscard]] const std::string &GetUuid() const; 120 121 virtual bool Marshalling(Parcel &parcel) const override; 122 123 static std::shared_ptr<ScanDeviceInfo> Unmarshalling(Parcel &parcel); 124 125 #ifndef TDD_ENABLE 126 private: 127 #endif 128 bool ReadFromParcel(Parcel &parcel); 129 130 #ifndef TDD_ENABLE 131 private: 132 #endif 133 std::string deviceId; 134 std::string manufacturer; 135 std::string model; 136 std::string deviceType; 137 uint32_t deviceState; 138 std::string discoverMode; 139 std::string serialNumber; 140 std::string deviceName; 141 std::string uniqueId; 142 std::string uuid; 143 }; 144 145 class ScanDeviceInfoSync final : public Parcelable { 146 public: 147 explicit ScanDeviceInfoSync(); 148 149 ScanDeviceInfoSync(const ScanDeviceInfoSync &right); 150 151 ScanDeviceInfoSync &operator=(const ScanDeviceInfoSync &ScanDeviceInfoSync); 152 153 ~ScanDeviceInfoSync() = default; 154 155 void SetDeviceId(const std::string &newDeviceId); 156 void SetDiscoverMode(const std::string &newDiscoverMode); 157 void SetSerialNumber(const std::string &newSerialNumber); 158 void SetSyncMode(const std::string &newSyncMode); 159 void SetDeviceState(const uint32_t &newDeviceState); 160 void SetOldDeviceId(const std::string &oldDeviceId); 161 void SetUniqueId(const std::string &uniqueId); 162 163 [[nodiscard]] const std::string &GetDeviceId() const; 164 [[nodiscard]] const std::string &GetDiscoverMode() const; 165 [[nodiscard]] const std::string &GetSerialNumber() const; 166 [[nodiscard]] const std::string &GetSyncMode() const; 167 [[nodiscard]] const uint32_t &GetDeviceState() const; 168 [[nodiscard]] const std::string &GetOldDeviceId() const; 169 [[nodiscard]] const std::string &GetUniqueId() const; 170 171 virtual bool Marshalling(Parcel &parcel) const override; 172 173 static std::shared_ptr<ScanDeviceInfoSync> Unmarshalling(Parcel &parcel); 174 175 #ifndef TDD_ENABLE 176 private: 177 #endif 178 void ReadFromParcel(Parcel &parcel); 179 180 #ifndef TDD_ENABLE 181 private: 182 #endif 183 std::string deviceId; 184 std::string discoverMode; 185 std::string serialNumber; 186 std::string syncMode; 187 uint32_t deviceState; 188 std::string oldDeviceId; 189 std::string uniqueId; 190 }; 191 192 } // namespace OHOS::Scan 193 #endif // SCAN_DEVICE_INFO_H 194