diff --git a/src/ippdiscovery.cpp b/src/ippdiscovery.cpp index 7e0ba02..c51c51c 100644 --- a/src/ippdiscovery.cpp +++ b/src/ippdiscovery.cpp @@ -1,4 +1,5 @@ #include "ippdiscovery.h" +#include "ippprinter.h" #include #define A 1 @@ -264,26 +265,6 @@ void IppDiscovery::readPendingDatagrams() } -void IppDiscovery::ignoreKnownSslErrors(QNetworkReply *reply, const QList &errors) -{ - QList IgnoredSslErrors = {QSslError::NoError, - QSslError::SelfSignedCertificate, - QSslError::HostNameMismatch, - QSslError::UnableToGetLocalIssuerCertificate, - QSslError::UnableToVerifyFirstCertificate - }; - - qDebug() << errors; - for (QList::const_iterator it = errors.constBegin(); it != errors.constEnd(); it++) { - if(!IgnoredSslErrors.contains(it->error())) { - qDebug() << "Bad error: " << int(it->error()) << it->error(); - return; - } - } - // For whatever reason, it doesn't work to pass IgnoredSslErrors here - reply->ignoreSslErrors(errors); -} - QImage IppDiscovery::requestImage(const QString &id, QSize *size, const QSize &requestedSize) { //TODO: consider caching images (doesn't appear to be needed currently) Q_UNUSED(size); @@ -292,7 +273,7 @@ QImage IppDiscovery::requestImage(const QString &id, QSize *size, const QSize &r QImage img; - QNetworkAccessManager* nam = new QNetworkAccessManager(this); + QNetworkAccessManager* nam = new QNetworkAccessManager(); QUrl url(id); qDebug() << url.host() << _AAs; // TODO IPv6 @@ -304,13 +285,14 @@ 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::ignoreKnownSslErrors); + QNetworkReply* reply = nam->get(request); - QEventLoop el; - connect(reply, SIGNAL(finished()),&el,SLOT(quit())); - connect(nam, SIGNAL(sslErrors(QNetworkReply*,QList)), - this, SLOT(ignoreKnownSslErrors(QNetworkReply*, const QList&))); - el.exec(); + QEventLoop loop; + connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); + loop.exec(); if (reply->error() == QNetworkReply::NoError) { diff --git a/src/ippdiscovery.h b/src/ippdiscovery.h index 470a2fd..f7df8cd 100644 --- a/src/ippdiscovery.h +++ b/src/ippdiscovery.h @@ -26,7 +26,6 @@ signals: public slots: void readPendingDatagrams(); void update(); - void ignoreKnownSslErrors(QNetworkReply *reply, const QList &errors); protected: private: diff --git a/src/ippprinter.h b/src/ippprinter.h index 5c07344..4e02a69 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -64,7 +64,7 @@ public slots: void getJobsRequestFinished(QNetworkReply* reply); void cancelJobFinished(QNetworkReply* reply); - void ignoreKnownSslErrors(QNetworkReply *reply, const QList &errors); + static void ignoreKnownSslErrors(QNetworkReply *reply, const QList &errors); void convertDone(QNetworkRequest request, QTemporaryFile* data); void convertFailed(QString message);