]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/dest-job.c
Fix source file header text duplication text duplication.
[thirdparty/cups.git] / cups / dest-job.c
index 40f0412370f241f41806631a3f789069a4f07ad7..b0d89b6e7b4506c529d96142f3dac642451c1a64 100644 (file)
@@ -1,15 +1,13 @@
 /*
- * "$Id$"
- *
  * Destination job support for CUPS.
  *
- * Copyright 2012-2014 by Apple Inc.
+ * Copyright 2012-2016 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/".
+ * missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
  *
  * The "job_id" is the number returned by cupsCreateDestJob.
  *
- * Returns IPP_STATUS_OK on success and IPP_NOT_AUTHORIZED or IPP_FORBIDDEN on
- * failure.
+ * Returns @code IPP_STATUS_OK@ on success and
+ * @code IPP_STATUS_ERRPR_NOT_AUTHORIZED@ or
+ * @code IPP_STATUS_ERROR_FORBIDDEN@ on failure.
  *
- * @since CUPS 1.6/OS X 10.8@
+ * @since CUPS 1.6/macOS 10.8@
  */
 
 ipp_status_t
@@ -37,13 +36,26 @@ cupsCancelDestJob(http_t      *http,        /* I - Connection to destination */
                   cups_dest_t *dest,   /* I - Destination */
                   int         job_id)  /* I - Job ID */
 {
-  /* TODO: Needs to be implemented! */
-  /* Probably also needs to be revved to accept cups_dinfo_t... */
-  (void)http;
-  (void)dest;
-  (void)job_id;
+  cups_dinfo_t *info;                  /* Destination information */
+
+
+  if ((info = cupsCopyDestInfo(http, dest)) != NULL)
+  {
+    ipp_t      *request;               /* Cancel-Job request */
+
+    request = ippNewRequest(IPP_OP_CANCEL_JOB);
+
+    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());
 
-  return (IPP_STATUS_ERROR_NOT_FOUND);
+    ippDelete(cupsDoRequest(http, request, info->resource));
+    cupsFreeDestInfo(info);
+  }
+
+  return (cupsLastError());
 }
 
 
@@ -54,7 +66,7 @@ cupsCancelDestJob(http_t      *http,  /* I - Connection to destination */
  * "job_id" is the job ID returned by cupsCreateDestJob. Returns @code IPP_STATUS_OK@
  * on success.
  *
- * @since CUPS 1.6/OS X 10.8@
+ * @since CUPS 1.6/macOS 10.8@
  */
 
 ipp_status_t                           /* O - IPP status code */
@@ -69,9 +81,7 @@ cupsCloseDestJob(
   ipp_attribute_t      *attr;          /* operations-supported attribute */
 
 
-  DEBUG_printf(("cupsCloseDestJob(http=%p, dest=%p(%s/%s), info=%p, job_id=%d)",
-                http, dest, dest ? dest->name : NULL,
-                dest ? dest->instance : NULL, info, job_id));
+  DEBUG_printf(("cupsCloseDestJob(http=%p, dest=%p(%s/%s), info=%p, job_id=%d)", (void *)http, (void *)dest, dest ? dest->name : NULL, dest ? dest->instance : NULL, (void *)info, job_id));
 
  /*
   * Range check input...
@@ -140,7 +150,7 @@ cupsCloseDestJob(
  * 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@
+ * @since CUPS 1.6/macOS 10.8@
  */
 
 ipp_status_t                           /* O - IPP status code */
@@ -159,10 +169,7 @@ cupsCreateDestJob(
 
 
   DEBUG_printf(("cupsCreateDestJob(http=%p, dest=%p(%s/%s), info=%p, "
-                "job_id=%p, title=\"%s\", num_options=%d, options=%p)",
-                http, dest, dest ? dest->name : NULL,
-                dest ? dest->instance : NULL, info, job_id, title, num_options,
-                options));
+                "job_id=%p, title=\"%s\", num_options=%d, options=%p)", (void *)http, (void *)dest, dest ? dest->name : NULL, dest ? dest->instance : NULL, (void *)info, (void *)job_id, title, num_options, (void *)options));
 
  /*
   * Range check input...
@@ -233,7 +240,7 @@ cupsCreateDestJob(
  *
  * Returns @code IPP_STATUS_OK@ or @code IPP_STATUS_OK_SUBST@ on success.
  *
- * @since CUPS 1.6/OS X 10.8@
+ * @since CUPS 1.6/macOS 10.8@
  */
 
 ipp_status_t                           /* O - Status of document submission */
@@ -242,9 +249,7 @@ cupsFinishDestDocument(
     cups_dest_t  *dest,                        /* I - Destination */
     cups_dinfo_t *info)                /* I - Destination information */
 {
-  DEBUG_printf(("cupsFinishDestDocument(http=%p, dest=%p(%s/%s), info=%p)",
-                http, dest, dest ? dest->name : NULL,
-                dest ? dest->instance : NULL, info));
+  DEBUG_printf(("cupsFinishDestDocument(http=%p, dest=%p(%s/%s), info=%p)", (void *)http, (void *)dest, dest ? dest->name : NULL, dest ? dest->instance : NULL, (void *)info));
 
  /*
   * Range check input...
@@ -280,7 +285,7 @@ cupsFinishDestDocument(
  * if this is the last document to be submitted in the job.  Returns
  * @code HTTP_CONTINUE@ on success.
  *
- * @since CUPS 1.6/OS X 10.8@
+ * @since CUPS 1.6/macOS 10.8@
  */
 
 http_status_t                          /* O - Status of document creation */
@@ -299,12 +304,7 @@ cupsStartDestDocument(
   http_status_t        status;                 /* HTTP status */
 
 
-  DEBUG_printf(("cupsStartDestDocument(http=%p, dest=%p(%s/%s), info=%p, "
-                "job_id=%d, docname=\"%s\", format=\"%s\", num_options=%d, "
-                "options=%p, last_document=%d)",
-                http, dest, dest ? dest->name : NULL,
-                dest ? dest->instance : NULL, info, job_id, docname, format,
-                num_options, options, last_document));
+  DEBUG_printf(("cupsStartDestDocument(http=%p, dest=%p(%s/%s), info=%p, job_id=%d, docname=\"%s\", format=\"%s\", num_options=%d, options=%p, last_document=%d)", (void *)http, (void *)dest, dest ? dest->name : NULL, dest ? dest->instance : NULL, (void *)info, job_id, docname, format, num_options, (void *)options, last_document));
 
  /*
   * Range check input...
@@ -357,8 +357,3 @@ cupsStartDestDocument(
 
   return (status);
 }
-
-
-/*
- * End of "$Id$".
- */