+ ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "document-password-supported", 127);
+
+ /* finishing-template-supported */
+ attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template-supported", cupsArrayCount(pc->templates) + 1, NULL, NULL);
+ ippSetString(attrs, &attr, 0, "none");
+ for (i = 1, template = (const char *)cupsArrayFirst(pc->templates); template; i ++, template = (const char *)cupsArrayNext(pc->templates))
+ ippSetString(attrs, &attr, i, template);
+
+ /* finishings-col-database */
+ attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "finishings-col-database", cupsArrayCount(pc->templates) + 1, NULL);
+
+ col = ippNew();
+ ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", NULL, "none");
+ ippSetCollection(attrs, &attr, 0, col);
+ ippDelete(col);
+
+ for (i = 1, template = (const char *)cupsArrayFirst(pc->templates); template; i ++, template = (const char *)cupsArrayNext(pc->templates))
+ {
+ col = ippNew();
+ ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", NULL, template);
+ ippSetCollection(attrs, &attr, i, col);
+ ippDelete(col);
+ }
+
+ /* finishings-col-default */
+ col = ippNew();
+ ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", NULL, "none");
+ ippAddCollection(attrs, IPP_TAG_PRINTER, "finishings-col-default", col);
+ ippDelete(col);
+
+ /* finishings-col-ready */
+ attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "finishings-col-ready", cupsArrayCount(pc->templates) + 1, NULL);
+
+ col = ippNew();
+ ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", NULL, "none");
+ ippSetCollection(attrs, &attr, 0, col);
+ ippDelete(col);
+
+ for (i = 1, template = (const char *)cupsArrayFirst(pc->templates); template; i ++, template = (const char *)cupsArrayNext(pc->templates))
+ {
+ col = ippNew();
+ ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", NULL, template);
+ ippSetCollection(attrs, &attr, i, col);
+ ippDelete(col);
+ }
+
+ /* finishings-col-supported */
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishings-col-supported", NULL, "finishing-template");
+
+ /* finishings-default */
+ ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "finishings-default", IPP_FINISHINGS_NONE);
+
+ /* finishings-ready */
+ attr = ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "finishings-ready", cupsArrayCount(pc->finishings) + 1, NULL);
+ ippSetInteger(attrs, &attr, 0, IPP_FINISHINGS_NONE);
+ for (i = 1, finishings = (_pwg_finishings_t *)cupsArrayFirst(pc->finishings); finishings; i ++, finishings = (_pwg_finishings_t *)cupsArrayNext(pc->finishings))
+ ippSetInteger(attrs, &attr, i, finishings->value);
+
+ /* finishings-supported */
+ attr = ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "finishings-supported", cupsArrayCount(pc->finishings) + 1, NULL);
+ ippSetInteger(attrs, &attr, 0, IPP_FINISHINGS_NONE);
+ for (i = 1, finishings = (_pwg_finishings_t *)cupsArrayFirst(pc->finishings); finishings; i ++, finishings = (_pwg_finishings_t *)cupsArrayNext(pc->finishings))
+ ippSetInteger(attrs, &attr, i, finishings->value);
+
+ /* media-bottom-margin-supported */
+ for (i = 0, num_margins = 0, pwg_size = pc->sizes; i < pc->num_sizes && num_margins < (int)(sizeof(margins) / sizeof(margins[0])); i ++, pwg_size ++)
+ {
+ for (j = 0; j < num_margins; j ++)
+ {
+ if (margins[j] == pwg_size->bottom)
+ break;
+ }
+
+ if (j >= num_margins)
+ margins[num_margins ++] = pwg_size->bottom;
+ }
+
+ for (i = 0; i < (num_margins - 1); i ++)
+ {
+ for (j = i + 1; j < num_margins; j ++)
+ {
+ if (margins[i] > margins[j])
+ {
+ int mtemp = margins[i];
+
+ margins[i] = margins[j];
+ margins[j] = mtemp;
+ }
+ }
+ }
+
+ ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-bottom-margin-supported", num_margins, margins);
+
+ /* media-col-database */
+ attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "media-col-database", pc->num_sizes, NULL);
+ for (i = 0, pwg_size = pc->sizes; i < pc->num_sizes; i ++, pwg_size ++)
+ {
+ col = create_media_col(pwg_size->map.pwg, NULL, NULL, pwg_size->width, pwg_size->length, pwg_size->bottom, pwg_size->left, pwg_size->right, pwg_size->top);
+ ippSetCollection(attrs, &attr, i, col);
+ ippDelete(col);
+ }
+
+ /* media-col-default */
+ col = create_media_col(default_size->map.pwg, NULL, NULL, default_size->width, default_size->length, default_size->bottom, default_size->left, default_size->right, default_size->top);
+ ippAddCollection(attrs, IPP_TAG_PRINTER, "media-col-default", col);
+ ippDelete(col);
+
+ /* media-col-ready */
+ col = create_media_col(default_size->map.pwg, pc->num_sources > 0 ? pc->sources[0].pwg : NULL, pc->num_types > 0 ? pc->types[0].pwg : NULL, default_size->width, default_size->length, default_size->bottom, default_size->left, default_size->right, default_size->top);
+ ippAddCollection(attrs, IPP_TAG_PRINTER, "media-col-ready", col);
+ ippDelete(col);
+
+ /* media-default */
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-default", NULL, default_size->map.pwg);
+
+ /* media-left-margin-supported */
+ for (i = 0, num_margins = 0, pwg_size = pc->sizes; i < pc->num_sizes && num_margins < (int)(sizeof(margins) / sizeof(margins[0])); i ++, pwg_size ++)
+ {
+ for (j = 0; j < num_margins; j ++)
+ {
+ if (margins[j] == pwg_size->left)
+ break;
+ }
+
+ if (j >= num_margins)
+ margins[num_margins ++] = pwg_size->left;
+ }
+
+ for (i = 0; i < (num_margins - 1); i ++)
+ {
+ for (j = i + 1; j < num_margins; j ++)
+ {
+ if (margins[i] > margins[j])
+ {
+ int mtemp = margins[i];
+
+ margins[i] = margins[j];
+ margins[j] = mtemp;
+ }
+ }
+ }
+
+ ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-left-margin-supported", num_margins, margins);
+
+ /* media-ready */
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-ready", NULL, default_size->map.pwg);
+
+ /* media-right-margin-supported */
+ for (i = 0, num_margins = 0, pwg_size = pc->sizes; i < pc->num_sizes && num_margins < (int)(sizeof(margins) / sizeof(margins[0])); i ++, pwg_size ++)
+ {
+ for (j = 0; j < num_margins; j ++)
+ {
+ if (margins[j] == pwg_size->right)
+ break;
+ }
+
+ if (j >= num_margins)
+ margins[num_margins ++] = pwg_size->right;
+ }
+
+ for (i = 0; i < (num_margins - 1); i ++)
+ {
+ for (j = i + 1; j < num_margins; j ++)
+ {
+ if (margins[i] > margins[j])
+ {
+ int mtemp = margins[i];
+
+ margins[i] = margins[j];
+ margins[j] = mtemp;
+ }
+ }
+ }
+
+ ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-right-margin-supported", num_margins, margins);
+
+ /* media-supported */
+ attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-supported", pc->num_sizes, NULL, NULL);
+ for (i = 0, pwg_size = pc->sizes; i < pc->num_sizes; i ++, pwg_size ++)
+ ippSetString(attrs, &attr, i, pwg_size->map.pwg);
+
+ /* media-size-supported */
+ attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "media-size-supported", pc->num_sizes, NULL);
+ for (i = 0, pwg_size = pc->sizes; i < pc->num_sizes; i ++, pwg_size ++)
+ {
+ col = create_media_size(pwg_size->width, pwg_size->length);
+ ippSetCollection(attrs, &attr, i, col);
+ ippDelete(col);
+ }
+
+ /* media-source-supported */
+ if (pc->num_sources > 0)
+ {
+ attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-source-supported", pc->num_sources, NULL, NULL);
+ for (i = 0, pwg_map = pc->sources; i < pc->num_sources; i ++, pwg_map ++)
+ ippSetString(attrs, &attr, i, pwg_map->pwg);
+ }
+ else
+ {
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-source-supported", NULL, "auto");
+ }
+
+ /* media-top-margin-supported */
+ for (i = 0, num_margins = 0, pwg_size = pc->sizes; i < pc->num_sizes && num_margins < (int)(sizeof(margins) / sizeof(margins[0])); i ++, pwg_size ++)
+ {
+ for (j = 0; j < num_margins; j ++)
+ {
+ if (margins[j] == pwg_size->top)
+ break;
+ }
+
+ if (j >= num_margins)
+ margins[num_margins ++] = pwg_size->top;
+ }
+
+ for (i = 0; i < (num_margins - 1); i ++)
+ {
+ for (j = i + 1; j < num_margins; j ++)
+ {
+ if (margins[i] > margins[j])
+ {
+ int mtemp = margins[i];
+
+ margins[i] = margins[j];
+ margins[j] = mtemp;
+ }
+ }
+ }
+
+ ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-top-margin-supported", num_margins, margins);
+
+ /* media-type-supported */
+ if (pc->num_types > 0)
+ {
+ attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-type-supported", pc->num_types, NULL, NULL);
+ for (i = 0, pwg_map = pc->types; i < pc->num_types; i ++, pwg_map ++)
+ ippSetString(attrs, &attr, i, pwg_map->pwg);
+ }
+ else
+ {
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-type-supported", NULL, "auto");
+ }
+
+ /* orientation-requested-default */
+ ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "orientation-requested-default", IPP_ORIENT_PORTRAIT);
+
+ /* orientation-requested-supported */
+ ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "orientation-requested-supported", (int)(sizeof(orientation_requested_supported) / sizeof(orientation_requested_supported[0])), orientation_requested_supported);
+
+ /* output-bin-default */
+ if (pc->num_bins > 0)
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "output-bin-default", NULL, pc->bins->pwg);
+ else
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "output-bin-default", NULL, "face-down");
+
+ /* output-bin-supported */
+ if (pc->num_bins > 0)
+ {
+ attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "output-bin-supported", pc->num_bins, NULL, NULL);
+ for (i = 0, pwg_map = pc->bins; i < pc->num_bins; i ++, pwg_map ++)
+ ippSetString(attrs, &attr, i, pwg_map->pwg);
+ }
+ else
+ {
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "output-bin-supported", NULL, "face-down");
+ }