source: server/lib/gutenbach/ipp/constants.py @ 94a4825

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

Add handler decorators for other handlers and throw an exception if they're not implemented; add documentation for create-job handler

  • Property mode set to 100644
File size: 10.5 KB
Line 
1class Misc():
2    """Miscellaneous config options for the IPP server.
3   
4    """
5   
6    IPP_VERSION = "1.1"
7    IPP_PORT = 8000
8
9    def __init__(self): pass
10
11class JobStates():
12    """Job state codes, as defined by RFC 2911, Section 4.3.7
13   
14    """
15   
16    PENDING    = 3
17    HELD       = 4
18    PROCESSING = 5
19    STOPPED    = 6
20    CANCELLED  = 7
21    ABORTED    = 8
22    COMPLETE   = 9
23
24    def __init__(self): pass
25
26class PrinterStates():
27    """Printer state codes, as defined by RFC 2911, Section 4.4.11
28   
29    """
30
31    IDLE       = 3
32    PROCESSING = 4
33    STOPPED    = 5
34
35    def __init__(self): pass
36
37class Operations():
38    """IPP and CUPS IPP Operations, as defined in various RFCs:
39
40        0x0002 - 0x0012      RFC 2911 (Section 4.4.15)
41        0x0013 - 0x0015      RFC 3380 (Section 4)
42        0x0016 - 0x001b      RFC 3995 (Section 7.1)
43        0x0022 - 0x0031      RFC 3998 (Section 14.3)
44        0x4000 - 0x4027      CUPS IPP Actions
45       
46    """
47
48    # These are defined in RFC 2911, Section 4.4.15
49    PRINT_JOB              = 0x0002
50    PRINT_URI              = 0x0003
51    VALIDATE_JOB           = 0x0004
52    CREATE_JOB             = 0x0005
53    SEND_DOCUMENT          = 0x0006
54    SEND_URI               = 0x0007
55    CANCEL_JOB             = 0x0008
56    GET_JOB_ATTRIBUTES     = 0x0009
57    GET_JOBS               = 0x000a
58    GET_PRINTER_ATTRIBUTES = 0x000b
59    #HOLD_JOB              = 0x000c
60    #RELEASE_JOB           = 0x000d
61    RESTART_JOB            = 0x000e
62    PAUSE_PRINTER          = 0x0010
63    RESUME_PRINTER         = 0x0011
64    #PURGE_JOBS            = 0x0012
65
66    # These are defined in RFC 3380, Section 4
67    SET_PRINTER_ATTRIBUTES           = 0x0013
68    SET_JOB_ATTRIBUTES               = 0x0014
69    #GET_PRINTER_SUPPORTED_VALUES    = 0x0015
70
71    # These are defined in RFC 3995, Section 7.1
72    #CREATE_PRINTER_SUBSCRIPTION     = 0x0016
73    #CREATE_JOB_SUBSCRIPTION         = 0x0017
74    #GET_SUBSCRIPTION_ATTRIBUTES     = 0x0018
75    #GET_SUBSCRIPTIONS               = 0x0019
76    #RENEW_SUBSCRIPTION              = 0x001a
77    #CANCEL_SUBSCRIPTION             = 0x001b
78
79    # These are defined in RFC 3998, Section 14.3
80    #ENABLE_PRINTER                  = 0x0022
81    #DISABLE_PRINTER                 = 0x0023
82    #PAUSE_PRINTER_AFTER_CURRENT_JOB = 0x0024
83    #HOLD_NEW_JOBS                   = 0x0025
84    #RELEASE_HELD_NEW_JOBS           = 0x0026
85    #DEACTIVATE_PRINTER              = 0x0027
86    #ACTIVATE_PRINTER                = 0x0028
87    #RESTART_PRINTER                 = 0x0029
88    #SHUTDOWN_PRINTER                = 0x002a
89    #STARTUP_PRINTER                 = 0x002b
90    #REPROCESS_JOB                   = 0x002c
91    #CANCEL_CURRENT_JOB              = 0x002d
92    #SUSPEND_CURRENT_JOB             = 0x002e
93    #RESUME_JOB                      = 0x002f
94    PROMOTE_JOB                      = 0x0030
95    #SCHEDULE_JOB_AFTER              = 0x0031
96
97    # These are special CUPS actions, defined in:
98    # http://www.cups.org/documentation.php/spec-ipp.html
99    #PRIVATE               = 0x4000
100    CUPS_GET_DEFAULT       = 0x4001
101    CUPS_GET_PRINTERS      = 0x4002
102    #CUPS_ADD_PRINTER      = 0x4003
103    #CUPS_DELETE_PRINTER   = 0x4004
104    CUPS_GET_CLASSES       = 0x4005
105    #CUPS_ADD_CLASS        = 0x4006
106    #CUPS_DELETE_CLASS     = 0x4007
107    #CUPS_ACCEPT_JOBS      = 0x4008
108    #CUPS_REJECT_JOBS      = 0x4009
109    #CUPS_SET_DEFAULT      = 0x400a
110    #CUPS_GET_DEVICES      = 0x400b
111    #CUPS_GET_PPDS         = 0x400c
112    #CUPS_MOVE_JOB         = 0x400d
113    #CUPS_AUTHENTICATE_JOB = 0x400e
114    #CUPS_GET_PPD          = 0x400f
115    CUPS_GET_DOCUMENT      = 0x4027
116
117    def __init__(self): pass
118
119class SuccessCodes():
120    """Success status codes as defined in RFC 2911, Section 13
121   
122    """
123   
124    OK                           = 0x0000
125    OK_SUBST                     = 0x0001
126    OK_CONFLICT                  = 0x0002
127    OK_IGNORED_SUBSCRIPTIONS     = 0x0003
128    OK_IGNORED_NOTIFICATIONS     = 0x0004
129    OK_TOO_MANY_EVENTS           = 0x0005
130    OK_BUT_CANCEL_SUBSCRIPTION   = 0x0006
131
132    def __init__(self): pass
133
134class ClientErrorCodes():
135    """Client error codes as defined in RFC 2911, Section 13
136   
137    """
138   
139    BAD_REQUEST                  = 0x0400
140    FORBIDDEN                    = 0x0401
141    NOT_AUTHENTICATED            = 0x0402
142    NOT_AUTHORIZED               = 0x0403
143    NOT_POSSIBLE                 = 0x0404
144    TIMEOUT                      = 0x0405
145    NOT_FOUND                    = 0x0406
146    GONE                         = 0x0407
147    REQUEST_ENTITY               = 0x0408
148    REQUEST_VALUE                = 0x0409
149    DOCUMENT_FORMAT              = 0x040a
150    ATTRIBUTES                   = 0x040b
151    URI_SCHEME                   = 0x040c
152    CHARSET                      = 0x040d
153    CONFLICT                     = 0x040e
154    COMPRESSION_NOT_SUPPORTED    = 0x040f
155    COMPRESSION_ERROR            = 0x0410
156    DOCUMENT_FORMAT_ERROR        = 0x0411
157    DOCUMENT_ACCESS_ERROR        = 0x0412
158    ATTRIBUTES_NOT_SETTABLE      = 0x0413
159    IGNORED_ALL_SUBSCRIPTIONS    = 0x0414
160    TOO_MANY_SUBSCRIPTIONS       = 0x0415
161    IGNORED_ALL_NOTIFICATIONS    = 0x0416
162    PRINT_SUPPORT_FILE_NOT_FOUND = 0x0417
163
164    def __init__(self): pass
165
166class ServerErrorCodes():
167    """Server error codes as defined in RFC 2911, Section 13
168   
169    """
170
171    INTERNAL_ERROR              = 0x0500
172    OPERATION_NOT_SUPPORTED     = 0x0501
173    SERVICE_UNAVAILABLE         = 0x0502
174    VERSION_NOT_SUPPORTED       = 0x0503
175    DEVICE_ERROR                = 0x0504
176    TEMPORARY_ERROR             = 0x0505
177    NOT_ACCEPTING               = 0x0506
178    PRINTER_BUSY                = 0x0507
179    ERROR_JOB_CANCELLED         = 0x0508
180    MULTIPLE_JOBS_NOT_SUPPORTED = 0x0509
181    PRINTER_IS_DEACTIVATED      = 0x050a
182
183    def __init__(self): pass
184
185class StatusCodes(SuccessCodes, ClientErrorCodes, ServerErrorCodes):
186    pass
187class ErrorCodes(ClientErrorCodes, ServerErrorCodes):
188    pass
189
190class CUPSPrinterType():
191    """Printer types as defined by cups_ptype_e in the CUPS API
192    specification:
193   
194    http://www.cups.org/documentation.php/doc-1.3/api-cups.html#cups_ptype_e
195   
196    """
197
198    LOCAL         = 0x000000
199    CLASS         = 0x000001
200    REMOTE        = 0x000002
201    BW            = 0x000004
202    COLOR         = 0x000008
203
204    DUPLEX        = 0x000010
205    STAPLE        = 0x000020
206    COPIES        = 0x000040
207    COLLATE       = 0x000080
208
209    PUNCH         = 0x000100
210    COVER         = 0x000200
211    BIND          = 0x000400
212    SORT          = 0x000800
213
214    SMALL         = 0x001000
215    MEDIUM        = 0x002000
216    LARGE         = 0x004000
217    VARIABLE      = 0x008000
218
219    IMPLICIT      = 0x010000
220    DEFAULT       = 0x020000
221    FAX           = 0x040000
222    REJECTING     = 0x080000
223
224    DELETE        = 0x100000
225    NOT_SHARED    = 0x200000
226    AUTHENTICATED = 0x400000
227    COMMANDS      = 0x800000
228
229    OPTIONS       = 0x00e6ff
230
231    def __init__(self): pass
232
233class AttributeTags():
234    """Contains constants for the attribute IPP tags, as defined by
235    RFC 2565.
236   
237    """
238   
239    ZERO_NAME_LENGTH   = 0x00
240    OPERATION          = 0x01
241    JOB                = 0x02
242    END                = 0x03
243    PRINTER            = 0x04
244    UNSUPPORTED        = 0x05
245    SUBSCRIPTION       = 0x06
246    EVENT_NOTIFICATION = 0x07
247
248    def __init__(self): pass
249
250class OutOfBandTags():
251    """Contains constants for the out-of-band value IPP tags, as
252    defined by RFC 2565.
253   
254    """
255   
256    UNSUPPORTED      = 0x10
257    DEFAULT          = 0x11
258    UNKNOWN          = 0x12
259    NO_VALUE         = 0x13
260    NOT_SETTABLE     = 0x15
261    DELETE_ATTRIBUTE = 0x16
262    ADMIN_DEFINE     = 0x17
263
264    def __init__(self): pass
265
266class IntegerTags():
267    """Contains constants for the integer value IPP tags, as defined
268    by RFC 2565.
269   
270    """
271   
272    GENERIC = 0x20
273    INTEGER = 0x21
274    BOOLEAN = 0x22
275    ENUM    = 0x23
276
277    def __init__(self): pass
278
279class OctetStringTags():
280    """Contains constants for the octetString value IPP tags, as
281    defined by RFC 2565.
282   
283    """
284   
285    UNSPECIFIED_OCTETSTRING = 0x30
286    DATETIME                = 0x31
287    RESOLUTION              = 0x32
288    RANGE_OF_INTEGER        = 0x33
289    BEG_COLLECTION          = 0x34
290    TEXT_WITH_LANGUAGE      = 0x35
291    NAME_WITH_LANGUAGE      = 0x36
292    END_COLLECTION          = 0x37
293
294    def __init__(self): pass
295
296class CharacterStringTags():
297    """Contains constants for the character-string value IPP tags, as
298    defined by RFC 2565.
299   
300    """
301   
302    GENERIC               = 0x40
303    TEXT_WITHOUT_LANGUAGE = 0x41
304    NAME_WITHOUT_LANGUAGE = 0x42
305    KEYWORD               = 0x44
306    URI                   = 0x45
307    URI_SCHEME            = 0x46
308    CHARSET               = 0x47
309    NATURAL_LANGUAGE      = 0x48
310    MIME_MEDIA_TYPE       = 0x49                                   
311    MEMBER_ATTR_NAME      = 0x4a
312
313class Tags(AttributeTags, OutOfBandTags, IntegerTags, OctetStringTags, CharacterStringTags):
314    pass
315
316operations_attribute_value_tags = {
317    'attributes-charset': CharacterStringTags.CHARSET,
318    'attributes-natural-language': CharacterStringTags.NATURAL_LANGUAGE,
319    'printer-uri': CharacterStringTags.URI,
320    'requesting-user-name': CharacterStringTags.NAME_WITHOUT_LANGUAGE
321    }
322
323job_attribute_value_tags = {
324    'job-id': IntegerTags.INTEGER,
325    'job-name': CharacterStringTags.NAME_WITHOUT_LANGUAGE,
326    'job-originating-user-name': CharacterStringTags.NAME_WITHOUT_LANGUAGE,
327    'job-k-octets': IntegerTags.INTEGER,
328    'job-state': IntegerTags.ENUM,
329    'job-printer-uri': CharacterStringTags.URI
330    }
331
332printer_attribute_value_tags = {
333    "printer-uri-supported": CharacterStringTags.URI,
334    "uri-authentication-supported": CharacterStringTags.KEYWORD,
335    "uri-security-supported": CharacterStringTags.KEYWORD,
336    "printer-name": CharacterStringTags.NAME_WITHOUT_LANGUAGE,
337    "printer-state": IntegerTags.ENUM,
338    "printer-state-reasons": CharacterStringTags.KEYWORD,
339    "ipp-versions-supported": CharacterStringTags.KEYWORD,
340    "operations-supported": IntegerTags.ENUM,
341    "charset-configured": CharacterStringTags.CHARSET,
342    "charset-supported": CharacterStringTags.CHARSET,
343    "natural-language-configured": CharacterStringTags.NATURAL_LANGUAGE,
344    "generated-natural-language-supported": CharacterStringTags.NATURAL_LANGUAGE,
345    "document-format-default": CharacterStringTags.MIME_MEDIA_TYPE,
346    "document-format-supported": CharacterStringTags.MIME_MEDIA_TYPE,
347    "printer-is-accepting-jobs": IntegerTags.BOOLEAN,
348    "queued-job-count": IntegerTags.INTEGER,
349    "pdl-override-supported": CharacterStringTags.KEYWORD,
350    "printer-up-time": IntegerTags.INTEGER,
351    "compression-supported": CharacterStringTags.KEYWORD
352    }
353   
Note: See TracBrowser for help on using the repository browser.