• 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 #ifndef PRINTER_CAPABILITY_H
16 #define PRINTER_CAPABILITY_H
17 
18 #include "iremote_broker.h"
19 #include "iremote_proxy.h"
20 #include "parcel.h"
21 #include "print_margin.h"
22 #include "print_page_size.h"
23 #include "print_resolution.h"
24 #include <json/json.h>
25 
26 namespace OHOS::Print {
27 class PrinterCapability final : public Parcelable {
28 public:
29     explicit PrinterCapability();
30 
31     PrinterCapability(const PrinterCapability &right);
32 
33     PrinterCapability &operator=(const PrinterCapability &right);
34 
35     virtual ~PrinterCapability();
36 
37     void Reset();
38 
39     [[nodiscard]] bool HasMargin() const;
40 
41     void GetMinMargin(PrintMargin &margin) const;
42 
43     void GetPageSize(std::vector<PrintPageSize> &pageSizeList) const;
44 
45     [[nodiscard]] bool HasResolution() const;
46 
47     void GetResolution(std::vector<PrintResolution> &resolutionList) const;
48 
49     [[nodiscard]] uint32_t GetColorMode() const;
50 
51     [[nodiscard]] uint32_t GetDuplexMode() const;
52 
53     void SetOption(const std::string &option);
54 
55     [[nodiscard]] bool HasOption() const;
56 
57     [[nodiscard]] std::string GetOption() const;
58 
59     [[nodiscard]] bool HasSupportedPageSize() const;
60 
61     [[nodiscard]] bool HasSupportedColorMode() const;
62 
63     [[nodiscard]] bool HasSupportedDuplexMode() const;
64 
65     [[nodiscard]] bool HasSupportedMediaType() const;
66 
67     [[nodiscard]] bool HasSupportedQuality() const;
68 
69     [[nodiscard]] bool HasSupportedOrientation() const;
70 
71     void GetSupportedPageSize(std::vector<PrintPageSize>& supportedPageSize) const;
72 
73     void GetSupportedColorMode(std::vector<uint32_t>& supportedColorModeList) const;
74 
75     void GetSupportedDuplexMode(std::vector<uint32_t>& supportedDuplexModeList) const;
76 
77     void GetSupportedMediaType(std::vector<std::string>& supportedMediaTypeList) const;
78 
79     void GetSupportedQuality(std::vector<uint32_t>& supportedQualityList) const;
80 
81     void GetSupportedOrientation(std::vector<uint32_t>& supportedOrientationList) const;
82 
83     void SetMinMargin(const PrintMargin& minMargin);
84 
85     void SetResolution(const std::vector<PrintResolution>& resolutionList);
86 
87     void SetColorMode(uint32_t colorMode);
88 
89     void SetDuplexMode(uint32_t duplexMode);
90 
91     void SetSupportedColorMode(const std::vector<uint32_t>& supportedColorModeList);
92 
93     void SetSupportedPageSize(const std::vector<PrintPageSize>& supportedPageSizeList);
94 
95     void SetSupportedDuplexMode(const std::vector<uint32_t>& supportedDuplexModeList);
96 
97     void SetSupportedMediaType(const std::vector<std::string>& supportedMediaTypeList);
98 
99     void SetSupportedQuality(const std::vector<uint32_t>& supportedQualityList);
100 
101     void SetSupportedOrientation(const std::vector<uint32_t>& supportedOrientationList);
102 
103     virtual bool Marshalling(Parcel& parcel) const override;
104 
105     static std::shared_ptr<PrinterCapability> Unmarshalling(Parcel& parcel);
106 
107     void Dump() const;
108 
109     const char* GetPrinterAttrValue(const char* name);
110 
111     void SetPrinterAttrNameAndValue(const char* name, const char* value);
112 
113     Json::Value GetPrinterAttrGroupJson();
114 
115     void ClearCurPrinterAttrGroup();
116 
117 private:
118     bool ReadFromParcel(Parcel &parcel);
119     std::vector<PrintPageSize> RemoveDuplicatePageSize(const std::vector<PrintPageSize> &supportedPageSizeList);
120 
121 private:
122     uint32_t colorMode_; // Property in API 10, deprecated in API 12
123     uint32_t duplexMode_; // Property in API 10, deprecated in API 12
124 
125     std::vector<PrintPageSize> pageSizeList_;
126 
127     bool hasResolution_;
128     std::vector<PrintResolution> resolutionList_;
129 
130     std::vector<PrintPageSize> supportedPageSizeList_;
131 
132     bool hasSupportedColorMode_;
133     std::vector<uint32_t> supportedColorModeList_;
134 
135     bool hasSupportedDuplexMode_;
136     std::vector<uint32_t> supportedDuplexModeList_;
137 
138     bool hasSupportedMediaType_;
139     std::vector<std::string> supportedMediaTypeList_;
140 
141     bool hasSupportedQuality_;
142     std::vector<uint32_t> supportedQualityList_;
143 
144     bool hasSupportedOrientation_;
145     std::vector<uint32_t> supportedOrientationList_;
146 
147     bool hasMargin_;
148     PrintMargin minMargin_;
149 
150     bool hasOption_;
151     std::string option_;
152 
153     std::map<std::string, std::string> printerAttr_group;
154 };
155 }  // namespace OHOS::Print
156 #endif  // PRINTER_CAPABILITY_H
157