Set IppMsg version to 2.0 if printer supports it
This commit is contained in:
parent
035e310069
commit
16f1edd818
4 changed files with 23 additions and 10 deletions
|
@ -1,16 +1,15 @@
|
|||
#include "ippmsg.h"
|
||||
|
||||
#define MAJ_VSN 1
|
||||
#define MIN_VSN 1
|
||||
|
||||
quint32 IppMsg::_reqid=1;
|
||||
|
||||
IppMsg::IppMsg()
|
||||
{
|
||||
}
|
||||
|
||||
IppMsg::IppMsg(QJsonObject opAttrs, QJsonObject jobAttrs)
|
||||
IppMsg::IppMsg(QJsonObject opAttrs, QJsonObject jobAttrs, quint8 majVsn, quint8 minVsn)
|
||||
{
|
||||
_majVsn = majVsn;
|
||||
_minVsn = minVsn;
|
||||
_opAttrs = opAttrs;
|
||||
_jobAttrs = QJsonArray {jobAttrs};
|
||||
}
|
||||
|
@ -25,11 +24,9 @@ IppMsg::IppMsg(QNetworkReply* resp)
|
|||
QByteArray tmp = resp->readAll();
|
||||
Bytestream bts(tmp.constData(), tmp.length());
|
||||
|
||||
quint8 majVsn;
|
||||
quint8 minVsn;
|
||||
quint32 reqId;
|
||||
|
||||
bts >> majVsn >> minVsn >> _status >> reqId;
|
||||
bts >> _majVsn >> _minVsn >> _status >> reqId;
|
||||
|
||||
QJsonObject attrs;
|
||||
IppMsg::IppTag currentAttrType = IppTag::EndAttrs;
|
||||
|
@ -295,7 +292,7 @@ QByteArray IppMsg::encode(Operation op)
|
|||
{
|
||||
Bytestream ipp;
|
||||
|
||||
ipp << quint8(MAJ_VSN) << quint8(MIN_VSN);
|
||||
ipp << _majVsn << _minVsn;
|
||||
|
||||
ipp << quint16(op);
|
||||
ipp << _reqid++;
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
|
||||
explicit IppMsg();
|
||||
explicit IppMsg(QNetworkReply* resp);
|
||||
IppMsg(QJsonObject opAttrs, QJsonObject jobAttrs = QJsonObject());
|
||||
IppMsg(QJsonObject opAttrs, QJsonObject jobAttrs=QJsonObject(), quint8 majVsn=1, quint8 minVsn=1);
|
||||
IppMsg(const IppMsg& other) = default;
|
||||
~IppMsg();
|
||||
|
||||
|
@ -87,6 +87,9 @@ private:
|
|||
QString consume_attribute(QJsonObject& attrs, Bytestream& data);
|
||||
Bytestream encode_attr(quint8 tag, QString name, QJsonValueRef value);
|
||||
|
||||
quint8 _majVsn;
|
||||
quint8 _minVsn;
|
||||
|
||||
QJsonObject _opAttrs;
|
||||
QJsonArray _jobAttrs;
|
||||
QJsonObject _printerAttrs;
|
||||
|
|
|
@ -405,7 +405,7 @@ void IppPrinter::print(QJsonObject attrs, QString filename,
|
|||
|
||||
qDebug() << "Final job attributes:" << attrs;
|
||||
|
||||
IppMsg job = IppMsg(o, attrs);
|
||||
IppMsg job = mk_msg(o, attrs);
|
||||
QByteArray contents = job.encode(IppMsg::PrintJob);
|
||||
// Always convert images to get resizing
|
||||
if((mimeType == documentFormat) && !mimeType.contains("image"))
|
||||
|
@ -541,3 +541,14 @@ QJsonValue IppPrinter::getAttrOrDefault(QJsonObject jobAttrs, QString name)
|
|||
return _attrs[name+"-default"].toObject()["value"];
|
||||
}
|
||||
}
|
||||
|
||||
IppMsg IppPrinter::mk_msg(QJsonObject opAttrs, QJsonObject jobAttrs)
|
||||
{
|
||||
if(_attrs.contains("ipp-versions-supported") &&
|
||||
_attrs["ipp-versions-supported"].toObject()["value"].toArray().contains("2.0"))
|
||||
{
|
||||
qDebug() << "TWO-POINT-ZERO";
|
||||
return IppMsg(opAttrs, jobAttrs, 2, 0);
|
||||
}
|
||||
return IppMsg(opAttrs, jobAttrs);
|
||||
}
|
||||
|
|
|
@ -79,6 +79,8 @@ private:
|
|||
|
||||
QJsonValue getAttrOrDefault(QJsonObject jobAttrs, QString name);
|
||||
|
||||
IppMsg mk_msg(QJsonObject opAttrs, QJsonObject jobAttrs=QJsonObject());
|
||||
|
||||
QNetworkAccessManager* _nam;
|
||||
QNetworkAccessManager* _jobs_nam;
|
||||
QNetworkAccessManager* _job_cancel_nam;
|
||||
|
|
Loading…
Reference in a new issue