diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index 65ed80f..c4a0a3f 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -265,11 +265,22 @@ Page { + (Utils.existsAndNotEmpty("printer-location", printer) ? " • "+printer.attrs["printer-location"].value : "") } - Label { - id: uri_label - color: canPrint || selectedFile == "" ? Theme.highlightColor : Theme.secondaryColor - font.pixelSize: Theme.fontSizeTiny - text: printer.url + Row { + Icon { + visible: printer.isIpps && !printer.tainted + color: canPrint || selectedFile == "" ? Theme.highlightColor : Theme.secondaryColor + 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 { diff --git a/src/ippdiscovery.cpp b/src/ippdiscovery.cpp index e6f4ec0..30fa0a6 100644 --- a/src/ippdiscovery.cpp +++ b/src/ippdiscovery.cpp @@ -430,7 +430,7 @@ QImage IppDiscovery::requestImage(const QString &id, QSize *size, const QSize &r QNetworkRequest request(url); request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint " SEAPRINT_VERSION); - connect(nam, &QNetworkAccessManager::sslErrors, &IppPrinter::onSslErrors); + connect(nam, &QNetworkAccessManager::sslErrors, &IppPrinter::ignoreSslErrors); QNetworkReply* reply = nam->get(request); diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index d979238..cc0b5ba 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -13,16 +13,16 @@ IppPrinter::IppPrinter() _job_cancel_nam = new QNetworkAccessManager(this); 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::sslErrors, &IppPrinter::onSslErrors); + connect(_print_nam, &QNetworkAccessManager::sslErrors, this, &IppPrinter::onSslErrors); 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::sslErrors, &IppPrinter::onSslErrors); + connect(_job_cancel_nam, &QNetworkAccessManager::sslErrors, this, &IppPrinter::onSslErrors); QObject::connect(this, &IppPrinter::urlChanged, this, &IppPrinter::onUrlChanged); qRegisterMetaType("QTemporaryFile*"); @@ -41,6 +41,7 @@ IppPrinter::IppPrinter() connect(_worker, &ConvertWorker::failed, this, &IppPrinter::convertFailed); _workerThread.start(); + _tainted = false; } IppPrinter::~IppPrinter() { @@ -262,8 +263,14 @@ void IppPrinter::cancelJobFinished(QNetworkReply *reply) getJobs(); } - void IppPrinter::onSslErrors(QNetworkReply *reply, const QList &errors) +{ + _tainted = true; + emit taintedChanged(); + return ignoreSslErrors(reply, errors); +} + +void IppPrinter::ignoreSslErrors(QNetworkReply *reply, const QList &errors) { bool ignore = Settings::instance()->ignoreSslErrors(); qDebug() << reply->request().url() << "SSL handshake failed" << errors << ignore; @@ -563,7 +570,6 @@ void IppPrinter::print(QJsonObject attrs, QString filename) bool IppPrinter::getJobs() { qDebug() << "getting jobs"; - QJsonObject o = opAttrs(); o.insert("requested-attributes", QJsonObject {{"tag", IppMsg::Keyword}, {"value", "all"}}); @@ -597,6 +603,11 @@ bool IppPrinter::cancelJob(qint32 jobId) { return true; } +bool IppPrinter::isIpps() +{ + return _url.scheme() == "ipps"; +} + QUrl IppPrinter::httpUrl() { qDebug() << _url; QUrl url = _url; diff --git a/src/ippprinter.h b/src/ippprinter.h index 7828d5e..dc0185e 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -18,6 +18,9 @@ class IppPrinter : public QObject Q_PROPERTY(QString busyMessage MEMBER _busyMessage NOTIFY busyMessageChanged) 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: IppPrinter(); ~IppPrinter(); @@ -31,6 +34,8 @@ public: Q_INVOKABLE bool getJobs(); Q_INVOKABLE bool cancelJob(qint32 jobId); + bool isIpps(); + signals: void urlChanged(); void attrsChanged(); @@ -61,6 +66,7 @@ signals: void additionalDocumentFormatsChanged(); void busyMessageChanged(); void progressChanged(); + void taintedChanged(); public slots: void print(QJsonObject attrs, QString file); @@ -73,7 +79,8 @@ public slots: void getJobsRequestFinished(QNetworkReply* reply); void cancelJobFinished(QNetworkReply* reply); - static void onSslErrors(QNetworkReply *reply, const QList &errors); + void onSslErrors(QNetworkReply *reply, const QList &errors); + static void ignoreSslErrors(QNetworkReply *reply, const QList &errors); void convertDone(QNetworkRequest request, QTemporaryFile* data); void convertFailed(QString message); @@ -108,6 +115,8 @@ private: QThread _workerThread; ConvertWorker* _worker; + + bool _tainted; }; #endif // IPPPRINTER_H