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