]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/dest-job.c
Automate creation of the libcups2.def file, since it is really out-of-date...
[thirdparty/cups.git] / cups / dest-job.c
index dc4f0879bf7e4a081c5e8975ec003d601e6d0ac2..40f0412370f241f41806631a3f789069a4f07ad7 100644 (file)
@@ -1,25 +1,17 @@
 /*
  * "$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.
  */
 
 /*
@@ -34,7 +26,7 @@
  *
  * 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@
@@ -45,7 +37,13 @@ cupsCancelDestJob(http_t      *http, /* I - Connection to destination */
                   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);
 }
 
 
@@ -53,7 +51,7 @@ cupsCancelDestJob(http_t      *http,  /* I - Connection to destination */
  * '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@
@@ -81,9 +79,9 @@ cupsCloseDestJob(
 
   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);
   }
 
  /*
@@ -94,31 +92,33 @@ cupsCloseDestJob(
                                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);
 
  /*
@@ -137,7 +137,7 @@ cupsCloseDestJob(
 /*
  * '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@
@@ -173,22 +173,24 @@ cupsCreateDestJob(
 
   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",
@@ -196,7 +198,10 @@ cupsCreateDestJob(
   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...
@@ -226,7 +231,7 @@ cupsCreateDestJob(
 /*
  * '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@
  */
@@ -247,9 +252,9 @@ cupsFinishDestDocument(
 
   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);
   }
 
  /*
@@ -307,23 +312,25 @@ cupsStartDestDocument(
 
   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);
@@ -335,8 +342,9 @@ cupsStartDestDocument(
   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);
 
  /*