source: server/lib/gutenbach/ipp/object_attributes/printer_description_attributes.py @ b828a96

no-cups
Last change on this file since b828a96 was b828a96, checked in by Jessica B. Hamrick <jhamrick@…>, 12 years ago

Use classes for standard IPP attributes

  • Property mode set to 100644
File size: 22.6 KB
Line 
1__all__ = [
2    'PrinterUriSupported',
3    'UriAuthenticationSupported',
4    'UriSecuritySupported',
5    'PrinterName',
6    'PrinterLocation',
7    'PrinterInfo',
8    'PrinterMoreInfo',
9    'PrinterDriverInstaller',
10    'PrinterMakeAndModel',
11    'PrinterMoreInfoManufacturer',
12    'PrinterState',
13    'PrinterStateReasons',
14    'PrinterStateMessage',
15    'IppVersionsSupported',
16    'OperationsSupported',
17    'MultipleDocumentJobsSupported',
18    'CharsetConfigured',
19    'CharsetSupported',
20    'NaturalLanguageConfigured',
21    'GeneratedNaturalLanguageSupported',
22    'DocumentFormatDefault',
23    'DocumentFormatSupported',
24    'PrinterIsAcceptingJobs',
25    'QueuedJobCount',
26    'PrinterMessageFromOperator',
27    'ColorSupported',
28    'ReferenceUriSchemeSupported',
29    'PdlOverrideSupported',
30    'PrinterUpTime',
31    'PrinterCurrentTime',
32    'MultipleOperationTimeOut',
33    'CompressionSupported',
34    'JobKOctetsSupported',
35    'JobImpressionsSupported',
36    'JobMediaSheetsSupported',
37    'PagesPerMinute',
38    'PagesPerMinuteColor'
39]
40
41from ..attribute import Attribute
42from ..value import Value
43from ..exceptions import ClientErrorAttributes
44from ..constants import *
45
46def PrinterUriSupported(*vals):
47    """4.4.1 printer-uri-supported (1setOf uri)
48
49    This REQUIRED Printer attribute contains at least one URI for the
50    Printer object. It OPTIONALLY contains more than one URI for the
51    Printer object.
52
53    An administrator determines a Printer object's URI(s) and
54    configures this attribute to contain those URIs by some means
55    outside the scope of this IPP/1.1 document. The precise format of
56    this URI is implementation dependent and depends on the protocol.
57    See the next two sections for a description of the 'uri-security-
58    supported' and 'uri-authentication-supported' attributes, both of
59    which are the REQUIRED companion attributes to this 'printer-uri-
60    supported' attribute. See section 2.4 on Printer object identity
61    and section 8.2 on security and URIs for more information.
62   
63    """
64   
65    return Attribute(
66        'printer-uri-supported',
67        [Value(CharacterStringTags.URI, val) for val in vals])
68
69
70def UriAuthenticationSupported(*vals):
71    """4.4.2 uri-authentication-supported (1setOf type2 keyword)
72
73    This REQUIRED Printer attribute MUST have the same cardinality
74    (contain the same number of values) as the 'printer-uri-supported'
75    attribute. This attribute identifies the Client Authentication
76    mechanism associated with each URI listed in the 'printer-uri-
77    supported' attribute. The Printer object uses the specified
78    mechanism to identify the authenticated user (see section
79    8.3). The 'i th' value in 'uri-authentication-supported'
80    corresponds to the 'i th' value in 'printer-uri-supported' and it
81    describes the authentication mechanisms used by the Printer when
82    accessed via that URI. See [RFC2910] for more details on Client
83    Authentication.
84
85    """
86   
87    return Attribute(
88        'uri-authentication-supported',
89        [Value(CharacterStringTags.KEYWORD, val) for val in vals])
90
91def UriSecuritySupported(*vals):
92    """4.4.3 uri-security-supported (1setOf type2 keyword)
93
94    This REQUIRED Printer attribute MUST have the same cardinality
95    (contain the same number of values) as the 'printer-uri-supported'
96    attribute. This attribute identifies the security mechanisms used
97    for each URI listed in the 'printer-uri-supported' attribute. The
98    'i th' value in 'uri-security-supported' corresponds to the 'i th'
99    value in 'printer-uri-supported' and it describes the security
100    mechanisms used for accessing the Printer object via that URI. See
101    [RFC2910] for more details on security mechanisms.
102
103    The following standard keyword values are defined:
104        'none': There are no secure communication channel protocols in
105                use for the given URI.
106        'ssl3': SSL3 [SSL] is the secure communications channel
107                protocol in use for the given URI.
108        'tls':  TLS [RFC2246] is the secure communications channel
109                protocol in use for the given URI.
110
111    This attribute is orthogonal to the definition of a Client
112    Authentication mechanism. Specifically, 'none' does not exclude
113    Client Authentication. See section 4.4.2.
114
115    """
116   
117    return Attribute(
118        'uri-security-supported',
119        [Value(CharacterStringTags.KEYWORD, val) for val in vals])
120
121def PrinterName(val):
122    """4.4.4 printer-name (name(127))
123
124    This REQUIRED Printer attribute contains the name of the Printer
125    object. It is a name that is more end-user friendly than a URI. An
126    administrator determines a printer's name and sets this attribute
127    to that name. This name may be the last part of the printer's URI
128    or it may be unrelated. In non-US-English locales, a name may
129    contain characters that are not allowed in a URI.
130
131    """
132   
133    return Attribute(
134        'printer-name',
135        [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)])
136
137def PrinterLocation(val):
138    """4.4.5 printer-location (text(127))
139
140    """
141
142    raise ClientErrorAttributes, "printer-location"
143
144def PrinterInfo(val):
145    """4.4.6 printer-info (text(127))
146
147    """
148
149    raise ClientErrorAttributes, "printer-info"
150
151def PrinterMoreInfo(val):
152    """4.4.7 printer-more-info (uri)
153
154    """
155
156    raise ClientErrorAttributes, "printer-more-info"
157
158def PrinterDriverInstaller(val):
159    """4.4.8 printer-driver-installer (uri)
160
161    """
162
163    raise ClientErrorAttributes, "printer-driver-installer"
164
165def PrinterMakeAndModel(val):
166    """4.4.9 printer-make-and-model (text(127))
167
168    """
169
170    raise ClientErrorAttributes, "printer-make-and-model"
171
172def PrinterMoreInfoManufacturer(val):
173    """4.4.10 printer-more-info-manufacturer (uri)
174
175    """
176
177    raise ClientErrorAttributes, "printer-more-info-manufacturer"
178
179def PrinterState(val):
180    """4.4.11 printer-state (type1 enum)
181
182    This REQUIRED Printer attribute identifies the current state of
183    the device. The 'printer-state reasons' attribute augments the
184    'printer-state' attribute to give more detailed information about
185    the Printer in the given printer state.
186
187    A Printer object need only update this attribute before responding
188    to an operation which requests the attribute; the Printer object
189    NEED NOT update this attribute continually, since asynchronous
190    event notification is not part of IPP/1.1. A Printer NEED NOT
191    implement
192
193    """
194   
195    return Attribute(
196        'printer-state',
197        [Value(IntegerTags.ENUM, val)])
198
199def PrinterStateReasons(*vals):
200    """4.4.12 printer-state-reasons (1setOf type2 keyword)
201
202    This REQUIRED Printer attribute supplies additional detail about
203    the device's state. Some of the these value definitions indicate
204    conformance requirements; the rest are OPTIONAL.
205
206    Each keyword value MAY have a suffix to indicate its level of
207    severity. The three levels are: report (least severe), warning,
208    and error (most severe).
209
210    """
211   
212    return Attribute(
213        'printer-state-reasons',
214        [Value(CharacterStringTags.KEYWORD, val) for val in vals])
215
216def PrinterStateMessage(val):
217    """4.4.13 printer-state-message (text(MAX))
218
219    """
220
221    raise ClientErrorAttributes, "printer-state-message"
222
223def IppVersionsSupported(*vals):
224    """4.4.14 ipp-versions-supported (1setOf type2 keyword)
225
226    This REQUIRED attribute identifies the IPP protocol version(s)
227    that this Printer supports, including major and minor versions,
228    i.e., the version numbers for which this Printer implementation
229    meets the conformance requirements. For version number validation,
230    the Printer matches the (two-octet binary) 'version-number'
231    parameter supplied by the client in each request (see sections
232    3.1.1 and 3.1.8) with the (US-ASCII) keyword values of this
233    attribute.
234
235    The following standard keyword values are defined:
236
237    '1.0': Meets the conformance requirement of IPP version 1.0 as
238           specified in RFC 2566 [RFC2566] and RFC 2565 [RFC2565]
239           including any extensions registered according to Section 6
240           and any extension defined in this version or any future
241           version of the IPP 'Model and Semantics' document or the
242           IPP 'Encoding and Transport' document following the rules,
243           if any, when the 'version-number' parameter is '1.0'.
244
245    '1.1': Meets the conformance requirement of IPP version 1.1 as
246           specified in this document and [RFC2910] including any
247           extensions registered according to Section 6 and any
248           extension defined in any future versions of the IPP 'Model
249           and Semantics' document or the IPP Encoding and Transport
250           document following the rules, if any, when the
251           'version-number' parameter is '1.1'.
252
253    """
254   
255    return Attribute(
256        'ipp-versions-supported',
257        [Value(CharacterStringTags.KEYWORD, val) for val in vals])
258
259def OperationsSupported(*vals):
260    """4.4.15 operations-supported (1setOf type2 enum)
261
262    This REQUIRED Printer attribute specifies the set of supported
263    operations for this Printer object and contained Job objects.
264    This attribute is encoded as any other enum attribute syntax
265    according to [RFC2910] as 32-bits. However, all 32-bit enum values
266    for this attribute MUST NOT exceed 0x00008FFF, since these same
267    values are also passed in two octets in the 'operation-id'
268    parameter (see section 3.1.1) in each Protocol request with the
269    two high order octets omitted in order to indicate the operation
270    being performed [RFC2910].
271
272    """
273   
274    return Attribute(
275        'operations-supported',
276        [Value(IntegerTags.ENUM, val) for val in vals])
277
278def MultipleDocumentJobsSupported(val):
279    """4.4.16 multiple-document-jobs-supported (boolean)
280
281    This Printer attribute indicates whether or not the Printer
282    supports more than one document per job, i.e., more than one
283    Send-Document or Send-Data operation with document data. If the
284    Printer supports the Create-Job and Send-Document operations (see
285    section 3.2.4 and 3.3.1), it MUST support this attribute.
286
287    """
288   
289    return Attribute(
290        'multiple-document-jobs-supported',
291        [Value(IntegerTags.BOOLEAN, val)])
292
293def CharsetConfigured(val):
294    """4.4.17 charset-configured (charset)
295
296    This REQUIRED Printer attribute identifies the charset that the
297    Printer object has been configured to represent 'text' and 'name'
298    Printer attributes that are set by the operator, system
299    administrator, or manufacturer, i.e., for 'printer-name' (name),
300    'printer-location' (text), 'printer-info' (text), and
301    'printer-make- and-model' (text). Therefore, the value of the
302    Printer object's 'charset-configured' attribute MUST also be among
303    the values of the Printer object's 'charset-supported' attribute.
304
305    """
306   
307    return Attribute(
308        'charset-configured',
309        [Value(CharacterStringTags.CHARSET, val)])
310
311def CharsetSupported(*vals):
312    """4.4.18 charset-supported (1setOf charset)
313
314    This REQUIRED Printer attribute identifies the set of charsets
315    that the Printer and contained Job objects support in attributes
316    with attribute syntax 'text' and 'name'. At least the value
317    'utf-8' MUST be present, since IPP objects MUST support the UTF-8
318    [RFC2279] charset. If a Printer object supports a charset, it
319    means that for all attributes of syntax 'text' and 'name' the IPP
320    object MUST (1) accept the charset in requests and return the
321    charset in responses as needed.
322
323    If more charsets than UTF-8 are supported, the IPP object MUST
324    perform charset conversion between the charsets as described in
325    Section 3.1.4.2.
326
327    """
328   
329    return Attribute(
330        'charset-supported',
331        [Value(CharacterStringTags.CHARSET, val) for val in vals])
332
333def NaturalLanguageConfigured(val):
334    """4.4.19 natural-language-configured (naturalLanguage)
335
336    This REQUIRED Printer attribute identifies the natural language
337    that the Printer object has been configured to represent 'text'
338    and 'name' Printer attributes that are set by the operator, system
339    administrator, or manufacturer, i.e., for 'printer-name' (name),
340    'printer-location' (text), 'printer-info' (text), and
341    'printer-make- and-model' (text). When returning these Printer
342    attributes, the Printer object MAY return them in the configured
343    natural language specified by this attribute, instead of the
344    natural language requested by the client in the
345    'attributes-natural-language' operation attribute. See Section
346    3.1.4.1 for the specification of the OPTIONAL multiple natural
347    language support. Therefore, the value of the Printer object's
348    'natural-language-configured' attribute MUST also be among the
349    values of the Printer object's 'generated-natural-
350    language-supported' attribute.
351
352    """
353   
354    return Attribute(
355        'natural-language-configured',
356        [Value(CharacterStringTags.NATURAL_LANGUAGE, val)])
357
358def GeneratedNaturalLanguageSupported(*vals):
359    """4.4.20 generated-natural-language-supported (1setOf naturalLanguage)
360
361    This REQUIRED Printer attribute identifies the natural language(s)
362    that the Printer object and contained Job objects support in
363    attributes with attribute syntax 'text' and 'name'. The natural
364    language(s) supported depends on implementation and/or
365    configuration.  Unlike charsets, IPP objects MUST accept requests
366    with any natural language or any Natural Language Override whether
367    the natural language is supported or not.
368
369    If a Printer object supports a natural language, it means that for
370    any of the attributes for which the Printer or Job object
371    generates messages, i.e., for the 'job-state-message' and
372    'printer-state- message' attributes and Operation Messages (see
373    Section 3.1.5) in operation responses, the Printer and Job objects
374    MUST be able to generate messages in any of the Printer's
375    supported natural languages. See section 3.1.4 for the definition
376    of 'text' and 'name' attributes in operation requests and
377    responses.
378
379    Note: A Printer object that supports multiple natural languages,
380    often has separate catalogs of messages, one for each natural
381    language supported.
382
383    """
384   
385    return Attribute(
386        'generated-natural-language-supported',
387        [Value(CharacterStringTags.NATURAL_LANGUAGE, val) for val in vals])
388
389def DocumentFormatDefault(val):
390    """4.4.21 document-format-default (mimeMediaType)
391
392    This REQUIRED Printer attribute identifies the document format
393    that the Printer object has been configured to assume if the
394    client does not supply a 'document-format' operation attribute in
395    any of the operation requests that supply document data. The
396    standard values for this attribute are Internet Media types
397    (sometimes called MIME types). For further details see the
398    description of the 'mimeMediaType' attribute syntax in Section
399    4.1.9.
400
401    """
402   
403    return Attribute(
404        'document-format-default',
405        [Value(CharacterStringTags.MIME_MEDIA_TYPE, val)])
406
407def DocumentFormatSupported(*vals):
408    """4.4.22 document-format-supported (1setOf mimeMediaType)
409
410    This REQUIRED Printer attribute identifies the set of document
411    formats that the Printer object and contained Job objects can
412    support. For further details see the description of the
413    'mimeMediaType' attribute syntax in Section 4.1.9.
414
415    """
416   
417    return Attribute(
418        'document-format-supported',
419        [Value(CharacterStringTags.MIME_MEDIA_TYPE, val) for val in vals])
420
421def PrinterIsAcceptingJobs(val):
422    """4.4.23 printer-is-accepting-jobs (boolean)
423
424    This REQUIRED Printer attribute indicates whether the printer is
425    currently able to accept jobs, i.e., is accepting Print-Job,
426    Print- URI, and Create-Job requests. If the value is 'true', the
427    printer is accepting jobs. If the value is 'false', the Printer
428    object is currently rejecting any jobs submitted to it. In this
429    case, the Printer object returns the
430    'server-error-not-accepting-jobs' status code.
431
432    This value is independent of the 'printer-state' and
433    'printer-state- reasons' attributes because its value does not
434    affect the current job; rather it affects future jobs. This
435    attribute, when 'false', causes the Printer to reject jobs even
436    when the 'printer-state' is 'idle' or, when 'true', causes the
437    Printer object to accepts jobs even when the 'printer-state' is
438    'stopped'.
439
440    """
441   
442    return Attribute(
443        'printer-is-accepting-jobs',
444        [Value(IntegerTags.BOOLEAN, val)])
445
446def QueuedJobCount(val):
447    """4.4.24 queued-job-count (integer(0:MAX))
448
449    This REQUIRED Printer attribute contains a count of the number of
450    jobs that are either 'pending', 'processing', 'pending-held', or
451    'processing-stopped' and is set by the Printer object.
452
453    """
454   
455    return Attribute(
456        'queued-job-count',
457        [Value(IntegerTags.INTEGER, val)])
458
459def PrinterMessageFromOperator(val):
460    """4.4.25 printer-message-from-operator (text(127))
461
462    """
463
464    raise ClientErrorAttributes, "printer-message-from-operator"
465
466def ColorSupported(val):
467    """4.4.26 color-supported (boolean)
468
469    """
470
471    raise ClientErrorAttributes, "color-supported"
472   
473def ReferenceUriSchemeSupported(val):
474    """4.4.27 reference-uri-schemes-supported (1setOf uriScheme)
475
476    """
477
478    raise ClientErrorAttributes, "reference-uri-scheme-supported"
479
480def PdlOverrideSupported(val):
481    """4.4.28 pdl-override-supported (type2 keyword)
482
483    This REQUIRED Printer attribute expresses the ability for a
484    particular Printer implementation to either attempt to override
485    document data instructions with IPP attributes or not.  This
486    attribute takes on the following keyword values:
487
488    - 'attempted': This value indicates that the Printer object
489      attempts to make the IPP attribute values take precedence over
490      embedded instructions in the document data, however there is no
491      guarantee.
492
493    - 'not-attempted': This value indicates that the Printer object
494      makes no attempt to make the IPP attribute values take
495      precedence over embedded instructions in the document data.
496
497    Section 15 contains a full description of how this attribute
498    interacts with and affects other IPP attributes, especially the
499    'ipp-attribute-fidelity' attribute.
500
501    """
502   
503    return Attribute(
504        'pdl-override-supported',
505        [Value(CharacterStringTags.KEYWORD, val)])
506
507def PrinterUpTime(val):
508    """4.4.29 printer-up-time (integer(1:MAX))
509
510    This REQUIRED Printer attribute indicates the amount of time (in
511    seconds) that this Printer instance has been up and running. The
512    value is a monotonically increasing value starting from 1 when the
513    Printer object is started-up (initialized, booted, etc.). This
514    value is used to populate the Event Time Job Description Job
515    attributes 'time-at-creation', 'time-at-processing', and
516    'time-at-completed' (see section 4.3.14).
517
518    If the Printer object goes down at some value 'n', and comes back
519    up, the implementation MAY:
520
521        1. Know how long it has been down, and resume at some value
522           greater than 'n', or
523
524        2. Restart from 1.
525
526    In other words, if the device or devices that the Printer object
527    is representing are restarted or power cycled, the Printer object
528    MAY continue counting this value or MAY reset this value to 1
529    depending on implementation. However, if the Printer object
530    software ceases running, and restarts without knowing the last
531    value for 'printer- up-time', the implementation MUST reset this
532    value to 1. If this value is reset and the Printer has persistent
533    jobs, the Printer MUST reset the 'time-at-xxx(integer) Event Time
534    Job Description attributes according to Section 4.3.14. An
535    implementation MAY use both implementation alternatives, depending
536    on warm versus cold start, respectively.
537
538    """
539   
540    return Attribute(
541        'printer-up-time',
542        [Value(IntegerTags.INTEGER, val)])
543
544def PrinterCurrentTime(val):
545    """4.4.30 printer-current-time (dateTime)
546
547    """
548
549    raise ClientErrorAttributes, "printer-current-time"
550
551def MultipleOperationTimeOut(val):
552    """4.4.31 multiple-operation-time-out (integer(1:MAX))
553
554    This Printer attributes identifies the minimum time (in seconds)
555    that the Printer object waits for additional Send-Document or
556    Send-URI operations to follow a still-open Job object before
557    taking any recovery actions, such as the ones indicated in section
558    3.3.1. If the Printer object supports the Create-Job and
559    Send-Document operations (see section 3.2.4 and 3.3.1), it MUST
560    support this attribute.
561
562    It is RECOMMENDED that vendors supply a value for this attribute
563    that is between 60 and 240 seconds. An implementation MAY allow a
564    system administrator to set this attribute (by means outside this
565    IPP/1.1 document). If so, the system administrator MAY be able to
566    set values outside this range.
567
568    """
569   
570    return Attribute(
571        'multiple-operation-time-out',
572        [Value(IntegerTags.INTEGER, val)])
573
574def CompressionSupported(*vals):
575    """4.4.32 compression-supported (1setOf type3 keyword)
576
577    This REQUIRED Printer attribute identifies the set of supported
578    compression algorithms for document data. Compression only applies
579    to the document data; compression does not apply to the encoding
580    of the IPP operation itself. The supported values are used to
581    validate the client supplied 'compression' operation attributes in
582    Print-Job, Send-Document, and Send-URI requests.
583
584    Standard keyword values are :
585        'none': no compression is used.
586        'deflate': ZIP public domain inflate/deflate) compression
587            technology in RFC 1951 [RFC1951]
588        'gzip' GNU zip compression technology described in RFC 1952
589            [RFC1952].
590        'compress': UNIX compression technology in RFC 1977 [RFC1977]
591
592    """
593   
594    return Attribute(
595        'compression-supported',
596        [Value(CharacterStringTags.KEYWORD, val) for val in vals])
597
598def JobKOctetsSupported(val):
599    """4.4.33 job-k-octets-supported (rangeOfInteger(0:MAX))
600
601    """
602
603    raise ClientErrorAttributes, "job-k-octets-supported"
604
605def JobImpressionsSupported(val):
606    """4.4.34 job-impressions-supported (rangeOfInteger(0:MAX))
607
608    """
609
610    raise ClientErrorAttributes, "job-impressions-supported"
611
612def JobMediaSheetsSupported(val):
613    """4.4.35 job-media-sheets-supported (rangeOfInteger(0:MAX))
614
615    """
616
617    raise ClientErrorAttributes, "job-media-sheets-supported"
618
619def PagesPerMinute(val):
620    """4.4.36 pages-per-minute (integer(0:MAX))
621
622    """
623
624    raise ClientErrorAttributes, "pages-per-minute"
625
626def PagesPerMinuteColor(val):
627    """4.4.37 pages-per-minute-color (integer(0:MAX))
628
629    """
630
631    raise ClientErrorAttributes, "pages-per-minute-color"
632   
Note: See TracBrowser for help on using the repository browser.