Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PPDs for driverless printing: Make jobs be printed in correct order for face-up/face-down #5345

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 107 additions & 1 deletion cups/ppd-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -3034,6 +3034,7 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
cups_array_t *sizes; /* Media sizes supported by printer */
cups_size_t *size; /* Current media size */
ipp_attribute_t *attr, /* xxx-supported */
*attr2,
*defattr, /* xxx-default */
*quality, /* print-quality-supported */
*x_dim, *y_dim; /* Media dimensions */
Expand Down Expand Up @@ -3071,7 +3072,14 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
/* Locale data */
cups_array_t *fin_options = NULL;
/* Finishing options */

char *defaultoutbin = NULL;
const char *outbin;
char outbin_properties[1024];
int octet_str_len;
void *outbin_properties_octet;
int outputorderinfofound = 0,
faceupdown = 1,
firsttolast = 1;

/*
* Range check input...
Expand Down Expand Up @@ -3138,6 +3146,55 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
cupsFilePrintf(fp, "*NickName: \"%s - IPP Everywhere\"\n", model);
cupsFilePrintf(fp, "*ShortNickName: \"%s - IPP Everywhere\"\n", model);

/* Which is the default output bin? */
if ((attr = ippFindAttribute(response, "output-bin-default", IPP_TAG_ZERO)) != NULL)
defaultoutbin = strdup(ippGetString(attr, 0, NULL));
/* Find out on which position of the list of output bins the default one is, if there
is no default bin, take the first of this list */
i = 0;
if ((attr = ippFindAttribute(response, "output-bin-supported", IPP_TAG_ZERO)) != NULL)
{
count = ippGetCount(attr);
for (i = 0; i < count; i ++)
{
outbin = ippGetString(attr, i, NULL);
if (outbin == NULL)
continue;
if (defaultoutbin == NULL)
{
defaultoutbin = strdup(outbin);
break;
}
else if (strcasecmp(outbin, defaultoutbin) == 0)
break;
}
}
/* Look up the corresponding entry in the "printer-output-tray" attribute */
if ((attr = ippFindAttribute(response, "printer-output-tray", IPP_TAG_STRING)) != NULL &&
i < ippGetCount(attr))
{
outbin_properties_octet = ippGetOctetString(attr, i, &octet_str_len);
memset(outbin_properties, 0, sizeof(outbin_properties));
memcpy(outbin_properties, outbin_properties_octet,
((size_t)octet_str_len < sizeof(outbin_properties) - 1 ?
(size_t)octet_str_len : sizeof(outbin_properties) - 1));
if (strcasestr(outbin_properties, "pagedelivery=faceUp"))
{
outputorderinfofound = 1;
faceupdown = -1;
}
if (strcasestr(outbin_properties, "stackingorder=lastToFirst"))
firsttolast = -1;
}
if (outputorderinfofound == 0 && defaultoutbin && strcasestr(defaultoutbin, "face-up"))
faceupdown = -1;
if (defaultoutbin)
free (defaultoutbin);
if (firsttolast * faceupdown < 0)
cupsFilePuts(fp, "*DefaultOutputOrder: Reverse\n");
else
cupsFilePuts(fp, "*DefaultOutputOrder: Normal\n");

if ((attr = ippFindAttribute(response, "color-supported", IPP_TAG_BOOLEAN)) != NULL && ippGetBoolean(attr, 0))
cupsFilePuts(fp, "*ColorDevice: True\n");
else
Expand Down Expand Up @@ -3916,6 +3973,7 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
cupsFilePrintf(fp, "*OpenUI *OutputBin: PickOne\n"
"*OrderDependency: 10 AnySetup *OutputBin\n"
"*DefaultOutputBin: %s\n", ppdname);
attr2 = ippFindAttribute(response, "printer-output-tray", IPP_TAG_STRING);
for (i = 0; i < count; i ++)
{
keyword = ippGetString(attr, i, NULL);
Expand All @@ -3928,6 +3986,54 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
msgstr = keyword;

cupsFilePrintf(fp, "*OutputBin %s/%s: \"\"\n", ppdname, msgstr);
outputorderinfofound = 0;
faceupdown = 1;
firsttolast = 1;
if (attr2 && i < ippGetCount(attr2))
{
outbin_properties_octet = ippGetOctetString(attr2, i, &octet_str_len);
memset(outbin_properties, 0, sizeof(outbin_properties));
memcpy(outbin_properties, outbin_properties_octet,
((size_t)octet_str_len < sizeof(outbin_properties) - 1 ?
(size_t)octet_str_len : sizeof(outbin_properties) - 1));
if (strcasestr(outbin_properties, "pagedelivery=faceUp"))
{
outputorderinfofound = 1;
faceupdown = -1;
}
else if (strcasestr(outbin_properties, "pagedelivery=faceDown"))
{
outputorderinfofound = 1;
faceupdown = 1;
}
if (strcasestr(outbin_properties, "stackingorder=lastToFirst"))
{
outputorderinfofound = 1;
firsttolast = -1;
}
else if (strcasestr(outbin_properties, "stackingorder=firstToLast"))
{
outputorderinfofound = 1;
firsttolast = 1;
}
}
if (outputorderinfofound == 0)
{
if (strcasestr(keyword, "face-up"))
{
outputorderinfofound = 1;
faceupdown = -1;
}
if (strcasestr(keyword, "face-down"))
{
outputorderinfofound = 1;
faceupdown = 1;
}
}
if (outputorderinfofound)
cupsFilePrintf(fp, "*PageStackOrder %s: %s\n",
ppdname,
(firsttolast * faceupdown < 0 ? "Reverse" : "Normal"));
}
cupsFilePuts(fp, "*CloseUI: *OutputBin\n");
}
Expand Down