Index: printing/backend/cups_jobs.h |
diff --git a/printing/backend/cups_jobs.h b/printing/backend/cups_jobs.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b04d1f4875ef390b2697e364dd1050e4c012a38e |
--- /dev/null |
+++ b/printing/backend/cups_jobs.h |
@@ -0,0 +1,123 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// Implementations of IPP requests for printer queue information. |
+ |
+#ifndef PRINTING_BACKEND_CUPS_JOBS_H_ |
+#define PRINTING_BACKEND_CUPS_JOBS_H_ |
+ |
+#include <cups/cups.h> |
+ |
+#include <memory> |
+#include <string> |
+#include <vector> |
+ |
+#include "printing/printing_export.h" |
+ |
+namespace printing { |
+ |
+// Represents a print job sent to the queue. |
+struct PRINTING_EXPORT CupsJob { |
Carlson
2017/02/24 00:02:09
Field comments please? At least for things that a
skau
2017/02/28 00:59:59
Done.
|
+ enum JobState { |
+ UNKNOWN, |
+ PENDING, |
+ HELD, |
+ COMPLETED, |
+ PROCESSING, |
+ STOPPED, |
+ CANCELED, |
+ ABORTED |
+ }; |
+ |
+ int id = -1; |
+ std::string printer_id; |
+ JobState state = UNKNOWN; |
+ int current_pages = -1; |
+ std::vector<std::string> state_reasons; |
+ std::string state_message; |
+ int processing_started = 0; |
+}; |
+ |
+// Represents the status of a printer containing the properties printer-state, |
+// printer-state-reasons, and printer-state-message. |
+struct PrinterStatus { |
+ struct PrinterReason { |
+ // Standardized reasons from RFC2911. |
+ enum Reason { |
+ UNKNOWN_REASON, |
+ NONE, |
+ MEDIA_NEEDED, |
+ MEDIA_JAM, |
+ MOVING_TO_PAUSED, |
+ PAUSED, |
+ SHUTDOWN, |
+ CONNECTING_TO_DEVICE, |
+ TIMED_OUT, |
+ STOPPING, |
+ STOPPED_PARTLY, |
+ TONER_LOW, |
+ TONER_EMPTY, |
+ SPOOL_AREA_FULL, |
+ COVER_OPEN, |
+ INTERLOCK_OPEN, |
+ DOOR_OPEN, |
+ INPUT_TRAY_MISSING, |
+ MEDIA_LOW, |
+ MEDIA_EMPTY, |
+ OUTPUT_TRAY_MISSING, |
+ OUTPUT_AREA_ALMOST_FULL, |
+ OUTPUT_AREA_FULL, |
+ MARKER_SUPPLY_LOW, |
+ MARKER_SUPPLY_EMPTY, |
+ MARKER_WASTE_ALMOST_FULL, |
+ MARKER_WASTE_FULL, |
+ FUSER_OVER_TEMP, |
+ FUSER_UNDER_TEMP, |
+ OPC_NEAR_EOL, |
+ OPC_LIFE_OVER, |
+ DEVELOPER_LOW, |
+ DEVELOPER_EMPTY, |
+ INTERPRETER_RESOURCE_UNAVAILABLE |
+ }; |
+ |
+ enum Severity { UNKNOWN_SEVERITY, REPORT, WARNING, ERROR }; |
+ |
+ Reason reason; |
+ Severity severity; |
+ }; |
+ |
+ ipp_pstate_t state; |
+ std::vector<PrinterReason> reasons; |
+ std::string message; |
+}; |
+ |
+// Extracts structured job information from the |response| for |printer_id|. |
+// Extracted jobs are added to |jobs|. |
+void ParseJobsResponse(ipp_t* response, |
+ const std::string& printer_id, |
+ std::vector<CupsJob>* jobs); |
+ |
+// Attempts to extract a PrinterStatus object out of |response|. |
+void ParsePrinterStatus(ipp_t* response, PrinterStatus* printer_status); |
+ |
+// Attmepts to retrieve printer status using connection |http| for |printer_id|. |
Carlson
2017/02/24 00:02:09
Attempts
skau
2017/02/28 00:59:59
Done.
|
+// Returns true if succcssful and updates the fields in |printer_status| as |
+// appropriate. Returns false if the request failed. |
+bool GetPrinterStatus(http_t* http, |
+ const std::string& printer_id, |
+ PrinterStatus* printer_status); |
+ |
+// Attempts to retrieve job information using connection |http| for the printer |
+// named |printer_id|. Retrieves at most |limit| jobs. If |completed| then |
+// completed jobs are retrieved. Otherwise, jobs that are currently in progress |
+// are retrieved. Results are added to |jobs| if the operation was successful. |
+bool GetCupsJobs(http_t* http, |
+ const std::string& printer_id, |
+ int limit, |
+ bool completed, |
Carlson
2017/02/24 00:02:09
Suggest renaming to "include_completed"
skau
2017/02/28 00:59:59
I've changed it to an enum. It's either completed
|
+ std::vector<CupsJob>* jobs); |
+ |
+} // namespace printing |
+ |
+#endif // PRINTING_BACKEND_CUPS_JOBS_H_ |