Add icon for when printer passes SSL validation
This commit is contained in:
parent
ab81e701fa
commit
b5ea29b372
4 changed files with 44 additions and 13 deletions
|
@ -265,11 +265,22 @@ Page {
|
||||||
+ (Utils.existsAndNotEmpty("printer-location", printer) ? " • "+printer.attrs["printer-location"].value : "")
|
+ (Utils.existsAndNotEmpty("printer-location", printer) ? " • "+printer.attrs["printer-location"].value : "")
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Row {
|
||||||
id: uri_label
|
Icon {
|
||||||
color: canPrint || selectedFile == "" ? Theme.highlightColor : Theme.secondaryColor
|
visible: printer.isIpps && !printer.tainted
|
||||||
font.pixelSize: Theme.fontSizeTiny
|
color: canPrint || selectedFile == "" ? Theme.highlightColor : Theme.secondaryColor
|
||||||
text: printer.url
|
height: Theme.fontSizeTiny
|
||||||
|
width: Theme.fontSizeTiny
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
source: "image://theme/icon-m-browser-permissions"
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: uri_label
|
||||||
|
color: canPrint || selectedFile == "" ? Theme.highlightColor : Theme.secondaryColor
|
||||||
|
font.pixelSize: Theme.fontSizeTiny
|
||||||
|
text: printer.url
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
|
|
|
@ -430,7 +430,7 @@ QImage IppDiscovery::requestImage(const QString &id, QSize *size, const QSize &r
|
||||||
|
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint " SEAPRINT_VERSION);
|
request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint " SEAPRINT_VERSION);
|
||||||
connect(nam, &QNetworkAccessManager::sslErrors, &IppPrinter::onSslErrors);
|
connect(nam, &QNetworkAccessManager::sslErrors, &IppPrinter::ignoreSslErrors);
|
||||||
|
|
||||||
QNetworkReply* reply = nam->get(request);
|
QNetworkReply* reply = nam->get(request);
|
||||||
|
|
||||||
|
|
|
@ -13,16 +13,16 @@ IppPrinter::IppPrinter()
|
||||||
_job_cancel_nam = new QNetworkAccessManager(this);
|
_job_cancel_nam = new QNetworkAccessManager(this);
|
||||||
|
|
||||||
connect(_nam, &QNetworkAccessManager::finished, this, &IppPrinter::getPrinterAttributesFinished);
|
connect(_nam, &QNetworkAccessManager::finished, this, &IppPrinter::getPrinterAttributesFinished);
|
||||||
connect(_nam, &QNetworkAccessManager::sslErrors, &IppPrinter::onSslErrors);
|
connect(_nam, &QNetworkAccessManager::sslErrors, this, &IppPrinter::onSslErrors);
|
||||||
|
|
||||||
connect(_print_nam, &QNetworkAccessManager::finished, this, &IppPrinter::printRequestFinished);
|
connect(_print_nam, &QNetworkAccessManager::finished, this, &IppPrinter::printRequestFinished);
|
||||||
connect(_print_nam, &QNetworkAccessManager::sslErrors, &IppPrinter::onSslErrors);
|
connect(_print_nam, &QNetworkAccessManager::sslErrors, this, &IppPrinter::onSslErrors);
|
||||||
|
|
||||||
connect(_jobs_nam, &QNetworkAccessManager::finished,this, &IppPrinter::getJobsRequestFinished);
|
connect(_jobs_nam, &QNetworkAccessManager::finished,this, &IppPrinter::getJobsRequestFinished);
|
||||||
connect(_jobs_nam, &QNetworkAccessManager::sslErrors, &IppPrinter::onSslErrors);
|
connect(_jobs_nam, &QNetworkAccessManager::sslErrors, this, &IppPrinter::onSslErrors);
|
||||||
|
|
||||||
connect(_job_cancel_nam, &QNetworkAccessManager::finished,this, &IppPrinter::cancelJobFinished);
|
connect(_job_cancel_nam, &QNetworkAccessManager::finished,this, &IppPrinter::cancelJobFinished);
|
||||||
connect(_job_cancel_nam, &QNetworkAccessManager::sslErrors, &IppPrinter::onSslErrors);
|
connect(_job_cancel_nam, &QNetworkAccessManager::sslErrors, this, &IppPrinter::onSslErrors);
|
||||||
|
|
||||||
QObject::connect(this, &IppPrinter::urlChanged, this, &IppPrinter::onUrlChanged);
|
QObject::connect(this, &IppPrinter::urlChanged, this, &IppPrinter::onUrlChanged);
|
||||||
qRegisterMetaType<QTemporaryFile*>("QTemporaryFile*");
|
qRegisterMetaType<QTemporaryFile*>("QTemporaryFile*");
|
||||||
|
@ -41,6 +41,7 @@ IppPrinter::IppPrinter()
|
||||||
connect(_worker, &ConvertWorker::failed, this, &IppPrinter::convertFailed);
|
connect(_worker, &ConvertWorker::failed, this, &IppPrinter::convertFailed);
|
||||||
|
|
||||||
_workerThread.start();
|
_workerThread.start();
|
||||||
|
_tainted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IppPrinter::~IppPrinter() {
|
IppPrinter::~IppPrinter() {
|
||||||
|
@ -262,8 +263,14 @@ void IppPrinter::cancelJobFinished(QNetworkReply *reply)
|
||||||
getJobs();
|
getJobs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IppPrinter::onSslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
|
void IppPrinter::onSslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
|
||||||
|
{
|
||||||
|
_tainted = true;
|
||||||
|
emit taintedChanged();
|
||||||
|
return ignoreSslErrors(reply, errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IppPrinter::ignoreSslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
|
||||||
{
|
{
|
||||||
bool ignore = Settings::instance()->ignoreSslErrors();
|
bool ignore = Settings::instance()->ignoreSslErrors();
|
||||||
qDebug() << reply->request().url() << "SSL handshake failed" << errors << ignore;
|
qDebug() << reply->request().url() << "SSL handshake failed" << errors << ignore;
|
||||||
|
@ -563,7 +570,6 @@ void IppPrinter::print(QJsonObject attrs, QString filename)
|
||||||
bool IppPrinter::getJobs() {
|
bool IppPrinter::getJobs() {
|
||||||
|
|
||||||
qDebug() << "getting jobs";
|
qDebug() << "getting jobs";
|
||||||
|
|
||||||
QJsonObject o = opAttrs();
|
QJsonObject o = opAttrs();
|
||||||
o.insert("requested-attributes", QJsonObject {{"tag", IppMsg::Keyword}, {"value", "all"}});
|
o.insert("requested-attributes", QJsonObject {{"tag", IppMsg::Keyword}, {"value", "all"}});
|
||||||
|
|
||||||
|
@ -597,6 +603,11 @@ bool IppPrinter::cancelJob(qint32 jobId) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IppPrinter::isIpps()
|
||||||
|
{
|
||||||
|
return _url.scheme() == "ipps";
|
||||||
|
}
|
||||||
|
|
||||||
QUrl IppPrinter::httpUrl() {
|
QUrl IppPrinter::httpUrl() {
|
||||||
qDebug() << _url;
|
qDebug() << _url;
|
||||||
QUrl url = _url;
|
QUrl url = _url;
|
||||||
|
|
|
@ -18,6 +18,9 @@ class IppPrinter : public QObject
|
||||||
Q_PROPERTY(QString busyMessage MEMBER _busyMessage NOTIFY busyMessageChanged)
|
Q_PROPERTY(QString busyMessage MEMBER _busyMessage NOTIFY busyMessageChanged)
|
||||||
Q_PROPERTY(QString progress MEMBER _progress NOTIFY progressChanged)
|
Q_PROPERTY(QString progress MEMBER _progress NOTIFY progressChanged)
|
||||||
|
|
||||||
|
Q_PROPERTY(bool tainted MEMBER _tainted NOTIFY taintedChanged)
|
||||||
|
Q_PROPERTY(bool isIpps READ isIpps() NOTIFY urlChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IppPrinter();
|
IppPrinter();
|
||||||
~IppPrinter();
|
~IppPrinter();
|
||||||
|
@ -31,6 +34,8 @@ public:
|
||||||
Q_INVOKABLE bool getJobs();
|
Q_INVOKABLE bool getJobs();
|
||||||
Q_INVOKABLE bool cancelJob(qint32 jobId);
|
Q_INVOKABLE bool cancelJob(qint32 jobId);
|
||||||
|
|
||||||
|
bool isIpps();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void urlChanged();
|
void urlChanged();
|
||||||
void attrsChanged();
|
void attrsChanged();
|
||||||
|
@ -61,6 +66,7 @@ signals:
|
||||||
void additionalDocumentFormatsChanged();
|
void additionalDocumentFormatsChanged();
|
||||||
void busyMessageChanged();
|
void busyMessageChanged();
|
||||||
void progressChanged();
|
void progressChanged();
|
||||||
|
void taintedChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void print(QJsonObject attrs, QString file);
|
void print(QJsonObject attrs, QString file);
|
||||||
|
@ -73,7 +79,8 @@ public slots:
|
||||||
void getJobsRequestFinished(QNetworkReply* reply);
|
void getJobsRequestFinished(QNetworkReply* reply);
|
||||||
void cancelJobFinished(QNetworkReply* reply);
|
void cancelJobFinished(QNetworkReply* reply);
|
||||||
|
|
||||||
static void onSslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
|
void onSslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
|
||||||
|
static void ignoreSslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
|
||||||
|
|
||||||
void convertDone(QNetworkRequest request, QTemporaryFile* data);
|
void convertDone(QNetworkRequest request, QTemporaryFile* data);
|
||||||
void convertFailed(QString message);
|
void convertFailed(QString message);
|
||||||
|
@ -108,6 +115,8 @@ private:
|
||||||
|
|
||||||
QThread _workerThread;
|
QThread _workerThread;
|
||||||
ConvertWorker* _worker;
|
ConvertWorker* _worker;
|
||||||
|
|
||||||
|
bool _tainted;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // IPPPRINTER_H
|
#endif // IPPPRINTER_H
|
||||||
|
|
Loading…
Reference in a new issue