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