/*
* "$Id$"
*
- * Destination job support for CUPS.
+ * Destination job support for CUPS.
*
- * Copyright 2012 by Apple Inc.
+ * Copyright 2012-2014 by Apple Inc.
*
- * 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/".
+ * 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/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsCancelDestJob() - Cancel a job on a destination.
- * cupsCloseDestJob() - Close a job and start printing.
- * cupsCreateDestJob() - Create a job on a destination.
- * cupsFinishDestDocument() - Finish the current document.
- * cupsStartDestDocument() - Start a new document.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
*
* The "job_id" is the number returned by cupsCreateDestJob.
*
- * Returns IPP_OK on success and IPP_NOT_AUTHORIZED or IPP_FORBIDDEN on
+ * Returns IPP_STATUS_OK on success and IPP_NOT_AUTHORIZED or IPP_FORBIDDEN on
* failure.
*
* @since CUPS 1.6/OS X 10.8@
cups_dest_t *dest, /* I - Destination */
int job_id) /* I - Job ID */
{
- return (IPP_NOT_FOUND);
+ /* TODO: Needs to be implemented! */
+ /* Probably also needs to be revved to accept cups_dinfo_t... */
+ (void)http;
+ (void)dest;
+ (void)job_id;
+
+ return (IPP_STATUS_ERROR_NOT_FOUND);
}
* 'cupsCloseDestJob()' - Close a job and start printing.
*
* Use when the last call to cupsStartDocument passed 0 for "last_document".
- * "job_id" is the job ID returned by cupsCreateDestJob. Returns @code IPP_OK@
+ * "job_id" is the job ID returned by cupsCreateDestJob. Returns @code IPP_STATUS_OK@
* on success.
*
* @since CUPS 1.6/OS X 10.8@
if (!http || !dest || !info || job_id <= 0)
{
- _cupsSetError(IPP_INTERNAL_ERROR, strerror(EINVAL), 0);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
DEBUG_puts("1cupsCloseDestJob: Bad arguments.");
- return (IPP_INTERNAL_ERROR);
+ return (IPP_STATUS_ERROR_INTERNAL);
}
/*
IPP_TAG_ENUM)) != NULL)
{
for (i = 0; i < attr->num_values; i ++)
- if (attr->values[i].integer == IPP_CLOSE_JOB)
+ if (attr->values[i].integer == IPP_OP_CLOSE_JOB)
{
- request = ippNewRequest(IPP_CLOSE_JOB);
+ request = ippNewRequest(IPP_OP_CLOSE_JOB);
break;
}
}
if (!request)
- request = ippNewRequest(IPP_SEND_DOCUMENT);
+ request = ippNewRequest(IPP_OP_SEND_DOCUMENT);
if (!request)
{
- _cupsSetError(IPP_INTERNAL_ERROR, strerror(ENOMEM), 0);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(ENOMEM), 0);
DEBUG_puts("1cupsCloseDestJob: Unable to create Close-Job/Send-Document "
"request.");
- return (IPP_INTERNAL_ERROR);
+ return (IPP_STATUS_ERROR_INTERNAL);
}
+ ippSetVersion(request, info->version / 10, info->version % 10);
+
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, info->uri);
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id",
job_id);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
NULL, cupsUser());
- if (ippGetOperation(request) == IPP_SEND_DOCUMENT)
+ if (ippGetOperation(request) == IPP_OP_SEND_DOCUMENT)
ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", 1);
/*
/*
* 'cupsCreateDestJob()' - Create a job on a destination.
*
- * Returns @code IPP_OK@ or @code IPP_OK_SUBST@ on success, saving the job ID
+ * Returns @code IPP_STATUS_OK@ or @code IPP_STATUS_OK_SUBST@ on success, saving the job ID
* in the variable pointed to by "job_id".
*
* @since CUPS 1.6/OS X 10.8@
if (!http || !dest || !info || !job_id)
{
- _cupsSetError(IPP_INTERNAL_ERROR, strerror(EINVAL), 0);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
DEBUG_puts("1cupsCreateDestJob: Bad arguments.");
- return (IPP_INTERNAL_ERROR);
+ return (IPP_STATUS_ERROR_INTERNAL);
}
/*
* Build a Create-Job request...
*/
- if ((request = ippNewRequest(IPP_CREATE_JOB)) == NULL)
+ if ((request = ippNewRequest(IPP_OP_CREATE_JOB)) == NULL)
{
- _cupsSetError(IPP_INTERNAL_ERROR, strerror(ENOMEM), 0);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(ENOMEM), 0);
DEBUG_puts("1cupsCreateDestJob: Unable to create Create-Job request.");
- return (IPP_INTERNAL_ERROR);
+ return (IPP_STATUS_ERROR_INTERNAL);
}
+ ippSetVersion(request, info->version / 10, info->version % 10);
+
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, info->uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
if (title)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", NULL,
title);
- cupsEncodeOptions(request, num_options, options);
+
+ 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...
/*
* 'cupsFinishDestDocument()' - Finish the current document.
*
- * Returns @code IPP_OK@ or @code IPP_OK_SUBST@ on success.
+ * Returns @code IPP_STATUS_OK@ or @code IPP_STATUS_OK_SUBST@ on success.
*
* @since CUPS 1.6/OS X 10.8@
*/
if (!http || !dest || !info)
{
- _cupsSetError(IPP_INTERNAL_ERROR, strerror(EINVAL), 0);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
DEBUG_puts("1cupsFinishDestDocument: Bad arguments.");
- return (IPP_INTERNAL_ERROR);
+ return (IPP_STATUS_ERROR_INTERNAL);
}
/*
if (!http || !dest || !info || job_id <= 0)
{
- _cupsSetError(IPP_INTERNAL_ERROR, strerror(EINVAL), 0);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
DEBUG_puts("1cupsStartDestDocument: Bad arguments.");
- return (HTTP_ERROR);
+ return (HTTP_STATUS_ERROR);
}
/*
* Create a Send-Document request...
*/
- if ((request = ippNewRequest(IPP_SEND_DOCUMENT)) == NULL)
+ if ((request = ippNewRequest(IPP_OP_SEND_DOCUMENT)) == NULL)
{
- _cupsSetError(IPP_INTERNAL_ERROR, strerror(ENOMEM), 0);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(ENOMEM), 0);
DEBUG_puts("1cupsStartDestDocument: Unable to create Send-Document "
"request.");
- return (HTTP_ERROR);
+ return (HTTP_STATUS_ERROR);
}
+ ippSetVersion(request, info->version / 10, info->version % 10);
+
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, info->uri);
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", job_id);
if (format)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE,
"document-format", NULL, format);
- ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", last_document);
+ ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", (char)last_document);
+ cupsEncodeOptions2(request, num_options, options, IPP_TAG_OPERATION);
cupsEncodeOptions2(request, num_options, options, IPP_TAG_DOCUMENT);
/*