• 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 PRINT_JOB_H
17 #define PRINT_JOB_H
18 #include <map>
19 #include <string>
20 #include <vector>
21 
22 #include "iremote_broker.h"
23 #include "iremote_proxy.h"
24 #include "parcel.h"
25 #include "print_margin.h"
26 #include "print_page_size.h"
27 #include "print_preview_attribute.h"
28 #include "print_range.h"
29 #include "print_attributes.h"
30 
31 namespace OHOS::Print {
32 class PrintJob final : public Parcelable {
33 public:
34     explicit PrintJob();
35 
36     PrintJob(const PrintJob &right);
37 
38     PrintJob &operator=(const PrintJob &right);
39 
40     virtual ~PrintJob();
41 
42     void SetFdList(const std::vector<uint32_t> &files);
43 
44     void SetJobId(const std::string &jobId);
45 
46     void SetPrinterId(const std::string &printerid);
47 
48     void SetJobState(uint32_t jobState);
49 
50     void SetSubState(uint32_t jobSubState);
51 
52     void SetCopyNumber(uint32_t copyNumber);
53 
54     void SetPageRange(const PrintRange &pageRange);
55 
56     void SetIsSequential(bool isSequential);
57 
58     void SetPageSize(const PrintPageSize &pageSize);
59 
60     void SetIsLandscape(bool isLandscape);
61 
62     void SetColorMode(uint32_t colorMode);
63 
64     void SetDuplexMode(uint32_t duplexmode);
65 
66     void SetMargin(const PrintMargin &margin);
67 
68     void SetOption(const std::string &option);
69 
70     void SetPreview(const PrintPreviewAttribute &preview);
71 
72     void UpdateParams(const PrintJob& jobInfo);
73 
74     void GetFdList(std::vector<uint32_t> &fdList) const;
75 
76     [[nodiscard]] const std::string &GetJobId() const;
77 
78     [[nodiscard]] const std::string &GetPrinterId() const;
79 
80     [[nodiscard]] uint32_t GetJobState() const;
81 
82     [[nodiscard]] uint32_t GetSubState() const;
83 
84     [[nodiscard]] uint32_t GetCopyNumber() const;
85 
86     void GetPageRange(PrintRange &range) const;
87 
88     [[nodiscard]] bool GetIsSequential() const;
89 
90     void GetPageSize(PrintPageSize &printPageSize) const;
91 
92     [[nodiscard]] bool GetIsLandscape() const;
93 
94     [[nodiscard]] uint32_t GetColorMode() const;
95 
96     [[nodiscard]] uint32_t GetDuplexMode() const;
97 
98     [[nodiscard]] bool HasMargin() const;
99 
100     void GetMargin(PrintMargin &printMargin) const;
101 
102     [[nodiscard]] bool HasPreview() const;
103 
104     void GetPreview(PrintPreviewAttribute &previewAttr) const;
105 
106     [[nodiscard]] bool HasOption() const;
107 
108     [[nodiscard]] const std::string &GetOption() const;
109 
110     virtual bool Marshalling(Parcel &parcel) const override;
111 
112     virtual bool MarshallingParam(Parcel &parcel) const;
113 
114     static std::shared_ptr<PrintJob> Unmarshalling(Parcel &parcel);
115 
116     void Dump();
117 
118 private:
119     void ReadFromParcel(Parcel &parcel);
120     void ReadParcelFD(Parcel &parcel);
121 
122 private:
123     std::vector<uint32_t> fdList_;
124     std::string jobId_;
125     std::string printerId_;
126     uint32_t jobState_;
127     uint32_t subState_;
128     uint32_t copyNumber_;
129     PrintRange pageRange_;
130     bool isSequential_;
131     PrintPageSize pageSize_;
132     bool isLandscape_;
133     uint32_t colorMode_;
134     uint32_t duplexMode_;
135     bool hasMargin_;
136     PrintMargin margin_;
137     bool hasPreview_;
138     PrintPreviewAttribute preview_;
139     bool hasOption_;
140     std::string option_;
141 };
142 }  // namespace OHOS::Print
143 #endif  // PRINT_JOB_H
144