mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 07:45:30 +00:00
Bug 1666964 - Retrieve Printer Default Media Through IPP Attribute r=hiro
cupsGetDestMediaDefault seems to not be returning the correct defaults, so this patch retrieves the default media through the IPP attribute instead, in hopes that this will provide more accurate defaults. Differential Revision: https://phabricator.services.mozilla.com/D91376
This commit is contained in:
parent
bbfbd2f113
commit
001639575c
@ -34,11 +34,13 @@ class nsCUPSShim {
|
||||
X(cupsCopyDest) \
|
||||
X(cupsCopyDestInfo) \
|
||||
X(cupsDoRequest) \
|
||||
X(cupsFindDestDefault) \
|
||||
X(cupsFreeDestInfo) \
|
||||
X(cupsFreeDests) \
|
||||
X(cupsGetDestMediaDefault) \
|
||||
X(cupsGetDestMediaCount) \
|
||||
X(cupsGetDestMediaByIndex) \
|
||||
X(cupsGetDestMediaByName) \
|
||||
X(cupsGetDest) \
|
||||
X(cupsGetDests) \
|
||||
X(cupsGetNamedDest) \
|
||||
|
@ -96,9 +96,23 @@ PrintSettingsInitializer nsPrinterCUPS::DefaultSettings() const {
|
||||
|
||||
cups_size_t media;
|
||||
|
||||
// cupsGetDestMediaDefault appears to return more accurate defaults on macOS,
|
||||
// and the IPP attribute appears to return more accurate defaults on Linux.
|
||||
#ifdef XP_MACOSX
|
||||
bool hasDefaultMedia =
|
||||
mShim.cupsGetDestMediaDefault(CUPS_HTTP_DEFAULT, mPrinter, printerInfo,
|
||||
CUPS_MEDIA_FLAGS_DEFAULT, &media);
|
||||
#else
|
||||
ipp_attribute_t* defaultMediaIPP = mShim.cupsFindDestDefault(
|
||||
CUPS_HTTP_DEFAULT, mPrinter, printerInfo, "media");
|
||||
|
||||
const char* defaultMediaName =
|
||||
mShim.ippGetString(defaultMediaIPP, 0, nullptr);
|
||||
|
||||
bool hasDefaultMedia = mShim.cupsGetDestMediaByName(
|
||||
CUPS_HTTP_DEFAULT, mPrinter, printerInfo, defaultMediaName,
|
||||
CUPS_MEDIA_FLAGS_DEFAULT, &media);
|
||||
#endif
|
||||
|
||||
if (!hasDefaultMedia) {
|
||||
return PrintSettingsInitializer{
|
||||
|
Loading…
Reference in New Issue
Block a user