2019-12-01 22:27:00 +03:00
|
|
|
#ifndef IPP_PROTO_H
|
|
|
|
#define IPP_PROTO_H
|
|
|
|
|
|
|
|
#include "bytestream.h"
|
|
|
|
|
|
|
|
#include <QByteArray>
|
2020-06-06 18:20:30 +03:00
|
|
|
#include <QObject>
|
2019-12-01 22:27:00 +03:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QUrl>
|
|
|
|
#include <QtNetwork>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QIODevice>
|
|
|
|
|
|
|
|
class IppMsg
|
|
|
|
{
|
2020-06-06 18:20:30 +03:00
|
|
|
Q_GADGET
|
2019-12-01 22:27:00 +03:00
|
|
|
public:
|
|
|
|
|
|
|
|
enum IppTag : quint8 {
|
|
|
|
OpAttrs = 0x01,
|
|
|
|
JobAttrs = 0x02,
|
|
|
|
EndAttrs = 0x03,
|
|
|
|
PrinterAttrs = 0x04,
|
2020-06-03 21:42:46 +03:00
|
|
|
UnsupportedAttrs = 0x05,
|
|
|
|
Unsupported = 0x10,
|
2019-12-01 22:27:00 +03:00
|
|
|
Integer = 0x21,
|
|
|
|
Boolean = 0x22,
|
|
|
|
Enum = 0x23,
|
|
|
|
OctetStringUnknown = 0x30,
|
|
|
|
DateTime = 0x31,
|
|
|
|
Resolution = 0x32,
|
|
|
|
IntegerRange = 0x33,
|
2020-06-13 11:42:07 +03:00
|
|
|
BeginCollection = 0x34,
|
2019-12-01 22:27:00 +03:00
|
|
|
TextWithLanguage = 0x35,
|
|
|
|
NameWithLanguage = 0x36,
|
2020-06-13 11:42:07 +03:00
|
|
|
EndCollection = 0x37,
|
2019-12-01 22:27:00 +03:00
|
|
|
TextWithoutLanguage = 0x41,
|
|
|
|
NameWithoutLanguage = 0x42,
|
|
|
|
Keyword = 0x44,
|
|
|
|
Uri = 0x45,
|
|
|
|
UriScheme = 0x46,
|
|
|
|
Charset = 0x47,
|
|
|
|
NaturalLanguage = 0x48,
|
2020-06-13 11:42:07 +03:00
|
|
|
MimeMediaType = 0x49,
|
|
|
|
MemberName = 0x4A
|
2019-12-01 22:27:00 +03:00
|
|
|
};
|
2020-06-06 18:20:30 +03:00
|
|
|
Q_ENUMS(IppTag)
|
2019-12-01 22:27:00 +03:00
|
|
|
|
|
|
|
enum Operation : quint16 {
|
|
|
|
PrintJob = 0x0002,
|
|
|
|
PrintUri = 0x0003,
|
|
|
|
ValidateJob = 0x0004,
|
|
|
|
CreateJob = 0x0005,
|
|
|
|
SendDocument = 0x0006,
|
|
|
|
SendUri = 0x0007,
|
|
|
|
CancelJob = 0x0008,
|
|
|
|
GetJobAttrs = 0x0009,
|
|
|
|
GetJobs = 0x000A,
|
|
|
|
GetPrinterAttrs = 0x000B,
|
|
|
|
HoldJob = 0x000C,
|
|
|
|
ReleaseJob = 0x000D,
|
|
|
|
RestartJob = 0x000E,
|
|
|
|
PausePrinter = 0x0010,
|
|
|
|
ResumePrinter = 0x0011,
|
|
|
|
PurgeJobs = 0x0012
|
|
|
|
};
|
|
|
|
|
2020-06-06 18:20:30 +03:00
|
|
|
explicit IppMsg();
|
|
|
|
explicit IppMsg(QNetworkReply* resp);
|
2020-06-13 13:35:51 +03:00
|
|
|
IppMsg(QJsonObject opAttrs, QJsonObject jobAttrs=QJsonObject(), quint8 majVsn=1, quint8 minVsn=1);
|
2019-12-01 22:27:00 +03:00
|
|
|
IppMsg(const IppMsg& other) = default;
|
|
|
|
~IppMsg();
|
|
|
|
|
|
|
|
QByteArray encode(Operation op);
|
|
|
|
QJsonObject getPrinterAttrs() {return _printerAttrs;}
|
2019-12-08 15:55:56 +03:00
|
|
|
QJsonArray getJobAttrs() {return _jobAttrs;}
|
2019-12-01 22:27:00 +03:00
|
|
|
QJsonObject getOpAttrs() {return _opAttrs;}
|
|
|
|
|
2019-12-06 22:18:48 +03:00
|
|
|
quint16 getStatus() {return _status;}
|
|
|
|
|
2019-12-01 22:27:00 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
private:
|
2020-06-12 19:56:06 +03:00
|
|
|
QJsonValue consume_value(quint8 tag, Bytestream& data);
|
|
|
|
QJsonArray get_unnamed_attributes(Bytestream& data);
|
2020-06-13 11:42:07 +03:00
|
|
|
QJsonValue collect_attributes(QJsonArray& attrs);
|
2020-06-12 19:56:06 +03:00
|
|
|
QString consume_attribute(QJsonObject& attrs, Bytestream& data);
|
2020-06-13 21:12:29 +03:00
|
|
|
void encode_attr(Bytestream& msg, quint8 tag, QString name, QJsonValue value, bool subCollection=false);
|
2019-12-01 22:27:00 +03:00
|
|
|
|
2020-06-13 13:35:51 +03:00
|
|
|
quint8 _majVsn;
|
|
|
|
quint8 _minVsn;
|
|
|
|
|
2019-12-01 22:27:00 +03:00
|
|
|
QJsonObject _opAttrs;
|
2019-12-08 15:55:56 +03:00
|
|
|
QJsonArray _jobAttrs;
|
2019-12-01 22:27:00 +03:00
|
|
|
QJsonObject _printerAttrs;
|
|
|
|
|
2019-12-06 22:18:48 +03:00
|
|
|
quint16 _status;
|
|
|
|
|
2019-12-01 22:27:00 +03:00
|
|
|
static quint32 _reqid;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // IPP_PROTO_H
|