Skip to content

Commit

Permalink
Fix output-bin-default and sides-default support with Set-Printer-Att…
Browse files Browse the repository at this point in the history
…ributes (Issue #305)
  • Loading branch information
michaelrsweet committed Nov 19, 2023
1 parent dfbf2d8 commit 19fe709
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ Changes in v2.0b1
- Fixed potential deadlock issue (Issue #297)
- Fixed loading of previous state (Issue #298)
- Fixed "printer-id" value for new printers (Issue #301)
- Fixed Set-Printer-Attributes for "output-bin-default" and "sides-default"
(Issue #305)
- Fixed default "copies" value with `papplJobCreateWithFile`.
38 changes: 37 additions & 1 deletion pappl/printer-ipp.c
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ _papplPrinterSetAttributes(
{ "media-default", IPP_TAG_KEYWORD, 1 },
{ "media-ready", IPP_TAG_KEYWORD, PAPPL_MAX_SOURCE },
{ "orientation-requested-default", IPP_TAG_ENUM, 1 },
{ "output-bin-default", IPP_TAG_KEYWORD, 1 },
{ "print-color-mode-default", IPP_TAG_KEYWORD, 1 },
{ "print-content-optimize-default", IPP_TAG_KEYWORD, 1 },
{ "print-darkness-default", IPP_TAG_INTEGER, 1 },
Expand All @@ -979,7 +980,8 @@ _papplPrinterSetAttributes(
{ "printer-organizational-unit", IPP_TAG_TEXT, 1 },
{ "printer-resolution-default", IPP_TAG_RESOLUTION, 1 },
{ "printer-wifi-password", IPP_TAG_STRING, 1 },
{ "printer-wifi-ssid", IPP_TAG_NAME, 1 }
{ "printer-wifi-ssid", IPP_TAG_NAME, 1 },
{ "sides-default", IPP_TAG_KEYWORD, 1 }
};


Expand Down Expand Up @@ -1115,6 +1117,25 @@ _papplPrinterSetAttributes(
driver_data.orient_default = (ipp_orient_t)ippGetInteger(rattr, 0);
do_defaults = true;
}
else if (!strcmp(name, "output-bin-default"))
{
const char *keyword = ippGetString(rattr, 0, NULL);
// Keyword value

for (i = 0; i < driver_data.num_bin; i ++)
{
if (!strcmp(keyword, driver_data.bin[i]))
{
driver_data.bin_default = i;
break;
}
}

if (i >= driver_data.num_bin)
papplClientRespondIPP(client, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, "Unsupported \"output-bin-default\" value '%s'.", keyword);
else
do_defaults = true;
}
else if (!strcmp(name, "print-color-mode-default"))
{
driver_data.color_default = _papplColorModeValue(ippGetString(rattr, 0, NULL));
Expand Down Expand Up @@ -1204,6 +1225,21 @@ _papplPrinterSetAttributes(
cupsCopyString(wifi_ssid, ippGetString(rattr, 0, NULL), sizeof(wifi_ssid));
do_wifi = true;
}
else if (!strcmp(name, "sides-default"))
{
pappl_sides_t sides_default = _papplSidesValue(ippGetString(rattr, 0, NULL));
// Sides value

if (!sides_default || !(driver_data.sides_supported & sides_default))
{
papplClientRespondIPP(client, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, "Unsupported \"sides-default\" value '%s'.", ippGetString(rattr, 0, NULL));
}
else
{
driver_data.sides_default = sides_default;
do_defaults = true;
}
}
}

if (ippGetStatusCode(client->response) != IPP_STATUS_OK)
Expand Down

0 comments on commit 19fe709

Please sign in to comment.