From 34b5a7f204e0222e4b2cfd3acb83404d9ebb216d Mon Sep 17 00:00:00 2001 From: mike Date: Mon, 15 Oct 2012 22:41:12 +0000 Subject: [PATCH] Next part of paid printing support - job-authorization-uri support, report printer-charge-info-uri when cupsChargeInfoURI is present in the PPD, add CUPS extensions for finishings punch values. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10646 7a7537e8-13f0-0310-91df-b6672ffda945 --- cups/encode.c | 1 + cups/ipp.h | 21 ++++++++++++++++++++- cups/ppd-cache.c | 13 +++++++++++-- cups/ppd-private.h | 3 ++- scheduler/ipp.c | 2 ++ scheduler/job.c | 1 + scheduler/printers.c | 4 ++++ 7 files changed, 41 insertions(+), 4 deletions(-) diff --git a/cups/encode.c b/cups/encode.c index 2e0bdd782f..ece2cbb65f 100644 --- a/cups/encode.c +++ b/cups/encode.c @@ -76,6 +76,7 @@ static const _ipp_option_t ipp_options[] = { 0, "job-account-id-default",IPP_TAG_NAME, IPP_TAG_PRINTER }, { 0, "job-accounting-user-id", IPP_TAG_NAME, IPP_TAG_JOB }, { 0, "job-accounting-user-id-default", IPP_TAG_NAME, IPP_TAG_PRINTER }, + { 0, "job-authorization-uri", IPP_TAG_URI, IPP_TAG_OPERATION }, { 0, "job-hold-until", IPP_TAG_KEYWORD, IPP_TAG_JOB }, { 0, "job-id", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */ { 0, "job-impressions", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */ diff --git a/cups/ipp.h b/cups/ipp.h index ed0017019e..4b0fcb8bd6 100644 --- a/cups/ipp.h +++ b/cups/ipp.h @@ -113,7 +113,26 @@ typedef enum ipp_finish_e /**** Finishings ****/ IPP_FINISHINGS_TRIM_AFTER_PAGES = 60, /* Trim output after each page */ IPP_FINISHINGS_TRIM_AFTER_DOCUMENTS, /* Trim output after each document */ IPP_FINISHINGS_TRIM_AFTER_COPIES, /* Trim output after each copy */ - IPP_FINISHINGS_TRIM_AFTER_JOB /* Trim output after job */ + IPP_FINISHINGS_TRIM_AFTER_JOB, /* Trim output after job */ + + /* Proposed extensions for finishings */ + CUPS_FINISHINGS_PUNCH_TOP_LEFT = 0x40000046, + /* Punch 1 hole top left */ + CUPS_FINISHINGS_PUNCH_BOTTOM_LEFT, /* Punch 1 hole bottom left */ + CUPS_FINISHINGS_PUNCH_TOP_RIGHT, /* Punch 1 hole top right */ + CUPS_FINISHINGS_PUNCH_BOTTOM_RIGHT, /* Punch 1 hole bottom right */ + CUPS_FINISHINGS_PUNCH_DUAL_LEFT, /* Punch 2 holes left side */ + CUPS_FINISHINGS_PUNCH_DUAL_TOP, /* Punch 2 holes top edge */ + CUPS_FINISHINGS_PUNCH_DUAL_RIGHT, /* Punch 2 holes right side */ + CUPS_FINISHINGS_PUNCH_DUAL_BOTTOM, /* Punch 2 holes bottom edge */ + CUPS_FINISHINGS_PUNCH_TRIPLE_LEFT, /* Punch 3 holes left side */ + CUPS_FINISHINGS_PUNCH_TRIPLE_TOP, /* Punch 3 holes top edge */ + CUPS_FINISHINGS_PUNCH_TRIPLE_RIGHT, /* Punch 3 holes right side */ + CUPS_FINISHINGS_PUNCH_TRIPLE_BOTTOM, /* Punch 3 holes bottom edge */ + CUPS_FINISHINGS_PUNCH_QUAD_LEFT, /* Punch 4 holes left side */ + CUPS_FINISHINGS_PUNCH_QUAD_TOP, /* Punch 4 holes top edge */ + CUPS_FINISHINGS_PUNCH_QUAD_RIGHT, /* Punch 4 holes right side */ + CUPS_FINISHINGS_PUNCH_QUAD_BOTTOM /* Punch 4 holes bottom edge */ } ipp_finish_t; typedef enum ipp_jcollate_e /**** Job collation types ****/ diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index 2e7a5d626d..be4c64e981 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -560,6 +560,8 @@ _ppdCacheCreateWithFile( } else if (!_cups_strcasecmp(line, "MaxCopies")) pc->max_copies = atoi(value); + else if (!_cups_strcasecmp(line, "ChargeInfoURI")) + pc->charge_info_uri = _cupsStrAlloc(value); else if (!_cups_strcasecmp(line, "JobAccountId")) pc->account_id = !_cups_strcasecmp(value, "true"); else if (!_cups_strcasecmp(line, "JobAccountingUserId")) @@ -1380,10 +1382,13 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */ pc->max_copies = 9999; /* - * cupsJobAccountId, cupsJobAccountingUserId, cupsJobPassword, and - * cupsMandatory. + * cupsChargeInfoURI, cupsJobAccountId, cupsJobAccountingUserId, + * cupsJobPassword, and cupsMandatory. */ + if ((ppd_attr = ppdFindAttr(ppd, "cupsChargeInfoURI", NULL)) != NULL) + pc->charge_info_uri = _cupsStrAlloc(ppd_attr->value); + if ((ppd_attr = ppdFindAttr(ppd, "cupsJobAccountId", NULL)) != NULL) pc->account_id = !_cups_strcasecmp(ppd_attr->value, "true"); @@ -1496,6 +1501,7 @@ _ppdCacheDestroy(_ppd_cache_t *pc) /* I - PPD cache and mapping data */ cupsArrayDelete(pc->prefilters); cupsArrayDelete(pc->finishings); + _cupsStrFree(pc->charge_info_uri); _cupsStrFree(pc->password); cupsArrayDelete(pc->mandatory); @@ -2395,6 +2401,9 @@ _ppdCacheWriteFile( * Accounting/quota/PIN/managed printing values... */ + if (pc->charge_info_uri) + cupsFilePutConf(fp, "ChargeInfoURI", pc->charge_info_uri); + cupsFilePrintf(fp, "AccountId %s\n", pc->account_id ? "true" : "false"); cupsFilePrintf(fp, "AccountingUserId %s\n", pc->accounting_user_id ? "true" : "false"); diff --git a/cups/ppd-private.h b/cups/ppd-private.h index 1eaa2c816d..03b014783d 100644 --- a/cups/ppd-private.h +++ b/cups/ppd-private.h @@ -49,7 +49,7 @@ extern "C" { * Constants... */ -# define _PPD_CACHE_VERSION 4 /* Version number in cache file */ +# define _PPD_CACHE_VERSION 5 /* Version number in cache file */ /* @@ -146,6 +146,7 @@ struct _ppd_cache_s /**** PPD cache and PWG conversion data ****/ accounting_user_id; /* cupsJobAccountingUserId value */ char *password; /* cupsJobPassword value */ cups_array_t *mandatory; /* cupsMandatory value */ + char *charge_info_uri; /* cupsChargeInfoURI value */ }; diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 3da7bb9f50..41b371f778 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -5315,6 +5315,7 @@ create_requested_array(ipp_t *request) /* I - IPP request */ cupsArrayAdd(ra, "date-time-at-completed"); cupsArrayAdd(ra, "date-time-at-creation"); cupsArrayAdd(ra, "date-time-at-processing"); + cupsArrayAdd(ra, "job-charge-info"); cupsArrayAdd(ra, "job-detailed-status-message"); cupsArrayAdd(ra, "job-document-access-errors"); cupsArrayAdd(ra, "job-id"); @@ -5384,6 +5385,7 @@ create_requested_array(ipp_t *request) /* I - IPP request */ cupsArrayAdd(ra, "pdl-override-supported"); cupsArrayAdd(ra, "printer-alert"); cupsArrayAdd(ra, "printer-alert-description"); + cupsArrayAdd(ra, "printer-charge-info-uri"); cupsArrayAdd(ra, "printer-commands"); cupsArrayAdd(ra, "printer-current-time"); cupsArrayAdd(ra, "printer-dns-sd-name"); diff --git a/scheduler/job.c b/scheduler/job.c index 33ce6a1c60..37e621dcec 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -3655,6 +3655,7 @@ get_options(cupsd_job_t *job, /* I - Job */ if (!strncmp(attr->name, "job-", 4) && strcmp(attr->name, "job-account-id") && strcmp(attr->name, "job-accounting-user-id") && + strcmp(attr->name, "job-authorization-uri") && strcmp(attr->name, "job-billing") && strcmp(attr->name, "job-impressions") && strcmp(attr->name, "job-originating-host-name") && diff --git a/scheduler/printers.c b/scheduler/printers.c index 3c77269e09..8c0a9fa9af 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -3781,6 +3781,10 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ ippAddBoolean(p->ppd_attrs, IPP_TAG_PRINTER, "color-supported", ppd->color_device); + if (p->pc && p->pc->charge_info_uri) + ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_URI, + "printer-charge-info-uri", NULL, p->pc->charge_info_uri); + if (p->pc && p->pc->account_id) ippAddBoolean(p->ppd_attrs, IPP_TAG_PRINTER, "job-account-id-supported", 1); -- 2.47.3