Sorta, kinda works

This commit is contained in:
Anton Thomasson 2020-05-01 13:49:17 +02:00
parent 88230fd466
commit 35cadccd1b
2 changed files with 12 additions and 6 deletions

View file

@ -23,6 +23,7 @@ IppPrinter::IppPrinter()
connect(_job_cancel_nam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), this, SLOT(ignoreKnownSslErrors(QNetworkReply*, const QList<QSslError>&))); connect(_job_cancel_nam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), this, SLOT(ignoreKnownSslErrors(QNetworkReply*, const QList<QSslError>&)));
QObject::connect(this, &IppPrinter::urlChanged, this, &IppPrinter::onUrlChanged); QObject::connect(this, &IppPrinter::urlChanged, this, &IppPrinter::onUrlChanged);
qRegisterMetaType<QTemporaryFile*>("QTemporaryFile*");
} }
IppPrinter::~IppPrinter() { IppPrinter::~IppPrinter() {
@ -229,7 +230,7 @@ void IppPrinter::doWork(QString filename, QTemporaryFile* tempfile)
connect(muraster, SIGNAL(finished(int, QProcess::ExitStatus)), muraster, SLOT(deleteLater())); connect(muraster, SIGNAL(finished(int, QProcess::ExitStatus)), muraster, SLOT(deleteLater()));
connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), ppm2pwg, SLOT(deleteLater())); connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), ppm2pwg, SLOT(deleteLater()));
connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), tempfile, SLOT(deleteLater())); //connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), tempfile, SLOT(deleteLater()));
qDebug() << "All connected"; qDebug() << "All connected";
@ -259,10 +260,18 @@ void IppPrinter::doWork(QString filename, QTemporaryFile* tempfile)
// IppRaster* raster = new IppRaster(ppm2pwg); // IppRaster* raster = new IppRaster(ppm2pwg);
// raster->open(QIODevice::ReadOnly); // raster->open(QIODevice::ReadOnly);
// request.setAttribute(QNetworkRequest::DoNotBufferUploadDataAttribute, true); // request.setAttribute(QNetworkRequest::DoNotBufferUploadDataAttribute, true);
_print_nam->post(request, tempfile); QMetaObject::invokeMethod(this, "doPost", Qt::QueuedConnection,
Q_ARG(QNetworkRequest, request), Q_ARG(QTemporaryFile*, tempfile) );
qDebug() << "posted"; qDebug() << "posted";
} }
void IppPrinter::doPost(QNetworkRequest request, QTemporaryFile* data)
{
data->open();
_print_nam->post(request, data);
}
void IppPrinter::print(QJsonObject attrs, QString filename){ void IppPrinter::print(QJsonObject attrs, QString filename){
qDebug() << "printing" << filename << attrs; qDebug() << "printing" << filename << attrs;
@ -294,9 +303,6 @@ void IppPrinter::print(QJsonObject attrs, QString filename){
IppMsg job = IppMsg(o, attrs); IppMsg job = IppMsg(o, attrs);
QByteArray contents = job.encode(IppMsg::PrintJob); QByteArray contents = job.encode(IppMsg::PrintJob);
QByteArray filedata = file.readAll();
contents = contents.append(filedata);
// TODO: do this only conditionally, and to the raster suppoerted/preferred // TODO: do this only conditionally, and to the raster suppoerted/preferred
bool transcode = true; bool transcode = true;

View file

@ -49,7 +49,7 @@ public slots:
void ignoreKnownSslErrors(QNetworkReply *reply, const QList<QSslError> &errors); void ignoreKnownSslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
void doWork(QString filename, QTemporaryFile* tempfile); void doWork(QString filename, QTemporaryFile* tempfile);
void doPost(QNetworkRequest request, QTemporaryFile* data);
private: private:
QUrl _url; QUrl _url;