cl-ipp

Internet Printing Protocol (IPP) for Common Lisp
git clone https://logand.com/git/cl-ipp.git/
Log | Files | Refs

commit 2f70e1c133ffad7b5d33ca7775b1f3f06185e891
parent b8cb0ca1acac411e0dc1672b36b8288f62f18c70
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sun, 11 Aug 2013 00:39:15 +0200

implemented get-printer-attributes pause-printer purge-jobs resume-printer

Diffstat:
Mipp.lisp | 187+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 170 insertions(+), 17 deletions(-)

diff --git a/ipp.lisp b/ipp.lisp @@ -24,8 +24,12 @@ (:use :cl) (:export :create-job :get-jobs + :get-printer-attributes :list-printers + :pause-printer :print-job + :purge-jobs + :resume-printer :validate-job)) (in-package :ipp) @@ -77,22 +81,34 @@ (:requesting-user-name . :nameWithoutLanguage) (:job-name . :nameWithoutLanguage) (:ipp-attribute-fidelity . :boolean) - (:document-name . nil) - (:document-format . nil) + (:document-name . nil) ;; TODO + (:document-format . nil) ;; TODO (:document-natural-language . :naturalLanguage) - (:compression . nil) - (:job-k-octets . nil) - (:job-impressions . nil) - (:job-media-sheets . nil) + (:compression . nil) ;; TODO + (:job-k-octets . nil) ;; TODO + (:job-impressions . nil) ;; TODO + (:job-media-sheets . nil) ;; TODO (:copies . :integer) (:sides . :keyword) - (:job-uri . nil) - (:job-id . nil) - (:job-state . nil) - (:job-state-reasons . nil) + (:job-uri . :uri) + (:job-id . nil) ;; TODO + (:job-state . nil) ;; TODO + (:job-state-reasons . nil) ;; TODO (:limit . :integer) (:requested-attributes . :keyword) (:status-message . :nameWithoutLanguage) ;; TODO really? + (:marker-change-time . nil) ;; TODO + (:printer-current-time . nil) ;; TODO + (:printer-dns-sd-name . nil) ;; TODO + (:printer-is-accepting-jobs . nil) ;; TODO + (:printer-error-policy . nil) ;; TODO + (:printer-error-policy-supported . nil) ;; TODO + (:job-sheets-default . nil) + (:all . nil) + (:which-jobs . nil) ;; TODO + (:completed . nil) ;; TODO + (:not-completed . nil) ;; TODO + (:my-jobs . nil) ;; TODO ))) (defun attribute-tag (attribute) @@ -119,7 +135,8 @@ (defun read-value (reader tag) (ecase tag - ;; :no-value + (:no-value + (assert (= 0 (rw:next-u16 reader)))) ((:integer :enum) (assert (= 4 (rw:next-u16 reader))) (rw:next-u32 reader)) @@ -127,7 +144,18 @@ (assert (= 1 (rw:next-u16 reader))) (not (zerop (rw:next-u32 reader)))) ;; :octetString - ;; :dateTime + (:dateTime + (assert (= 11 (rw:next-u16 reader))) + `(:dateTime ,(rw:next-u16 reader) + ,(rw:next-u8 reader) + ,(rw:next-u8 reader) + ,(rw:next-u8 reader) + ,(rw:next-u8 reader) + ,(rw:next-u8 reader) + ,(rw:next-u8 reader) + ,(rw:next-u8 reader) + ,(rw:next-u8 reader) + ,(rw:next-u8 reader))) ;; :resolution ;; :rangeOfInteger ((:textWithLanguage @@ -428,8 +456,13 @@ &key (attributes-charset "utf-8") (attributes-natural-language "en") + (requesting-user-name (user-name)) limit - requested-attributes) + requested-attributes + which-jobs + completed + not-completed + my-jobs) (ipp ipp-client printer-uri request-file @@ -441,16 +474,108 @@ :attributes-charset ,attributes-charset :attributes-natural-language ,attributes-natural-language :printer-uri ,printer-uri + :requesting-user-name ,requesting-user-name + :limit ,limit + :requested-attributes ,requested-attributes + :which-jobs ,which-jobs + :completed ,completed + :not-completed ,not-completed + :my-jobs ,my-jobs)))) + +(defun get-printer-attributes (ipp-client + printer-uri + request-file + response-file + request-id + &key + (attributes-charset "utf-8") + (attributes-natural-language "en") + limit + requested-attributes) + (ipp ipp-client + printer-uri + request-file + response-file + nil + request-id + :get-printer-attributes + `((,(tag :operation-attributes-tag) + :attributes-charset ,attributes-charset + :attributes-natural-language ,attributes-natural-language + :printer-uri ,printer-uri :limit ,limit :requested-attributes ,requested-attributes)))) -;; TODO get-printer-attributes ;; TODO hold-job ;; TODO release-job ;; TODO restart-job -;; TODO pause-printer -;; TODO resume-printer -;; TODO purge-jobs + +(defun pause-printer (ipp-client + printer-uri + request-file + response-file + request-id + &key + (attributes-charset "utf-8") + (attributes-natural-language "en") + (requesting-user-name (user-name))) + (ipp ipp-client + printer-uri + request-file + response-file + nil + request-id + :pause-printer + `((,(tag :operation-attributes-tag) + :attributes-charset ,attributes-charset + :attributes-natural-language ,attributes-natural-language + :printer-uri ,printer-uri + :requesting-user-name ,requesting-user-name)))) + +(defun resume-printer (ipp-client + printer-uri + request-file + response-file + request-id + &key + (attributes-charset "utf-8") + (attributes-natural-language "en") + (requesting-user-name (user-name))) + (ipp ipp-client + printer-uri + request-file + response-file + nil + request-id + :resume-printer + `((,(tag :operation-attributes-tag) + :attributes-charset ,attributes-charset + :attributes-natural-language ,attributes-natural-language + :printer-uri ,printer-uri + :requesting-user-name ,requesting-user-name)))) + +(defun purge-jobs (ipp-client + printer-uri + request-file + response-file + request-id + &key + (attributes-charset "utf-8") + (attributes-natural-language "en") + (requesting-user-name (user-name))) + (ipp ipp-client + printer-uri + request-file + response-file + nil + request-id + :purge-jobs + `((,(tag :operation-attributes-tag) + :attributes-charset ,attributes-charset + :attributes-natural-language ,attributes-natural-language + :printer-uri ,printer-uri + :requesting-user-name ,requesting-user-name)))) + ;; TODO set-job-attributes ;; TODO create-printer-subscription ;; TODO create-job-subscription @@ -614,6 +739,34 @@ 314) #+nil +(ipp:get-printer-attributes ;; TODO fix read-attribute + 'ipp-client + "http://localhost:631/printers/Virtual_PDF_Printer" + "request2.dat" + "response2.dat" + 314) + +#+nil +(ipp:get-printer-attributes + 'ipp-client + "http://localhost:631/printers/Virtual_PDF_Printer" + "request2.dat" + "response2.dat" + 314 + :limit 2 + :requested-attributes '(:job-template :printer-description)) + +#+nil +(ipp:get-printer-attributes + 'ipp-client + "http://localhost:631/printers/Virtual_PDF_Printer" + "request2.dat" + "response2.dat" + 314 + :limit 2 + :requested-attributes '(:all)) + +#+nil (ipp:get-jobs 'ipp-client "http://localhost:631/printers/Virtual_PDF_Printer" "request2.dat"