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

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

Issue 2891643002: Add a method to query IPP printers for attributes. (Closed)
Patch Set: fix compilation Created 3 years, 6 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
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
18 // This file contains a collection of functions used to query IPP printers or
19 // print servers and the related code to parse these responses. All Get*
20 // operations block on the network request and cannot be run on the UI thread.
Carlson 2017/05/30 17:36:42 Can you add assertions to the relevant functions a
skau 2017/05/31 00:01:20 I'm looking into it. There's a migration away fro
21
17 namespace printing { 22 namespace printing {
18 23
19 // Represents a print job sent to the queue. 24 // Represents a print job sent to the queue.
20 struct PRINTING_EXPORT CupsJob { 25 struct PRINTING_EXPORT CupsJob {
21 // Corresponds to job-state from RFC2911. 26 // Corresponds to job-state from RFC2911.
22 enum JobState { 27 enum JobState {
23 UNKNOWN, 28 UNKNOWN,
24 PENDING, // waiting to be processed 29 PENDING, // waiting to be processed
25 HELD, // the job has not begun printing and will not without intervention 30 HELD, // the job has not begun printing and will not without intervention
26 COMPLETED, 31 COMPLETED,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 ~PrinterStatus(); 108 ~PrinterStatus();
104 109
105 // printer-state 110 // printer-state
106 ipp_pstate_t state; 111 ipp_pstate_t state;
107 // printer-state-reasons 112 // printer-state-reasons
108 std::vector<PrinterReason> reasons; 113 std::vector<PrinterReason> reasons;
109 // printer-state-message 114 // printer-state-message
110 std::string message; 115 std::string message;
111 }; 116 };
112 117
118 struct PRINTING_EXPORT PrinterInfo {
119 PrinterInfo();
120 PrinterInfo(const PrinterInfo& info);
121
122 ~PrinterInfo();
123
124 // printer-make-and-model
125 std::string make_and_model;
126
127 // document-format-supported
128 // MIME types for supported formats.
129 std::vector<std::string> document_formats;
130
131 // ipp-versions-supported
132 // A collection of major, minor pairs.
133 std::vector<std::pair<int, int>> ipp_versions;
134
135 // Does ipp-features-supported contain 'ipp-everywhere'.
136 bool ipp_everywhere = false;
137 };
138
113 // Specifies classes of jobs. 139 // Specifies classes of jobs.
114 enum JobCompletionState { 140 enum JobCompletionState {
115 COMPLETED, // only completed jobs 141 COMPLETED, // only completed jobs
116 PROCESSING // only jobs that are being processed 142 PROCESSING // only jobs that are being processed
117 }; 143 };
118 144
119 // Extracts structured job information from the |response| for |printer_id|. 145 // Extracts structured job information from the |response| for |printer_id|.
120 // Extracted jobs are added to |jobs|. 146 // Extracted jobs are added to |jobs|.
121 void ParseJobsResponse(ipp_t* response, 147 void ParseJobsResponse(ipp_t* response,
122 const std::string& printer_id, 148 const std::string& printer_id,
123 std::vector<CupsJob>* jobs); 149 std::vector<CupsJob>* jobs);
124 150
125 // Attempts to extract a PrinterStatus object out of |response|. 151 // Attempts to extract a PrinterStatus object out of |response|.
126 void ParsePrinterStatus(ipp_t* response, PrinterStatus* printer_status); 152 void ParsePrinterStatus(ipp_t* response, PrinterStatus* printer_status);
127 153
154 // Queries the printer at |address| on |port| with a Get-Printer-Attributes
155 // request to populate |printer_info|. Returns false if the request failed.
156 bool PRINTING_EXPORT GetPrinterInfo(const std::string& address,
157 const int port,
158 const std::string& resource,
159 PrinterInfo* printer_info);
160
128 // Attempts to retrieve printer status using connection |http| for |printer_id|. 161 // Attempts to retrieve printer status using connection |http| for |printer_id|.
129 // Returns true if succcssful and updates the fields in |printer_status| as 162 // Returns true if succcssful and updates the fields in |printer_status| as
130 // appropriate. Returns false if the request failed. 163 // appropriate. Returns false if the request failed.
131 bool GetPrinterStatus(http_t* http, 164 bool GetPrinterStatus(http_t* http,
132 const std::string& printer_id, 165 const std::string& printer_id,
133 PrinterStatus* printer_status); 166 PrinterStatus* printer_status);
134 167
135 // Attempts to retrieve job information using connection |http| for the printer 168 // Attempts to retrieve job information using connection |http| for the printer
136 // named |printer_id|. Retrieves at most |limit| jobs. If |completed| then 169 // named |printer_id|. Retrieves at most |limit| jobs. If |completed| then
137 // completed jobs are retrieved. Otherwise, jobs that are currently in progress 170 // completed jobs are retrieved. Otherwise, jobs that are currently in progress
138 // are retrieved. Results are added to |jobs| if the operation was successful. 171 // are retrieved. Results are added to |jobs| if the operation was successful.
139 bool GetCupsJobs(http_t* http, 172 bool GetCupsJobs(http_t* http,
140 const std::string& printer_id, 173 const std::string& printer_id,
141 int limit, 174 int limit,
142 JobCompletionState completed, 175 JobCompletionState completed,
143 std::vector<CupsJob>* jobs); 176 std::vector<CupsJob>* jobs);
144 177
145 } // namespace printing 178 } // namespace printing
146 179
147 #endif // PRINTING_BACKEND_CUPS_JOBS_H_ 180 #endif // PRINTING_BACKEND_CUPS_JOBS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698