• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "printer_preferences.h"
22 
23 namespace OHOS::Print {
24 class PrinterInfo final : public Parcelable {
25 public:
26     explicit PrinterInfo();
27 
28     PrinterInfo(const PrinterInfo &right);
29 
30     PrinterInfo &operator=(const PrinterInfo &right);
31 
32     virtual ~PrinterInfo();
33 
34     void SetPrinterId(const std::string &printerId);
35 
36     void SetPrinterName(std::string printerName);
37 
38     void SetPrinterIcon(uint32_t printIcon);
39 
40     void SetPrinterState(uint32_t printerState);
41 
42     void SetDescription(std::string description);
43 
44     void SetCapability(const PrinterCapability &capability);
45 
46     void SetUri(const std::string &uri);
47 
48     void SetPrinterMake(const std::string &printerMake);
49 
50     void SetPrinterUuid(const std::string &printerUuid);
51 
52     void SetOption(const std::string &option);
53 
54     void SetIsDefaultPrinter(bool isDefaultPrinter);
55 
56     void SetIsLastUsedPrinter(bool isLastUsedPrinter);
57 
58     void SetPrinterStatus(uint32_t printerStatus);
59 
60     void SetPreferences(const PrinterPreferences &preferences);
61 
62     void SetAlias(const std::string &alias);
63 
64     void SetPpdHashCode(const std::string &ppdHashCode);
65 
66     [[nodiscard]] const std::string &GetPrinterId() const;
67 
68     [[nodiscard]] const std::string &GetPrinterName() const;
69 
70     [[nodiscard]] bool HasPrinterIcon() const;
71 
72     [[nodiscard]] uint32_t GetPrinterIcon() const;
73 
74     [[nodiscard]] uint32_t GetPrinterState() const;
75 
76     [[nodiscard]] bool HasDescription() const;
77 
78     [[nodiscard]] const std::string &GetDescription() const;
79 
80     [[nodiscard]] bool HasCapability() const;
81 
82     void GetCapability(PrinterCapability &cap) const;
83 
84     [[nodiscard]] bool HasUri() const;
85 
86     [[nodiscard]] std::string GetUri() const;
87 
88     [[nodiscard]] bool HasPrinterMake() const;
89 
90     [[nodiscard]] std::string GetPrinterMake() const;
91 
92     [[nodiscard]] bool HasPrinterUuid() const;
93 
94     [[nodiscard]] std::string GetPrinterUuid() const;
95 
96     [[nodiscard]] bool HasOption() const;
97 
98     [[nodiscard]] std::string GetOption() const;
99 
100     [[nodiscard]] bool HasIsDefaultPrinter() const;
101 
102     [[nodiscard]] bool GetIsDefaultPrinter() const;
103 
104     [[nodiscard]] bool HasIsLastUsedPrinter() const;
105 
106     [[nodiscard]] bool GetIsLastUsedPrinter() const;
107 
108     [[nodiscard]] bool HasPrinterStatus() const;
109 
110     [[nodiscard]] uint32_t GetPrinterStatus() const;
111 
112     [[nodiscard]] bool HasPreferences() const;
113 
114     void GetPreferences(PrinterPreferences &preferences) const;
115 
116     [[nodiscard]] bool HasAlias() const;
117 
118     [[nodiscard]] std::string GetAlias() const;
119 
120     [[nodiscard]] std::string GetPpdHashCode() const;
121 
122     virtual bool Marshalling(Parcel &parcel) const override;
123 
124     static std::shared_ptr<PrinterInfo> Unmarshalling(Parcel &parcel);
125 
126     void Dump() const;
127 
128 private:
129     bool ReadFromParcel(Parcel &parcel);
130 
131     bool ReadInnerPropertyFromParcel(PrinterInfo& right, Parcel& parcel);
132 
133     void MarshallingInnerProperty(Parcel &parcel) const;
134 
135     bool ValidateAll();
136 
137 private:
138     std::string printerId_;
139 
140     std::string printerName_;
141 
142     uint32_t printerState_;
143 
144     bool hasPrinterIcon_;
145 
146     uint32_t printerIcon_;
147 
148     bool hasDescription_;
149 
150     std::string description_;
151 
152     bool hasPrinterStatus_;
153 
154     uint32_t printerStatus_;
155 
156     bool hasCapability_;
157 
158     PrinterCapability capability_;
159 
160     bool hasUri_;
161 
162     std::string uri_;
163 
164     bool hasPrinterMake_;
165 
166     std::string printerMake_;
167 
168     bool hasPreferences_;
169 
170     PrinterPreferences preferences_;
171 
172     bool hasAlias_;
173 
174     std::string alias_;
175 
176     bool hasOption_;
177 
178     std::string option_;
179 
180     bool hasPrinterUuid_;
181 
182     std::string printerUuid_;
183 
184     bool hasIsDefaultPrinter_; // Deprecated, to be removed in a future version.
185 
186     bool isDefaultPrinter_; // Deprecated, to be removed in a future version.
187 
188     bool hasIsLastUsedPrinter_; // Deprecated, to be removed in a future version.
189 
190     bool isLastUsedPrinter_; // Deprecated, to be removed in a future version.
191 
192     std::string ppdHashCode_;
193 };
194 }  // namespace OHOS::Print
195 #endif  // PRINTER_INFO_H
196