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 15, 2023
1 parent b05d62c commit 2fa7ed1
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 @@ -10,6 +10,8 @@ Changes in v1.4.3
- Fixed missing mutex unlock in DNS-SD code (Issue #299)
- Fixed "printer-id" value for new printers (Issue #301)
- Fixed DNS-SD device list crash (Issue #302)
- Fixed Set-Printer-Attributes for "output-bin-default" and "sides-default"
(Issue #305)
- Fixed default "copies" value with `papplJobCreateWithFile`.


Expand Down
38 changes: 37 additions & 1 deletion pappl/printer-ipp.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,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 @@ -983,7 +984,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 @@ -1119,6 +1121,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 @@ -1208,6 +1229,21 @@ _papplPrinterSetAttributes(
papplCopyString(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 2fa7ed1

Please sign in to comment.