From e9a5dce1593172a69fbcc1a8e2c62cc63d33b486 Mon Sep 17 00:00:00 2001 From: kh1 Date: Fri, 25 Nov 2011 14:36:25 +0100 Subject: Update the test app to use a proxy factory as well. Change-Id: I35fe8570b12109254a31758141e4159518ed2ac5 Reviewed-by: Tim Jenssen --- examples/downloadspeed/main.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'examples') diff --git a/examples/downloadspeed/main.cpp b/examples/downloadspeed/main.cpp index 835a38faa..f4e694c33 100644 --- a/examples/downloadspeed/main.cpp +++ b/examples/downloadspeed/main.cpp @@ -28,6 +28,8 @@ #include #include +#include + static QString format(double data) { if (data < 1024.0) @@ -131,6 +133,22 @@ private: // http://get.qt.nokia.com/qt/source/qt-mac-opensource-4.7.4.dmg // ftp://ftp.trolltech.com/qt/source/qt-mac-opensource-4.7.4.dmg +class ProxyFactory : public KDUpdater::FileDownloaderProxyFactory +{ +public: + ProxyFactory() {} + + ProxyFactory *clone() const + { + return new ProxyFactory(); + } + + QList queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery()) + { + return QNetworkProxyFactory::systemProxyForQuery(query); + } +}; + int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); @@ -143,6 +161,7 @@ int main(int argc, char *argv[]) KDUpdater::FileDownloader *loader = KDUpdater::FileDownloaderFactory::instance().create(url.scheme()); if (loader) { loader->setUrl(url); + loader->setProxyFactory(new ProxyFactory()); Receiver r; r.connect(loader, SIGNAL(downloadStarted()), &r, SLOT(downloadStarted())); -- cgit v1.2.3