cl-ipp

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

commit 5917ee1ecaecb951de9bf890b69f028fdfd9ddaa
parent a8de6492f20d207f49172a67a56cc66cf4f0511f
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sat, 10 Aug 2013 23:31:19 +0200

create-job and get-jobs implemented

Diffstat:
Mipp.lisp | 141+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 134 insertions(+), 7 deletions(-)

diff --git a/ipp.lisp b/ipp.lisp @@ -22,8 +22,10 @@ (defpackage :ipp (:use :cl) - (:export :print-job - :list-printers)) + (:export :create-job + :get-jobs + :list-printers + :print-job)) (in-package :ipp) @@ -86,7 +88,9 @@ (:job-uri . nil) (:job-id . nil) (:job-state . nil) - (:job-state-reasons . nil)))) + (:job-state-reasons . nil) + (:limit . :integer) + (:requested-attributes . :keyword)))) (defun attribute-tag (attribute) (or (cdr (assoc attribute attributes)) @@ -199,11 +203,18 @@ (loop for (k v) on plist by #'cddr when v - do (let ((tag (attribute-tag k))) - ;; TODO additional value (when v is list) - (rw:write-u8 writer (tag tag)) + do (let* ((tag (attribute-tag k)) + (n (tag tag))) + (rw:write-u8 writer n) (write-text writer (attribute-name k)) - (write-value writer tag v)))))) + (if (atom v) + (write-value writer tag v) + (progn + (write-value writer tag (attribute-name (car v))) + (dolist (v (cdr v)) + (rw:write-u8 writer n) + (rw:write-u16 writer 0) + (write-value writer tag (attribute-name v)))))))))) (defun operation-code (operation) (cdr (assoc operation '((:print-job 1 0 #x0002) @@ -337,6 +348,90 @@ :copies ,copies :sides ,sides)))) +;; TODO validate-job + +(defun create-job (ipp-client + printer-uri + request-file + response-file + request-id + &key + (attributes-charset "utf-8") + (attributes-natural-language "en")) + (ipp ipp-client + printer-uri + request-file + response-file + nil + request-id + :create-job + `((,(tag :operation-attributes-tag) + :attributes-charset ,attributes-charset + :attributes-natural-language ,attributes-natural-language + :printer-uri ,printer-uri)))) + +;; TODO send-document +;; TODO cancel-job +;; TODO get-job-attributes + +(defun get-jobs (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-jobs + `((,(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 +;; TODO set-job-attributes +;; TODO create-printer-subscription +;; TODO create-job-subscription +;; TODO get-subscription-attributes +;; TODO get-subscriptions +;; TODO renew-subscription +;; TODO cancel-subscription +;; TODO get-notifications +;; TODO enable-printer +;; TODO disable-printer +;; TODO cups-get-default +;; TODO cups-get-printers +;; TODO cups-add-modify-printer +;; TODO cups-delete-printer +;; TODO cups-get-classes +;; TODO cups-add-modify-class +;; TODO cups-delete-class +;; TODO cups-accept-jobs +;; TODO cups-reject-jobs +;; TODO cups-set-default +;; TODO cups-get-devices +;; TODO cups-get-ppds +;; TODO cups-move-job +;; TODO cups-authenticate-job +;; TODO cups-get-ppd +;; TODO cups-get-document + (defun printer-search-reader (reader) (let* ((k '#.(coerce "\"/printers/" 'list)) ;; TODO #\' as attribute quote (n (length k)) @@ -434,6 +529,7 @@ ,url))) ;;(curl "http://localhost:631/printers/" :response-file "printers.html") +;;(curl "http://localhost:631/jobs/82" :response-file "job-status.html") (defun ipp-client (content-type printer-uri request-file response-file) (curl printer-uri @@ -454,6 +550,37 @@ ) #+nil +(ipp:create-job 'ipp-client + "http://localhost:631/printers/Virtual_PDF_Printer" + "create-jobs.in" + "create-jobs.out" + 314) + +#+nil +(ipp:get-jobs 'ipp-client + "http://localhost:631/printers/Virtual_PDF_Printer" + "request2.dat" + "response2.dat" + 314) + +#+nil +(ipp:get-jobs 'ipp-client + "http://localhost:631/printers/Virtual_PDF_Printer" + "request2.dat" + "response2.dat" + 314 + :limit 2) + +#+nil +(ipp:get-jobs 'ipp-client + "http://localhost:631/printers/Virtual_PDF_Printer" + "request2.dat" + "response2.dat" + 314 + :limit 2 + :requested-attributes '(:job-id)) + +#+nil (ipp:list-printers 'ipp-client "http://localhost:631/printers/" "printers.html")