Put op-attrs in order, fixed understanding of document-format

This commit is contained in:
Anton Thomasson 2020-06-13 17:56:28 +02:00
parent a73b0b734a
commit 011c897e76
9 changed files with 25 additions and 67 deletions

View file

@ -28,7 +28,6 @@ Page {
PageStackAction.Immediate)
printer.print(jobParams, page.selectedFile,
alwaysConvertSetting.value,
forceIncluDeDocumentFormatSetting.value,
removeRedundantConvertAttrsSetting.value)
}
}
@ -118,7 +117,7 @@ Page {
prettyName: prettyName,
tag: tag,
valid: printer.attrs.hasOwnProperty(name+"-supported"),
choices: maybeSupplementChoices(name, printer.attrs[name+"-supported"].value),
choices: printer.attrs[name+"-supported"].value,
default_choice: printer.attrs[name+"-default"].value,
mime_type: Mimer.get_type(selectedFile)
})
@ -126,15 +125,6 @@ Page {
}
}
function maybeSupplementChoices(name, choices)
{
if(name == "document-format" && considerAdditionalFormatsSetting.value)
{
return choices.concat(printer.additionalDocumentFormats)
}
return choices
}
}
VerticalScrollDecorator {}
}

View file

@ -48,15 +48,6 @@ Page {
}
}
TextSwitch {
text: qsTr("Force-include document format")
description: qsTr("Force the document-format attribute to be included. Some printers have trouble recognizing certain formats, sometimes it helps to include this atribute even if the printer does not claim to support it.")
checked: forceIncluDeDocumentFormatSetting.value
onCheckedChanged: {
forceIncluDeDocumentFormatSetting.value = checked
}
}
TextSwitch {
text: qsTr("Remove redundant attributes")
description: qsTr("Remove redundant IPP attributes, if they are also conveyed in the transfer format. Some printers reject the job even if the settings are consistent.")

View file

@ -297,14 +297,23 @@ QByteArray IppMsg::encode(Operation op)
ipp << quint16(op);
ipp << _reqid++;
if(!_opAttrs.empty())
ipp << quint8(OpAttrs);
// attributes-charset and attributes-natural-language are required to be first
// some printers fail if the other mandatory parameters are not in this specific order
QStringList InitialAttrs = {"attributes-charset",
"attributes-natural-language",
"printer-uri",
"requesting-user-name"};
foreach(QString key, InitialAttrs)
{
ipp << quint8(1);
for(QJsonObject::iterator it = _opAttrs.begin(); it != _opAttrs.end(); it++)
{
QJsonObject val = it.value().toObject();
ipp << encode_attr(val["tag"].toInt(), it.key(), val["value"]);
}
QJsonObject val = _opAttrs.take(key).toObject();
ipp << encode_attr(val["tag"].toInt(), key, val["value"]);
}
for(QJsonObject::iterator it = _opAttrs.begin(); it != _opAttrs.end(); it++)
{ // encode any remaining op-attrs
QJsonObject val = it.value().toObject();
ipp << encode_attr(val["tag"].toInt(), it.key(), val["value"]);
}
for(QJsonArray::iterator ait = _jobAttrs.begin(); ait != _jobAttrs.end(); ait++)
{

View file

@ -299,10 +299,10 @@ QString targetFormatIfAuto(QString documentFormat, QString mimeType, QJsonArray
}
void IppPrinter::print(QJsonObject attrs, QString filename,
bool alwaysConvert, bool forceIncluDeDocumentFormat, bool removeRedundantConvertAttrs)
bool alwaysConvert, bool removeRedundantConvertAttrs)
{
qDebug() << "printing" << filename << attrs
<< alwaysConvert << forceIncluDeDocumentFormat << removeRedundantConvertAttrs;
<< alwaysConvert << removeRedundantConvertAttrs;
_progress = "";
emit progressChanged();
@ -337,6 +337,10 @@ void IppPrinter::print(QJsonObject attrs, QString filename,
QString documentFormat = getAttrOrDefault(attrs, "document-format").toString();
qDebug() << "target format:" << documentFormat << "alwaysConvert:" << alwaysConvert;
// document-format goes in the op-attrs and not the job-attrs
o.insert("document-format", QJsonObject {{"tag", IppMsg::MimeMediaType}, {"value", documentFormat}});
attrs.remove("document-format");
documentFormat = targetFormatIfAuto(documentFormat, mimeType, supportedMimeTypes, alwaysConvert);
qDebug() << "adjusted target format:" << documentFormat;
@ -346,11 +350,6 @@ void IppPrinter::print(QJsonObject attrs, QString filename,
return;
}
if(!jobCreationAttributes.contains("document-format") && !forceIncluDeDocumentFormat)
{ // Only include if printer supports it
attrs.remove("document-format");
}
qDebug() << "Printing job" << o << attrs;
QNetworkRequest request;
@ -404,6 +403,7 @@ void IppPrinter::print(QJsonObject attrs, QString filename,
attrs.remove("sides");
}
qDebug() << "Final op attributes:" << o;
qDebug() << "Final job attributes:" << attrs;
IppMsg job = mk_msg(o, attrs);

View file

@ -54,7 +54,7 @@ signals:
public slots:
void print(QJsonObject attrs, QString file,
bool alwaysConvert, bool forceIncluDeDocumentFormat, bool removeRedundantAttributesForRaster);
bool alwaysConvert, bool removeRedundantAttributesForRaster);
void onUrlChanged();

View file

@ -349,14 +349,6 @@
<source>Force conversion to PWG/URF raster format. This is mainly intended for testing.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Force-include document format</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Force the document-format attribute to be included. Some printers have trouble recognizing certain formats, sometimes it helps to include this atribute even if the printer does not claim to support it.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove redundant attributes</source>
<translation type="unfinished"></translation>

View file

@ -349,14 +349,6 @@
<source>Force conversion to PWG/URF raster format. This is mainly intended for testing.</source>
<translation>Forzar conversión a formato ráster PWG/URF. Esto es para hacer pruebas principalmente.</translation>
</message>
<message>
<source>Force-include document format</source>
<translation>Forzar incluisión de formato de documento</translation>
</message>
<message>
<source>Force the document-format attribute to be included. Some printers have trouble recognizing certain formats, sometimes it helps to include this atribute even if the printer does not claim to support it.</source>
<translation>Forzar la inclusión del atributo de formato de documento. Algunas impresoras tienen problemas para reconocer ciertos formatos, a veces es útil incluir este atributo aunque la impresora no asegure que lo soporte.</translation>
</message>
<message>
<source>Remove redundant attributes</source>
<translation>Eliminar atributos redundantes</translation>

View file

@ -349,14 +349,6 @@
<source>Force conversion to PWG/URF raster format. This is mainly intended for testing.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Force-include document format</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Force the document-format attribute to be included. Some printers have trouble recognizing certain formats, sometimes it helps to include this atribute even if the printer does not claim to support it.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove redundant attributes</source>
<translation type="unfinished"></translation>

View file

@ -349,14 +349,6 @@
<source>Force conversion to PWG/URF raster format. This is mainly intended for testing.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Force-include document format</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Force the document-format attribute to be included. Some printers have trouble recognizing certain formats, sometimes it helps to include this atribute even if the printer does not claim to support it.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove redundant attributes</source>
<translation type="unfinished"></translation>