/*
* Printing utilities for CUPS.
*
- * Copyright 2007-2015 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright © 2007-2018 by Apple Inc.
+ * Copyright © 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
* property of Apple Inc. and are protected by Federal copyright
* law. Distribution and use rights are outlined in the file "LICENSE.txt"
* which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * missing or damaged, see the license at "http://www.cups.org/".
*
* This file is subject to the Apple OS-Developed Software exception.
*/
*
* Use the @link cupsLastError@ and @link cupsLastErrorString@ functions to get
* the cause of any failure.
+ *
+ * @exclude all@
*/
int /* O - 1 on success, 0 on failure */
* Use the @link cupsLastError@ and @link cupsLastErrorString@ functions to get
* the cause of any failure.
*
- * @since CUPS 1.4/macOS 10.6@
+ * @since CUPS 1.4/macOS 10.6@ @exclude all@
*/
ipp_status_t /* O - IPP status */
* print, use the @link cupsPrintFile2@ or @link cupsPrintFiles2@ function
* instead.
*
- * @since CUPS 1.4/macOS 10.6@
+ * @since CUPS 1.4/macOS 10.6@ @exclude all@
*/
int /* O - Job ID or 0 on error */
int num_options, /* I - Number of options */
cups_option_t *options) /* I - Options */
{
- char printer_uri[1024], /* Printer URI */
- resource[1024]; /* Printer resource */
- ipp_t *request, /* Create-Job request */
- *response; /* Create-Job response */
- ipp_attribute_t *attr; /* job-id attribute */
int job_id = 0; /* job-id value */
+ ipp_status_t status; /* Create-Job status */
+ cups_dest_t *dest; /* Destination */
+ cups_dinfo_t *info; /* Destination information */
DEBUG_printf(("cupsCreateJob(http=%p, name=\"%s\", title=\"%s\", num_options=%d, options=%p)", (void *)http, name, title, num_options, (void *)options));
}
/*
- * Build a Create-Job request...
+ * Lookup the destination...
*/
- if ((request = ippNewRequest(IPP_OP_CREATE_JOB)) == NULL)
+ if ((dest = cupsGetNamedDest(http, name, NULL)) == NULL)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(ENOMEM), 0);
+ DEBUG_puts("1cupsCreateJob: Destination not found.");
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(ENOENT), 0);
return (0);
}
- httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri), "ipp",
- NULL, "localhost", ippPort(), "/printers/%s", name);
- snprintf(resource, sizeof(resource), "/printers/%s", name);
-
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
- NULL, printer_uri);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
- if (title)
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", NULL,
- title);
- cupsEncodeOptions2(request, num_options, options, IPP_TAG_OPERATION);
- cupsEncodeOptions2(request, num_options, options, IPP_TAG_JOB);
- cupsEncodeOptions2(request, num_options, options, IPP_TAG_SUBSCRIPTION);
-
/*
- * Send the request and get the job-id...
+ * Query dest information and create the job...
*/
- response = cupsDoRequest(http, request, resource);
+ DEBUG_puts("1cupsCreateJob: Querying destination info.");
+ if ((info = cupsCopyDestInfo(http, dest)) == NULL)
+ {
+ DEBUG_puts("1cupsCreateJob: Query failed.");
+ cupsFreeDests(1, dest);
+ return (0);
+ }
- if ((attr = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER)) != NULL)
- job_id = attr->values[0].integer;
+ status = cupsCreateDestJob(http, dest, info, &job_id, title, num_options, options);
+ DEBUG_printf(("1cupsCreateJob: cupsCreateDestJob returned %04x (%s)", status, ippErrorString(status)));
- ippDelete(response);
+ cupsFreeDestInfo(info);
+ cupsFreeDests(1, dest);
/*
- * Return it...
+ * Return the job...
*/
- return (job_id);
+ if (status >= IPP_STATUS_REDIRECTION_OTHER_SITE)
+ return (0);
+ else
+ return (job_id);
}
*
* The document must have been started using @link cupsStartDocument@.
*
- * @since CUPS 1.4/macOS 10.6@
+ * @since CUPS 1.4/macOS 10.6@ @exclude all@
*/
ipp_status_t /* O - Status of document submission */
* This function is deprecated and no longer returns a list of printer
* classes - use @link cupsGetDests@ instead.
*
- * @deprecated@
+ * @deprecated@ @exclude all@
*/
int /* O - Number of classes */
* Applications should use the @link cupsGetDests@ and @link cupsGetDest@
* functions to get the user-defined default printer, as this function does
* not support the lpoptions-defined default printer.
+ *
+ * @exclude all@
*/
const char * /* O - Default printer or @code NULL@ */
* functions to get the user-defined default printer, as this function does
* not support the lpoptions-defined default printer.
*
- * @since CUPS 1.1.21/macOS 10.4@
+ * @since CUPS 1.1.21/macOS 10.4@ @exclude all@
*/
const char * /* O - Default printer or @code NULL@ */
* of state, while @code CUPS_WHICHJOBS_ACTIVE@ returns jobs that are
* pending, processing, or held and @code CUPS_WHICHJOBS_COMPLETED@ returns
* jobs that are stopped, canceled, aborted, or completed.
+ *
+ * @exclude all@
*/
int /* O - Number of jobs */
* This function is deprecated and no longer returns a list of printers - use
* @link cupsGetDests@ instead.
*
- * @deprecated@
+ * @deprecated@ @exclude all@
*/
int /* O - Number of printers */
/*
* 'cupsPrintFile()' - Print a file to a printer or class on the default server.
+ *
+ * @exclude all@
*/
int /* O - Job ID or 0 on error */
* 'cupsPrintFile2()' - Print a file to a printer or class on the specified
* server.
*
- * @since CUPS 1.1.21/macOS 10.4@
+ * @since CUPS 1.1.21/macOS 10.4@ @exclude all@
*/
int /* O - Job ID or 0 on error */
/*
* 'cupsPrintFiles()' - Print one or more files to a printer or class on the
* default server.
+ *
+ * @exclude all@
*/
int /* O - Job ID or 0 on error */
* 'cupsPrintFiles2()' - Print one or more files to a printer or class on the
* specified server.
*
- * @since CUPS 1.1.21/macOS 10.4@
+ * @since CUPS 1.1.21/macOS 10.4@ @exclude all@
*/
int /* O - Job ID or 0 on error */
* @code CUPS_FORMAT_TEXT@ are provided for the "format" argument, although
* any supported MIME type string can be supplied.
*
- * @since CUPS 1.4/macOS 10.6@
+ * @since CUPS 1.4/macOS 10.6@ @exclude all@
*/
http_status_t /* O - HTTP status of request */
return (status);
}
+