!375 print 5.0release:fix quality and media type bug

Merge pull request !375 from 包泽伟/OpenHarmony-5.0-Release
This commit is contained in:
openharmony_ci 2024-09-25 03:06:25 +00:00 committed by Gitee
commit dda0345b5b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 7 additions and 7 deletions

View File

@ -96,9 +96,9 @@ bool ConvertDuplexModeCode(const char *src, DuplexModeCode &dst)
return true;
}
std::string ConvertIppAttributesToJsonString(ipp_t *response, const std::string &keyword)
std::string ConvertIppAttributesToJsonString(ipp_t *response, const std::string &keyword, ipp_tag_t tag)
{
ipp_attribute_t *attrPtr = ippFindAttribute(response, keyword.c_str(), IPP_TAG_KEYWORD);
ipp_attribute_t *attrPtr = ippFindAttribute(response, keyword.c_str(), tag);
if (attrPtr == nullptr) {
return "";
}
@ -377,14 +377,14 @@ void ParseOrientationAttributes(ipp_t *response, PrinterCapability &printerCaps)
void ParseOtherAttributes(ipp_t *response, PrinterCapability &printerCaps)
{
std::string keyword = "media-source-supported";
std::string attrString = ConvertIppAttributesToJsonString(response, keyword);
std::string attrString = ConvertIppAttributesToJsonString(response, keyword, IPP_TAG_KEYWORD);
PRINT_HILOGD("%{public}s: %{public}s", keyword.c_str(), attrString.c_str());
if (!attrString.empty()) {
printerCaps.SetPrinterAttrNameAndValue(keyword.c_str(), attrString.c_str());
}
keyword = "multiple-document-handling-supported";
attrString = ConvertIppAttributesToJsonString(response, keyword);
attrString = ConvertIppAttributesToJsonString(response, keyword, IPP_TAG_KEYWORD);
PRINT_HILOGD("%{public}s: %{public}s", keyword.c_str(), attrString.c_str());
if (!attrString.empty()) {
printerCaps.SetPrinterAttrNameAndValue(keyword.c_str(), attrString.c_str());
@ -405,7 +405,7 @@ void SetOptionAttribute(ipp_t *response, PrinterCapability &printerCaps)
options["printerName"] = ippGetString(attrPtr, 0, NULL);
}
std::string keyword = "media-type-supported";
std::string supportTypes = ConvertIppAttributesToJsonString(response, keyword);
std::string supportTypes = ConvertIppAttributesToJsonString(response, keyword, IPP_TAG_ZERO);
PRINT_HILOGD("%{public}s: %{public}s", keyword.c_str(), supportTypes.c_str());
if (!supportTypes.empty()) {
printerCaps.SetPrinterAttrNameAndValue(keyword.c_str(), supportTypes.c_str());

View File

@ -1267,8 +1267,8 @@ JobParameters* PrintCupsClient::BuildJobParameters(const PrintJob &jobInfo)
params->printerAttrsOption_cupsOption = optionJson["cupsOptions"];
}
UpdateBorderlessJobParameter(optionJson, params);
if (optionJson.contains("printQuality") && optionJson["printQuality"].is_number()) {
params->printQuality = GetQulityString(optionJson["printQuality"]);
if (optionJson.contains("printQuality") && optionJson["printQuality"].is_string()) {
params->printQuality = optionJson["printQuality"].get<std::string>();
} else {
params->printQuality = CUPS_PRINT_QUALITY_NORMAL;
}