summaryrefslogtreecommitdiffstats
path: root/examples/network
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2011-03-21 14:32:33 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2011-03-22 14:41:12 (GMT)
commit7e36013828de19bcb3256c38ac29bcf9abdcc05a (patch)
tree974df55430e027e9c61b73a74205bd15e387f74b /examples/network
parent26737dcd4296dce49e5f562439de3a0d13127e63 (diff)
downloadQt-7e36013828de19bcb3256c38ac29bcf9abdcc05a.zip
Qt-7e36013828de19bcb3256c38ac29bcf9abdcc05a.tar.gz
Qt-7e36013828de19bcb3256c38ac29bcf9abdcc05a.tar.bz2
Examples: Make the download example also print the SSL errors
Diffstat (limited to 'examples/network')
-rw-r--r--examples/network/download/main.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/examples/network/download/main.cpp b/examples/network/download/main.cpp
index 5980ecd..1b7e54b 100644
--- a/examples/network/download/main.cpp
+++ b/examples/network/download/main.cpp
@@ -45,12 +45,19 @@
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
+#include <QSslError>
#include <QStringList>
#include <QTimer>
#include <QUrl>
#include <stdio.h>
+QT_BEGIN_NAMESPACE
+class QSslError;
+QT_END_NAMESPACE
+
+QT_USE_NAMESPACE
+
class DownloadManager: public QObject
{
Q_OBJECT
@@ -66,6 +73,7 @@ public:
public slots:
void execute();
void downloadFinished(QNetworkReply *reply);
+ void sslErrors(const QList<QSslError> &errors);
};
DownloadManager::DownloadManager()
@@ -78,6 +86,7 @@ void DownloadManager::doDownload(const QUrl &url)
{
QNetworkRequest request(url);
QNetworkReply *reply = manager.get(request);
+ connect(reply, SIGNAL(sslErrors(QList<QSslError>)), SLOT(sslErrors(QList<QSslError>)));
currentDownloads.append(reply);
}
@@ -140,6 +149,14 @@ void DownloadManager::execute()
}
}
+void DownloadManager::sslErrors(const QList<QSslError> &sslErrors)
+{
+#ifndef QT_NO_OPENSSL
+ foreach (const QSslError &error, sslErrors)
+ fprintf(stderr, "SSL error: %s\n", qPrintable(error.errorString()));
+#endif
+}
+
void DownloadManager::downloadFinished(QNetworkReply *reply)
{
QUrl url = reply->url();