diff options
author | Andrey Leonov <aleonov@rim.com> | 2012-10-04 23:37:00 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-14 01:41:49 (GMT) |
commit | c680ca946be60ce9c2629a3fef62c5a29407b355 (patch) | |
tree | 22585b6eee0620aca0bc05670b5927e21675e344 /src | |
parent | ce52989b3b955c1e91e8449b77ea6aa5e1b4d5f6 (diff) | |
download | Qt-c680ca946be60ce9c2629a3fef62c5a29407b355.zip Qt-c680ca946be60ce9c2629a3fef62c5a29407b355.tar.gz Qt-c680ca946be60ce9c2629a3fef62c5a29407b355.tar.bz2 |
Implementation of the BlackBerry Qt Proxy support.
An implementation for BlackBerry devices based on the BPS netstatus API.
(backport of qtbase/cf66e41728ae70595365833c9ed00d0e2e6c4200)
Change-Id: I155f287274c4d92e0546740b8dbe595ea030b505
Reviewed-by: Peter Hartmann <phartmann@rim.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/network/kernel/kernel.pri | 2 | ||||
-rw-r--r-- | src/network/kernel/qnetworkproxy.cpp | 11 | ||||
-rw-r--r-- | src/network/kernel/qnetworkproxy_blackberry.cpp | 125 |
3 files changed, 138 insertions, 0 deletions
diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri index ceaecbd..eb647e3 100644 --- a/src/network/kernel/kernel.pri +++ b/src/network/kernel/kernel.pri @@ -30,6 +30,8 @@ qpa:mac:!ios:SOURCES += kernel/qnetworkproxy_mac.cpp else:!qpa:mac:SOURCES += kernel/qnetworkproxy_mac.cpp else:win32:SOURCES += kernel/qnetworkproxy_win.cpp else:symbian:SOURCES += kernel/qnetworkproxy_symbian.cpp +else:blackberry:SOURCES += kernel/qnetworkproxy_blackberry.cpp else:SOURCES += kernel/qnetworkproxy_generic.cpp symbian: LIBS += -lcommsdat +blackberry: LIBS_PRIVATE += -lbps diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp index 3b8a5d6..393f049 100644 --- a/src/network/kernel/qnetworkproxy.cpp +++ b/src/network/kernel/qnetworkproxy.cpp @@ -1394,6 +1394,12 @@ void QNetworkProxyFactory::setApplicationProxyFactory(QNetworkProxyFactory *fact SOCKS server for all queries. If SOCKS isn't enabled, it will use the HTTPS proxy for all TcpSocket and UrlRequest queries. + On BlackBerry, this function obtains proxy settings for the default + configuration using system configuration. The type will be set based on + protocol tag "http", "https", "ftp", respectively. By default, it + assumes http type. Proxy username and password are also set during + the query using system configuration. + On other systems, this function will pick up proxy settings from the "http_proxy" environment variable. This variable must be a URL using one of the following schemes: "http", "socks5" or "socks5h". @@ -1410,6 +1416,11 @@ void QNetworkProxyFactory::setApplicationProxyFactory(QNetworkProxyFactory *fact \o On Windows platforms, this function may take several seconds to execute depending on the configuration of the user's system. + + \li On BlackBerry, this function ignores network configuration specified + in \a query. Only UrlRequest quieries are supported. SOCKS is not supported. + The proxy information is retrieved only for the default configuration. + Also, PAC and exclusion lists are currently not supported. \endlist */ diff --git a/src/network/kernel/qnetworkproxy_blackberry.cpp b/src/network/kernel/qnetworkproxy_blackberry.cpp new file mode 100644 index 0000000..c985219 --- /dev/null +++ b/src/network/kernel/qnetworkproxy_blackberry.cpp @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtNetwork module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/** + * Some notes about the code: + * + * ** It is assumed that the system proxies are for url based requests + * ie. HTTP/HTTPS based. + */ + +#include <QtNetwork/qnetworkproxy.h> + +#ifndef QT_NO_NETWORKPROXY + + +#include <QtCore/qurl.h> +#include <QtNetwork/qnetworkconfiguration.h> + +#include <bps/netstatus.h> +#include <errno.h> + + +QT_BEGIN_NAMESPACE + +QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkProxyQuery &query) +{ + QNetworkProxy proxy; + + if (query.queryType() != QNetworkProxyQuery::UrlRequest) { + qWarning("Unsupported query type: %d", query.queryType()); + return QList<QNetworkProxy>() << QNetworkProxy(QNetworkProxy::NoProxy); + } + + QUrl url = query.url(); + + if (!url.isValid()) { + qWarning("Invalid URL: %s", qPrintable(url.toString())); + return QList<QNetworkProxy>() << QNetworkProxy(QNetworkProxy::NoProxy); + } + + netstatus_proxy_details_t details; + memset(&details, 0, sizeof(netstatus_proxy_details_t)); + if (netstatus_get_proxy_details(&details) != BPS_SUCCESS) { + qWarning("netstatus_get_proxy_details failed! errno: %d", errno); + return QList<QNetworkProxy>() << QNetworkProxy(QNetworkProxy::NoProxy); + } + + if (details.http_proxy_host == NULL) { // No proxy + netstatus_free_proxy_details(&details); + return QList<QNetworkProxy>() << QNetworkProxy(QNetworkProxy::NoProxy); + } + + QString protocol = query.protocolTag(); + if (protocol.startsWith(QLatin1String("http"), Qt::CaseInsensitive)) { // http, https + proxy.setType((QNetworkProxy::HttpProxy)); + } else if (protocol == QLatin1String("ftp")) { + proxy.setType(QNetworkProxy::FtpCachingProxy); + } else { // assume http proxy + qDebug("Proxy type: %s assumed to be http proxy", qPrintable(protocol)); + proxy.setType((QNetworkProxy::HttpProxy)); + } + + // Set host + // Note: ftp and https proxy type fields *are* obsolete. + // The user interface allows only one host/port which gets duplicated + // to all proxy type fields. + proxy.setHostName(QString::fromUtf8(details.http_proxy_host)); + + // Set port + proxy.setPort(details.http_proxy_port); + + // Set username + if (details.http_proxy_login_user) + proxy.setUser(QString::fromUtf8(details.http_proxy_login_user)); + + // Set password + if (details.http_proxy_login_password) + proxy.setPassword(QString::fromUtf8(details.http_proxy_login_password)); + + netstatus_free_proxy_details(&details); + + return QList<QNetworkProxy>() << proxy; +} + +QT_END_NAMESPACE + +#endif |