+ if ((attr = ippFindAttribute(response, "finishings-col-database", IPP_TAG_BEGIN_COLLECTION)) != NULL)
+ {
+ ipp_t *finishing_col; /* Current finishing collection */
+ const char *template, /* Current finishing template */
+ *loctemplate; /* Localized template name */
+ cups_array_t *templates; /* Finishing templates */
+
+ 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")));
+
+ templates = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+ count = ippGetCount(attr);
+
+ for (i = 0; i < count; i ++)
+ {
+ finishing_col = ippGetCollection(attr, i);
+ template = ippGetString(ippFindAttribute(finishing_col, "finishing_template", IPP_TAG_ZERO), 0, NULL);
+
+ if (!template || cupsArrayFind(templates, (void *)template))
+ continue;
+
+ if (strncmp(template, "fold-", 5) && (strstr(template, "-bottom") || strstr(template, "-left") || strstr(template, "-right") || strstr(template, "-top")))
+ continue;
+
+ cupsArrayAdd(templates, (void *)template);
+
+ for (j = 0, loctemplate = NULL; j < (int)(sizeof(finishings) / sizeof(finishings[0])); j ++)
+ {
+ if (!strcmp(finishings[j][0], template))
+ {
+ loctemplate = _cupsLangString(lang, finishings[j][1]);
+ break;
+ }
+ }
+
+ if (!loctemplate)
+ {
+ char msg[256]; /* Message key */
+
+ snprintf(msg, sizeof(msg), "finishing-template.%s", template);
+ if ((loctemplate = _cupsMessageLookup(strings, msg)) == msg)
+ loctemplate = template;
+ }
+
+ cupsFilePrintf(fp, "*cupsFinishingTemplate %s/%s: \"\"\n", template, loctemplate);
+ }
+
+ cupsFilePuts(fp, "*CloseUI: *cupsFinishingTemplate\n");
+
+ if (cupsArrayCount(fin_options))
+ {
+ const char *fin_option; /* Current finishing option */
+
+ cupsFilePuts(fp, "*cupsUIConstraint finisings: \"*cupsFinishingTemplate");
+ for (fin_option = (const char *)cupsArrayFirst(fin_options); fin_option; fin_option = (const char *)cupsArrayNext(fin_options))
+ cupsFilePrintf(fp, " %s", fin_option);
+ cupsFilePuts(fp, "\"\n");
+
+ cupsFilePuts(fp, "*cupsUIResolver finisings: \"*cupsFinishingTemplate None");
+ for (fin_option = (const char *)cupsArrayFirst(fin_options); fin_option; fin_option = (const char *)cupsArrayNext(fin_options))
+ cupsFilePrintf(fp, " %s None", fin_option);
+ cupsFilePuts(fp, "\"\n");
+ }
+
+ cupsArrayDelete(templates);
+ }
+
+ cupsArrayDelete(fin_options);
+