From 7ae00c352c603d70722c6272ccf620979f804ff7 Mon Sep 17 00:00:00 2001 From: msweet Date: Mon, 15 Feb 2016 23:39:23 +0000 Subject: [PATCH] First half of new "local temporary printer" queues, to support on-demand IPP Everywhere printers. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@13088 a1ca3aef-8c08-0410-bb20-df032aa958be --- cups/cups-private.h | 1 + cups/cups.h | 6 +- cups/dest.c | 58 +- cups/encode.c | 1 + cups/ipp-support.c | 1 + cups/ipp.h | 9 +- doc/help/man-cupsd.html | 16 +- doc/help/spec-ipp.html | 1879 +++++++++++---------------------------- scheduler/ipp.c | 59 +- scheduler/job.c | 19 + scheduler/printers.c | 42 +- scheduler/printers.h | 3 +- 12 files changed, 689 insertions(+), 1405 deletions(-) diff --git a/cups/cups-private.h b/cups/cups-private.h index d312320a4..c36fde6ee 100644 --- a/cups/cups-private.h +++ b/cups/cups-private.h @@ -236,6 +236,7 @@ extern char *_cupsBufferGet(size_t size); extern void _cupsBufferRelease(char *b); extern http_t *_cupsConnect(void); +extern char *_cupsCreateDest(const char *name, const char *info, const char *device_id, const char *device_uri, char *uri, size_t urisize); extern int _cupsGet1284Values(const char *device_id, cups_option_t **values); extern const char *_cupsGetDestResource(cups_dest_t *dest, char *resource, diff --git a/cups/cups.h b/cups/cups.h index f478d2c49..0e374b450 100644 --- a/cups/cups.h +++ b/cups/cups.h @@ -3,7 +3,7 @@ * * API definitions for CUPS. * - * Copyright 2007-2015 by Apple Inc. + * Copyright 2007-2016 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -241,7 +241,7 @@ enum cups_ptype_e /* Printer type/capability bit * @since CUPS 1.4/OS X 10.6@ */ CUPS_PRINTER_MFP = 0x4000000, /* Printer with scanning capabilities * @since CUPS 1.4/OS X 10.6@ */ - CUPS_PRINTER_3D = 0x8000000, /* 3D Printing @since CUPS 2.1@ */ + CUPS_PRINTER_3D = 0x8000000, /* Printer with 3D capabilities @since CUPS 2.1@ */ CUPS_PRINTER_OPTIONS = 0x6fffc /* ~(CLASS | REMOTE | IMPLICIT | * DEFAULT | FAX | REJECTING | DELETE | * NOT_SHARED | AUTHENTICATED | @@ -596,7 +596,7 @@ extern int cupsGetDestMediaByIndex(http_t *http, cups_dest_t *dest, unsigned flags, cups_size_t *size) _CUPS_API_1_7; -extern int cupsGetDestMediaCount(http_t *http, cups_dest_t *dest, +extern int cupsGetDestMediaCount(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags) _CUPS_API_1_7; extern int cupsGetDestMediaDefault(http_t *http, cups_dest_t *dest, diff --git a/cups/dest.c b/cups/dest.c index 34abfdbcf..f54d5eec2 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -1,6 +1,4 @@ /* - * "$Id$" - * * User-defined destination (and option) support for CUPS. * * Copyright 2007-2016 by Apple Inc. @@ -804,6 +802,57 @@ cupsCopyDest(cups_dest_t *dest, } +/* + * '_cupsCreateDest()' - Create a local (temporary) queue. + */ + +char * /* O - Printer URI or @code NULL@ on error */ +_cupsCreateDest(const char *name, /* I - Printer name */ + const char *info, /* I - Printer description of @code NULL@ */ + const char *device_id, /* I - 1284 Device ID or @code NULL@ */ + const char *device_uri, /* I - Device URI */ + char *uri, /* I - Printer URI buffer */ + size_t urisize) /* I - Size of URI buffer */ +{ + http_t *http; /* Connection to server */ + ipp_t *request, /* CUPS-Create-Local-Printer request */ + *response; /* CUPS-Create-Local-Printer response */ + ipp_attribute_t *attr; /* printer-uri-supported attribute */ + + + (void)info; + (void)device_id; + + if (!name || !device_uri || !uri || urisize < 32) + return (NULL); + + if ((http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, HTTP_ENCRYPTION_IF_REQUESTED, 1, 30000, NULL)) == NULL) + return (NULL); + + request = ippNewRequest(IPP_OP_CUPS_CREATE_LOCAL_PRINTER); + + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser()); + + ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_URI, "device-uri", NULL, device_uri); + ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME, "printer-name", NULL, name); + if (info) + ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-info", NULL, info); + if (device_id) + ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-device-id", NULL, device_id); + + response = cupsDoRequest(http, request, "/"); + + httpClose(http); + + if ((attr = ippFindAttribute(response, "printer-uri-supported", IPP_TAG_URI)) != NULL) + strlcpy(uri, ippGetString(attr, 0, NULL), urisize); + + ippDelete(response); + + return (attr ? uri : NULL); +} + + /* * 'cupsEnumDests()' - Enumerate available destinations with a callback function. * @@ -3948,8 +3997,3 @@ cups_make_string( return (buffer); } - - -/* - * End of "$Id$". - */ diff --git a/cups/encode.c b/cups/encode.c index ccefe8a0d..44fe31ea2 100644 --- a/cups/encode.c +++ b/cups/encode.c @@ -281,6 +281,7 @@ static const _ipp_option_t ipp_options[] = { 0, "printer-info", IPP_TAG_TEXT, IPP_TAG_PRINTER }, { 0, "printer-is-accepting-jobs", IPP_TAG_BOOLEAN, IPP_TAG_PRINTER }, { 0, "printer-is-shared", IPP_TAG_BOOLEAN, IPP_TAG_PRINTER }, + { 0, "printer-is-temporary", IPP_TAG_BOOLEAN, IPP_TAG_PRINTER }, { 0, "printer-location", IPP_TAG_TEXT, IPP_TAG_PRINTER }, { 0, "printer-make-and-model", IPP_TAG_TEXT, IPP_TAG_PRINTER }, { 0, "printer-more-info", IPP_TAG_URI, IPP_TAG_PRINTER }, diff --git a/cups/ipp-support.c b/cups/ipp-support.c index 86767e69b..5b16bc29d 100644 --- a/cups/ipp-support.c +++ b/cups/ipp-support.c @@ -1564,6 +1564,7 @@ ippCreateRequestedArray(ipp_t *request) /* I - IPP request */ "printer-input-tray", /* IPP JPS3 */ "printer-is-accepting-jobs", "printer-is-shared", /* CUPS extension */ + "printer-is-temporary", /* CUPS extension */ "printer-kind", /* IPP Paid Printing */ "printer-location", "printer-make-and-model", diff --git a/cups/ipp.h b/cups/ipp.h index 3461d658e..aefdcbfa4 100644 --- a/cups/ipp.h +++ b/cups/ipp.h @@ -330,12 +330,13 @@ typedef enum ipp_op_e /**** IPP operations ****/ IPP_OP_CUPS_ACCEPT_JOBS, /* Accept new jobs on a printer */ IPP_OP_CUPS_REJECT_JOBS, /* Reject new jobs on a printer */ IPP_OP_CUPS_SET_DEFAULT, /* Set the default printer */ - IPP_OP_CUPS_GET_DEVICES, /* Get a list of supported devices */ - IPP_OP_CUPS_GET_PPDS, /* Get a list of supported drivers */ + IPP_OP_CUPS_GET_DEVICES, /* Get a list of supported devices @deprecated@ */ + IPP_OP_CUPS_GET_PPDS, /* Get a list of supported drivers @deprecated@ */ IPP_OP_CUPS_MOVE_JOB, /* Move a job to a different printer */ IPP_OP_CUPS_AUTHENTICATE_JOB, /* Authenticate a job @since CUPS 1.2/OS X 10.5@ */ - IPP_OP_CUPS_GET_PPD, /* Get a PPD file @since CUPS 1.3/OS X 10.5@ */ - IPP_OP_CUPS_GET_DOCUMENT = 0x4027 /* Get a document file @since CUPS 1.4/OS X 10.6@ */ + IPP_OP_CUPS_GET_PPD, /* Get a PPD file @deprecated@ */ + IPP_OP_CUPS_GET_DOCUMENT = 0x4027, /* Get a document file @since CUPS 1.4/OS X 10.6@ */ + IPP_OP_CUPS_CREATE_LOCAL_PRINTER /* Create a local (temporary) printer @since CUPS 2.2 */ # ifndef _CUPS_NO_DEPRECATED # define IPP_PRINT_JOB IPP_OP_PRINT_JOB diff --git a/doc/help/man-cupsd.html b/doc/help/man-cupsd.html index de1294217..009485128 100644 --- a/doc/help/man-cupsd.html +++ b/doc/help/man-cupsd.html @@ -13,7 +13,7 @@ cupsd - cups scheduler cupsd [ -c -config-file +cupsd.conf ] [ -f ] [ @@ -23,17 +23,20 @@ cupsd - cups scheduler ] [ -l ] [ +-s +cups-files.conf +] [ -t ]

