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 108 [[nodiscard]] const std::string &GetDeviceId() const; 109 [[nodiscard]] const std::string &GetManufacturer() const; 110 [[nodiscard]] const std::string &GetModel() const; 111 [[nodiscard]] const std::string &GetDeviceType() const; 112 [[nodiscard]] const uint32_t &GetDeviceState() const; 113 [[nodiscard]] const std::string &GetDiscoverMode() const; 114 [[nodiscard]] const std::string &GetSerialNumber() const; 115 [[nodiscard]] const std::string &GetDeviceName() const; 116 117 virtual bool Marshalling(Parcel &parcel) const override; 118 119 static std::shared_ptr<ScanDeviceInfo> Unmarshalling(Parcel &parcel); 120 121 #ifndef TDD_ENABLE 122 private: 123 #endif 124 bool ReadFromParcel(Parcel &parcel); 125 126 #ifndef TDD_ENABLE 127 private: 128 #endif 129 std::string deviceId; 130 std::string manufacturer; 131 std::string model; 132 std::string deviceType; 133 uint32_t deviceState; 134 std::string discoverMode; 135 std::string serialNumber; 136 std::string deviceName; 137 }; 138 139 class ScanDeviceInfoSync final : public Parcelable { 140 public: 141 explicit ScanDeviceInfoSync(); 142 143 ScanDeviceInfoSync(const ScanDeviceInfoSync &right); 144 145 ScanDeviceInfoSync &operator=(const ScanDeviceInfoSync &ScanDeviceInfoSync); 146 147 ~ScanDeviceInfoSync() = default; 148 149 void SetDeviceId(const std::string &newDeviceId); 150 void SetDiscoverMode(const std::string &newDiscoverMode); 151 void SetSerialNumber(const std::string &newSerialNumber); 152 void SetSyncMode(const std::string &newSyncMode); 153 void SetDeviceState(const uint32_t &newDeviceState); 154 155 [[nodiscard]] const std::string &GetDeviceId() const; 156 [[nodiscard]] const std::string &GetDiscoverMode() const; 157 [[nodiscard]] const std::string &GetSerialNumber() const; 158 [[nodiscard]] const std::string &GetSyncMode() const; 159 [[nodiscard]] const uint32_t &GetDeviceState() const; 160 161 virtual bool Marshalling(Parcel &parcel) const override; 162 163 static std::shared_ptr<ScanDeviceInfoSync> Unmarshalling(Parcel &parcel); 164 165 #ifndef TDD_ENABLE 166 private: 167 #endif 168 void ReadFromParcel(Parcel &parcel); 169 170 #ifndef TDD_ENABLE 171 private: 172 #endif 173 std::string deviceId; 174 std::string discoverMode; 175 std::string serialNumber; 176 std::string syncMode; 177 uint32_t deviceState; 178 }; 179 180 } // namespace OHOS::Scan 181 #endif // SCAN_DEVICE_INFO_H 182