1 | from . import verify_operations |
---|
2 | from . import verify_printer_uri |
---|
3 | from . import verify_requesting_username |
---|
4 | from . import make_empty_response |
---|
5 | |
---|
6 | import logging |
---|
7 | logger = logging.getLogger(__name__) |
---|
8 | |
---|
9 | def verify_print_job_request(request): |
---|
10 | """3.2.1.1 Print-Job Request |
---|
11 | |
---|
12 | The following groups of attributes are supplied as part of the |
---|
13 | Print-Job Request: |
---|
14 | |
---|
15 | Group 1: Operation Attributes |
---|
16 | Natural Language and Character Set: |
---|
17 | The 'attributes-charset' and 'attributes-natural-language' |
---|
18 | attributes as described in section 3.1.4.1. The Printer |
---|
19 | object MUST copy these values to the corresponding Job |
---|
20 | Description attributes described in sections 4.3.19 and |
---|
21 | 4.3.20. |
---|
22 | Target: |
---|
23 | The 'printer-uri' (uri) operation attribute which is the |
---|
24 | target for this operation as described in section 3.1.5. |
---|
25 | Requesting User Name: |
---|
26 | The 'requesting-user-name' (name(MAX)) attribute SHOULD be |
---|
27 | supplied by the client as described in section 8.3. |
---|
28 | 'job-name' (name(MAX)): |
---|
29 | The client OPTIONALLY supplies this attribute. The Printer |
---|
30 | object MUST support this attribute. It contains the client |
---|
31 | supplied Job name. If this attribute is supplied by the |
---|
32 | client, its value is used for the 'job-name' attribute of |
---|
33 | the newly created Job object. The client MAY automatically |
---|
34 | include any information that will help the end-user |
---|
35 | distinguish amongst his/her jobs, such as the name of the |
---|
36 | application program along with information from the |
---|
37 | document, such as the document name, document subject, or |
---|
38 | source file name. If this attribute is not supplied by the |
---|
39 | client, the Printer generates a name to use in the |
---|
40 | 'job-name' attribute of the newly created Job object (see |
---|
41 | Section 4.3.5). |
---|
42 | 'ipp-attribute-fidelity' (boolean): |
---|
43 | The client OPTIONALLY supplies this attribute. The Printer |
---|
44 | object MUST support this attribute. The value 'true' |
---|
45 | indicates that total fidelity to client supplied Job |
---|
46 | Template attributes and values is required, else the |
---|
47 | Printer object MUST reject the Print-Job request. The |
---|
48 | value 'false' indicates that a reasonable attempt to print |
---|
49 | the Job object is acceptable and the Printer object MUST |
---|
50 | accept the Print-Job request. If not supplied, the Printer |
---|
51 | object assumes the value is 'false'. All Printer objects |
---|
52 | MUST support both types of job processing. See section 15 |
---|
53 | for a full description of 'ipp-attribute-fidelity' and its |
---|
54 | relationship to other attributes, especially the Printer |
---|
55 | object's 'pdl-override-supported' attribute. |
---|
56 | 'document-name' (name(MAX)): |
---|
57 | The client OPTIONALLY supplies this attribute. The Printer |
---|
58 | object MUST support this attribute. It contains the |
---|
59 | client supplied document name. The document name MAY be |
---|
60 | different than the Job name. Typically, the client |
---|
61 | software automatically supplies the document name on |
---|
62 | behalf of the end user by using a file name or an |
---|
63 | application generated name. If this attribute is supplied, |
---|
64 | its value can be used in a manner defined by each |
---|
65 | implementation. Examples include: printed along with the |
---|
66 | Job (job start sheet, page adornments, etc.), used by |
---|
67 | accounting or resource tracking management tools, or even |
---|
68 | stored along with the document as a document level |
---|
69 | attribute. IPP/1.1 does not support the concept of |
---|
70 | document level attributes. |
---|
71 | 'compression' (type3 keyword): |
---|
72 | The client OPTIONALLY supplies this attribute. The Printer |
---|
73 | object MUST support this attribute and the 'compression- |
---|
74 | supported' attribute (see section 4.4.32). The client |
---|
75 | supplied 'compression' operation attribute identifies the |
---|
76 | compression algorithm used on the document data. The |
---|
77 | following cases exist: |
---|
78 | a) If the client omits this attribute, the Printer object |
---|
79 | MUST assume that the data is not compressed (i.e. the |
---|
80 | Printer follows the rules below as if the client |
---|
81 | supplied the 'compression' attribute with a value of |
---|
82 | 'none'). |
---|
83 | b) If the client supplies this attribute, but the value is |
---|
84 | not supported by the Printer object, i.e., the value is |
---|
85 | not one of the values of the Printer object's |
---|
86 | 'compression- supported' attribute, the Printer object |
---|
87 | MUST reject the request, and return the |
---|
88 | 'client-error-compression-not- supported' status |
---|
89 | code. See section 3.1.7 for returning unsupported |
---|
90 | attributes and values. |
---|
91 | c) If the client supplies the attribute and the Printer |
---|
92 | object supports the attribute value, the Printer object |
---|
93 | uses the corresponding decompression algorithm on the |
---|
94 | document data. |
---|
95 | d) If the decompression algorithm fails before the Printer |
---|
96 | returns an operation response, the Printer object MUST |
---|
97 | reject the request and return the 'client-error- |
---|
98 | compression-error' status code. |
---|
99 | e) If the decompression algorithm fails after the Printer |
---|
100 | returns an operation response, the Printer object MUST |
---|
101 | abort the job and add the 'compression-error' value to |
---|
102 | the job's 'job-state-reasons' attribute. |
---|
103 | f) If the decompression algorithm succeeds, the document |
---|
104 | data MUST then have the format specified by the job's |
---|
105 | 'document- format' attribute, if supplied (see |
---|
106 | 'document-format' operation attribute definition |
---|
107 | below). |
---|
108 | 'document-format' (mimeMediaType): |
---|
109 | The client OPTIONALLY supplies this attribute. The Printer |
---|
110 | object MUST support this attribute. The value of this |
---|
111 | attribute identifies the format of the supplied document |
---|
112 | data. The following cases exist: |
---|
113 | a) If the client does not supply this attribute, the |
---|
114 | Printer object assumes that the document data is in the |
---|
115 | format defined by the Printer object's |
---|
116 | 'document-format-default' attribute. (i.e. the Printer |
---|
117 | follows the rules below as if the client supplied the |
---|
118 | 'document-format' attribute with a value equal to the |
---|
119 | printer's default value). |
---|
120 | b) If the client supplies this attribute, but the value is |
---|
121 | not supported by the Printer object, i.e., the value is |
---|
122 | not one of the values of the Printer object's |
---|
123 | 'document-format- supported' attribute, the Printer |
---|
124 | object MUST reject the request and return the |
---|
125 | 'client-error-document-format-not- supported' status |
---|
126 | code. |
---|
127 | c) If the client supplies this attribute and its value is |
---|
128 | 'application/octet-stream' (i.e. to be auto-sensed, see |
---|
129 | Section 4.1.9.1), and the format is not one of the |
---|
130 | document-formats that the Printer can auto-sense, and |
---|
131 | this check occurs before the Printer returns an |
---|
132 | operation response, then the Printer MUST reject the |
---|
133 | request and return the |
---|
134 | 'client-error-document-format-not-supported' status |
---|
135 | code. |
---|
136 | d) If the client supplies this attribute, and the value is |
---|
137 | supported by the Printer object, the Printer is capable |
---|
138 | of interpreting the document data. |
---|
139 | e) If interpreting of the document data fails before the |
---|
140 | Printer returns an operation response, the Printer |
---|
141 | object MUST reject the request and return the |
---|
142 | 'client-error- document-format-error' status code. |
---|
143 | f) If interpreting of the document data fails after the |
---|
144 | Printer returns an operation response, the Printer |
---|
145 | object MUST abort the job and add the |
---|
146 | 'document-format-error' value to the job's |
---|
147 | 'job-state-reasons' attribute. |
---|
148 | 'document-natural-language' (naturalLanguage): |
---|
149 | The client OPTIONALLY supplies this attribute. The Printer |
---|
150 | object OPTIONALLY supports this attribute. This attribute |
---|
151 | specifies the natural language of the document for those |
---|
152 | document-formats that require a specification of the |
---|
153 | natural language in order to image the document |
---|
154 | unambiguously. There are no particular values required for |
---|
155 | the Printer object to support. |
---|
156 | 'job-k-octets' (integer(0:MAX)): |
---|
157 | The client OPTIONALLY supplies this attribute. The Printer |
---|
158 | object OPTIONALLY supports this attribute and the 'job-k- |
---|
159 | octets-supported' attribute (see section 4.4.33). The |
---|
160 | client supplied 'job-k-octets' operation attribute |
---|
161 | identifies the total size of the document(s) in K octets |
---|
162 | being submitted (see section 4.3.17.1 for the complete |
---|
163 | semantics). If the client supplies the attribute and the |
---|
164 | Printer object supports the attribute, the value of the |
---|
165 | attribute is used to populate the Job object's |
---|
166 | 'job-k-octets' Job Description attribute. For this |
---|
167 | attribute and the following two attributes ('job- |
---|
168 | impressions', and 'job-media-sheets'), if the client |
---|
169 | supplies the attribute, but the Printer object does not |
---|
170 | support the attribute, the Printer object ignores the |
---|
171 | client-supplied value. If the client supplies the |
---|
172 | attribute and the Printer supports the attribute, and the |
---|
173 | value is within the range of the corresponding Printer |
---|
174 | object's 'xxx-supported' attribute, the Printer object |
---|
175 | MUST use the value to populate the Job object's 'xxx' |
---|
176 | attribute. If the client supplies the attribute and the |
---|
177 | Printer supports the attribute, but the value is outside |
---|
178 | the range of the corresponding Printer object's 'xxx- |
---|
179 | supported' attribute, the Printer object MUST copy the |
---|
180 | attribute and its value to the Unsupported Attributes |
---|
181 | response group, reject the request, and return the |
---|
182 | 'client-error- attributes-or-values-not-supported' status |
---|
183 | code. If the client does not supply the attribute, the |
---|
184 | Printer object MAY choose to populate the corresponding |
---|
185 | Job object attribute depending on whether the Printer |
---|
186 | object supports the attribute and is able to calculate or |
---|
187 | discern the correct value. |
---|
188 | 'job-impressions' (integer(0:MAX)): |
---|
189 | The client OPTIONALLY supplies this attribute. The Printer |
---|
190 | object OPTIONALLY supports this attribute and the 'job- |
---|
191 | impressions-supported' attribute (see section 4.4.34). The |
---|
192 | client supplied 'job-impressions' operation attribute |
---|
193 | identifies the total size in number of impressions of the |
---|
194 | document(s) being submitted (see section 4.3.17.2 for the |
---|
195 | complete semantics). |
---|
196 | See last paragraph under 'job-k-octets'. |
---|
197 | 'job-media-sheets' (integer(0:MAX)): |
---|
198 | The client OPTIONALLY supplies this attribute. The Printer |
---|
199 | object OPTIONALLY supports this attribute and the |
---|
200 | 'job-media- sheets-supported' attribute (see section |
---|
201 | 4.4.35). The client supplied 'job-media-sheets' operation |
---|
202 | attribute identifies the total number of media sheets to |
---|
203 | be produced for this job (see section 4.3.17.3 for the |
---|
204 | complete semantics). |
---|
205 | See last paragraph under 'job-k-octets'. |
---|
206 | |
---|
207 | Group 2: Job Template Attributes |
---|
208 | The client OPTIONALLY supplies a set of Job Template |
---|
209 | attributes as defined in section 4.2. If the client is not |
---|
210 | supplying any Job Template attributes in the request, the |
---|
211 | client SHOULD omit Group 2 rather than sending an empty |
---|
212 | group. However, a Printer object MUST be able to accept an |
---|
213 | empty group. |
---|
214 | |
---|
215 | Group 3: Document Content |
---|
216 | The client MUST supply the document data to be processed. In |
---|
217 | addition to the MANDATORY parameters required for every |
---|
218 | operation request, the simplest Print-Job Request consists of |
---|
219 | just the 'attributes-charset' and |
---|
220 | 'attributes-natural-language' operation attributes; the |
---|
221 | 'printer-uri' target operation attribute; the Document Content |
---|
222 | and nothing else. In this simple case, the Printer object: |
---|
223 | - creates a new Job object (the Job object contains a single |
---|
224 | document), |
---|
225 | - stores a generated Job name in the 'job-name' attribute in |
---|
226 | the natural language and charset requested (see Section |
---|
227 | 3.1.4.1) (if those are supported, otherwise using the |
---|
228 | Printer object's default natural language and charset), and |
---|
229 | - at job processing time, uses its corresponding default value |
---|
230 | attributes for the supported Job Template attributes that |
---|
231 | were not supplied by the client as IPP attribute or embedded |
---|
232 | instructions in the document data. |
---|
233 | |
---|
234 | """ |
---|
235 | |
---|
236 | pass |
---|
237 | |
---|
238 | def make_print_job_response(job, request): |
---|
239 | """3.2.1.2 Print-Job Response |
---|
240 | |
---|
241 | The Printer object MUST return to the client the following sets of |
---|
242 | attributes as part of the Print-Job Response: |
---|
243 | |
---|
244 | Group 1: Operation Attributes |
---|
245 | Status Message: |
---|
246 | In addition to the REQUIRED status code returned in every |
---|
247 | response, the response OPTIONALLY includes a |
---|
248 | 'status-message' (text(255)) and/or a |
---|
249 | 'detailed-status-message' (text(MAX)) operation attribute |
---|
250 | as described in sections 13 and 3.1.6. If the client |
---|
251 | supplies unsupported or conflicting Job Template |
---|
252 | attributes or values, the Printer object MUST reject or |
---|
253 | accept the Print-Job request depending on the whether the |
---|
254 | client supplied a 'true' or 'false' value for the |
---|
255 | 'ipp-attribute- fidelity' operation attribute. See the |
---|
256 | Implementer's Guide [IPP-IIG] for a complete description |
---|
257 | of the suggested steps for processing a create request. |
---|
258 | Natural Language and Character Set: |
---|
259 | The 'attributes-charset' and 'attributes-natural-language' |
---|
260 | attributes as described in section 3.1.4.2. |
---|
261 | |
---|
262 | Group 2: Unsupported Attributes |
---|
263 | See section 3.1.7 for details on returning Unsupported |
---|
264 | Attributes. The value of the 'ipp-attribute-fidelity' |
---|
265 | supplied by the client does not affect what attributes the |
---|
266 | Printer object returns in this group. The value of |
---|
267 | 'ipp-attribute-fidelity' only affects whether the Print-Job |
---|
268 | operation is accepted or rejected. If the job is accepted, the |
---|
269 | client may query the job using the Get-Job- Attributes |
---|
270 | operation requesting the unsupported attributes that were |
---|
271 | returned in the create response to see which attributes were |
---|
272 | ignored (not stored on the Job object) and which attributes |
---|
273 | were stored with other (substituted) values. |
---|
274 | |
---|
275 | Group 3: Job Object Attributes |
---|
276 | 'job-uri' (uri): |
---|
277 | The Printer object MUST return the Job object's URI by |
---|
278 | returning the contents of the REQUIRED 'job-uri' Job |
---|
279 | object attribute. The client uses the Job object's URI |
---|
280 | when directing operations at the Job object. The Printer |
---|
281 | object always uses its configured security policy when |
---|
282 | creating the new URI. However, if the Printer object |
---|
283 | supports more than one URI, the Printer object also uses |
---|
284 | information about which URI was used in the Print-Job |
---|
285 | Request to generated the new URI so that the new URI |
---|
286 | references the correct access channel. In other words, if |
---|
287 | the Print-Job Request comes in over a secure channel, the |
---|
288 | Printer object MUST generate a Job URI that uses the |
---|
289 | secure channel as well. |
---|
290 | 'job-id' (integer(1:MAX)): |
---|
291 | The Printer object MUST return the Job object's Job ID by |
---|
292 | returning the REQUIRED 'job-id' Job object attribute. The |
---|
293 | client uses this 'job-id' attribute in conjunction with |
---|
294 | the 'printer-uri' attribute used in the Print-Job Request |
---|
295 | when directing Job operations at the Printer object. |
---|
296 | 'job-state' (type1 enum): |
---|
297 | The Printer object MUST return the Job object's REQUIRED |
---|
298 | 'job- state' attribute. The value of this attribute (along |
---|
299 | with the value of the next attribute: 'job-state-reasons') |
---|
300 | is taken from a 'snapshot' of the new Job object at some |
---|
301 | meaningful point in time (implementation defined) between |
---|
302 | when the Printer object receives the Print-Job Request and |
---|
303 | when the Printer object returns the response. |
---|
304 | 'job-state-reasons' (1setOf type2 keyword): |
---|
305 | The Printer object MUST return the Job object's REQUIRED |
---|
306 | 'job- state-reasons' attribute. |
---|
307 | 'job-state-message' (text(MAX)): |
---|
308 | The Printer object OPTIONALLY returns the Job object's |
---|
309 | OPTIONAL 'job-state-message' attribute. If the Printer |
---|
310 | object supports this attribute then it MUST be returned in |
---|
311 | the response. If this attribute is not returned in the |
---|
312 | response, the client can assume that the |
---|
313 | 'job-state-message' attribute is not supported and will |
---|
314 | not be returned in a subsequent Job object query. |
---|
315 | 'number-of-intervening-jobs' (integer(0:MAX)): |
---|
316 | The Printer object OPTIONALLY returns the Job object's |
---|
317 | OPTIONAL 'number-of-intervening-jobs' attribute. If the |
---|
318 | Printer object supports this attribute then it MUST be |
---|
319 | returned in the response. If this attribute is not |
---|
320 | returned in the response, the client can assume that the |
---|
321 | 'number-of-intervening-jobs' attribute is not supported |
---|
322 | and will not be returned in a subsequent Job object query. |
---|
323 | |
---|
324 | Note: Since any printer state information which affects a job's |
---|
325 | state is reflected in the 'job-state' and 'job-state-reasons' |
---|
326 | attributes, it is sufficient to return only these attributes and |
---|
327 | no specific printer status attributes. |
---|
328 | |
---|
329 | Note: In addition to the MANDATORY parameters required for every |
---|
330 | operation response, the simplest response consists of the just the |
---|
331 | 'attributes-charset' and 'attributes-natural-language' operation |
---|
332 | attributes and the 'job-uri', 'job-id', and 'job-state' Job Object |
---|
333 | Attributes. In this simplest case, the status code is 'successful- |
---|
334 | ok' and there is no 'status-message' or 'detailed-status-message' |
---|
335 | operation attribute. |
---|
336 | |
---|
337 | """ |
---|
338 | |
---|
339 | pass |
---|