Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Implementations of IPP requests for printer queue information. | 5 // Implementations of IPP requests for printer queue information. |
| 6 | 6 |
| 7 #ifndef PRINTING_BACKEND_CUPS_JOBS_H_ | 7 #ifndef PRINTING_BACKEND_CUPS_JOBS_H_ |
| 8 #define PRINTING_BACKEND_CUPS_JOBS_H_ | 8 #define PRINTING_BACKEND_CUPS_JOBS_H_ |
| 9 | 9 |
| 10 #include <cups/cups.h> | 10 #include <cups/cups.h> |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | |
| 13 #include <vector> | 14 #include <vector> |
| 14 | 15 |
| 15 #include "printing/printing_export.h" | 16 #include "printing/printing_export.h" |
| 16 | 17 |
| 17 namespace printing { | 18 namespace printing { |
| 18 | 19 |
| 19 // Represents a print job sent to the queue. | 20 // Represents a print job sent to the queue. |
| 20 struct PRINTING_EXPORT CupsJob { | 21 struct PRINTING_EXPORT CupsJob { |
| 21 // Corresponds to job-state from RFC2911. | 22 // Corresponds to job-state from RFC2911. |
| 22 enum JobState { | 23 enum JobState { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 ~PrinterStatus(); | 104 ~PrinterStatus(); |
| 104 | 105 |
| 105 // printer-state | 106 // printer-state |
| 106 ipp_pstate_t state; | 107 ipp_pstate_t state; |
| 107 // printer-state-reasons | 108 // printer-state-reasons |
| 108 std::vector<PrinterReason> reasons; | 109 std::vector<PrinterReason> reasons; |
| 109 // printer-state-message | 110 // printer-state-message |
| 110 std::string message; | 111 std::string message; |
| 111 }; | 112 }; |
| 112 | 113 |
| 114 struct PRINTING_EXPORT PrinterInfo { | |
| 115 PrinterInfo(); | |
| 116 PrinterInfo(const PrinterInfo& info); | |
| 117 | |
| 118 ~PrinterInfo(); | |
| 119 | |
| 120 // printer-make-and-model | |
| 121 std::string make_and_model; | |
| 122 | |
| 123 // ipp-versions-supported | |
| 124 // A collection of major, minor pairs. | |
| 125 std::vector<std::pair<int, int>> ipp_versions; | |
| 126 | |
| 127 // Does ipp-features-supported contain 'ipp-everywhere'. | |
| 128 bool ipp_everywhere = false; | |
| 129 }; | |
| 130 | |
| 113 // Specifies classes of jobs. | 131 // Specifies classes of jobs. |
| 114 enum JobCompletionState { | 132 enum JobCompletionState { |
| 115 COMPLETED, // only completed jobs | 133 COMPLETED, // only completed jobs |
| 116 PROCESSING // only jobs that are being processed | 134 PROCESSING // only jobs that are being processed |
| 117 }; | 135 }; |
| 118 | 136 |
| 119 // Extracts structured job information from the |response| for |printer_id|. | 137 // Extracts structured job information from the |response| for |printer_id|. |
| 120 // Extracted jobs are added to |jobs|. | 138 // Extracted jobs are added to |jobs|. |
| 121 void ParseJobsResponse(ipp_t* response, | 139 void ParseJobsResponse(ipp_t* response, |
| 122 const std::string& printer_id, | 140 const std::string& printer_id, |
| 123 std::vector<CupsJob>* jobs); | 141 std::vector<CupsJob>* jobs); |
| 124 | 142 |
| 125 // Attempts to extract a PrinterStatus object out of |response|. | 143 // Attempts to extract a PrinterStatus object out of |response|. |
| 126 void ParsePrinterStatus(ipp_t* response, PrinterStatus* printer_status); | 144 void ParsePrinterStatus(ipp_t* response, PrinterStatus* printer_status); |
| 127 | 145 |
| 146 // Queries the printer at |address| on |port| with a Get-Printer-Attributes | |
| 147 // request to populate |printer_info|. Returns false if the request failed. | |
|
Carlson
2017/05/25 19:04:36
This is a long latency function with no callback,
skau
2017/05/27 02:01:20
I've added a file comment since it applies to all
| |
| 148 bool PRINTING_EXPORT GetPrinterInfo(const std::string& address, | |
| 149 const int port, | |
| 150 const std::string& resource, | |
| 151 PrinterInfo* printer_info); | |
| 152 | |
| 128 // Attempts to retrieve printer status using connection |http| for |printer_id|. | 153 // Attempts to retrieve printer status using connection |http| for |printer_id|. |
| 129 // Returns true if succcssful and updates the fields in |printer_status| as | 154 // Returns true if succcssful and updates the fields in |printer_status| as |
| 130 // appropriate. Returns false if the request failed. | 155 // appropriate. Returns false if the request failed. |
| 131 bool GetPrinterStatus(http_t* http, | 156 bool GetPrinterStatus(http_t* http, |
| 132 const std::string& printer_id, | 157 const std::string& printer_id, |
| 133 PrinterStatus* printer_status); | 158 PrinterStatus* printer_status); |
| 134 | 159 |
| 135 // Attempts to retrieve job information using connection |http| for the printer | 160 // Attempts to retrieve job information using connection |http| for the printer |
| 136 // named |printer_id|. Retrieves at most |limit| jobs. If |completed| then | 161 // named |printer_id|. Retrieves at most |limit| jobs. If |completed| then |
| 137 // completed jobs are retrieved. Otherwise, jobs that are currently in progress | 162 // completed jobs are retrieved. Otherwise, jobs that are currently in progress |
| 138 // are retrieved. Results are added to |jobs| if the operation was successful. | 163 // are retrieved. Results are added to |jobs| if the operation was successful. |
| 139 bool GetCupsJobs(http_t* http, | 164 bool GetCupsJobs(http_t* http, |
| 140 const std::string& printer_id, | 165 const std::string& printer_id, |
| 141 int limit, | 166 int limit, |
| 142 JobCompletionState completed, | 167 JobCompletionState completed, |
| 143 std::vector<CupsJob>* jobs); | 168 std::vector<CupsJob>* jobs); |
| 144 | 169 |
| 145 } // namespace printing | 170 } // namespace printing |
| 146 | 171 |
| 147 #endif // PRINTING_BACKEND_CUPS_JOBS_H_ | 172 #endif // PRINTING_BACKEND_CUPS_JOBS_H_ |
| OLD | NEW |