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 PRINTER_INFO_H
17 #define PRINTER_INFO_H
18 
19 #include "parcel.h"
20 #include "printer_capability.h"
21 
22 namespace OHOS::Print {
23 class PrinterInfo final : public Parcelable {
24 public:
25     explicit PrinterInfo();
26 
27     PrinterInfo(const PrinterInfo &right);
28 
29     PrinterInfo &operator=(const PrinterInfo &right);
30 
31     virtual ~PrinterInfo();
32 
33     void SetPrinterId(const std::string &printerId);
34 
35     void SetPrinterName(std::string printerName);
36 
37     void SetPrinterIcon(uint32_t printIcon);
38 
39     void SetPrinterState(uint32_t printerState);
40 
41     void SetDescription(std::string description);
42 
43     void SetCapability(const PrinterCapability &capability);
44 
45     void SetUri(const std::string &uri);
46 
47     void SetPrinterMake(const std::string &printerMake);
48 
49     void SetOption(const std::string &option);
50 
51     void SetIsDefaultPrinter(bool isDefaultPrinter);
52 
53     void SetIsLastUsedPrinter(bool isLastUsedPrinter);
54 
55     void SetPrinterStatus(uint32_t printerStatus);
56 
57     [[nodiscard]] const std::string &GetPrinterId() const;
58 
59     [[nodiscard]] const std::string &GetPrinterName() const;
60 
61     [[nodiscard]] bool HasPrinterIcon() const;
62 
63     [[nodiscard]] uint32_t GetPrinterIcon() const;
64 
65     [[nodiscard]] uint32_t GetPrinterState() const;
66 
67     [[nodiscard]] bool HasDescription() const;
68 
69     [[nodiscard]] const std::string &GetDescription() const;
70 
71     [[nodiscard]] bool HasCapability() const;
72 
73     void GetCapability(PrinterCapability &cap) const;
74 
75     [[nodiscard]] bool HasUri() const;
76 
77     [[nodiscard]] std::string GetUri() const;
78 
79     [[nodiscard]] bool HasPrinterMake() const;
80 
81     [[nodiscard]] std::string GetPrinterMake() const;
82 
83     [[nodiscard]] bool HasOption() const;
84 
85     [[nodiscard]] std::string GetOption() const;
86 
87     [[nodiscard]] bool HasIsDefaultPrinter() const;
88 
89     [[nodiscard]] bool GetIsDefaultPrinter() const;
90 
91     [[nodiscard]] bool HasIsLastUsedPrinter() const;
92 
93     [[nodiscard]] bool GetIsLastUsedPrinter() const;
94 
95     [[nodiscard]] bool HasPrinterStatus() const;
96 
97     [[nodiscard]] uint32_t GetPrinterStatus() const;
98 
99     virtual bool Marshalling(Parcel &parcel) const override;
100 
101     static std::shared_ptr<PrinterInfo> Unmarshalling(Parcel &parcel);
102 
103     void Dump() const;
104 
105 private:
106     bool ReadFromParcel(Parcel &parcel);
107 
108     void ReadInnerPropertyFromParcel(PrinterInfo& right, Parcel& parcel);
109 
110     bool ValidateAll();
111 
112 private:
113     std::string printerId_;
114 
115     std::string printerName_;
116 
117     uint32_t printerState_;
118 
119     bool hasPrinterIcon_;
120 
121     uint32_t printerIcon_;
122 
123     bool hasDescription_;
124 
125     std::string description_;
126 
127     bool hasPrinterStatus_;
128 
129     uint32_t printerStatus_;
130 
131     bool hasCapability_;
132 
133     PrinterCapability capability_;
134 
135     bool hasUri_;
136 
137     std::string uri_;
138 
139     bool hasPrinterMake_;
140 
141     std::string printerMake_;
142 
143     bool hasOption_;
144 
145     std::string option_;
146 
147     bool hasIsDefaultPrinter_; // Deprecated, to be removed in a future version.
148 
149     bool isDefaultPrinter_; // Deprecated, to be removed in a future version.
150 
151     bool hasIsLastUsedPrinter_; // Deprecated, to be removed in a future version.
152 
153     bool isLastUsedPrinter_; // Deprecated, to be removed in a future version.
154 };
155 }  // namespace OHOS::Print
156 #endif  // PRINTER_INFO_H
157