Add Identify-Printer

This commit is contained in:
Anton Thomasson 2022-05-16 20:29:53 +02:00
parent b4aaa85a2d
commit ff2eae04cf
12 changed files with 67 additions and 1 deletions

View file

@ -12,6 +12,17 @@ Page {
anchors.fill: parent
contentHeight: col.height
PullDownMenu {
MenuItem {
id: identifyLabel
text: qsTr("Identify printer")
visible: printer.attrs.hasOwnProperty("identify-actions-supported")
onClicked: printer.identify()
}
}
Column {
id: col

View file

@ -61,7 +61,8 @@ public:
RestartJob = 0x000E,
PausePrinter = 0x0010,
ResumePrinter = 0x0011,
PurgeJobs = 0x0012
PurgeJobs = 0x0012,
IdentifyPrinter = 0x003C
};
explicit IppMsg();

View file

@ -17,6 +17,7 @@ IppPrinter::IppPrinter() : _worker(this)
connect(this, &IppPrinter::doDoGetPrinterAttributes, &_worker, &PrinterWorker::getPrinterAttributes);
connect(this, &IppPrinter::doGetJobs, &_worker, &PrinterWorker::getJobs);
connect(this, &IppPrinter::doCancelJob, &_worker, &PrinterWorker::cancelJob);
connect(this, &IppPrinter::doIdentify, &_worker, &PrinterWorker::identify);
connect(this, &IppPrinter::doJustUpload, &_worker, &PrinterWorker::justUpload);
connect(this, &IppPrinter::doFixupPlaintext, &_worker, &PrinterWorker::fixupPlaintext);
connect(this, &IppPrinter::doFixupJpeg, &_worker, &PrinterWorker::fixupJpeg);
@ -294,6 +295,11 @@ void IppPrinter::cancelJobFinished(CURLcode res, Bytestream data)
getJobs();
}
void IppPrinter::identifyFinished(CURLcode /*res*/, Bytestream /*data*/)
{
}
void IppPrinter::getStringsFinished(CURLcode res, Bytestream data)
{
qDebug() << res << data.size();
@ -760,6 +766,19 @@ bool IppPrinter::cancelJob(qint32 jobId) {
return true;
}
bool IppPrinter::identify() {
qDebug() << "identifying";
QJsonObject o = opAttrs();
IppMsg job = IppMsg(o, QJsonObject());
emit doCancelJob(job.encode(IppMsg::IdentifyPrinter));
return true;
}
bool IppPrinter::correctSuffix()
{
foreach(QJsonValue u, _attrs["printer-uri-supported"].toObject()["value"].toArray())

View file

@ -38,6 +38,7 @@ public:
Q_INVOKABLE bool getJobs();
Q_INVOKABLE bool cancelJob(qint32 jobId);
Q_INVOKABLE bool identify();
bool correctSuffix();
QStringList suffixes();
@ -57,6 +58,7 @@ signals:
void doDoGetPrinterAttributes(Bytestream msg);
void doGetJobs(Bytestream msg);
void doCancelJob(Bytestream msg);
void doIdentify(Bytestream msg);
void doJustUpload(QString filename, Bytestream header);
void doFixupPlaintext(QString filename, Bytestream header);
@ -89,6 +91,7 @@ public slots:
void printRequestFinished(CURLcode res, Bytestream data);
void getJobsRequestFinished(CURLcode res, Bytestream data);
void cancelJobFinished(CURLcode res, Bytestream data);
void identifyFinished(CURLcode res, Bytestream data);
void getStringsFinished(CURLcode res, Bytestream data);
void getImageFinished(CURLcode res, Bytestream data);

View file

@ -56,6 +56,13 @@ void PrinterWorker::cancelJob(Bytestream msg)
cr.write((char*)msg.raw(), msg.size());
}
void PrinterWorker::identify(Bytestream msg)
{
CurlRequester cr(_printer->httpUrl());
connect(&cr, &CurlRequester::done, _printer, &IppPrinter::identifyFinished);
cr.write((char*)msg.raw(), msg.size());
}
void PrinterWorker::justUpload(QString filename, Bytestream header)
{
try {

View file

@ -36,6 +36,7 @@ public slots:
void getPrinterAttributes(Bytestream msg);
void getJobs(Bytestream msg);
void cancelJob(Bytestream msg);
void identify(Bytestream msg);
void justUpload(QString filename, Bytestream header);

View file

@ -217,6 +217,10 @@
<source>pages/min (color)</source>
<translation>Farbseiten/Min</translation>
</message>
<message>
<source>Identify printer</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FirstPage</name>

View file

@ -217,6 +217,10 @@
<source>pages/min (color)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Identify printer</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FirstPage</name>

View file

@ -217,6 +217,10 @@
<source>pages/min (color)</source>
<translation>pages/min (couleur)</translation>
</message>
<message>
<source>Identify printer</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FirstPage</name>

View file

@ -217,6 +217,10 @@
<source>pages/min (color)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Identify printer</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FirstPage</name>

View file

@ -217,6 +217,10 @@
<source>pages/min (color)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Identify printer</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FirstPage</name>

View file

@ -217,6 +217,10 @@
<source>pages/min (color)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Identify printer</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FirstPage</name>