mirror of https://gitee.com/openkylin/cups.git
Apply patchs.
This commit is contained in:
parent
85af453aee
commit
60985f3827
1231
cups/ppd-cache.c
1231
cups/ppd-cache.c
File diff suppressed because it is too large
Load Diff
|
@ -36,7 +36,7 @@ extern "C" {
|
|||
* Constants...
|
||||
*/
|
||||
|
||||
# define _PPD_CACHE_VERSION 10 /* Version number in cache file */
|
||||
# define _PPD_CACHE_VERSION 11 /* Version number in cache file */
|
||||
|
||||
|
||||
/*
|
||||
|
@ -101,6 +101,16 @@ typedef enum _pwg_print_quality_e /**** PWG print-quality values ****/
|
|||
_PWG_PRINT_QUALITY_MAX
|
||||
} _pwg_print_quality_t;
|
||||
|
||||
typedef enum _pwg_print_content_optimize_e /** PWG print-content-optimize **/
|
||||
{
|
||||
_PWG_PRINT_CONTENT_OPTIMIZE_AUTO = 0, /* print-content-optimize=auto */
|
||||
_PWG_PRINT_CONTENT_OPTIMIZE_PHOTO, /* print-content-optimize=photo */
|
||||
_PWG_PRINT_CONTENT_OPTIMIZE_GRAPHICS, /* print-content-optimize=graphics */
|
||||
_PWG_PRINT_CONTENT_OPTIMIZE_TEXT, /* print-content-optimize=text */
|
||||
_PWG_PRINT_CONTENT_OPTIMIZE_TEXT_AND_GRAPHICS, /* ...=text-and-graphics */
|
||||
_PWG_PRINT_CONTENT_OPTIMIZE_MAX
|
||||
} _pwg_print_content_optimize_t;
|
||||
|
||||
typedef struct _pwg_finishings_s /**** PWG finishings mapping data ****/
|
||||
{
|
||||
ipp_finishings_t value; /* finishings value */
|
||||
|
@ -131,6 +141,11 @@ struct _ppd_cache_s /**** PPD cache and PWG conversion data ****/
|
|||
/* Number of print-color-mode/print-quality options */
|
||||
cups_option_t *presets[_PWG_PRINT_COLOR_MODE_MAX][_PWG_PRINT_QUALITY_MAX];
|
||||
/* print-color-mode/print-quality options */
|
||||
int num_optimize_presets[_PWG_PRINT_CONTENT_OPTIMIZE_MAX];
|
||||
/* Number of print-content-optimize
|
||||
options */
|
||||
cups_option_t *optimize_presets[_PWG_PRINT_CONTENT_OPTIMIZE_MAX];
|
||||
/* print-content-optimize options */
|
||||
char *sides_option, /* PPD option for sides */
|
||||
*sides_1sided, /* Choice for one-sided */
|
||||
*sides_2sided_long, /* Choice for two-sided-long-edge */
|
||||
|
@ -214,6 +229,8 @@ extern const char *_pwgMediaTypeForType(const char *media_type,
|
|||
extern const char *_pwgPageSizeForMedia(pwg_media_t *media,
|
||||
char *name, size_t namesize) _CUPS_PRIVATE;
|
||||
|
||||
extern void _ppdCacheAssignPresets(ppd_file_t *ppd, _ppd_cache_t *pc) _CUPS_PRIVATE;
|
||||
|
||||
|
||||
/*
|
||||
* C++ magic...
|
||||
|
|
|
@ -150,6 +150,8 @@ extern int _cups_strcasecmp(const char *, const char *) _CUPS_PRIVATE;
|
|||
|
||||
extern int _cups_strncasecmp(const char *, const char *, size_t n) _CUPS_PRIVATE;
|
||||
|
||||
extern char *_cups_strcasestr(const char *, const char *) _CUPS_PRIVATE;
|
||||
|
||||
# ifndef HAVE_STRLCAT
|
||||
extern size_t _cups_strlcat(char *, const char *, size_t) _CUPS_PRIVATE;
|
||||
# define strlcat _cups_strlcat
|
||||
|
|
|
@ -670,6 +670,36 @@ _cups_strncasecmp(const char *s, /* I - First string */
|
|||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* '_cups_strcasestr()' - Do a case-insensitive search for a sub-string.
|
||||
*/
|
||||
|
||||
char * /* O - Pointer to found sub-string or
|
||||
NULL if not found */
|
||||
_cups_strcasestr(const char *haystack, /* I - String in which to searh */
|
||||
const char *needle) /* I - Sub-string */
|
||||
{
|
||||
char cn, /* Character in needle */
|
||||
ch; /* Character in haystack */
|
||||
size_t len; /* Length of needle */
|
||||
|
||||
if ((cn = *needle++) != 0)
|
||||
{
|
||||
cn = _cups_tolower(cn);
|
||||
len = strlen(needle);
|
||||
do
|
||||
{
|
||||
do
|
||||
{
|
||||
if ((ch = *haystack++) == 0)
|
||||
return (NULL);
|
||||
} while (_cups_tolower(ch) != cn);
|
||||
} while (_cups_strncasecmp(haystack, needle, len) != 0);
|
||||
haystack --;
|
||||
}
|
||||
return ((char *)haystack);
|
||||
}
|
||||
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
/*
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
cups (2.4.2-ok3) yangtze; urgency=medium
|
||||
|
||||
* Apply patchs.
|
||||
|
||||
-- sufang <sufang@kylinos.cn> Tue, 21 Mar 2023 14:46:32 +0800
|
||||
|
||||
cups (2.4.2-ok2) yangtze; urgency=medium
|
||||
|
||||
* Update the debian directory.
|
||||
|
|
|
@ -5439,6 +5439,11 @@ create_local_printer(
|
|||
*nameptr, /* Pointer into name */
|
||||
uri[1024]; /* printer-uri-supported value */
|
||||
const char *ptr; /* Pointer into attribute value */
|
||||
char scheme[HTTP_MAX_URI], /* Scheme portion of URI */
|
||||
userpass[HTTP_MAX_URI], /* Username portion of URI */
|
||||
host[HTTP_MAX_URI], /* Host portion of URI */
|
||||
resource[HTTP_MAX_URI]; /* Resource portion of URI */
|
||||
int port; /* Port portion of URI */
|
||||
|
||||
|
||||
/*
|
||||
|
@ -5502,6 +5507,13 @@ create_local_printer(
|
|||
|
||||
return;
|
||||
}
|
||||
ptr = ippGetString(device_uri, 0, NULL);
|
||||
if (!ptr || !ptr[0])
|
||||
{
|
||||
send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("Attribute \"%s\" has empty value."), "device-uri");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
printer_geo_location = ippFindAttribute(con->request, "printer-geo-location", IPP_TAG_URI);
|
||||
printer_info = ippFindAttribute(con->request, "printer-info", IPP_TAG_TEXT);
|
||||
|
@ -5530,7 +5542,57 @@ create_local_printer(
|
|||
printer->shared = 0;
|
||||
printer->temporary = 1;
|
||||
|
||||
cupsdSetDeviceURI(printer, ippGetString(device_uri, 0, NULL));
|
||||
/*
|
||||
* Check device URI if it has the same hostname as we have, if so, replace
|
||||
* the hostname by localhost. This way we assure that local-only services
|
||||
* like ipp-usb or Printer Applications always work.
|
||||
*
|
||||
* When comparing our hostname with the one in the device URI, consider
|
||||
* names with ¨.local(.)" suffix and names without suffix the same.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_DNSSD
|
||||
if (DNSSDHostName)
|
||||
nameptr = DNSSDHostName;
|
||||
else
|
||||
#endif
|
||||
if (ServerName)
|
||||
nameptr = ServerName;
|
||||
else
|
||||
nameptr = NULL;
|
||||
|
||||
if (nameptr)
|
||||
{
|
||||
int host_len,
|
||||
server_name_len;
|
||||
|
||||
httpSeparateURI(HTTP_URI_CODING_ALL, ptr,
|
||||
scheme, sizeof(scheme), userpass, sizeof(userpass), host,
|
||||
sizeof(host), &port, resource, sizeof(resource));
|
||||
|
||||
host_len = strlen(host);
|
||||
if (strcmp(host + host_len - 6, ".local") == 0)
|
||||
host_len -= 6;
|
||||
if (strcmp(host + host_len - 7, ".local.") == 0)
|
||||
host_len -= 7;
|
||||
|
||||
server_name_len = strlen(nameptr);
|
||||
if (strcmp(nameptr + server_name_len - 6, ".local") == 0)
|
||||
server_name_len -= 6;
|
||||
if (strcmp(nameptr + server_name_len - 7, ".local.") == 0)
|
||||
server_name_len -= 7;
|
||||
|
||||
if (host_len == server_name_len && strncmp(host, nameptr, host_len) == 0)
|
||||
ptr = "localhost";
|
||||
else
|
||||
ptr = host;
|
||||
|
||||
httpAssembleURI(HTTP_URI_CODING_ALL, uri, sizeof(uri), scheme, userpass,
|
||||
ptr, port, resource);
|
||||
cupsdSetDeviceURI(printer, uri);
|
||||
}
|
||||
else
|
||||
cupsdSetDeviceURI(printer, ptr);
|
||||
|
||||
if (printer_geo_location)
|
||||
cupsdSetString(&printer->geo_location, ippGetString(printer_geo_location, 0, NULL));
|
||||
|
|
|
@ -3639,9 +3639,13 @@ get_options(cupsd_job_t *job, /* I - Job */
|
|||
cups_option_t *pwgppds, /* PWG->PPD options */
|
||||
*pwgppd, /* Current PWG->PPD option */
|
||||
*preset; /* Current preset option */
|
||||
int print_color_mode,
|
||||
int print_color_mode = _PWG_PRINT_COLOR_MODE_COLOR,
|
||||
/* Output mode (if any) */
|
||||
print_quality; /* Print quality (if any) */
|
||||
print_quality = _PWG_PRINT_QUALITY_NORMAL,
|
||||
/* Print quality (if any) */
|
||||
print_content_optimize =
|
||||
_PWG_PRINT_CONTENT_OPTIMIZE_AUTO;
|
||||
/* Print content type (if any)*/
|
||||
const char *ppd; /* PPD option choice */
|
||||
int exact; /* Did we get an exact match? */
|
||||
static char *options = NULL;/* Full list of options */
|
||||
|
@ -3663,7 +3667,7 @@ get_options(cupsd_job_t *job, /* I - Job */
|
|||
if (pc &&
|
||||
!ippFindAttribute(job->attrs, "com.apple.print.DocumentTicket.PMSpoolFormat", IPP_TAG_ZERO) &&
|
||||
!ippFindAttribute(job->attrs, "APPrinterPreset", IPP_TAG_ZERO) &&
|
||||
(ippFindAttribute(job->attrs, "print-color-mode", IPP_TAG_ZERO) || ippFindAttribute(job->attrs, "print-quality", IPP_TAG_ZERO) || ippFindAttribute(job->attrs, "cupsPrintQuality", IPP_TAG_ZERO)))
|
||||
(ippFindAttribute(job->attrs, "print-color-mode", IPP_TAG_ZERO) || ippFindAttribute(job->attrs, "print-quality", IPP_TAG_ZERO) || ippFindAttribute(job->attrs, "print-content-optimize", IPP_TAG_ZERO) || ippFindAttribute(job->attrs, "cupsPrintQuality", IPP_TAG_ZERO)))
|
||||
{
|
||||
/*
|
||||
* Map print-color-mode and print-quality to a preset...
|
||||
|
@ -3725,6 +3729,12 @@ get_options(cupsd_job_t *job, /* I - Job */
|
|||
}
|
||||
}
|
||||
|
||||
cupsdLogJob(job, CUPSD_LOG_DEBUG,
|
||||
"print-color-mode=%s, print-quality=%s",
|
||||
print_color_mode == _PWG_PRINT_COLOR_MODE_MONOCHROME ?
|
||||
"gray" : "color",
|
||||
print_quality == _PWG_PRINT_QUALITY_DRAFT ? "draft" :
|
||||
(print_quality == _PWG_PRINT_QUALITY_HIGH ? "high" : "normal"));
|
||||
if (pc->num_presets[print_color_mode][print_quality] > 0)
|
||||
{
|
||||
/*
|
||||
|
@ -3739,7 +3749,72 @@ get_options(cupsd_job_t *job, /* I - Job */
|
|||
{
|
||||
if (!ippFindAttribute(job->attrs, preset->name, IPP_TAG_ZERO))
|
||||
{
|
||||
cupsdLogJob(job, CUPSD_LOG_DEBUG2, "Adding preset option %s=%s", preset->name, preset->value);
|
||||
cupsdLogJob(job, CUPSD_LOG_DEBUG, "Adding preset option %s=%s", preset->name, preset->value);
|
||||
|
||||
num_pwgppds = cupsAddOption(preset->name, preset->value, num_pwgppds, &pwgppds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pc &&
|
||||
ippFindAttribute(job->attrs, "print-content-optimize", IPP_TAG_ZERO))
|
||||
{
|
||||
/*
|
||||
* Map print-content-optimize to a preset...
|
||||
*/
|
||||
|
||||
if ((attr = ippFindAttribute(job->attrs, "print-content-optimize",
|
||||
IPP_TAG_KEYWORD)) != NULL)
|
||||
{
|
||||
if (!strcmp(attr->values[0].string.text, "auto"))
|
||||
print_content_optimize = _PWG_PRINT_CONTENT_OPTIMIZE_AUTO;
|
||||
else if (!strcmp(attr->values[0].string.text, "photo"))
|
||||
print_content_optimize = _PWG_PRINT_CONTENT_OPTIMIZE_PHOTO;
|
||||
else if (!strcmp(attr->values[0].string.text, "graphics") ||
|
||||
!strcmp(attr->values[0].string.text, "graphic"))
|
||||
print_content_optimize = _PWG_PRINT_CONTENT_OPTIMIZE_GRAPHICS;
|
||||
else if (!strcmp(attr->values[0].string.text, "text"))
|
||||
print_content_optimize = _PWG_PRINT_CONTENT_OPTIMIZE_TEXT;
|
||||
else if (!strcmp(attr->values[0].string.text, "text-and-graphics") ||
|
||||
!strcmp(attr->values[0].string.text, "text-and-graphic"))
|
||||
print_content_optimize = _PWG_PRINT_CONTENT_OPTIMIZE_TEXT_AND_GRAPHICS;
|
||||
else
|
||||
print_content_optimize = _PWG_PRINT_CONTENT_OPTIMIZE_AUTO;
|
||||
}
|
||||
else
|
||||
print_content_optimize = _PWG_PRINT_CONTENT_OPTIMIZE_AUTO;
|
||||
|
||||
cupsdLogJob(job, CUPSD_LOG_DEBUG,
|
||||
"print-content-optimize=%s",
|
||||
(print_content_optimize == _PWG_PRINT_CONTENT_OPTIMIZE_AUTO ?
|
||||
"automatic" :
|
||||
(print_content_optimize == _PWG_PRINT_CONTENT_OPTIMIZE_PHOTO ?
|
||||
"photo" :
|
||||
(print_content_optimize == _PWG_PRINT_CONTENT_OPTIMIZE_GRAPHICS ?
|
||||
"graphics" :
|
||||
(print_content_optimize == _PWG_PRINT_CONTENT_OPTIMIZE_TEXT ?
|
||||
"text" :
|
||||
"text and graphics")))));
|
||||
if (pc->num_optimize_presets[print_content_optimize] > 0)
|
||||
{
|
||||
/*
|
||||
* Copy the preset options as long as the corresponding names are not
|
||||
* already defined in the IPP request and also if it does not change
|
||||
* the print quality preset (as long as we do not print in high quality)
|
||||
* ...
|
||||
*/
|
||||
|
||||
for (i = pc->num_optimize_presets[print_content_optimize],
|
||||
preset = pc->optimize_presets[print_content_optimize];
|
||||
i > 0;
|
||||
i --, preset ++)
|
||||
{
|
||||
if (!ippFindAttribute(job->attrs, preset->name, IPP_TAG_ZERO) &&
|
||||
(print_quality == _PWG_PRINT_QUALITY_HIGH ||
|
||||
cupsGetOption(preset->name, num_pwgppds, pwgppds) == NULL))
|
||||
{
|
||||
cupsdLogJob(job, CUPSD_LOG_DEBUG, "Adding content optimization preset option %s=%s", preset->name, preset->value);
|
||||
|
||||
num_pwgppds = cupsAddOption(preset->name, preset->value, num_pwgppds, &pwgppds);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue