*
* Job management routines for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007-2009 by Apple Inc.
+ * Copyright 2007-2010 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
if (!cupsdLoadJob(job))
return;
- /*
- * Don't do anything if the state is unchanged...
- */
+ /*
+ * Don't do anything if the state is unchanged and we aren't purging the
+ * job...
+ */
- if (newstate == (oldstate = job->state_value))
- return;
+ oldstate = job->state_value;
+ if (newstate == oldstate && action != CUPSD_JOB_PURGE)
+ return;
/*
* Stop any processes that are working on the current job...
job->dirty = 1;
cupsdMarkDirty(CUPSD_DIRTY_JOBS);
}
+ else if (!job->printer)
+ {
+ /*
+ * Delete the job immediately if not actively printing...
+ */
+
+ cupsdDeleteJob(job, CUPSD_JOB_PURGE);
+ job = NULL;
+ }
break;
}
* Finalize the job immediately if we forced things...
*/
- if (action >= CUPSD_JOB_FORCE && job->printer)
+ if (action >= CUPSD_JOB_FORCE && job && job->printer)
finalize_job(job, 0);
/*
job->sheets->values[0].integer += copies;
if (job->printer->page_limit)
- {
- cupsd_quota_t *q = cupsdUpdateQuota(job->printer, job->username,
- copies, 0);
-
-#ifdef __APPLE__
- if (AppleQuotas && q->page_count == -3)
- {
- /*
- * Quota limit exceeded, cancel job in progress immediately...
- */
-
- cupsdSetJobState(job, IPP_JOB_CANCELED, CUPSD_JOB_DEFAULT,
- "Canceled job because pages exceed user %s "
- "quota limit on printer %s (%s).",
- job->username, job->printer->name,
- job->printer->info);
- return;
- }
-#else
- (void)q;
-#endif /* __APPLE__ */
- }
+ cupsdUpdateQuota(job->printer, job->username, copies, 0);
}
cupsdLogPage(job, message);
cupsdLogJob(job, loglevel, "%s", ptr);
- if (loglevel < CUPSD_LOG_DEBUG)
+ if (loglevel < CUPSD_LOG_DEBUG &&
+ strcmp(job->printer->state_message, ptr))
{
strlcpy(job->printer->state_message, ptr,
sizeof(job->printer->state_message));
if (event & CUPSD_EVENT_JOB_PROGRESS)
cupsdAddEvent(CUPSD_EVENT_JOB_PROGRESS, job->printer, job,
"%s", job->printer->state_message);
- else if (event & CUPSD_EVENT_PRINTER_STATE)
+ if (event & CUPSD_EVENT_PRINTER_STATE)
cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, job->printer, NULL,
(job->printer->type & CUPS_PRINTER_CLASS) ?
"Class \"%s\" state changed." :