diff options
author | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2015-05-27 19:30:32 +0000 |
---|---|---|
committer | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2015-05-27 19:30:32 +0000 |
commit | 9514a192a5c373f90dca896a19f5f57fbe18008c (patch) | |
tree | 15591ffa0efbf7b0c1dc5ab9689f2314d333e8fb /scheduler | |
parent | 9b4bd602fbd050009b8789c66843c8539ec805d6 (diff) |
Add support for job-impressions[-completed].
Fix regression in remote printing (needed to block date-time-at-xxx attrs)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12668 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'scheduler')
-rw-r--r-- | scheduler/ipp.c | 73 | ||||
-rw-r--r-- | scheduler/job.c | 38 | ||||
-rw-r--r-- | scheduler/job.h | 5 |
3 files changed, 83 insertions, 33 deletions
diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 5cd3bbc23..bebae49ac 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -1217,13 +1217,22 @@ add_job(cupsd_client_t *con, /* I - Client connection */ "date-time-at-completed", "date-time-at-creation", "date-time-at-processing", + "job-detailed-status-messages", + "job-document-access-errors", "job-id", - "job-k-octets-completed", "job-impressions-completed", + "job-k-octets-completed", "job-media-sheets-completed", + "job-pages-completed", + "job-printer-up-time", + "job-printer-uri", "job-state", "job-state-message", "job-state-reasons", + "job-uri", + "number-of-documents", + "number-of-intervening-jobs", + "output-device-assigned", "time-at-completed", "time-at-creation", "time-at-processing" @@ -1299,22 +1308,17 @@ add_job(cupsd_client_t *con, /* I - Client connection */ for (i = 0; i < (int)(sizeof(readonly) / sizeof(readonly[0])); i ++) { - if ((attr = ippFindAttribute(con->request, readonly[i], - IPP_TAG_ZERO)) != NULL) + if ((attr = ippFindAttribute(con->request, readonly[i], IPP_TAG_ZERO)) != NULL) { ippDeleteAttribute(con->request, attr); if (StrictConformance) { - send_ipp_status(con, IPP_BAD_REQUEST, - _("The '%s' Job Description attribute cannot be " - "supplied in a job creation request."), readonly[i]); + send_ipp_status(con, IPP_BAD_REQUEST, _("The '%s' Job Status attribute cannot be supplied in a job creation request."), readonly[i]); return (NULL); } - cupsdLogMessage(CUPSD_LOG_INFO, - "Unexpected '%s' Job Description attribute in a job " - "creation request.", readonly[i]); + cupsdLogMessage(CUPSD_LOG_INFO, "Unexpected '%s' Job Status attribute in a job creation request.", readonly[i]); } } @@ -1694,6 +1698,7 @@ add_job(cupsd_client_t *con, /* I - Client connection */ job->state_value = (ipp_jstate_t)job->state->values[0].integer; job->reasons = ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "job-incoming"); + job->impressions = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-impressions-completed", 0); job->sheets = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-media-sheets-completed", 0); ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, "job-printer-uri", NULL, @@ -8079,6 +8084,7 @@ print_job(cupsd_client_t *con, /* I - Client connection */ ipp_attribute_t *uri) /* I - Printer URI */ { ipp_attribute_t *attr; /* Current attribute */ + ipp_attribute_t *doc_name; /* document-name attribute */ ipp_attribute_t *format; /* Document-format attribute */ const char *default_format; /* document-format-default value */ cupsd_job_t *job; /* New job */ @@ -8156,6 +8162,10 @@ print_job(cupsd_client_t *con, /* I - Client connection */ * Is it a format we support? */ + doc_name = ippFindAttribute(con->request, "document-name", IPP_TAG_NAME); + if (doc_name) + ippSetName(con->request, &doc_name, "document-name-supplied"); + if ((format = ippFindAttribute(con->request, "document-format", IPP_TAG_MIMETYPE)) != NULL) { @@ -8171,6 +8181,8 @@ print_job(cupsd_client_t *con, /* I - Client connection */ format->values[0].string.text); return; } + + ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_MIMETYPE, "document-format-supplied", NULL, ippGetString(format, 0, NULL)); } else if ((default_format = cupsGetOption("document-format", printer->num_options, @@ -8204,12 +8216,9 @@ print_job(cupsd_client_t *con, /* I - Client connection */ * Auto-type the file... */ - ipp_attribute_t *doc_name; /* document-name attribute */ - - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job ???] Auto-typing file..."); - doc_name = ippFindAttribute(con->request, "document-name", IPP_TAG_NAME); + filetype = mimeFileType(MimeDatabase, con->filename, doc_name ? doc_name->values[0].string.text : NULL, &compression); @@ -8219,6 +8228,9 @@ print_job(cupsd_client_t *con, /* I - Client connection */ cupsdLogMessage(CUPSD_LOG_INFO, "[Job ???] Request file type is %s/%s.", filetype->super, filetype->type); + + snprintf(mimetype, sizeof(mimetype), "%s/%s", filetype->super, filetype->type); + ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_MIMETYPE, "document-format-detected", NULL, mimetype); } else filetype = mimeType(MimeDatabase, super, type); @@ -8467,12 +8479,17 @@ read_job_ticket(cupsd_client_t *con) /* I - Client connection */ if (attr->group_tag != IPP_TAG_JOB || !attr->name) continue; - if (!strcmp(attr->name, "job-originating-host-name") || - !strcmp(attr->name, "job-originating-user-name") || + if (!strncmp(attr->name, "date-time-at-", 13) || + !strcmp(attr->name, "job-impressions-completed") || !strcmp(attr->name, "job-media-sheets-completed") || - !strcmp(attr->name, "job-k-octets") || + !strncmp(attr->name, "job-k-octets", 12) || !strcmp(attr->name, "job-id") || + !strcmp(attr->name, "job-originating-host-name") || + !strcmp(attr->name, "job-originating-user-name") || + !strcmp(attr->name, "job-pages-completed") || + !strcmp(attr->name, "job-printer-uri") || !strncmp(attr->name, "job-state", 9) || + !strcmp(attr->name, "job-uri") || !strncmp(attr->name, "time-at-", 8)) continue; /* Read-only attrs */ @@ -9398,6 +9415,8 @@ send_document(cupsd_client_t *con, /* I - Client connection */ * Is it a format we support? */ + cupsdLoadJob(job); + if ((format = ippFindAttribute(con->request, "document-format", IPP_TAG_MIMETYPE)) != NULL) { @@ -9412,6 +9431,8 @@ send_document(cupsd_client_t *con, /* I - Client connection */ format->values[0].string.text); return; } + + ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_MIMETYPE, "document-format-supplied", NULL, ippGetString(format, 0, NULL)); } else if ((default_format = cupsGetOption("document-format", printer->num_options, @@ -9460,6 +9481,9 @@ send_document(cupsd_client_t *con, /* I - Client connection */ if (filetype) cupsdLogJob(job, CUPSD_LOG_DEBUG, "Request file type is %s/%s.", filetype->super, filetype->type); + + snprintf(mimetype, sizeof(mimetype), "%s/%s", filetype->super, filetype->type); + ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_MIMETYPE, "document-format-detected", NULL, mimetype); } else filetype = mimeType(MimeDatabase, super, type); @@ -9517,11 +9541,12 @@ send_document(cupsd_client_t *con, /* I - Client connection */ * Add the file to the job... */ - cupsdLoadJob(job); - if (add_file(con, job, filetype, compression)) return; + if ((attr = ippFindAttribute(con->request, "document-name", IPP_TAG_NAME)) != NULL) + ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "document-name-supplied", NULL, ippGetString(attr, 0, NULL)); + if (stat(con->filename, &fileinfo)) kbytes = 0; else @@ -9977,15 +10002,18 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ if (!strcmp(attr->name, "attributes-charset") || !strcmp(attr->name, "attributes-natural-language") || - !strcmp(attr->name, "document-compression") || - !strcmp(attr->name, "document-format") || + !strncmp(attr->name, "date-time-at-", 13) || + !strncmp(attr->name, "document-compression", 20) || + !strncmp(attr->name, "document-format", 15) || !strcmp(attr->name, "job-detailed-status-messages") || !strcmp(attr->name, "job-document-access-errors") || !strcmp(attr->name, "job-id") || !strcmp(attr->name, "job-impressions-completed") || - !strcmp(attr->name, "job-k-octets") || + !strcmp(attr->name, "job-k-octets-completed") || + !strcmp(attr->name, "job-media-sheets-completed") || !strcmp(attr->name, "job-originating-host-name") || !strcmp(attr->name, "job-originating-user-name") || + !strcmp(attr->name, "job-pages-completed") || !strcmp(attr->name, "job-printer-up-time") || !strcmp(attr->name, "job-printer-uri") || !strcmp(attr->name, "job-sheets") || @@ -9995,9 +10023,6 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ !strcmp(attr->name, "number-of-documents") || !strcmp(attr->name, "number-of-intervening-jobs") || !strcmp(attr->name, "output-device-assigned") || - !strncmp(attr->name, "date-time-at-", 13) || - !strncmp(attr->name, "job-k-octets", 12) || - !strncmp(attr->name, "job-media-sheets", 16) || !strncmp(attr->name, "time-at-", 8)) { /* diff --git a/scheduler/job.c b/scheduler/job.c index 1edf585e1..393dceca9 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -1823,9 +1823,12 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ ippSetString(job->attrs, &job->reasons, 0, "none"); } - job->sheets = ippFindAttribute(job->attrs, "job-media-sheets-completed", - IPP_TAG_INTEGER); - job->job_sheets = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME); + job->impressions = ippFindAttribute(job->attrs, "job-impressions-completed", IPP_TAG_INTEGER); + job->sheets = ippFindAttribute(job->attrs, "job-media-sheets-completed", IPP_TAG_INTEGER); + job->job_sheets = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME); + + if (!job->impressions) + job->impressions = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-impressions-completed", 0); if (!job->priority) { @@ -4822,6 +4825,7 @@ unload_job(cupsd_job_t *job) /* I - Job */ job->attrs = NULL; job->state = NULL; job->reasons = NULL; + job->impressions = NULL; job->sheets = NULL; job->job_sheets = NULL; job->printer_message = NULL; @@ -4880,6 +4884,25 @@ update_job(cupsd_job_t *job) /* I - Job to check */ cupsdLogJob(job, CUPSD_LOG_DEBUG, "PAGE: %s", message); + if (job->impressions) + { + if (!_cups_strncasecmp(message, "total ", 6)) + { + /* + * Got a total count of pages from a backend or filter... + */ + + copies = atoi(message + 6); + copies -= ippGetInteger(job->impressions, 0); /* Just track the delta */ + } + else if (!sscanf(message, "%*d%d", &copies)) + copies = 1; + + ippSetInteger(job->attrs, &job->impressions, 0, ippGetInteger(job->impressions, 0) + copies); + job->dirty = 1; + cupsdMarkDirty(CUPSD_DIRTY_JOBS); + } + if (job->sheets) { if (!_cups_strncasecmp(message, "total ", 6)) @@ -4889,12 +4912,14 @@ update_job(cupsd_job_t *job) /* I - Job to check */ */ copies = atoi(message + 6); - copies -= job->sheets->values[0].integer; /* Just track the delta */ + copies -= ippGetInteger(job->sheets, 0); /* Just track the delta */ } else if (!sscanf(message, "%*d%d", &copies)) copies = 1; - job->sheets->values[0].integer += copies; + ippSetInteger(job->attrs, &job->sheets, 0, ippGetInteger(job->sheets, 0) + copies); + job->dirty = 1; + cupsdMarkDirty(CUPSD_DIRTY_JOBS); if (job->printer->page_limit) cupsdUpdateQuota(job->printer, job->username, copies, 0); @@ -4903,8 +4928,7 @@ update_job(cupsd_job_t *job) /* I - Job to check */ cupsdLogPage(job, message); if (job->sheets) - cupsdAddEvent(CUPSD_EVENT_JOB_PROGRESS, job->printer, job, - "Printed %d page(s).", job->sheets->values[0].integer); + cupsdAddEvent(CUPSD_EVENT_JOB_PROGRESS, job->printer, job, "Printed %d page(s).", ippGetInteger(job->sheets, 0)); } else if (loglevel == CUPSD_LOG_JOBSTATE) { diff --git a/scheduler/job.h b/scheduler/job.h index 37b20dadd..32e2fd747 100644 --- a/scheduler/job.h +++ b/scheduler/job.h @@ -3,7 +3,7 @@ * * Print job definitions for the CUPS scheduler. * - * Copyright 2007-2014 by Apple Inc. + * Copyright 2007-2015 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -46,7 +46,8 @@ struct cupsd_job_s /**** Job request ****/ int num_files; /* Number of files in job */ mime_type_t **filetypes; /* File types */ int *compressions; /* Compression status of each file */ - ipp_attribute_t *sheets; /* job-media-sheets-completed */ + ipp_attribute_t *impressions, /* job-impressions-completed */ + *sheets; /* job-media-sheets-completed */ time_t access_time, /* Last access time */ cancel_time, /* When to cancel/send SIGTERM */ creation_time, /* When job was created */ |