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

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

Issue 2691093006: Implement IPP Get-Jobs and Get-Printer-Attributes requests. (Closed)
Patch Set: rebase 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>
Lei Zhang 2017/03/07 23:31:29 Not needed?
skau 2017/03/10 01:07:00 Done.
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 {
22 // Cooresponds to job-state from RFC2911.
Lei Zhang 2017/03/07 23:31:29 typo: Corresponds
skau 2017/03/10 01:07:00 Done.
23 enum JobState {
24 UNKNOWN,
25 PENDING, // waiting to be processed
26 HELD, // the job has not begun printing and will not without intervention
27 COMPLETED,
28 PROCESSING, // job is being sent to the printer/printed
29 STOPPED, // job was being processed and has now stopped
30 CANCELED, // either the spooler or a user canclled the job
31 ABORTED // an error occurred causing the printer to give up
32 };
33
34 // job id
35 int id = -1;
36 // printer name in CUPS
37 std::string printer_id;
38 JobState state = UNKNOWN;
39 // the last page printed
40 int current_pages = -1;
41 // detail for the job state
42 std::vector<std::string> state_reasons;
43 // human readable message explaining the state
44 std::string state_message;
45 // most recent timestamp where the job entered PROCESSING
46 int processing_started = 0;
47 };
48
49 // Represents the status of a printer containing the properties printer-state,
50 // printer-state-reasons, and printer-state-message.
51 struct PrinterStatus {
52 struct PrinterReason {
53 // Standardized reasons from RFC2911.
54 enum Reason {
55 UNKNOWN_REASON,
56 NONE,
57 MEDIA_NEEDED,
58 MEDIA_JAM,
59 MOVING_TO_PAUSED,
60 PAUSED,
61 SHUTDOWN,
62 CONNECTING_TO_DEVICE,
63 TIMED_OUT,
64 STOPPING,
65 STOPPED_PARTLY,
66 TONER_LOW,
67 TONER_EMPTY,
68 SPOOL_AREA_FULL,
69 COVER_OPEN,
70 INTERLOCK_OPEN,
71 DOOR_OPEN,
72 INPUT_TRAY_MISSING,
73 MEDIA_LOW,
74 MEDIA_EMPTY,
75 OUTPUT_TRAY_MISSING,
76 OUTPUT_AREA_ALMOST_FULL,
77 OUTPUT_AREA_FULL,
78 MARKER_SUPPLY_LOW,
79 MARKER_SUPPLY_EMPTY,
80 MARKER_WASTE_ALMOST_FULL,
81 MARKER_WASTE_FULL,
82 FUSER_OVER_TEMP,
83 FUSER_UNDER_TEMP,
84 OPC_NEAR_EOL,
85 OPC_LIFE_OVER,
86 DEVELOPER_LOW,
87 DEVELOPER_EMPTY,
88 INTERPRETER_RESOURCE_UNAVAILABLE
89 };
90
91 // Severity of the state-reason.
92 enum Severity { UNKNOWN_SEVERITY, REPORT, WARNING, ERROR };
93
94 Reason reason;
95 Severity severity;
96 };
97
98 // printer-state
99 ipp_pstate_t state;
100 // printer-state-reasons
101 std::vector<PrinterReason> reasons;
102 // printer-state-message
103 std::string message;
104 };
105
106 // Specifies classes of jobs.
107 enum WhichJobs {
Lei Zhang 2017/03/07 23:31:29 Maybe JobCompletionState?
skau 2017/03/10 01:07:00 Done.
108 COMPLETED, // only completed jobs
109 PROCESSING // only jobs that are being processed
110 };
111
112 // Extracts structured job information from the |response| for |printer_id|.
113 // Extracted jobs are added to |jobs|.
114 void ParseJobsResponse(ipp_t* response,
115 const std::string& printer_id,
116 std::vector<CupsJob>* jobs);
117
118 // Attempts to extract a PrinterStatus object out of |response|.
119 void ParsePrinterStatus(ipp_t* response, PrinterStatus* printer_status);
120
121 // Attempts to retrieve printer status using connection |http| for |printer_id|.
122 // Returns true if succcssful and updates the fields in |printer_status| as
123 // appropriate. Returns false if the request failed.
124 bool GetPrinterStatus(http_t* http,
125 const std::string& printer_id,
126 PrinterStatus* printer_status);
127
128 // Attempts to retrieve job information using connection |http| for the printer
129 // named |printer_id|. Retrieves at most |limit| jobs. If |completed| then
130 // completed jobs are retrieved. Otherwise, jobs that are currently in progress
131 // are retrieved. Results are added to |jobs| if the operation was successful.
132 bool GetCupsJobs(http_t* http,
133 const std::string& printer_id,
134 int limit,
135 WhichJobs completed,
136 std::vector<CupsJob>* jobs);
137
138 } // namespace printing
139
140 #endif // PRINTING_BACKEND_CUPS_JOBS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698