From: mike Date: Mon, 21 Jan 2013 14:25:46 +0000 (+0000) Subject: Add support for "-x" option, now "cancel -a" does not purge, it just cancels all X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d56ab747643be13b7b5e2557555f1baf989e4973;p=thirdparty%2Fcups.git Add support for "-x" option, now "cancel -a" does not purge, it just cancels all jobs (STR #4103) git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10831 7a7537e8-13f0-0310-91df-b6672ffda945 --- diff --git a/CHANGES.txt b/CHANGES.txt index 38f8edf70a..972000fb51 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,8 +1,9 @@ -CHANGES.txt - 1.7b1 - 2012-12-11 +CHANGES.txt - 1.7b1 - 2013-01-21 -------------------------------- CHANGES IN CUPS V1.7b1 + - Added a new "-x" option to the cancel command (STR #4103) - Added new IPP APIs for checking values (STR #4167) - Added new IPP APis for adding and setting formatted strings. - Added new HTTP APIs to support basic server functionality via libcups. diff --git a/man/cancel.man b/man/cancel.man index 5b67f771fa..15adcb22d7 100644 --- a/man/cancel.man +++ b/man/cancel.man @@ -12,7 +12,7 @@ .\" 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/". .\" -.TH cancel 1 "CUPS" "20 March 2006" "Apple Inc." +.TH cancel 1 "CUPS" "21 January 2013" "Apple Inc." .SH NAME cancel - cancel jobs .SH SYNOPSIS @@ -23,7 +23,7 @@ cancel - cancel jobs .I hostname[:port] ] [ -u .I username -] [ +] [ -x ] [ .I id ] [ .I destination @@ -56,6 +56,10 @@ Chooses an alternate server. -u username .br Cancels jobs owned by \fIusername\fR. +.TP 5 +-x +.br +Deletes job data files in addition to canceling. .SH COMPATIBILITY Unlike the System V printing system, CUPS allows printer names to contain any printable character except SPACE, TAB, "/", or "#". diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 8e92f0f3bf..50765bb5d2 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -3,7 +3,7 @@ * * IPP routines for the CUPS scheduler. * - * Copyright 2007-2012 by Apple Inc. + * Copyright 2007-2013 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * This file contains Kerberos support code, copyright 2006 by @@ -3286,8 +3286,12 @@ cancel_all_jobs(cupsd_client_t *con, /* I - Client connection */ { for (i = 0; i < job_ids->num_values; i ++) { - if (!cupsdFindJob(job_ids->values[i].integer)) + if ((job = cupsdFindJob(job_ids->values[i].integer)) == NULL) break; + + if (con->request->request.op.operation_id == IPP_CANCEL_MY_JOBS && + _cups_strcasecmp(job->username, username)) + break; } if (i < job_ids->num_values) @@ -3343,6 +3347,10 @@ cancel_all_jobs(cupsd_client_t *con, /* I - Client connection */ if ((job = cupsdFindJob(job_ids->values[i].integer)) == NULL || _cups_strcasecmp(job->dest, printer->name)) break; + + if (con->request->request.op.operation_id == IPP_CANCEL_MY_JOBS && + _cups_strcasecmp(job->username, username)) + break; } if (i < job_ids->num_values) diff --git a/systemv/cancel.c b/systemv/cancel.c index 9307e19433..b4f7b56dc5 100644 --- a/systemv/cancel.c +++ b/systemv/cancel.c @@ -3,7 +3,7 @@ * * "cancel" command for CUPS. * - * Copyright 2007-2011 by Apple Inc. + * Copyright 2007-2013 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -101,8 +101,7 @@ main(int argc, /* I - Number of command-line arguments */ break; case 'a' : /* Cancel all jobs */ - purge = 1; - op = IPP_PURGE_JOBS; + op = IPP_CANCEL_JOBS; break; case 'h' : /* Connect to host */ @@ -151,6 +150,10 @@ main(int argc, /* I - Number of command-line arguments */ } break; + case 'x' : /* Purge job(s) */ + purge = 1; + break; + default : _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%c\"."), @@ -271,19 +274,22 @@ main(int argc, /* I - Number of command-line arguments */ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, user); ippAddBoolean(request, IPP_TAG_OPERATION, "my-jobs", 1); + + if (op == IPP_CANCEL_JOBS) + op = IPP_CANCEL_MY_JOBS; } else ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser()); - if (op == IPP_PURGE_JOBS) + if (purge) ippAddBoolean(request, IPP_TAG_OPERATION, "purge-jobs", purge); /* * Do the request and get back a response... */ - if (op == IPP_PURGE_JOBS && (!user || _cups_strcasecmp(user, cupsUser()))) + if (op == IPP_CANCEL_JOBS && (!user || _cups_strcasecmp(user, cupsUser()))) response = cupsDoRequest(http, request, "/admin/"); else response = cupsDoRequest(http, request, "/jobs/");