Skip to content

Commit

Permalink
Add support for finishings-col (Issue #5180)
Browse files Browse the repository at this point in the history
- cups/ppd-cache.c: Look for cupsFinishingTemplate option,
  finishings-col-database attribute.  Add finishings-col with
  finishing-template.
- cups/ppd-private.h: Add array of finishing-template names.
- scheduler/printers.c: Add finishings-col-database.
  • Loading branch information
michaelrsweet committed Nov 28, 2017
1 parent 27ee2c4 commit 4f63d6c
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 23 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CHANGES - 2.3b1 - 2017-11-27
CHANGES - 2.3b1 - 2017-11-28
============================


Expand Down Expand Up @@ -41,4 +41,5 @@ Changes in CUPS v2.3b1
when available (Issue #5168)
- The cups-driverd program incorrectly stopped scanning PPDs as soon as a loop
was seen (Issue #5170)
- IPP Everywhere PPDs now support finishing templates (Issue #5180)

63 changes: 53 additions & 10 deletions cups/ppd-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ _cupsConvertOptions(
*media_type, /* media-type value */
*collate_str, /* multiple-document-handling value */
*color_attr_name, /* Supported color attribute */
*mandatory; /* Mandatory attributes */
*mandatory, /* Mandatory attributes */
*finishing_template; /* Finishing template */
int num_finishings = 0, /* Number of finishing values */
finishings[10]; /* Finishing enum values */
ppd_choice_t *choice; /* Marked choice */
Expand Down Expand Up @@ -136,6 +137,8 @@ _cupsConvertOptions(
if (strcmp(mandatory, "copies") &&
strcmp(mandatory, "destination-uris") &&
strcmp(mandatory, "finishings") &&
strcmp(mandatory, "finishings-col") &&
strcmp(mandatory, "finishing-template") &&
strcmp(mandatory, "job-account-id") &&
strcmp(mandatory, "job-accounting-user-id") &&
strcmp(mandatory, "job-password") &&
Expand Down Expand Up @@ -358,10 +361,16 @@ _cupsConvertOptions(
* Map finishing options...
*/

num_finishings = _ppdCacheGetFinishingValues(pc, num_options, options, (int)(sizeof(finishings) / sizeof(finishings[0])), finishings);
if (num_finishings > 0)
if ((finishing_template = cupsGetOption("cupsFinishingTemplate", num_options, options)) == NULL)
finishing_template = cupsGetOption("finishing-template", num_options, options);

if (finishing_template)
{
ippAddIntegers(request, IPP_TAG_JOB, IPP_TAG_ENUM, "finishings", num_finishings, finishings);
ipp_t *fin_col = ippNew(); /* finishings-col value */

ippAddString(fin_col, IPP_TAG_JOB, IPP_TAG_KEYWORD, "finishing-template", NULL, finishing_template);
ippAddCollection(request, IPP_TAG_JOB, "finishings-col", fin_col);
ippDelete(fin_col);

if (copies != finishings_copies && (keyword = cupsGetOption("job-impressions", num_options, options)) != NULL)
{
Expand All @@ -372,6 +381,23 @@ _cupsConvertOptions(
ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-pages-per-set", atoi(keyword) / finishings_copies);
}
}
else
{
num_finishings = _ppdCacheGetFinishingValues(pc, num_options, options, (int)(sizeof(finishings) / sizeof(finishings[0])), finishings);
if (num_finishings > 0)
{
ippAddIntegers(request, IPP_TAG_JOB, IPP_TAG_ENUM, "finishings", num_finishings, finishings);

if (copies != finishings_copies && (keyword = cupsGetOption("job-impressions", num_options, options)) != NULL)
{
/*
* Send job-pages-per-set attribute to apply finishings correctly...
*/

ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-pages-per-set", atoi(keyword) / finishings_copies);
}
}
}

return (copies);
}
Expand Down Expand Up @@ -863,6 +889,13 @@ _ppdCacheCreateWithFile(

cupsArrayAdd(pc->finishings, finishings);
}
else if (!_cups_strcasecmp(line, "FinishingTemplate"))
{
if (!pc->templates)
pc->templates = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)_cupsStrAlloc, (cups_afree_func_t)_cupsStrFree);

cupsArrayAdd(pc->templates, value);
}
else if (!_cups_strcasecmp(line, "MaxCopies"))
pc->max_copies = atoi(value);
else if (!_cups_strcasecmp(line, "ChargeInfoURI"))
Expand Down Expand Up @@ -958,7 +991,8 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */
*media_type, /* MediaType option */
*output_bin, /* OutputBin option */
*color_model, /* ColorModel option */
*duplex; /* Duplex option */
*duplex, /* Duplex option */
*ppd_option; /* Other PPD option */
ppd_choice_t *choice; /* Current InputSlot/MediaType */
pwg_map_t *map; /* Current source/type map */
ppd_attr_t *ppd_attr; /* Current PPD preset attribute */
Expand Down Expand Up @@ -1695,8 +1729,6 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */
* No IPP mapping data, try to map common/standard PPD keywords...
*/

ppd_option_t *ppd_option; /* PPD option */

pc->finishings = cupsArrayNew3((cups_array_func_t)pwg_compare_finishings, NULL, NULL, 0, NULL, (cups_afree_func_t)pwg_free_finishings);

if ((ppd_option = ppdFindOption(ppd, "StapleLocation")) != NULL)
Expand Down Expand Up @@ -1798,6 +1830,14 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */
}
}

if ((ppd_option = ppdFindOption(ppd, "cupsFinishingTemplate")) != NULL)
{
pc->templates = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)_cupsStrAlloc, (cups_afree_func_t)_cupsStrFree);

for (choice = ppd_option->choices, i = ppd_option->num_choices; i > 0; choice ++, i --)
cupsArrayAdd(pc->templates, (void *)choice->choice);
}

/*
* Max copies...
*/
Expand Down Expand Up @@ -2730,7 +2770,7 @@ _ppdCacheWriteFile(
pwg_map_t *map; /* Current map */
_pwg_finishings_t *f; /* Current finishing option */
cups_option_t *option; /* Current option */
const char *value; /* Filter/pre-filter value */
const char *value; /* String value */
char newfile[1024]; /* New filename */


Expand Down Expand Up @@ -2878,6 +2918,9 @@ _ppdCacheWriteFile(
cupsFilePutChar(fp, '\n');
}

for (value = (const char *)cupsArrayFirst(pc->templates); value; value = (const char *)cupsArrayNext(pc->templates))
cupsFilePutConf(fp, "FinishingTemplate", value);

/*
* Max copies...
*/
Expand Down Expand Up @@ -4036,8 +4079,8 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */

cupsFilePrintf(fp, "*OpenUI *cupsFinishingTemplate/%s: PickOne\n", _cupsLangString(lang, _("Finishing Preset")));
cupsFilePuts(fp, "*OrderDependency: 10 AnySetup *cupsFinishingTemplate\n");
cupsFilePuts(fp, "*DefaultcupsFinishingTemplate: None\n");
cupsFilePrintf(fp, "*cupsFinishingTemplate None/%s: \"\"\n", _cupsLangString(lang, _("None")));
cupsFilePuts(fp, "*DefaultcupsFinishingTemplate: none\n");
cupsFilePrintf(fp, "*cupsFinishingTemplate none/%s: \"\"\n", _cupsLangString(lang, _("None")));

templates = cupsArrayNew((cups_array_func_t)strcmp, NULL);
count = ippGetCount(attr);
Expand Down
1 change: 1 addition & 0 deletions cups/ppd-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ struct _ppd_cache_s /**** PPD cache and PWG conversion data ****/
*prefilters; /* cupsPreFilter values */
int single_file; /* cupsSingleFile value */
cups_array_t *finishings; /* cupsIPPFinishings values */
cups_array_t *templates; /* cupsFinishingTemplate values */
int max_copies, /* cupsMaxCopies value */
account_id, /* cupsJobAccountId value */
accounting_user_id; /* cupsJobAccountingUserId value */
Expand Down
Binary file modified doc/help/cupspm.epub
Binary file not shown.
29 changes: 29 additions & 0 deletions doc/help/cupspm.html
Original file line number Diff line number Diff line change
Expand Up @@ -6291,15 +6291,21 @@ <h3 class="enumeration"><a id="ipp_op_e">ipp_op_e</a></h3>
<p class="description">IPP operations</p>
<h4 class="constants">Constants</h4>
<table class="list"><tbody>
<tr><th>IPP_OP_ALLOCATE_PRINTER_RESOURCES </th> <td class="description">Allocate-Printer-Resources: Use resources for a printer.</td></tr>
<tr><th>IPP_OP_CANCEL_CURRENT_JOB </th> <td class="description">Cancel-Current-Job: Cancel the current job</td></tr>
<tr><th>IPP_OP_CANCEL_JOB </th> <td class="description">Cancel-Job: Cancel a job</td></tr>
<tr><th>IPP_OP_CANCEL_JOBS </th> <td class="description">Cancel-Jobs: Cancel all jobs (administrative)</td></tr>
<tr><th>IPP_OP_CANCEL_MY_JOBS </th> <td class="description">Cancel-My-Jobs: Cancel a user's jobs</td></tr>
<tr><th>IPP_OP_CANCEL_RESOURCE </th> <td class="description">Cancel-Resource: Uninstall a resource.</td></tr>
<tr><th>IPP_OP_CANCEL_SUBSCRIPTION <span class="info">&#160;CUPS 1.2/macOS 10.5&#160;</span></th> <td class="description">Cancel-Subscription: Cancel a subscription </td></tr>
<tr><th>IPP_OP_CLOSE_JOB </th> <td class="description">Close-Job: Close a job and start printing</td></tr>
<tr><th>IPP_OP_CREATE_JOB </th> <td class="description">Create-Job: Create an empty print job</td></tr>
<tr><th>IPP_OP_CREATE_JOB_SUBSCRIPTIONS <span class="info">&#160;CUPS 1.2/macOS 10.5&#160;</span></th> <td class="description">Create-Job-Subscriptions: Create one of more job subscriptions </td></tr>
<tr><th>IPP_OP_CREATE_PRINTER </th> <td class="description">Create-Printer: Create a new service.</td></tr>
<tr><th>IPP_OP_CREATE_PRINTER_SUBSCRIPTIONS <span class="info">&#160;CUPS 1.2/macOS 10.5&#160;</span></th> <td class="description">Create-Printer-Subscriptions: Create one or more printer subscriptions </td></tr>
<tr><th>IPP_OP_CREATE_RESOURCE </th> <td class="description">Create-Resource: Create a new (empty) resource.</td></tr>
<tr><th>IPP_OP_CREATE_RESOURCE_SUBSCRIPTIONS </th> <td class="description">Create-Resource-Subscriptions: Create event subscriptions for a resource.</td></tr>
<tr><th>IPP_OP_CREATE_SYSTEM_SUBSCRIPTIONS </th> <td class="description">Create-System-Subscriptions: Create event subscriptions for a system.</td></tr>
<tr><th>IPP_OP_CUPS_ADD_MODIFY_CLASS </th> <td class="description">CUPS-Add-Modify-Class: Add or modify a class</td></tr>
<tr><th>IPP_OP_CUPS_ADD_MODIFY_PRINTER </th> <td class="description">CUPS-Add-Modify-Printer: Add or modify a printer</td></tr>
<tr><th>IPP_OP_CUPS_AUTHENTICATE_JOB <span class="info">&#160;CUPS 1.2/macOS 10.5&#160;</span></th> <td class="description">CUPS-Authenticate-Job: Authenticate a job </td></tr>
Expand All @@ -6315,32 +6321,52 @@ <h4 class="constants">Constants</h4>
<tr><th>IPP_OP_CUPS_INVALID </th> <td class="description">Invalid operation name for <a href="#ippOpValue"><code>ippOpValue</code></a></td></tr>
<tr><th>IPP_OP_CUPS_MOVE_JOB </th> <td class="description">CUPS-Move-Job: Move a job to a different printer</td></tr>
<tr><th>IPP_OP_CUPS_SET_DEFAULT </th> <td class="description">CUPS-Set-Default: Set the default printer</td></tr>
<tr><th>IPP_OP_DEALLOCATE_PRINTER_RESOURCES </th> <td class="description">Deallocate-Printer-Resources: Stop using resources for a printer.</td></tr>
<tr><th>IPP_OP_DELETE_PRINTER </th> <td class="description">Delete-Printer: Delete an existing service.</td></tr>
<tr><th>IPP_OP_DISABLE_ALL_PRINTERS </th> <td class="description">Disable-All-Printers: Stop accepting new jobs on all services.</td></tr>
<tr><th>IPP_OP_DISABLE_PRINTER </th> <td class="description">Disable-Printer: Reject new jobs for a printer</td></tr>
<tr><th>IPP_OP_ENABLE_ALL_PRINTERS </th> <td class="description">Enable-All-Printers: Start accepting new jobs on all services.</td></tr>
<tr><th>IPP_OP_ENABLE_PRINTER </th> <td class="description">Enable-Printer: Accept new jobs for a printer</td></tr>
<tr><th>IPP_OP_GET_JOBS </th> <td class="description">Get-Jobs: Get a list of jobs</td></tr>
<tr><th>IPP_OP_GET_JOB_ATTRIBUTES </th> <td class="description">Get-Job-Attribute: Get information about a job</td></tr>
<tr><th>IPP_OP_GET_NOTIFICATIONS <span class="info">&#160;CUPS 1.2/macOS 10.5&#160;</span></th> <td class="description">Get-Notifications: Get notification events </td></tr>
<tr><th>IPP_OP_GET_PRINTERS </th> <td class="description">Get-Printers: Get a list of services.</td></tr>
<tr><th>IPP_OP_GET_PRINTER_ATTRIBUTES </th> <td class="description">Get-Printer-Attributes: Get information about a printer</td></tr>
<tr><th>IPP_OP_GET_PRINTER_SUPPORTED_VALUES </th> <td class="description">Get-Printer-Supported-Values: Get supported values</td></tr>
<tr><th>IPP_OP_GET_SUBSCRIPTIONS <span class="info">&#160;CUPS 1.2/macOS 10.5&#160;</span></th> <td class="description">Get-Subscriptions: Get list of subscriptions </td></tr>
<tr><th>IPP_OP_GET_SUBSCRIPTION_ATTRIBUTES <span class="info">&#160;CUPS 1.2/macOS 10.5&#160;</span></th> <td class="description">Get-Subscription-Attributes: Get subscription information </td></tr>
<tr><th>IPP_OP_GET_SYSTEM_ATTRIBUTES </th> <td class="description">Get-System-Attributes: Get system object attributes.</td></tr>
<tr><th>IPP_OP_GET_SYSTEM_SUPPORTED_VALUES </th> <td class="description">Get-System-Supported-Values: Get supported values for system object attributes.</td></tr>
<tr><th>IPP_OP_HOLD_JOB </th> <td class="description">Hold-Job: Hold a job for printing</td></tr>
<tr><th>IPP_OP_HOLD_NEW_JOBS </th> <td class="description">Hold-New-Jobs: Hold new jobs</td></tr>
<tr><th>IPP_OP_IDENTIFY_PRINTER </th> <td class="description">Identify-Printer: Make the printer beep, flash, or display a message for identification</td></tr>
<tr><th>IPP_OP_INSTALL_RESOURCE </th> <td class="description">Install-Resource: Install a resource.</td></tr>
<tr><th>IPP_OP_PAUSE_ALL_PRINTERS </th> <td class="description">Pause-All-Printers: Stop all services immediately.</td></tr>
<tr><th>IPP_OP_PAUSE_ALL_PRINTERS_AFTER_CURRENT_JOB </th> <td class="description">Pause-All-Printers-After-Current-Job: Stop all services after processing the current jobs.</td></tr>
<tr><th>IPP_OP_PAUSE_PRINTER </th> <td class="description">Pause-Printer: Stop a printer</td></tr>
<tr><th>IPP_OP_PAUSE_PRINTER_AFTER_CURRENT_JOB </th> <td class="description">Pause-Printer-After-Current-Job: Stop printer after the current job</td></tr>
<tr><th>IPP_OP_PRINT_JOB </th> <td class="description">Print-Job: Print a single file</td></tr>
<tr><th>IPP_OP_PROMOTE_JOB </th> <td class="description">Promote-Job: Promote a job to print sooner</td></tr>
<tr><th>IPP_OP_REGISTER_OUTPUT_DEVICE </th> <td class="description">Register-Output-Device: Register a remote service.</td></tr>
<tr><th>IPP_OP_RELEASE_HELD_NEW_JOBS </th> <td class="description">Release-Held-New-Jobs: Release new jobs that were previously held</td></tr>
<tr><th>IPP_OP_RELEASE_JOB </th> <td class="description">Release-Job: Release a job for printing</td></tr>
<tr><th>IPP_OP_RENEW_SUBSCRIPTION <span class="info">&#160;CUPS 1.2/macOS 10.5&#160;</span></th> <td class="description">Renew-Subscription: Renew a printer subscription </td></tr>
<tr><th>IPP_OP_RESTART_JOB <span class="info">&#160;DEPRECATED&#160;</span></th> <td class="description">Restart-Job: Reprint a job </td></tr>
<tr><th>IPP_OP_RESTART_SYSTEM </th> <td class="description">Restart-System: Restart all services.</td></tr>
<tr><th>IPP_OP_RESUME_ALL_PRINTERS </th> <td class="description">Resume-All-Printers: Start job processing on all services.</td></tr>
<tr><th>IPP_OP_RESUME_JOB </th> <td class="description">Resume-Job: Resume the current job</td></tr>
<tr><th>IPP_OP_RESUME_PRINTER </th> <td class="description">Resume-Printer: Start a printer</td></tr>
<tr><th>IPP_OP_SCHEDULE_JOB_AFTER </th> <td class="description">Schedule-Job-After: Schedule a job to print after another</td></tr>
<tr><th>IPP_OP_SEND_DOCUMENT </th> <td class="description">Send-Document: Add a file to a job</td></tr>
<tr><th>IPP_OP_SEND_RESOURCE_DATA </th> <td class="description">Send-Resource-Data: Upload the data for a resource.</td></tr>
<tr><th>IPP_OP_SET_JOB_ATTRIBUTES </th> <td class="description">Set-Job-Attributes: Set job values</td></tr>
<tr><th>IPP_OP_SET_PRINTER_ATTRIBUTES </th> <td class="description">Set-Printer-Attributes: Set printer values</td></tr>
<tr><th>IPP_OP_SET_RESOURCE_ATTRIBUTES </th> <td class="description">Set-Resource-Attributes: Set resource object attributes.</td></tr>
<tr><th>IPP_OP_SET_SYSTEM_ATTRIBUTES </th> <td class="description">Set-System-Attributes: Set system object attributes.</td></tr>
<tr><th>IPP_OP_SHUTDOWN_ALL_PRINTERS </th> <td class="description">Shutdown-All-Printers: Shutdown all services.</td></tr>
<tr><th>IPP_OP_SHUTDOWN_ONE_PRINTER </th> <td class="description">Shutdown-One-Printer: Shutdown a service.</td></tr>
<tr><th>IPP_OP_STARTUP_ALL_PRINTERS </th> <td class="description">Startup-All-Printers: Startup all services.</td></tr>
<tr><th>IPP_OP_STARTUP_ONE_PRINTER </th> <td class="description">Startup-One-Printer: Start a service.</td></tr>
<tr><th>IPP_OP_SUSPEND_CURRENT_JOB </th> <td class="description">Suspend-Current-Job: Suspend the current job</td></tr>
<tr><th>IPP_OP_VALIDATE_JOB </th> <td class="description">Validate-Job: Validate job values prior to submission</td></tr>
</tbody></table>
Expand Down Expand Up @@ -6461,6 +6487,7 @@ <h4 class="constants">Constants</h4>
<tr><th>IPP_TAG_DATE </th> <td class="description">Date/time value</td></tr>
<tr><th>IPP_TAG_DEFAULT </th> <td class="description">Default value</td></tr>
<tr><th>IPP_TAG_DELETEATTR </th> <td class="description">Delete-attribute value</td></tr>
<tr><th>IPP_TAG_DOCUMENT </th> <td class="description">Document group</td></tr>
<tr><th>IPP_TAG_END </th> <td class="description">End-of-attributes</td></tr>
<tr><th>IPP_TAG_ENUM </th> <td class="description">Enumeration value</td></tr>
<tr><th>IPP_TAG_EVENT_NOTIFICATION </th> <td class="description">Event group</td></tr>
Expand All @@ -6477,8 +6504,10 @@ <h4 class="constants">Constants</h4>
<tr><th>IPP_TAG_PRINTER </th> <td class="description">Printer group</td></tr>
<tr><th>IPP_TAG_RANGE </th> <td class="description">Range value</td></tr>
<tr><th>IPP_TAG_RESOLUTION </th> <td class="description">Resolution value</td></tr>
<tr><th>IPP_TAG_RESOURCE </th> <td class="description">Resource group</td></tr>
<tr><th>IPP_TAG_STRING </th> <td class="description">Octet string value</td></tr>
<tr><th>IPP_TAG_SUBSCRIPTION </th> <td class="description">Subscription group</td></tr>
<tr><th>IPP_TAG_SYSTEM </th> <td class="description">System group</td></tr>
<tr><th>IPP_TAG_TEXT </th> <td class="description">Text value</td></tr>
<tr><th>IPP_TAG_TEXTLANG </th> <td class="description">Text-with-language value</td></tr>
<tr><th>IPP_TAG_UNKNOWN </th> <td class="description">Unknown value</td></tr>
Expand Down

0 comments on commit 4f63d6c

Please sign in to comment.