• 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 <nlohmann/json.hpp>
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     void SetMinMargin(const PrintMargin &minMargin);
60 
61     void SetPageSize(const std::vector<PrintPageSize> &pageSizeList);
62 
63     void SetResolution(const std::vector<PrintResolution> &resolutionList);
64 
65     void SetColorMode(uint32_t colorMode);
66 
67     void SetDuplexMode(uint32_t duplexMode);
68 
69     virtual bool Marshalling(Parcel &parcel) const override;
70 
71     static std::shared_ptr<PrinterCapability> Unmarshalling(Parcel &parcel);
72 
73     void Dump();
74 
75     const char* GetPrinterAttrValue(const char* name);
76 
77     void SetPrinterAttrNameAndValue(const char* name, const char* value);
78 
79     nlohmann::json GetPrinterAttrGroupJson();
80 
81     void ClearCurPrinterAttrGroup();
82 
83 private:
84     bool ReadFromParcel(Parcel &parcel);
85 
86 private:
87     uint32_t colorMode_;
88     uint32_t duplexMode_;
89     std::vector<PrintPageSize> pageSizeList_;
90 
91     bool hasResolution_;
92     std::vector<PrintResolution> resolutionList_;
93 
94     bool hasMargin_;
95     PrintMargin minMargin_;
96 
97     bool hasOption_;
98     std::string option_;
99 
100     std::map<std::string, std::string> printerAttr_group;
101 };
102 }  // namespace OHOS::Print
103 #endif  // PRINTER_CAPABILITY_H
104