/*
* Printer routines for the CUPS scheduler.
*
- * Copyright 2007-2017 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright © 2007-2018 by Apple Inc.
+ * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
*
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more
+ * information.
*/
/*
struct statfs spoolinfo; /* FS info for spool directory */
double spoolsize; /* FS size */
#endif /* HAVE_STATVFS */
- static const int nups[] = /* number-up-supported values */
+ static const char * const page_delivery[] =
+ { /* page-delivery-supported values */
+ "reverse-order",
+ "same-order"
+ };
+ static const char * const print_scaling[] =
+ { /* print-scaling-supported values */
+ "auto",
+ "auto-fit",
+ "fill",
+ "fit",
+ "none"
+ };
+ static const int number_up[] = /* number-up-supported values */
{ 1, 2, 4, 6, 9, 16 };
+ static const char * const number_up_layout[] =
+ { /* number-up-layout-supported values */
+ "btlr",
+ "btrl",
+ "lrbt",
+ "lrtb",
+ "rlbt",
+ "rltb",
+ "tblr",
+ "tbrl"
+ };
static const int orients[4] =/* orientation-requested-supported values */
{
IPP_PORTRAIT,
{ /* job-creation-attributes-supported */
"copies",
"finishings",
+ "finishings-col",
"ipp-attribute-fidelity",
"job-hold-until",
"job-name",
"media-col",
"multiple-document-handling",
"number-up",
- "output-bin",
+ "number-up-layout",
"orientation-requested",
+ "output-bin",
+ "page-delivery",
"page-ranges",
"print-color-mode",
"print-quality",
+ "print-scaling",
"printer-resolution",
"sides"
};
/* number-up-supported */
ippAddIntegers(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
- "number-up-supported", sizeof(nups) / sizeof(nups[0]), nups);
+ "number-up-supported", sizeof(number_up) / sizeof(number_up[0]), number_up);
+
+ /* number-up-layout-supported */
+ ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "number-up-layout-supported", sizeof(number_up_layout) / sizeof(number_up_layout[0]), NULL, number_up_layout);
/* operations-supported */
ippAddIntegers(CommonData, IPP_TAG_PRINTER, IPP_TAG_ENUM,
ippAddIntegers(CommonData, IPP_TAG_PRINTER, IPP_TAG_ENUM,
"orientation-requested-supported", 4, orients);
+ /* page-delivery-supported */
+ ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "page-delivery-supported", sizeof(page_delivery) / sizeof(page_delivery[0]), NULL, page_delivery);
+
/* page-ranges-supported */
ippAddBoolean(CommonData, IPP_TAG_PRINTER, "page-ranges-supported", 1);
ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD | IPP_TAG_COPY,
"pdl-override-supported", NULL, "attempted");
+ /* print-scaling-supported */
+ ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-scaling-supported", sizeof(print_scaling) / sizeof(print_scaling[0]), NULL, print_scaling);
+
/* printer-get-attributes-supported */
ippAddString(CommonData, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "printer-get-attributes-supported", NULL, "document-format");
cupsdClearString(&p->port_monitor);
cupsdClearString(&p->op_policy);
cupsdClearString(&p->error_policy);
+ cupsdClearString(&p->strings);
cupsdClearString(&p->alert);
cupsdClearString(&p->alert_description);
*filter; /* Current filter */
- DEBUG_printf(("cupsdSetPrinterAttrs: entering name = %s, type = %x\n", p->name,
- p->type));
-
/*
* Make sure that we have the common attributes defined...
*/
add_printer_formats(p);
- DEBUG_printf(("cupsdSetPrinterAttrs: leaving name = %s, type = %x\n", p->name,
- p->type));
-
/*
* Add name-default attributes...
*/
int port; /* Port portion of URI */
- DEBUG_printf(("cupsdValidateDest(uri=\"%s\", dtype=%p, printer=%p)\n", uri,
- dtype, printer));
-
/*
* Initialize return values...
*/
}
}
- DEBUG_printf(("localized hostname is \"%s\"...\n", localname));
-
/*
* Find a matching printer or class...
*/
ppd_file_t *ppd; /* PPD file */
char ppd_name[1024]; /* PPD filename */
struct stat ppd_info; /* PPD file info */
+ char strings_name[1024]; /* Strings filename */
int num_media; /* Number of media options */
ppd_size_t *size; /* Current PPD size */
ppd_option_t *duplex, /* Duplex option */
if (stat(ppd_name, &ppd_info))
ppd_info.st_mtime = 1;
+ snprintf(strings_name, sizeof(strings_name), "%s/%s.strings", CacheDir, p->name);
+
ippDelete(p->ppd_attrs);
p->ppd_attrs = NULL;
ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
"printer-make-and-model", NULL, p->make_model);
- if (p->pc->strings_uri)
- ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-strings-uri", NULL, p->pc->strings_uri);
+ if (p->pc && p->pc->strings)
+ _cupsMessageSave(strings_name, _CUPS_MESSAGE_STRINGS, p->pc->strings);
+
+ if (!access(strings_name, R_OK))
+ cupsdSetString(&p->strings, strings_name);
+ else
+ cupsdClearString(&p->strings);
/*
* Add media options from the PPD file...
input_slot = ppdFindMarkedChoice(ppd, "InputSlot");
media_type = ppdFindMarkedChoice(ppd, "MediaType");
col = new_media_col(pwgsize,
- input_slot ?
- _ppdCacheGetSource(p->pc,
- input_slot->choice) :
- NULL,
- media_type ?
- _ppdCacheGetType(p->pc,
- media_type->choice) :
- NULL);
-
- ippAddCollection(p->ppd_attrs, IPP_TAG_PRINTER, "media-col-default",
- col);
+ input_slot ? _ppdCacheGetSource(p->pc, input_slot->choice) : NULL,
+ media_type ? _ppdCacheGetType(p->pc, media_type->choice) : NULL);
+
+ ippAddCollection(p->ppd_attrs, IPP_TAG_PRINTER, "media-col-default", col);
ippDelete(col);
}
}
}
+ if (p->pc && p->pc->templates)
+ {
+ const char *template; /* Finishing template */
+ ipp_attribute_t *fin_col_db; /* finishings-col-database attribute */
+ ipp_t *fin_col; /* finishings-col value */
+
+ fin_col_db = ippAddCollections(p->ppd_attrs, IPP_TAG_PRINTER, "finishings-col-database", cupsArrayCount(p->pc->templates), NULL);
+ for (i = 0, template = (const char *)cupsArrayFirst(p->pc->templates); template; i ++, template = (const char *)cupsArrayNext(p->pc->templates))
+ {
+ fin_col = ippNew();
+ ippAddString(fin_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", NULL, template);
+ ippSetCollection(p->ppd_attrs, &fin_col_db, i, fin_col);
+ ippDelete(fin_col);
+ }
+ }
+
for (i = 0; i < ppd->num_sizes; i ++)
if (ppd->sizes[i].length > 1728)
p->type |= CUPS_PRINTER_LARGE;