Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: printing/backend/cups_jobs.h

Issue 2691093006: Implement IPP Get-Jobs and Get-Printer-Attributes requests. (Closed)
Patch Set: assign default values to id and state Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Implementations of IPP requests for printer queue information.
6
7 #ifndef PRINTING_BACKEND_CUPS_JOBS_H_
8 #define PRINTING_BACKEND_CUPS_JOBS_H_
9
10 #include <cups/cups.h>
11
12 #include <memory>
13 #include <string>
14 #include <vector>
15
16 #include "printing/printing_export.h"
17
18 namespace printing {
19
20 // Represents a print job sent to the queue.
21 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.
22 enum JobState {
23 UNKNOWN,
24 PENDING,
25 HELD,
26 COMPLETED,
27 PROCESSING,
28 STOPPED,
29 CANCELED,
30 ABORTED
31 };
32
33 int id = -1;
34 std::string printer_id;
35 JobState state = UNKNOWN;
36 int current_pages = -1;
37 std::vector<std::string> state_reasons;
38 std::string state_message;
39 int processing_started = 0;
40 };
41
42 // Represents the status of a printer containing the properties printer-state,
43 // printer-state-reasons, and printer-state-message.
44 struct PrinterStatus {
45 struct PrinterReason {
46 // Standardized reasons from RFC2911.
47 enum Reason {
48 UNKNOWN_REASON,
49 NONE,
50 MEDIA_NEEDED,
51 MEDIA_JAM,
52 MOVING_TO_PAUSED,
53 PAUSED,
54 SHUTDOWN,
55 CONNECTING_TO_DEVICE,
56 TIMED_OUT,
57 STOPPING,
58 STOPPED_PARTLY,
59 TONER_LOW,
60 TONER_EMPTY,
61 SPOOL_AREA_FULL,
62 COVER_OPEN,
63 INTERLOCK_OPEN,
64 DOOR_OPEN,
65 INPUT_TRAY_MISSING,
66 MEDIA_LOW,
67 MEDIA_EMPTY,
68 OUTPUT_TRAY_MISSING,
69 OUTPUT_AREA_ALMOST_FULL,
70 OUTPUT_AREA_FULL,
71 MARKER_SUPPLY_LOW,
72 MARKER_SUPPLY_EMPTY,
73 MARKER_WASTE_ALMOST_FULL,
74 MARKER_WASTE_FULL,
75 FUSER_OVER_TEMP,
76 FUSER_UNDER_TEMP,
77 OPC_NEAR_EOL,
78 OPC_LIFE_OVER,
79 DEVELOPER_LOW,
80 DEVELOPER_EMPTY,
81 INTERPRETER_RESOURCE_UNAVAILABLE
82 };
83
84 enum Severity { UNKNOWN_SEVERITY, REPORT, WARNING, ERROR };
85
86 Reason reason;
87 Severity severity;
88 };
89
90 ipp_pstate_t state;
91 std::vector<PrinterReason> reasons;
92 std::string message;
93 };
94
95 // Extracts structured job information from the |response| for |printer_id|.
96 // Extracted jobs are added to |jobs|.
97 void ParseJobsResponse(ipp_t* response,
98 const std::string& printer_id,
99 std::vector<CupsJob>* jobs);
100
101 // Attempts to extract a PrinterStatus object out of |response|.
102 void ParsePrinterStatus(ipp_t* response, PrinterStatus* printer_status);
103
104 // 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.
105 // Returns true if succcssful and updates the fields in |printer_status| as
106 // appropriate. Returns false if the request failed.
107 bool GetPrinterStatus(http_t* http,
108 const std::string& printer_id,
109 PrinterStatus* printer_status);
110
111 // Attempts to retrieve job information using connection |http| for the printer
112 // named |printer_id|. Retrieves at most |limit| jobs. If |completed| then
113 // completed jobs are retrieved. Otherwise, jobs that are currently in progress
114 // are retrieved. Results are added to |jobs| if the operation was successful.
115 bool GetCupsJobs(http_t* http,
116 const std::string& printer_id,
117 int limit,
118 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
119 std::vector<CupsJob>* jobs);
120
121 } // namespace printing
122
123 #endif // PRINTING_BACKEND_CUPS_JOBS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698