Description

cupsd -is the scheduler for CUPS. It implements a printing system based upon the Internet Printing Protocol, version 2.1. If no options are specified on the command-line then the default configuration file +is the scheduler for CUPS. It implements a printing system based upon the Internet Printing Protocol, version 2.1, and supports most of the requirements for IPP Everywhere. If no options are specified on the command-line then the default configuration file /etc/cups/cupsd.conf will be used.

Options

-
-c config-file -
Uses the named configuration file. +
-c cupsd.conf +
Uses the named cupsd.conf configuration file.
-f
Run cupsd @@ -54,6 +57,8 @@ when it is run from launchd(8) or systemd(8). +
-s cups-files.conf +
Uses the named cups-files.conf configuration file.
-t
Test the configuration file for syntax errors.
@@ -99,6 +104,7 @@ in the foreground with a test configuration file called backend(7), classes.conf(5), cups(1), +cups-files.conf(5), cups-lpd(8), cupsd.conf(5), cupsd-helper(8), @@ -111,7 +117,7 @@ in the foreground with a test configuration file called systemd(8), CUPS Online Help (http://localhost:631/help)

Copyright

-Copyright © 2007-2015 by Apple Inc. +Copyright © 2007-2016 by Apple Inc. diff --git a/doc/help/spec-ipp.html b/doc/help/spec-ipp.html index 4766002f0..54cd00c58 100644 --- a/doc/help/spec-ipp.html +++ b/doc/help/spec-ipp.html @@ -1,4 +1,4 @@ - + @@ -8,11 +8,9 @@