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

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

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

Powered by Google App Engine
This is Rietveld 408576698