Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/lib/gutenbach/server/requests.py

    rd994f15 rc1dc25f  
    268268    @handler_for(ipp.OperationCodes.PRINT_URI)
    269269    def print_uri(self, request, response):
     270        """3.2.2 Print-URI Operation
     271
     272        This OPTIONAL operation is identical to the Print-Job operation
     273        (section 3.2.1) except that a client supplies a URI reference to the
     274        document data using the 'document-uri' (uri) operation attribute (in
     275        Group 1) rather than including the document data itself.  Before
     276        returning the response, the Printer MUST validate that the Printer
     277        supports the retrieval method (e.g., http, ftp, etc.) implied by the
     278        URI, and MUST check for valid URI syntax.  If the client-supplied URI
     279        scheme is not supported, i.e. the value is not in the Printer
     280        object's 'referenced-uri-scheme-supported' attribute, the Printer
     281        object MUST reject the request and return the 'client-error-uri-
     282        scheme-not-supported' status code.
     283
     284        The IPP Printer MAY validate the accessibility of the document as
     285        part of the operation or subsequently.  If the Printer determines an
     286        accessibility problem before returning an operation response, it
     287        rejects the request and returns the 'client-error-document-access-
     288        error' status code.  The Printer MAY also return a specific document
     289        access error code using the 'document-access-error' operation
     290        attribute (see section 3.1.6.4).
     291
     292        If the Printer determines this document accessibility problem after
     293        accepting the request and returning an operation response with one
     294        of the successful status codes, the Printer adds the
     295        'document-access- error' value to the job's 'job-state-reasons'
     296        attribute and MAY populate the job's 'job-document-access-errors'
     297        Job Description attribute (see section 4.3.11).  See The
     298        Implementer's Guide [IPP- IIG] for suggested additional checks.
     299                                                                             
     300        If the Printer object supports this operation, it MUST support the
     301        'reference-uri-schemes-supported' Printer attribute (see section 4.4.27).
     302
     303        It is up to the IPP object to interpret the URI and subsequently
     304        'pull' the document from the source referenced by the URI string."""
    270305        raise ipp.errors.ServerErrorOperationNotSupported
    271306
     
    364399    @handler_for(ipp.OperationCodes.PAUSE_PRINTER)
    365400    def pause_printer(self, request, response):
     401        """
     402            3.2.7 Pause-Printer Operation
     403
     404            This OPTIONAL operation allows a client to stop the Printer object
     405            from scheduling jobs on all its devices.  Depending on
     406            implementation, the Pause-Printer operation MAY also stop the Printer
     407            from processing the current job or jobs.  Any job that is currently
     408            being printed is either stopped as soon as the implementation permits
     409            or is completed, depending on implementation.  The Printer object
     410            MUST still accept create operations to create new jobs, but MUST
     411            prevent any jobs from entering the 'processing' state.
     412
     413            If the Pause-Printer operation is supported, then the Resume-Printer
     414            operation MUST be supported, and vice-versa.
     415
     416            The IPP Printer stops the current job(s) on its device(s) that were
     417            in the 'processing' or 'processing-stopped' states as soon as the
     418            implementation permits.  If the implementation will take appreciable
     419            time to stop, the IPP Printer adds the 'moving-to-paused' value to
     420            the Printer object's 'printer-state-reasons' attribute (see section
     421            4.4.12).  When the device(s) have all stopped, the IPP Printer
     422            transitions the Printer object to the 'stopped' state, removes the
     423            'moving-to-paused' value, if present, and adds the 'paused' value to
     424            the Printer object's 'printer-state-reasons' attribute.
     425
     426            When the current job(s) complete that were in the 'processing' state,
     427            the IPP Printer transitions them to the 'completed' state.  When the
     428            current job(s) stop in mid processing that were in the 'processing'
     429            state, the IPP Printer transitions them to the 'processing-stopped'
     430            state and adds the 'printer-stopped' value to the job's 'job-state-
     431            reasons' attribute.
     432
     433            For any jobs that are 'pending' or 'pending-held', the 'printer-
     434            stopped' value of the jobs' 'job-state-reasons' attribute also
     435            applies.  However, the IPP Printer NEED NOT update those jobs' 'job-
     436            state-reasons' attributes and only need return the 'printer-stopped'
     437            value when those jobs are queried (so-called 'lazy evaluation').
     438
     439            Whether the Pause-Printer operation affects jobs that were submitted
     440            to the device from other sources than the IPP Printer object in the
     441            same way that the Pause-Printer operation affects jobs that were
     442            submitted to the IPP Printer object using IPP, depends on
     443            implementation, i.e., on whether the IPP protocol is being used as a
     444            universal management protocol or just to manage IPP jobs,
     445            respectively.
     446
     447            The IPP Printer MUST accept the request in any state and transition
     448            the Printer to the indicated new 'printer-state' before returning as
     449            follows:
     450
     451            Current        New      'printer   IPP Printer's response status
     452            'printer-    'printer-   -state-          code and action:
     453            state'       state'    reasons'
     454
     455            'idle'       'stopped'    'paused'  'successful-ok'
     456            'processing' 'processing' 'moving-  OPTION 1: 'successful-ok';
     457                                                      to-       Later, when all output has
     458                                                      paused'   stopped, the 'printer-state'
     459                                                                            becomes 'stopped', and the
     460                                                                            'paused' value replaces the
     461                                                                            'moving-to-paused' value in the
     462                                                                            'printer-state-reasons'
     463                                                                            attribute
     464            'processing' 'stopped'    'paused'  OPTION 2: 'successful-ok';
     465                                                                            all device output stopped
     466                                                                            immediately
     467            'stopped'    'stopped'    'paused'  'successful-ok'
     468
     469            Access Rights: The authenticated user (see section 8.3) performing
     470            this operation must be an operator or administrator of the Printer
     471            object (see Sections 1 and 8.5).   Otherwise, the IPP Printer MUST
     472            reject the operation and return:  'client-error-forbidden', 'client-
     473            error-not-authenticated', or 'client-error-not-authorized' as
     474            appropriate.
     475
     476            3.2.7.1 Pause-Printer Request
     477
     478            The following groups of attributes are part of the Pause-Printer
     479            Request:
     480
     481            Group 1: Operation Attributes
     482
     483            Natural Language and Character Set:
     484            The 'attributes-charset' and 'attributes-natural-language'
     485            attributes as described in section 3.1.4.1.
     486
     487            Target:
     488            The 'printer-uri' (uri) operation attribute which is the target
     489            for this operation as described in section 3.1.5.
     490
     491            Requesting User Name:
     492            The 'requesting-user-name' (name(MAX)) attribute SHOULD be
     493            supplied by the client as described in section 8.3.
     494
     495            3.2.7.2 Pause-Printer Response
     496
     497            The following groups of attributes are part of the Pause-Printer
     498            Response:
     499
     500            Group 1: Operation Attributes
     501
     502            Status Message:
     503            In addition to the REQUIRED status code returned in every
     504            response, the response OPTIONALLY includes a 'status-message'
     505            (text(255)) and/or a 'detailed-status-message' (text(MAX))
     506            operation attribute as described in sections 13 and  3.1.6.
     507
     508            Natural Language and Character Set:
     509            The 'attributes-charset' and 'attributes-natural-language'
     510            attributes as described in section 3.1.4.2.
     511
     512            Group 2: Unsupported Attributes
     513
     514            See section 3.1.7 for details on returning Unsupported Attributes.
     515
     516   
     517    """
    366518        raise ipp.errors.ServerErrorOperationNotSupported
    367519
    368520    @handler_for(ipp.OperationCodes.RESUME_PRINTER)
    369521    def resume_printer(self, request, response):
     522        """
     523        3.2.8 Resume-Printer Operation
     524
     525        This operation allows a client to resume the Printer object
     526        scheduling jobs on all its devices.  The Printer object MUST remove
     527        the 'paused' and 'moving-to-paused' values from the Printer object's
     528        'printer-state-reasons' attribute, if present.  If there are no other
     529        reasons to keep a device paused (such as media-jam), the IPP Printer
     530        is free to transition itself to the 'processing' or 'idle' states,
     531        depending on whether there are jobs to be processed or not,
     532        respectively, and the device(s) resume processing jobs.
     533
     534        If the Pause-Printer operation is supported, then the Resume-Printer
     535        operation MUST be supported, and vice-versa.
     536
     537        The IPP Printer removes the 'printer-stopped' value from any job's
     538        'job-state-reasons' attributes contained in that Printer.
     539
     540        The IPP Printer MUST accept the request in any state, transition the
     541        Printer object to the indicated new state as follows:
     542
     543
     544        Current    New 'printer-  IPP Printer's response status code and
     545        'printer-      state'                     action:
     546        state'
     547
     548        'idle'       'idle'         'successful-ok'
     549        'processing' 'processing'   'successful-ok'
     550
     551        'stopped'    'processing'   'successful-ok';
     552                                                   when there are jobs to be processed
     553        'stopped'    'idle'         'successful-ok';
     554                                                   when there are no jobs to be processed.
     555
     556        Access Rights: The authenticated user (see section 8.3) performing
     557        this operation must be an operator or administrator of the Printer
     558        object (see Sections 1 and 8.5).  Otherwise, the IPP Printer MUST
     559        reject the operation and return:  'client-error-forbidden', 'client-
     560        error-not-authenticated', or 'client-error-not-authorized' as
     561        appropriate.
     562
     563        The Resume-Printer Request and Resume-Printer Response have the same
     564        attribute groups and attributes as the Pause-Printer operation (see
     565        sections 3.2.7.1 and 3.2.7.2).                 
     566        """
    370567        raise ipp.errors.ServerErrorOperationNotSupported
    371568
     
    442639    @handler_for(ipp.OperationCodes.SET_PRINTER_ATTRIBUTES)
    443640    def set_printer_attributes(self, request, response):
     641
    444642        raise ipp.errors.ServerErrorOperationNotSupported
    445643
     
    699897    @handler_for(ipp.OperationCodes.SEND_URI)
    700898    def send_uri(self, request, response):
    701         raise ipp.errors.ServerErrorOperationNotSupported
     899
     900        """3.2.2 Send URI
     901
     902        This OPTIONAL operation is identical to the Send-Document
     903        operation (see section 3.3.1) except that a client MUST supply
     904        a URI reference ('document-uri' operation attribute) rather
     905        than the document data itself.  If a Printer object supports
     906        this operation, clients can use both Send-URI or Send-Document
     907        operations to add new documents to an existing multi-document
     908        Job object.  However, if a client needs to indicate that the
     909        previous Send-URI or Send-Document was the last document, the
     910        client MUST use the Send-Document operation with no document
     911        data and the 'last-document' flag set to 'true' (rather than
     912        using a Send-URI operation with no 'document-uri' operation
     913        attribute).
     914
     915        If a Printer object supports this operation, it MUST also
     916        support the Print-URI operation (see section 3.2.2).
     917
     918        The Printer object MUST validate the syntax and URI scheme of
     919        the supplied URI before returning a response, just as in the
     920        Print-URI operation.  The IPP Printer MAY validate the
     921        accessibility of the document as part of the operation or
     922        subsequently (see section 3.2.2).
     923
     924        Request
     925        -------
     926
     927        Group 1: Operation Attributes
     928            REQUIRED 'attributes-charset'
     929            REQUIRED 'attributes-natural-language'
     930            REQUIRED 'job-id' (integer(1:MAX)) and 'printer-uri' (uri)
     931            REQUIRED 'document-uri' (uri)
     932            OPTIONAL 'job-uri' (uri)
     933            OPTIONAL 'requesting-user-name' (name(MAX))
     934            OPTIONAL 'document-name' (name(MAX))
     935            OPTIONAL 'compression' (type3 keyword)
     936            OPTIONAL 'document-format' (mimeMediaType)
     937            OPTIONAL 'document-natural-language' (naturalLanguage)
     938           
     939        Response
     940        --------
     941
     942        Group 1: Operation Attributes
     943            OPTIONAL 'status-message' (text(255))
     944            OPTIONAL 'detailed-status-message' (text(MAX))
     945            REQUIRED 'attributes-charset'
     946            REQUIRED 'attributes-natural-language'
     947        Group 2: Unsupported Attributes
     948        Group 3: Job Object Attributes
     949            REQUIRED 'job-uri' (uri)
     950            REQUIRED 'job-id' (integer(1:MAX))
     951            REQUIRED 'job-state' (type1 enum)
     952            REQUIRED 'job-state-reasons' (1setOf type2 keyword)
     953            OPTIONAL 'job-state-message' (text(MAX))
     954            OPTIONAL 'number-of-intervening-jobs' (integer(0:MAX))
     955
     956        """
     957       
     958        operation = request.attribute_groups[0]
     959
     960        job_id = None
     961        printer_uri = None
     962        requesting_user_name = None
     963        document_name = None
     964        compression = None
     965        document_format = None
     966        document_natural_language = None
     967        last_document = None
     968
     969        # required attributes
     970        if 'job-id' not in operation:
     971            raise ipp.errors.ClientErrorBadRequest("Missing 'job-id' attribute")
     972        job_id = verify_attribute(operation['job-id'], ipp.JobId)[0]
     973
     974        if 'last-document' not in operation:
     975            raise ipp.errors.ClientErrorBadRequest("Missing 'last-document' attribute")
     976        last_document = verify_attribute(operation['last-document'], ipp.LastDocument)[0]
     977
     978        if 'document-uri' not in operation:
     979            raise ipp.errors.ClientErrorBadRequest("Missing 'document-uri' attribute")
     980        document_uri = verify_attribute(operation['document-uri'], ipp.DocumentUri)[0]
     981        if not last_document:
     982            raise ipp.errors.ServerErrorMultipleJobsNotSupported
     983
     984        # optional attributes
     985        if 'printer-uri' in operation:
     986            printer_uri = verify_attribute(operation['printer-uri'], ipp.PrinterUri)[0]
     987            if printer_uri not in self.printer.uris:
     988                raise ipp.errors.ClientErrorAttributes(
     989                    str(operation['printer-uri']), operation['printer-uri'])
     990
     991        if 'requesting-user-name' in operation:
     992            user_name = verify_attribute(
     993                operation['requesting-user-name'], ipp.RequestingUserName)[0]
     994
     995        if 'document-name' in operation:
     996            document_name = verify_attribute(
     997                operation['document-name'], ipp.DocumentName)[0]
     998
     999        if 'compression' in operation:
     1000            compression = verify_attribute(
     1001                operation['compression'], ipp.Compression)[0]
     1002
     1003        if 'document-format' in operation:
     1004            document_format = verify_attribute(
     1005                operation['document-format'], ipp.DocumentFormat)[0]
     1006
     1007        if 'document-natural-language' in operation:
     1008            document_natural_language = verify_attribute(
     1009                operation['document_natural_language'],
     1010                ipp.DocumentNaturalLanguage)[0]
     1011
     1012        try:
     1013            self.printer.send_uri(
     1014                job_id,
     1015                document_uri,
     1016                document_name=document_name,
     1017                document_format=document_format,
     1018                document_natural_language=document_natural_language,
     1019                requesting_user_name=user_name,
     1020                compression=compression,
     1021                last_document=last_document)
     1022            attrs = self.printer.get_job_attributes(job_id)
     1023        except InvalidJobException:
     1024            raise ipp.errors.ClientErrorNotFound("bad job: %d" % job_id)
     1025
     1026        response.attribute_groups.append(ipp.AttributeGroup(
     1027            ipp.AttributeTags.JOB, attrs))
    7021028
    7031029    @handler_for(ipp.OperationCodes.GET_JOB_ATTRIBUTES)
     
    8071133    @handler_for(ipp.OperationCodes.SET_JOB_ATTRIBUTES)
    8081134    def set_job_attributes(self, request, response):
     1135       
    8091136        raise ipp.errors.ServerErrorOperationNotSupported
    8101137
Note: See TracChangeset for help on using the changeset viewer.