summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/access.pri2
-rw-r--r--src/network/access/qabstractnetworkcache.cpp4
-rw-r--r--src/network/access/qabstractnetworkcache.h5
-rw-r--r--src/network/access/qabstractnetworkcache_p.h4
-rw-r--r--src/network/access/qftp.cpp6
-rw-r--r--src/network/access/qftp_p.h5
-rw-r--r--src/network/access/qhttpheader.cpp770
-rw-r--r--src/network/access/qhttpheader_p.h147
-rw-r--r--src/network/access/qhttpmultipart.cpp4
-rw-r--r--src/network/access/qhttpmultipart.h5
-rw-r--r--src/network/access/qhttpmultipart_p.h4
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp4
-rw-r--r--src/network/access/qhttpnetworkconnection_p.h4
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp4
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel_p.h4
-rw-r--r--src/network/access/qhttpnetworkheader.cpp4
-rw-r--r--src/network/access/qhttpnetworkheader_p.h4
-rw-r--r--src/network/access/qhttpnetworkreply.cpp4
-rw-r--r--src/network/access/qhttpnetworkreply_p.h5
-rw-r--r--src/network/access/qhttpnetworkrequest.cpp4
-rw-r--r--src/network/access/qhttpnetworkrequest_p.h4
-rw-r--r--src/network/access/qhttpthreaddelegate.cpp4
-rw-r--r--src/network/access/qhttpthreaddelegate_p.h4
-rw-r--r--src/network/access/qnetworkaccessauthenticationmanager.cpp4
-rw-r--r--src/network/access/qnetworkaccessauthenticationmanager_p.h4
-rw-r--r--src/network/access/qnetworkaccessbackend.cpp4
-rw-r--r--src/network/access/qnetworkaccessbackend_p.h4
-rw-r--r--src/network/access/qnetworkaccesscache.cpp4
-rw-r--r--src/network/access/qnetworkaccesscache_p.h4
-rw-r--r--src/network/access/qnetworkaccesscachebackend.cpp4
-rw-r--r--src/network/access/qnetworkaccesscachebackend_p.h4
-rw-r--r--src/network/access/qnetworkaccessdebugpipebackend.cpp4
-rw-r--r--src/network/access/qnetworkaccessdebugpipebackend_p.h4
-rw-r--r--src/network/access/qnetworkaccessfilebackend.cpp4
-rw-r--r--src/network/access/qnetworkaccessfilebackend_p.h4
-rw-r--r--src/network/access/qnetworkaccessftpbackend.cpp4
-rw-r--r--src/network/access/qnetworkaccessftpbackend_p.h4
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp5
-rw-r--r--src/network/access/qnetworkaccessmanager.h5
-rw-r--r--src/network/access/qnetworkaccessmanager_p.h4
-rw-r--r--src/network/access/qnetworkcookie.cpp41
-rw-r--r--src/network/access/qnetworkcookie.h8
-rw-r--r--src/network/access/qnetworkcookie_p.h4
-rw-r--r--src/network/access/qnetworkcookiejar.cpp150
-rw-r--r--src/network/access/qnetworkcookiejar.h10
-rw-r--r--src/network/access/qnetworkcookiejar_p.h4
-rw-r--r--src/network/access/qnetworkdiskcache.cpp4
-rw-r--r--src/network/access/qnetworkdiskcache.h5
-rw-r--r--src/network/access/qnetworkdiskcache_p.h4
-rw-r--r--src/network/access/qnetworkreply.cpp4
-rw-r--r--src/network/access/qnetworkreply.h5
-rw-r--r--src/network/access/qnetworkreply_p.h4
-rw-r--r--src/network/access/qnetworkreplydataimpl.cpp4
-rw-r--r--src/network/access/qnetworkreplydataimpl_p.h4
-rw-r--r--src/network/access/qnetworkreplyfileimpl.cpp4
-rw-r--r--src/network/access/qnetworkreplyfileimpl_p.h4
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp18
-rw-r--r--src/network/access/qnetworkreplyhttpimpl_p.h4
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp4
-rw-r--r--src/network/access/qnetworkreplyimpl_p.h4
-rw-r--r--src/network/access/qnetworkrequest.cpp4
-rw-r--r--src/network/access/qnetworkrequest.h5
-rw-r--r--src/network/access/qnetworkrequest_p.h4
-rw-r--r--src/network/bearer/qbearerengine.cpp4
-rw-r--r--src/network/bearer/qbearerengine_p.h4
-rw-r--r--src/network/bearer/qbearerplugin.cpp4
-rw-r--r--src/network/bearer/qbearerplugin_p.h7
-rw-r--r--src/network/bearer/qnetworkconfigmanager.cpp38
-rw-r--r--src/network/bearer/qnetworkconfigmanager.h8
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.cpp40
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.h7
-rw-r--r--src/network/bearer/qnetworkconfiguration.cpp35
-rw-r--r--src/network/bearer/qnetworkconfiguration.h13
-rw-r--r--src/network/bearer/qnetworkconfiguration_p.h9
-rw-r--r--src/network/bearer/qnetworksession.cpp6
-rw-r--r--src/network/bearer/qnetworksession.h6
-rw-r--r--src/network/bearer/qnetworksession_p.h4
-rw-r--r--src/network/bearer/qsharednetworksession.cpp4
-rw-r--r--src/network/bearer/qsharednetworksession_p.h4
-rw-r--r--src/network/kernel/kernel.pri9
-rw-r--r--src/network/kernel/qauthenticator.cpp20
-rw-r--r--src/network/kernel/qauthenticator.h5
-rw-r--r--src/network/kernel/qauthenticator_p.h7
-rw-r--r--src/network/kernel/qdnslookup.cpp988
-rw-r--r--src/network/kernel/qdnslookup.h235
-rw-r--r--src/network/kernel/qdnslookup_p.h213
-rw-r--r--src/network/kernel/qdnslookup_unix.cpp322
-rw-r--r--src/network/kernel/qdnslookup_win.cpp177
-rw-r--r--src/network/kernel/qhostaddress.cpp4
-rw-r--r--src/network/kernel/qhostaddress.h5
-rw-r--r--src/network/kernel/qhostaddress_p.h4
-rw-r--r--src/network/kernel/qhostinfo.cpp4
-rw-r--r--src/network/kernel/qhostinfo.h5
-rw-r--r--src/network/kernel/qhostinfo_p.h4
-rw-r--r--src/network/kernel/qhostinfo_unix.cpp13
-rw-r--r--src/network/kernel/qhostinfo_win.cpp12
-rw-r--r--src/network/kernel/qnetworkinterface.cpp4
-rw-r--r--src/network/kernel/qnetworkinterface.h5
-rw-r--r--src/network/kernel/qnetworkinterface_p.h4
-rw-r--r--src/network/kernel/qnetworkinterface_unix.cpp4
-rw-r--r--src/network/kernel/qnetworkinterface_win.cpp4
-rw-r--r--src/network/kernel/qnetworkinterface_win_p.h4
-rw-r--r--src/network/kernel/qnetworkproxy.cpp4
-rw-r--r--src/network/kernel/qnetworkproxy.h5
-rw-r--r--src/network/kernel/qnetworkproxy_generic.cpp4
-rw-r--r--src/network/kernel/qnetworkproxy_mac.cpp4
-rw-r--r--src/network/kernel/qnetworkproxy_p.h4
-rw-r--r--src/network/kernel/qnetworkproxy_win.cpp6
-rw-r--r--src/network/kernel/qurlinfo.cpp4
-rw-r--r--src/network/kernel/qurlinfo.h5
-rw-r--r--src/network/socket/qabstractsocket.cpp112
-rw-r--r--src/network/socket/qabstractsocket.h35
-rw-r--r--src/network/socket/qabstractsocket_p.h6
-rw-r--r--src/network/socket/qabstractsocketengine.cpp4
-rw-r--r--src/network/socket/qabstractsocketengine_p.h4
-rw-r--r--src/network/socket/qhttpsocketengine.cpp58
-rw-r--r--src/network/socket/qhttpsocketengine_p.h7
-rw-r--r--src/network/socket/qlocalserver.cpp4
-rw-r--r--src/network/socket/qlocalserver.h5
-rw-r--r--src/network/socket/qlocalserver_p.h4
-rw-r--r--src/network/socket/qlocalserver_tcp.cpp4
-rw-r--r--src/network/socket/qlocalserver_unix.cpp4
-rw-r--r--src/network/socket/qlocalserver_win.cpp4
-rw-r--r--src/network/socket/qlocalsocket.cpp4
-rw-r--r--src/network/socket/qlocalsocket.h5
-rw-r--r--src/network/socket/qlocalsocket_p.h4
-rw-r--r--src/network/socket/qlocalsocket_tcp.cpp4
-rw-r--r--src/network/socket/qlocalsocket_unix.cpp4
-rw-r--r--src/network/socket/qlocalsocket_win.cpp6
-rw-r--r--src/network/socket/qnativesocketengine.cpp4
-rw-r--r--src/network/socket/qnativesocketengine_p.h4
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp4
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp10
-rw-r--r--src/network/socket/qnet_unix_p.h4
-rw-r--r--src/network/socket/qsocks5socketengine.cpp4
-rw-r--r--src/network/socket/qsocks5socketengine_p.h4
-rw-r--r--src/network/socket/qtcpserver.cpp4
-rw-r--r--src/network/socket/qtcpserver.h5
-rw-r--r--src/network/socket/qtcpsocket.cpp4
-rw-r--r--src/network/socket/qtcpsocket.h5
-rw-r--r--src/network/socket/qtcpsocket_p.h4
-rw-r--r--src/network/socket/qudpsocket.cpp7
-rw-r--r--src/network/socket/qudpsocket.h5
-rw-r--r--src/network/ssl/qssl.cpp4
-rw-r--r--src/network/ssl/qssl.h5
-rw-r--r--src/network/ssl/qsslcertificate.cpp4
-rw-r--r--src/network/ssl/qsslcertificate.h8
-rw-r--r--src/network/ssl/qsslcertificate_p.h4
-rw-r--r--src/network/ssl/qsslcertificateextension.cpp4
-rw-r--r--src/network/ssl/qsslcertificateextension.h5
-rw-r--r--src/network/ssl/qsslcertificateextension_p.h4
-rw-r--r--src/network/ssl/qsslcipher.cpp4
-rw-r--r--src/network/ssl/qsslcipher.h5
-rw-r--r--src/network/ssl/qsslcipher_p.h4
-rw-r--r--src/network/ssl/qsslconfiguration.cpp4
-rw-r--r--src/network/ssl/qsslconfiguration.h7
-rw-r--r--src/network/ssl/qsslconfiguration_p.h4
-rw-r--r--src/network/ssl/qsslerror.cpp4
-rw-r--r--src/network/ssl/qsslerror.h5
-rw-r--r--src/network/ssl/qsslkey.cpp4
-rw-r--r--src/network/ssl/qsslkey.h5
-rw-r--r--src/network/ssl/qsslkey_p.h4
-rw-r--r--src/network/ssl/qsslsocket.cpp78
-rw-r--r--src/network/ssl/qsslsocket.h13
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp156
-rw-r--r--src/network/ssl/qsslsocket_openssl_p.h6
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols.cpp4
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols_p.h4
-rw-r--r--src/network/ssl/qsslsocket_p.h11
-rw-r--r--src/network/ssl/ssl.pri4
170 files changed, 2754 insertions, 1614 deletions
diff --git a/src/network/access/access.pri b/src/network/access/access.pri
index 0047084eb1..e0a0253b6c 100644
--- a/src/network/access/access.pri
+++ b/src/network/access/access.pri
@@ -2,7 +2,6 @@
HEADERS += \
access/qftp_p.h \
- access/qhttpheader_p.h \
access/qhttpnetworkheader_p.h \
access/qhttpnetworkrequest_p.h \
access/qhttpnetworkreply_p.h \
@@ -39,7 +38,6 @@ HEADERS += \
SOURCES += \
access/qftp.cpp \
- access/qhttpheader.cpp \
access/qhttpnetworkheader.cpp \
access/qhttpnetworkrequest.cpp \
access/qhttpnetworkreply.cpp \
diff --git a/src/network/access/qabstractnetworkcache.cpp b/src/network/access/qabstractnetworkcache.cpp
index 638e93be53..69acf080ec 100644
--- a/src/network/access/qabstractnetworkcache.cpp
+++ b/src/network/access/qabstractnetworkcache.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qabstractnetworkcache.h b/src/network/access/qabstractnetworkcache.h
index 5d03756957..8d7e77eeb0 100644
--- a/src/network/access/qabstractnetworkcache.h
+++ b/src/network/access/qabstractnetworkcache.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -51,7 +51,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QIODevice;
class QDateTime;
diff --git a/src/network/access/qabstractnetworkcache_p.h b/src/network/access/qabstractnetworkcache_p.h
index 162422f8c0..4577d16b0b 100644
--- a/src/network/access/qabstractnetworkcache_p.h
+++ b/src/network/access/qabstractnetworkcache_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp
index 6fafff0f56..c7ad810084 100644
--- a/src/network/access/qftp.cpp
+++ b/src/network/access/qftp.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -472,7 +472,7 @@ static void _q_fixupDateTime(QDateTime *dateTime)
const int futureTolerance = 86400;
if (dateTime->secsTo(QDateTime::currentDateTime()) < -futureTolerance) {
QDate d = dateTime->date();
- d.setYMD(d.year() - 1, d.month(), d.day());
+ d.setDate(d.year() - 1, d.month(), d.day());
dateTime->setDate(d);
}
}
diff --git a/src/network/access/qftp_p.h b/src/network/access/qftp_p.h
index 0dc6a2006f..8dc423973a 100644
--- a/src/network/access/qftp_p.h
+++ b/src/network/access/qftp_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -61,7 +61,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
#ifndef QT_NO_FTP
diff --git a/src/network/access/qhttpheader.cpp b/src/network/access/qhttpheader.cpp
deleted file mode 100644
index 6e87a05c6b..0000000000
--- a/src/network/access/qhttpheader.cpp
+++ /dev/null
@@ -1,770 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//#define QHTTP_DEBUG
-
-#include <qplatformdefs.h>
-#include "qhttpheader_p.h"
-
-#ifndef QT_NO_HTTP
-# include "private/qobject_p.h"
-# include "qtcpsocket.h"
-# include "qsslsocket.h"
-# include "qtextstream.h"
-# include "qmap.h"
-# include "qlist.h"
-# include "qstring.h"
-# include "qstringlist.h"
-# include "qbuffer.h"
-# include "private/qringbuffer_p.h"
-# include "qcoreevent.h"
-# include "qurl.h"
-# include "qnetworkproxy.h"
-# include "qauthenticator.h"
-# include "qauthenticator_p.h"
-# include "qdebug.h"
-# include "qtimer.h"
-#endif
-
-#ifndef QT_NO_HTTP
-
-QT_BEGIN_NAMESPACE
-
-class QHttpHeaderPrivate
-{
- Q_DECLARE_PUBLIC(QHttpHeader)
-public:
- inline virtual ~QHttpHeaderPrivate() {}
-
- QList<QPair<QString, QString> > values;
- bool valid;
- QHttpHeader *q_ptr;
-};
-
-/****************************************************
- *
- * QHttpHeader
- *
- ****************************************************/
-
-/*!
- \class QHttpHeader
- \obsolete
- \brief The QHttpHeader class contains header information for HTTP.
-
- \ingroup network
- \inmodule QtNetwork
-
- In most cases you should use the more specialized derivatives of
- this class, QHttpResponseHeader and QHttpRequestHeader, rather
- than directly using QHttpHeader.
-
- QHttpHeader provides the HTTP header fields. A HTTP header field
- consists of a name followed by a colon, a single space, and the
- field value. (See RFC 1945.) Field names are case-insensitive. A
- typical header field looks like this:
- \snippet doc/src/snippets/code/src_network_access_qhttp.cpp 0
-
- In the API the header field name is called the "key" and the
- content is called the "value". You can get and set a header
- field's value by using its key with value() and setValue(), e.g.
- \snippet doc/src/snippets/code/src_network_access_qhttp.cpp 1
-
- Some fields are so common that getters and setters are provided
- for them as a convenient alternative to using \l value() and
- \l setValue(), e.g. contentLength() and contentType(),
- setContentLength() and setContentType().
-
- Each header key has a \e single value associated with it. If you
- set the value for a key which already exists the previous value
- will be discarded.
-
- \sa QHttpRequestHeader QHttpResponseHeader
-*/
-
-/*!
- \fn int QHttpHeader::majorVersion() const
-
- Returns the major protocol-version of the HTTP header.
-*/
-
-/*!
- \fn int QHttpHeader::minorVersion() const
-
- Returns the minor protocol-version of the HTTP header.
-*/
-
-/*!
- Constructs an empty HTTP header.
-*/
-QHttpHeader::QHttpHeader()
- : d_ptr(new QHttpHeaderPrivate)
-{
- Q_D(QHttpHeader);
- d->q_ptr = this;
- d->valid = true;
-}
-
-/*!
- Constructs a copy of \a header.
-*/
-QHttpHeader::QHttpHeader(const QHttpHeader &header)
- : d_ptr(new QHttpHeaderPrivate)
-{
- Q_D(QHttpHeader);
- d->q_ptr = this;
- d->valid = header.d_func()->valid;
- d->values = header.d_func()->values;
-}
-
-/*!
- Constructs a HTTP header for \a str.
-
- This constructor parses the string \a str for header fields and
- adds this information. The \a str should consist of one or more
- "\r\n" delimited lines; each of these lines should have the format
- key, colon, space, value.
-*/
-QHttpHeader::QHttpHeader(const QString &str)
- : d_ptr(new QHttpHeaderPrivate)
-{
- Q_D(QHttpHeader);
- d->q_ptr = this;
- d->valid = true;
- parse(str);
-}
-
-/*! \internal
- */
-QHttpHeader::QHttpHeader(QHttpHeaderPrivate &dd, const QString &str)
- : d_ptr(&dd)
-{
- Q_D(QHttpHeader);
- d->q_ptr = this;
- d->valid = true;
- if (!str.isEmpty())
- parse(str);
-}
-
-/*! \internal
- */
-QHttpHeader::QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header)
- : d_ptr(&dd)
-{
- Q_D(QHttpHeader);
- d->q_ptr = this;
- d->valid = header.d_func()->valid;
- d->values = header.d_func()->values;
-}
-/*!
- Destructor.
-*/
-QHttpHeader::~QHttpHeader()
-{
-}
-
-/*!
- Assigns \a h and returns a reference to this http header.
-*/
-QHttpHeader &QHttpHeader::operator=(const QHttpHeader &h)
-{
- Q_D(QHttpHeader);
- d->values = h.d_func()->values;
- d->valid = h.d_func()->valid;
- return *this;
-}
-
-/*!
- Returns true if the HTTP header is valid; otherwise returns false.
-
- A QHttpHeader is invalid if it was created by parsing a malformed string.
-*/
-bool QHttpHeader::isValid() const
-{
- Q_D(const QHttpHeader);
- return d->valid;
-}
-
-/*! \internal
- Parses the HTTP header string \a str for header fields and adds
- the keys/values it finds. If the string is not parsed successfully
- the QHttpHeader becomes \link isValid() invalid\endlink.
-
- Returns true if \a str was successfully parsed; otherwise returns false.
-
- \sa toString()
-*/
-bool QHttpHeader::parse(const QString &str)
-{
- Q_D(QHttpHeader);
- QStringList lst;
- int pos = str.indexOf(QLatin1Char('\n'));
- if (pos > 0 && str.at(pos - 1) == QLatin1Char('\r'))
- lst = str.trimmed().split(QLatin1String("\r\n"));
- else
- lst = str.trimmed().split(QLatin1String("\n"));
- lst.removeAll(QString()); // No empties
-
- if (lst.isEmpty())
- return true;
-
- QStringList lines;
- QStringList::Iterator it = lst.begin();
- for (; it != lst.end(); ++it) {
- if (!(*it).isEmpty()) {
- if ((*it)[0].isSpace()) {
- if (!lines.isEmpty()) {
- lines.last() += QLatin1Char(' ');
- lines.last() += (*it).trimmed();
- }
- } else {
- lines.append((*it));
- }
- }
- }
-
- int number = 0;
- it = lines.begin();
- for (; it != lines.end(); ++it) {
- if (!parseLine(*it, number++)) {
- d->valid = false;
- return false;
- }
- }
- return true;
-}
-
-/*! \internal
-*/
-void QHttpHeader::setValid(bool v)
-{
- Q_D(QHttpHeader);
- d->valid = v;
-}
-
-/*!
- Returns the first value for the entry with the given \a key. If no entry
- has this \a key, an empty string is returned.
-
- \sa setValue() removeValue() hasKey() keys()
-*/
-QString QHttpHeader::value(const QString &key) const
-{
- Q_D(const QHttpHeader);
- QString lowercaseKey = key.toLower();
- QList<QPair<QString, QString> >::ConstIterator it = d->values.constBegin();
- while (it != d->values.constEnd()) {
- if ((*it).first.toLower() == lowercaseKey)
- return (*it).second;
- ++it;
- }
- return QString();
-}
-
-/*!
- Returns all the entries with the given \a key. If no entry
- has this \a key, an empty string list is returned.
-*/
-QStringList QHttpHeader::allValues(const QString &key) const
-{
- Q_D(const QHttpHeader);
- QString lowercaseKey = key.toLower();
- QStringList valueList;
- QList<QPair<QString, QString> >::ConstIterator it = d->values.constBegin();
- while (it != d->values.constEnd()) {
- if ((*it).first.toLower() == lowercaseKey)
- valueList.append((*it).second);
- ++it;
- }
- return valueList;
-}
-
-/*!
- Returns a list of the keys in the HTTP header.
-
- \sa hasKey()
-*/
-QStringList QHttpHeader::keys() const
-{
- Q_D(const QHttpHeader);
- QStringList keyList;
- QSet<QString> seenKeys;
- QList<QPair<QString, QString> >::ConstIterator it = d->values.constBegin();
- while (it != d->values.constEnd()) {
- const QString &key = (*it).first;
- QString lowercaseKey = key.toLower();
- if (!seenKeys.contains(lowercaseKey)) {
- keyList.append(key);
- seenKeys.insert(lowercaseKey);
- }
- ++it;
- }
- return keyList;
-}
-
-/*!
- Returns true if the HTTP header has an entry with the given \a
- key; otherwise returns false.
-
- \sa value() setValue() keys()
-*/
-bool QHttpHeader::hasKey(const QString &key) const
-{
- Q_D(const QHttpHeader);
- QString lowercaseKey = key.toLower();
- QList<QPair<QString, QString> >::ConstIterator it = d->values.constBegin();
- while (it != d->values.constEnd()) {
- if ((*it).first.toLower() == lowercaseKey)
- return true;
- ++it;
- }
- return false;
-}
-
-/*!
- Sets the value of the entry with the \a key to \a value.
-
- If no entry with \a key exists, a new entry with the given \a key
- and \a value is created. If an entry with the \a key already
- exists, the first value is discarded and replaced with the given
- \a value.
-
- \sa value() hasKey() removeValue()
-*/
-void QHttpHeader::setValue(const QString &key, const QString &value)
-{
- Q_D(QHttpHeader);
- QString lowercaseKey = key.toLower();
- QList<QPair<QString, QString> >::Iterator it = d->values.begin();
- while (it != d->values.end()) {
- if ((*it).first.toLower() == lowercaseKey) {
- (*it).second = value;
- return;
- }
- ++it;
- }
- // not found so add
- addValue(key, value);
-}
-
-/*!
- Sets the header entries to be the list of key value pairs in \a values.
-*/
-void QHttpHeader::setValues(const QList<QPair<QString, QString> > &values)
-{
- Q_D(QHttpHeader);
- d->values = values;
-}
-
-/*!
- Adds a new entry with the \a key and \a value.
-*/
-void QHttpHeader::addValue(const QString &key, const QString &value)
-{
- Q_D(QHttpHeader);
- d->values.append(qMakePair(key, value));
-}
-
-/*!
- Returns all the entries in the header.
-*/
-QList<QPair<QString, QString> > QHttpHeader::values() const
-{
- Q_D(const QHttpHeader);
- return d->values;
-}
-
-/*!
- Removes the entry with the key \a key from the HTTP header.
-
- \sa value() setValue()
-*/
-void QHttpHeader::removeValue(const QString &key)
-{
- Q_D(QHttpHeader);
- QString lowercaseKey = key.toLower();
- QList<QPair<QString, QString> >::Iterator it = d->values.begin();
- while (it != d->values.end()) {
- if ((*it).first.toLower() == lowercaseKey) {
- d->values.erase(it);
- return;
- }
- ++it;
- }
-}
-
-/*!
- Removes all the entries with the key \a key from the HTTP header.
-*/
-void QHttpHeader::removeAllValues(const QString &key)
-{
- Q_D(QHttpHeader);
- QString lowercaseKey = key.toLower();
- QList<QPair<QString, QString> >::Iterator it = d->values.begin();
- while (it != d->values.end()) {
- if ((*it).first.toLower() == lowercaseKey) {
- it = d->values.erase(it);
- continue;
- }
- ++it;
- }
-}
-
-/*! \internal
- Parses the single HTTP header line \a line which has the format
- key, colon, space, value, and adds key/value to the headers. The
- linenumber is \a number. Returns true if the line was successfully
- parsed and the key/value added; otherwise returns false.
-
- \sa parse()
-*/
-bool QHttpHeader::parseLine(const QString &line, int)
-{
- int i = line.indexOf(QLatin1Char(':'));
- if (i == -1)
- return false;
-
- addValue(line.left(i).trimmed(), line.mid(i + 1).trimmed());
-
- return true;
-}
-
-/*!
- Returns a string representation of the HTTP header.
-
- The string is suitable for use by the constructor that takes a
- QString. It consists of lines with the format: key, colon, space,
- value, "\r\n".
-*/
-QString QHttpHeader::toString() const
-{
- Q_D(const QHttpHeader);
- if (!isValid())
- return QLatin1String("");
-
- QString ret = QLatin1String("");
-
- QList<QPair<QString, QString> >::ConstIterator it = d->values.constBegin();
- while (it != d->values.constEnd()) {
- ret += (*it).first + QLatin1String(": ") + (*it).second + QLatin1String("\r\n");
- ++it;
- }
- return ret;
-}
-
-/*!
- Returns true if the header has an entry for the special HTTP
- header field \c content-length; otherwise returns false.
-
- \sa contentLength() setContentLength()
-*/
-bool QHttpHeader::hasContentLength() const
-{
- return hasKey(QLatin1String("content-length"));
-}
-
-/*!
- Returns the value of the special HTTP header field \c
- content-length.
-
- \sa setContentLength() hasContentLength()
-*/
-uint QHttpHeader::contentLength() const
-{
- return value(QLatin1String("content-length")).toUInt();
-}
-
-/*!
- Sets the value of the special HTTP header field \c content-length
- to \a len.
-
- \sa contentLength() hasContentLength()
-*/
-void QHttpHeader::setContentLength(int len)
-{
- setValue(QLatin1String("content-length"), QString::number(len));
-}
-
-/*!
- Returns true if the header has an entry for the special HTTP
- header field \c content-type; otherwise returns false.
-
- \sa contentType() setContentType()
-*/
-bool QHttpHeader::hasContentType() const
-{
- return hasKey(QLatin1String("content-type"));
-}
-
-/*!
- Returns the value of the special HTTP header field \c content-type.
-
- \sa setContentType() hasContentType()
-*/
-QString QHttpHeader::contentType() const
-{
- QString type = value(QLatin1String("content-type"));
- if (type.isEmpty())
- return QString();
-
- int pos = type.indexOf(QLatin1Char(';'));
- if (pos == -1)
- return type;
-
- return type.left(pos).trimmed();
-}
-
-/*!
- Sets the value of the special HTTP header field \c content-type to
- \a type.
-
- \sa contentType() hasContentType()
-*/
-void QHttpHeader::setContentType(const QString &type)
-{
- setValue(QLatin1String("content-type"), type);
-}
-
-class QHttpResponseHeaderPrivate : public QHttpHeaderPrivate
-{
- Q_DECLARE_PUBLIC(QHttpResponseHeader)
-public:
- int statCode;
- QString reasonPhr;
- int majVer;
- int minVer;
-};
-
-/****************************************************
- *
- * QHttpResponseHeader
- *
- ****************************************************/
-
-/*!
- \class QHttpResponseHeader
- \obsolete
- \brief The QHttpResponseHeader class contains response header information for HTTP.
-
- \ingroup network
- \inmodule QtNetwork
-
- HTTP responses have a status code that indicates the status of the
- response. This code is a 3-digit integer result code (for details
- see to RFC 1945). In addition to the status code, you can also
- specify a human-readable text that describes the reason for the
- code ("reason phrase"). This class allows you to get the status
- code and the reason phrase.
-
- \sa QHttpRequestHeader, {HTTP Example}
-*/
-
-/*!
- Constructs an empty HTTP response header.
-*/
-QHttpResponseHeader::QHttpResponseHeader()
- : QHttpHeader(*new QHttpResponseHeaderPrivate)
-{
- setValid(false);
-}
-
-/*!
- Constructs a copy of \a header.
-*/
-QHttpResponseHeader::QHttpResponseHeader(const QHttpResponseHeader &header)
- : QHttpHeader(*new QHttpResponseHeaderPrivate, header)
-{
- Q_D(QHttpResponseHeader);
- d->statCode = header.d_func()->statCode;
- d->reasonPhr = header.d_func()->reasonPhr;
- d->majVer = header.d_func()->majVer;
- d->minVer = header.d_func()->minVer;
-}
-
-/*!
- Copies the contents of \a header into this QHttpResponseHeader.
-*/
-QHttpResponseHeader &QHttpResponseHeader::operator=(const QHttpResponseHeader &header)
-{
- Q_D(QHttpResponseHeader);
- QHttpHeader::operator=(header);
- d->statCode = header.d_func()->statCode;
- d->reasonPhr = header.d_func()->reasonPhr;
- d->majVer = header.d_func()->majVer;
- d->minVer = header.d_func()->minVer;
- return *this;
-}
-
-/*!
- Constructs a HTTP response header from the string \a str. The
- string is parsed and the information is set. The \a str should
- consist of one or more "\r\n" delimited lines; the first line should be the
- status-line (format: HTTP-version, space, status-code, space,
- reason-phrase); each of remaining lines should have the format key, colon,
- space, value.
-*/
-QHttpResponseHeader::QHttpResponseHeader(const QString &str)
- : QHttpHeader(*new QHttpResponseHeaderPrivate)
-{
- parse(str);
-}
-
-/*!
- \since 4.1
-
- Constructs a QHttpResponseHeader, setting the status code to \a code, the
- reason phrase to \a text and the protocol-version to \a majorVer and \a
- minorVer.
-
- \sa statusCode() reasonPhrase() majorVersion() minorVersion()
-*/
-QHttpResponseHeader::QHttpResponseHeader(int code, const QString &text, int majorVer, int minorVer)
- : QHttpHeader(*new QHttpResponseHeaderPrivate)
-{
- setStatusLine(code, text, majorVer, minorVer);
-}
-
-/*!
- \since 4.1
-
- Sets the status code to \a code, the reason phrase to \a text and
- the protocol-version to \a majorVer and \a minorVer.
-
- \sa statusCode() reasonPhrase() majorVersion() minorVersion()
-*/
-void QHttpResponseHeader::setStatusLine(int code, const QString &text, int majorVer, int minorVer)
-{
- Q_D(QHttpResponseHeader);
- setValid(true);
- d->statCode = code;
- d->reasonPhr = text;
- d->majVer = majorVer;
- d->minVer = minorVer;
-}
-
-/*!
- Returns the status code of the HTTP response header.
-
- \sa reasonPhrase() majorVersion() minorVersion()
-*/
-int QHttpResponseHeader::statusCode() const
-{
- Q_D(const QHttpResponseHeader);
- return d->statCode;
-}
-
-/*!
- Returns the reason phrase of the HTTP response header.
-
- \sa statusCode() majorVersion() minorVersion()
-*/
-QString QHttpResponseHeader::reasonPhrase() const
-{
- Q_D(const QHttpResponseHeader);
- return d->reasonPhr;
-}
-
-/*!
- Returns the major protocol-version of the HTTP response header.
-
- \sa minorVersion() statusCode() reasonPhrase()
-*/
-int QHttpResponseHeader::majorVersion() const
-{
- Q_D(const QHttpResponseHeader);
- return d->majVer;
-}
-
-/*!
- Returns the minor protocol-version of the HTTP response header.
-
- \sa majorVersion() statusCode() reasonPhrase()
-*/
-int QHttpResponseHeader::minorVersion() const
-{
- Q_D(const QHttpResponseHeader);
- return d->minVer;
-}
-
-/*! \internal
-*/
-bool QHttpResponseHeader::parseLine(const QString &line, int number)
-{
- Q_D(QHttpResponseHeader);
- if (number != 0)
- return QHttpHeader::parseLine(line, number);
-
- QString l = line.simplified();
- if (l.length() < 10)
- return false;
-
- if (l.left(5) == QLatin1String("HTTP/") && l[5].isDigit() && l[6] == QLatin1Char('.') &&
- l[7].isDigit() && l[8] == QLatin1Char(' ') && l[9].isDigit()) {
- d->majVer = l[5].toLatin1() - '0';
- d->minVer = l[7].toLatin1() - '0';
-
- int pos = l.indexOf(QLatin1Char(' '), 9);
- if (pos != -1) {
- d->reasonPhr = l.mid(pos + 1);
- d->statCode = l.mid(9, pos - 9).toInt();
- } else {
- d->statCode = l.mid(9).toInt();
- d->reasonPhr.clear();
- }
- } else {
- return false;
- }
-
- return true;
-}
-
-/*! \reimp
-*/
-QString QHttpResponseHeader::toString() const
-{
- Q_D(const QHttpResponseHeader);
- QString ret(QLatin1String("HTTP/%1.%2 %3 %4\r\n%5\r\n"));
- return ret.arg(d->majVer).arg(d->minVer).arg(d->statCode).arg(d->reasonPhr).arg(QHttpHeader::toString());
-}
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/network/access/qhttpheader_p.h b/src/network/access/qhttpheader_p.h
deleted file mode 100644
index fec7da4f92..0000000000
--- a/src/network/access/qhttpheader_p.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QHTTP_H
-#define QHTTP_H
-
-#include <QtCore/qobject.h>
-#include <QtCore/qstringlist.h>
-#include <QtCore/qmap.h>
-#include <QtCore/qpair.h>
-#include <QtCore/qscopedpointer.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Network)
-
-#ifndef QT_NO_HTTP
-
-#if 0
-#pragma qt_class(QHttp)
-#endif
-
-class QHttpHeaderPrivate;
-class QHttpHeader
-{
-public:
- QHttpHeader();
- QHttpHeader(const QHttpHeader &header);
- QHttpHeader(const QString &str);
- virtual ~QHttpHeader();
-
- QHttpHeader &operator=(const QHttpHeader &h);
-
- void setValue(const QString &key, const QString &value);
- void setValues(const QList<QPair<QString, QString> > &values);
- void addValue(const QString &key, const QString &value);
- QList<QPair<QString, QString> > values() const;
- bool hasKey(const QString &key) const;
- QStringList keys() const;
- QString value(const QString &key) const;
- QStringList allValues(const QString &key) const;
- void removeValue(const QString &key);
- void removeAllValues(const QString &key);
-
- // ### Qt 5: change to qint64
- bool hasContentLength() const;
- uint contentLength() const;
- void setContentLength(int len);
-
- bool hasContentType() const;
- QString contentType() const;
- void setContentType(const QString &type);
-
- virtual QString toString() const;
- bool isValid() const;
-
- virtual int majorVersion() const = 0;
- virtual int minorVersion() const = 0;
-
-protected:
- virtual bool parseLine(const QString &line, int number);
- bool parse(const QString &str);
- void setValid(bool);
-
- QHttpHeader(QHttpHeaderPrivate &dd, const QString &str = QString());
- QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header);
- QScopedPointer<QHttpHeaderPrivate> d_ptr;
-
-private:
- Q_DECLARE_PRIVATE(QHttpHeader)
-};
-
-class QHttpResponseHeaderPrivate;
-class QHttpResponseHeader : public QHttpHeader
-{
-public:
- QHttpResponseHeader();
- QHttpResponseHeader(const QHttpResponseHeader &header);
- QHttpResponseHeader(const QString &str);
- QHttpResponseHeader(int code, const QString &text = QString(), int majorVer = 1, int minorVer = 1);
- QHttpResponseHeader &operator=(const QHttpResponseHeader &header);
-
- void setStatusLine(int code, const QString &text = QString(), int majorVer = 1, int minorVer = 1);
-
- int statusCode() const;
- QString reasonPhrase() const;
-
- int majorVersion() const;
- int minorVersion() const;
-
- QString toString() const;
-
-protected:
- bool parseLine(const QString &line, int number);
-
-private:
- Q_DECLARE_PRIVATE(QHttpResponseHeader)
- friend class QHttpPrivate;
-};
-
-#endif // QT_NO_HTTP
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QHTTP_H
diff --git a/src/network/access/qhttpmultipart.cpp b/src/network/access/qhttpmultipart.cpp
index 6de7a807e4..e24c0606ef 100644
--- a/src/network/access/qhttpmultipart.cpp
+++ b/src/network/access/qhttpmultipart.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qhttpmultipart.h b/src/network/access/qhttpmultipart.h
index 317b068e3d..c25beb7ae3 100644
--- a/src/network/access/qhttpmultipart.h
+++ b/src/network/access/qhttpmultipart.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -50,7 +50,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QHttpPartPrivate;
class QHttpMultiPart;
diff --git a/src/network/access/qhttpmultipart_p.h b/src/network/access/qhttpmultipart_p.h
index 0ab2fa1d7f..14bf50ec03 100644
--- a/src/network/access/qhttpmultipart_p.h
+++ b/src/network/access/qhttpmultipart_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index 104a21f591..b49bda04ec 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h
index 8ce9bf24fe..41ee11db51 100644
--- a/src/network/access/qhttpnetworkconnection_p.h
+++ b/src/network/access/qhttpnetworkconnection_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 3acfe54ef7..70368d5e50 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h
index d5a0925f7d..1198ec9941 100644
--- a/src/network/access/qhttpnetworkconnectionchannel_p.h
+++ b/src/network/access/qhttpnetworkconnectionchannel_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qhttpnetworkheader.cpp b/src/network/access/qhttpnetworkheader.cpp
index 531afe92e0..9c5c8b063f 100644
--- a/src/network/access/qhttpnetworkheader.cpp
+++ b/src/network/access/qhttpnetworkheader.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qhttpnetworkheader_p.h b/src/network/access/qhttpnetworkheader_p.h
index 00393b5e92..1748514294 100644
--- a/src/network/access/qhttpnetworkheader_p.h
+++ b/src/network/access/qhttpnetworkheader_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp
index a9ba5d2b24..8206cfaab7 100644
--- a/src/network/access/qhttpnetworkreply.cpp
+++ b/src/network/access/qhttpnetworkreply.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h
index 1bb0832d19..97400d3b15 100644
--- a/src/network/access/qhttpnetworkreply_p.h
+++ b/src/network/access/qhttpnetworkreply_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -156,6 +156,7 @@ Q_SIGNALS:
void authenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *authenticator);
private:
Q_DECLARE_PRIVATE(QHttpNetworkReply)
+ friend class QHttpSocketEngine;
friend class QHttpNetworkConnection;
friend class QHttpNetworkConnectionPrivate;
friend class QHttpNetworkConnectionChannel;
diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp
index e39faaeaa8..f32251935b 100644
--- a/src/network/access/qhttpnetworkrequest.cpp
+++ b/src/network/access/qhttpnetworkrequest.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qhttpnetworkrequest_p.h b/src/network/access/qhttpnetworkrequest_p.h
index 71e09eba06..949d98484f 100644
--- a/src/network/access/qhttpnetworkrequest_p.h
+++ b/src/network/access/qhttpnetworkrequest_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp
index 39a7e8ed08..5cf153325b 100644
--- a/src/network/access/qhttpthreaddelegate.cpp
+++ b/src/network/access/qhttpthreaddelegate.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qhttpthreaddelegate_p.h b/src/network/access/qhttpthreaddelegate_p.h
index 366d3bcc60..24affdd8de 100644
--- a/src/network/access/qhttpthreaddelegate_p.h
+++ b/src/network/access/qhttpthreaddelegate_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkaccessauthenticationmanager.cpp b/src/network/access/qnetworkaccessauthenticationmanager.cpp
index 30e3174f25..85e7f65ba2 100644
--- a/src/network/access/qnetworkaccessauthenticationmanager.cpp
+++ b/src/network/access/qnetworkaccessauthenticationmanager.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkaccessauthenticationmanager_p.h b/src/network/access/qnetworkaccessauthenticationmanager_p.h
index 7e7be8ca8a..92f5fcb5b4 100644
--- a/src/network/access/qnetworkaccessauthenticationmanager_p.h
+++ b/src/network/access/qnetworkaccessauthenticationmanager_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp
index 6647c58f8d..d7b6b78e22 100644
--- a/src/network/access/qnetworkaccessbackend.cpp
+++ b/src/network/access/qnetworkaccessbackend.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkaccessbackend_p.h b/src/network/access/qnetworkaccessbackend_p.h
index f9563da4a7..f4c6bb65ac 100644
--- a/src/network/access/qnetworkaccessbackend_p.h
+++ b/src/network/access/qnetworkaccessbackend_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkaccesscache.cpp b/src/network/access/qnetworkaccesscache.cpp
index 2594e53949..bd3cee530f 100644
--- a/src/network/access/qnetworkaccesscache.cpp
+++ b/src/network/access/qnetworkaccesscache.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkaccesscache_p.h b/src/network/access/qnetworkaccesscache_p.h
index 813ba3c35f..dfe33b8db7 100644
--- a/src/network/access/qnetworkaccesscache_p.h
+++ b/src/network/access/qnetworkaccesscache_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkaccesscachebackend.cpp b/src/network/access/qnetworkaccesscachebackend.cpp
index baf6292124..6abe42f795 100644
--- a/src/network/access/qnetworkaccesscachebackend.cpp
+++ b/src/network/access/qnetworkaccesscachebackend.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkaccesscachebackend_p.h b/src/network/access/qnetworkaccesscachebackend_p.h
index 5444703793..112a9ccfa9 100644
--- a/src/network/access/qnetworkaccesscachebackend_p.h
+++ b/src/network/access/qnetworkaccesscachebackend_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkaccessdebugpipebackend.cpp b/src/network/access/qnetworkaccessdebugpipebackend.cpp
index 678d6e404e..5a4cd7b20d 100644
--- a/src/network/access/qnetworkaccessdebugpipebackend.cpp
+++ b/src/network/access/qnetworkaccessdebugpipebackend.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkaccessdebugpipebackend_p.h b/src/network/access/qnetworkaccessdebugpipebackend_p.h
index 411c38b3ba..edac78383a 100644
--- a/src/network/access/qnetworkaccessdebugpipebackend_p.h
+++ b/src/network/access/qnetworkaccessdebugpipebackend_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp
index 0080e23a8f..dbe964ac8d 100644
--- a/src/network/access/qnetworkaccessfilebackend.cpp
+++ b/src/network/access/qnetworkaccessfilebackend.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkaccessfilebackend_p.h b/src/network/access/qnetworkaccessfilebackend_p.h
index 2fbf806851..4b25a2c651 100644
--- a/src/network/access/qnetworkaccessfilebackend_p.h
+++ b/src/network/access/qnetworkaccessfilebackend_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp
index 7b7ebb5e46..98967e730e 100644
--- a/src/network/access/qnetworkaccessftpbackend.cpp
+++ b/src/network/access/qnetworkaccessftpbackend.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkaccessftpbackend_p.h b/src/network/access/qnetworkaccessftpbackend_p.h
index 7338121493..6105be9816 100644
--- a/src/network/access/qnetworkaccessftpbackend_p.h
+++ b/src/network/access/qnetworkaccessftpbackend_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 3a80b9ed92..8537502116 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -985,7 +985,6 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
#endif // QT_NO_HTTP
// first step: create the reply
- QUrl url = request.url();
QNetworkReplyImpl *reply = new QNetworkReplyImpl(this);
#ifndef QT_NO_BEARERMANAGEMENT
if (!isLocalFile) {
diff --git a/src/network/access/qnetworkaccessmanager.h b/src/network/access/qnetworkaccessmanager.h
index 72fd86c5a5..fdbcf01dad 100644
--- a/src/network/access/qnetworkaccessmanager.h
+++ b/src/network/access/qnetworkaccessmanager.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -48,7 +48,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QIODevice;
class QAbstractNetworkCache;
diff --git a/src/network/access/qnetworkaccessmanager_p.h b/src/network/access/qnetworkaccessmanager_p.h
index bc8df575a0..0733756be4 100644
--- a/src/network/access/qnetworkaccessmanager_p.h
+++ b/src/network/access/qnetworkaccessmanager_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp
index a5c4fb516c..c987c50017 100644
--- a/src/network/access/qnetworkcookie.cpp
+++ b/src/network/access/qnetworkcookie.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -156,7 +156,7 @@ QNetworkCookie &QNetworkCookie::operator=(const QNetworkCookie &other)
However, in some contexts, two cookies of the same name could be
considered equal.
- \sa operator!=()
+ \sa operator!=(), hasSameIdentifier()
*/
bool QNetworkCookie::operator==(const QNetworkCookie &other) const
{
@@ -172,6 +172,17 @@ bool QNetworkCookie::operator==(const QNetworkCookie &other) const
}
/*!
+ Returns true if this cookie has the same identifier tuple as \a other.
+ The identifier tuple is composed of the name, domain and path.
+
+ \sa operator==()
+*/
+bool QNetworkCookie::hasSameIdentifier(const QNetworkCookie &other) const
+{
+ return d->name == other.d->name && d->domain == other.d->domain && d->path == other.d->path;
+}
+
+/*!
Returns true if the "secure" option was specified in the cookie
string, false otherwise.
@@ -1042,6 +1053,30 @@ QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByt
return result;
}
+/*!
+ This functions normalizes the path and domain of the cookie if they were previously empty.
+*/
+void QNetworkCookie::normalize(const QUrl &url)
+{
+ // don't do path checking. See http://bugreports.qt.nokia.com/browse/QTBUG-5815
+ if (d->path.isEmpty()) {
+ QString pathAndFileName = url.path();
+ QString defaultPath = pathAndFileName.left(pathAndFileName.lastIndexOf(QLatin1Char('/'))+1);
+ if (defaultPath.isEmpty())
+ defaultPath = QLatin1Char('/');
+ d->path = defaultPath;
+ }
+
+ if (d->domain.isEmpty())
+ d->domain = url.host();
+ else if (!d->domain.startsWith(QLatin1Char('.')))
+ // Ensure the domain starts with a dot if its field was not empty
+ // in the HTTP header. There are some servers that forget the
+ // leading dot and this is actually forbidden according to RFC 2109,
+ // but all browsers accept it anyway so we do that as well.
+ d->domain.prepend(QLatin1Char('.'));
+}
+
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug s, const QNetworkCookie &cookie)
{
diff --git a/src/network/access/qnetworkcookie.h b/src/network/access/qnetworkcookie.h
index fd9c825ddc..32307e305e 100644
--- a/src/network/access/qnetworkcookie.h
+++ b/src/network/access/qnetworkcookie.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -51,7 +51,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QByteArray;
class QDateTime;
@@ -98,6 +97,9 @@ public:
QByteArray toRawForm(RawForm form = Full) const;
+ bool hasSameIdentifier(const QNetworkCookie &other) const;
+ void normalize(const QUrl &url);
+
static QList<QNetworkCookie> parseCookies(const QByteArray &cookieString);
private:
diff --git a/src/network/access/qnetworkcookie_p.h b/src/network/access/qnetworkcookie_p.h
index 7e45219fce..2d74fad7c9 100644
--- a/src/network/access/qnetworkcookie_p.h
+++ b/src/network/access/qnetworkcookie_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkcookiejar.cpp b/src/network/access/qnetworkcookiejar.cpp
index 54c2ccfaba..4136043e2e 100644
--- a/src/network/access/qnetworkcookiejar.cpp
+++ b/src/network/access/qnetworkcookiejar.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -155,8 +155,7 @@ static inline bool isParentDomain(QString domain, QString reference)
/*!
Adds the cookies in the list \a cookieList to this cookie
- jar. Default values for path and domain are taken from the \a
- url object.
+ jar. Before being inserted cookies are normalized.
Returns true if one or more cookies are set for \a url,
otherwise false.
@@ -173,72 +172,18 @@ static inline bool isParentDomain(QString domain, QString reference)
size. Reimplement this function to discard older cookies to create
room for new ones.
- \sa cookiesForUrl(), QNetworkAccessManager::setCookieJar()
+ \sa cookiesForUrl(), QNetworkAccessManager::setCookieJar(), QNetworkCookie::normalize()
*/
bool QNetworkCookieJar::setCookiesFromUrl(const QList<QNetworkCookie> &cookieList,
const QUrl &url)
{
- Q_D(QNetworkCookieJar);
- QString defaultDomain = url.host();
- QString pathAndFileName = url.path();
- QString defaultPath = pathAndFileName.left(pathAndFileName.lastIndexOf(QLatin1Char('/'))+1);
- if (defaultPath.isEmpty())
- defaultPath = QLatin1Char('/');
-
- int added = 0;
- QDateTime now = QDateTime::currentDateTime();
+ bool added = false;
foreach (QNetworkCookie cookie, cookieList) {
- bool isDeletion = !cookie.isSessionCookie() &&
- cookie.expirationDate() < now;
-
- // validate the cookie & set the defaults if unset
- if (cookie.path().isEmpty())
- cookie.setPath(defaultPath);
- // don't do path checking. See http://bugreports.qt.nokia.com/browse/QTBUG-5815
-// else if (!isParentPath(pathAndFileName, cookie.path())) {
-// continue; // not accepted
-// }
- if (cookie.domain().isEmpty()) {
- cookie.setDomain(defaultDomain);
- } else {
- // Ensure the domain starts with a dot if its field was not empty
- // in the HTTP header. There are some servers that forget the
- // leading dot and this is actually forbidden according to RFC 2109,
- // but all browsers accept it anyway so we do that as well.
- if (!cookie.domain().startsWith(QLatin1Char('.')))
- cookie.setDomain(QLatin1Char('.') + cookie.domain());
-
- QString domain = cookie.domain();
- if (!(isParentDomain(domain, defaultDomain)
- || isParentDomain(defaultDomain, domain)))
- continue; // not accepted
-
- // the check for effective TLDs makes the "embedded dot" rule from RFC 2109 section 4.3.2
- // redundant; the "leading dot" rule has been relaxed anyway, see above
- // we remove the leading dot for this check
- if (qIsEffectiveTLD(domain.remove(0, 1)))
- continue; // not accepted
- }
-
- QList<QNetworkCookie>::Iterator it = d->allCookies.begin(),
- end = d->allCookies.end();
- for ( ; it != end; ++it)
- // does this cookie already exist?
- if (cookie.name() == it->name() &&
- cookie.domain() == it->domain() &&
- cookie.path() == it->path()) {
- // found a match
- d->allCookies.erase(it);
- break;
- }
-
- // did not find a match
- if (!isDeletion) {
- d->allCookies += cookie;
- ++added;
- }
+ cookie.normalize(url);
+ if (validateCookie(cookie, url) && insertCookie(cookie))
+ added = true;
}
- return (added > 0);
+ return added;
}
/*!
@@ -304,4 +249,81 @@ QList<QNetworkCookie> QNetworkCookieJar::cookiesForUrl(const QUrl &url) const
return result;
}
+/*!
+ Adds \a cookie to this cookie jar.
+
+ Returns true if \a cookie was added, false otherwise.
+
+ If a cookie with the same identifier already exists in the
+ cookie jar, it will be overridden.
+*/
+bool QNetworkCookieJar::insertCookie(const QNetworkCookie &cookie)
+{
+ Q_D(QNetworkCookieJar);
+ QDateTime now = QDateTime::currentDateTime();
+ bool isDeletion = !cookie.isSessionCookie() &&
+ cookie.expirationDate() < now;
+
+ deleteCookie(cookie);
+
+ if (!isDeletion) {
+ d->allCookies += cookie;
+ return true;
+ }
+ return false;
+}
+
+/*!
+ If a cookie with the same identifier as \a cookie exists in this cookie jar
+ it will be updated. This function uses insertCookie().
+
+ Returns true if \a cookie was updated, false if no cookie in the jar matches
+ the identifier of \a cookie.
+
+ \sa QNetworkCookie::hasSameIdentifier()
+*/
+bool QNetworkCookieJar::updateCookie(const QNetworkCookie &cookie)
+{
+ if (deleteCookie(cookie))
+ return insertCookie(cookie);
+ return false;
+}
+
+/*!
+ Deletes from cookie jar the cookie found to have the same identifier as \a cookie.
+
+ Returns true if a cookie was deleted, false otherwise.
+
+ \sa QNetworkCookie::hasSameIdentifier()
+*/
+bool QNetworkCookieJar::deleteCookie(const QNetworkCookie &cookie)
+{
+ Q_D(QNetworkCookieJar);
+ QList<QNetworkCookie>::Iterator it;
+ for (it = d->allCookies.begin(); it != d->allCookies.end(); it++)
+ if (it->hasSameIdentifier(cookie)) {
+ d->allCookies.erase(it);
+ return true;
+ }
+ return false;
+}
+
+/*!
+ Returns true if the domain and path of \a cookie are valid, false otherwise.
+*/
+bool QNetworkCookieJar::validateCookie(const QNetworkCookie &cookie, const QUrl &url) const
+{
+ QString domain = cookie.domain();
+ if (!(isParentDomain(domain, url.host()) || isParentDomain(url.host(), domain)))
+ return false; // not accepted
+
+ // the check for effective TLDs makes the "embedded dot" rule from RFC 2109 section 4.3.2
+ // redundant; the "leading dot" rule has been relaxed anyway, see QNetworkCookie::normalize()
+ // we remove the leading dot for this check if it's present
+ if (qIsEffectiveTLD(domain.startsWith('.') ? domain.remove(0, 1) : domain))
+ return false; // not accepted
+
+ return true;
+}
+
QT_END_NAMESPACE
diff --git a/src/network/access/qnetworkcookiejar.h b/src/network/access/qnetworkcookiejar.h
index 4ff27d8cf0..513fb3b66c 100644
--- a/src/network/access/qnetworkcookiejar.h
+++ b/src/network/access/qnetworkcookiejar.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -49,7 +49,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QNetworkCookie;
@@ -64,9 +63,14 @@ public:
virtual QList<QNetworkCookie> cookiesForUrl(const QUrl &url) const;
virtual bool setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const QUrl &url);
+ virtual bool insertCookie(const QNetworkCookie &cookie);
+ virtual bool updateCookie(const QNetworkCookie &cookie);
+ virtual bool deleteCookie(const QNetworkCookie &cookie);
+
protected:
QList<QNetworkCookie> allCookies() const;
void setAllCookies(const QList<QNetworkCookie> &cookieList);
+ virtual bool validateCookie(const QNetworkCookie &cookie, const QUrl &url) const;
private:
Q_DECLARE_PRIVATE(QNetworkCookieJar)
diff --git a/src/network/access/qnetworkcookiejar_p.h b/src/network/access/qnetworkcookiejar_p.h
index 32fdecdb50..a3caa1d03d 100644
--- a/src/network/access/qnetworkcookiejar_p.h
+++ b/src/network/access/qnetworkcookiejar_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp
index 8dd2033a35..bcaf81a6a0 100644
--- a/src/network/access/qnetworkdiskcache.cpp
+++ b/src/network/access/qnetworkdiskcache.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkdiskcache.h b/src/network/access/qnetworkdiskcache.h
index b8f1de5930..20da4cac8a 100644
--- a/src/network/access/qnetworkdiskcache.h
+++ b/src/network/access/qnetworkdiskcache.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -48,7 +48,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
#ifndef QT_NO_NETWORKDISKCACHE
diff --git a/src/network/access/qnetworkdiskcache_p.h b/src/network/access/qnetworkdiskcache_p.h
index d8f386e9eb..eb2b474964 100644
--- a/src/network/access/qnetworkdiskcache_p.h
+++ b/src/network/access/qnetworkdiskcache_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkreply.cpp b/src/network/access/qnetworkreply.cpp
index db62f2935a..123418dbcd 100644
--- a/src/network/access/qnetworkreply.cpp
+++ b/src/network/access/qnetworkreply.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkreply.h b/src/network/access/qnetworkreply.h
index 492336bbf6..89ccc2fb92 100644
--- a/src/network/access/qnetworkreply.h
+++ b/src/network/access/qnetworkreply.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -53,7 +53,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QUrl;
class QVariant;
diff --git a/src/network/access/qnetworkreply_p.h b/src/network/access/qnetworkreply_p.h
index b725a11520..9c838a5539 100644
--- a/src/network/access/qnetworkreply_p.h
+++ b/src/network/access/qnetworkreply_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkreplydataimpl.cpp b/src/network/access/qnetworkreplydataimpl.cpp
index 22f40b2420..ab2c97b653 100644
--- a/src/network/access/qnetworkreplydataimpl.cpp
+++ b/src/network/access/qnetworkreplydataimpl.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkreplydataimpl_p.h b/src/network/access/qnetworkreplydataimpl_p.h
index 0b47bbbb34..10cee7231b 100644
--- a/src/network/access/qnetworkreplydataimpl_p.h
+++ b/src/network/access/qnetworkreplydataimpl_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkreplyfileimpl.cpp b/src/network/access/qnetworkreplyfileimpl.cpp
index 0b4c89987c..6b5dba2bfa 100644
--- a/src/network/access/qnetworkreplyfileimpl.cpp
+++ b/src/network/access/qnetworkreplyfileimpl.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkreplyfileimpl_p.h b/src/network/access/qnetworkreplyfileimpl_p.h
index c097fedb68..c7c2bba671 100644
--- a/src/network/access/qnetworkreplyfileimpl_p.h
+++ b/src/network/access/qnetworkreplyfileimpl_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index 2c1ad95ea8..71bc03e8d0 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -1499,10 +1499,11 @@ bool QNetworkReplyHttpImplPrivate::start()
{
#ifndef QT_NO_BEARERMANAGEMENT
if (!managerPrivate->networkSession) {
+#endif
postRequest();
return true;
+#ifndef QT_NO_BEARERMANAGEMENT
}
-#endif
// This is not ideal.
const QString host = url.host();
@@ -1513,15 +1514,14 @@ bool QNetworkReplyHttpImplPrivate::start()
return true;
}
-#ifndef QT_NO_BEARERMANAGEMENT
if (managerPrivate->networkSession->isOpen() &&
managerPrivate->networkSession->state() == QNetworkSession::Connected) {
postRequest();
return true;
}
-#endif
return false;
+#endif
}
void QNetworkReplyHttpImplPrivate::_q_startOperation()
@@ -1533,13 +1533,12 @@ void QNetworkReplyHttpImplPrivate::_q_startOperation()
}
state = Working;
+ if (!start()) {
#ifndef QT_NO_BEARERMANAGEMENT
- if (!start()) { // ### we should call that method even if bearer is not used
// backend failed to start because the session state is not Connected.
// QNetworkAccessManager will call reply->backend->start() again for us when the session
// state changes.
state = WaitingForSession;
-
QNetworkSession *session = managerPrivate->networkSession.data();
if (session) {
@@ -1553,10 +1552,9 @@ void QNetworkReplyHttpImplPrivate::_q_startOperation()
} else {
qWarning("Backend is waiting for QNetworkSession to connect, but there is none!");
}
-
+#endif
return;
}
-#endif
if (synchronous) {
state = Finished;
@@ -1964,7 +1962,7 @@ void QNetworkReplyHttpImplPrivate::setCachingEnabled(bool enable)
if (enable) {
if (bytesDownloaded) {
- qDebug("setCachingEnabled: %d bytesDownloaded", bytesDownloaded);
+ qDebug("setCachingEnabled: %lld bytesDownloaded", bytesDownloaded);
// refuse to enable in this case
qCritical("QNetworkReplyImpl: backend error: caching was enabled after some bytes had been written");
return;
diff --git a/src/network/access/qnetworkreplyhttpimpl_p.h b/src/network/access/qnetworkreplyhttpimpl_p.h
index 432b769add..b0a8e59b94 100644
--- a/src/network/access/qnetworkreplyhttpimpl_p.h
+++ b/src/network/access/qnetworkreplyhttpimpl_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 1f9efa6ed9..f97d98ec5a 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h
index 0b7664acc6..39c3b9ca2e 100644
--- a/src/network/access/qnetworkreplyimpl_p.h
+++ b/src/network/access/qnetworkreplyimpl_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index c909ce2fea..b9c149e5d8 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h
index 66bfcf5942..1eb0fff045 100644
--- a/src/network/access/qnetworkrequest.h
+++ b/src/network/access/qnetworkrequest.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -51,7 +51,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QSslConfiguration;
diff --git a/src/network/access/qnetworkrequest_p.h b/src/network/access/qnetworkrequest_p.h
index eb61f092f1..13861cc80e 100644
--- a/src/network/access/qnetworkrequest_p.h
+++ b/src/network/access/qnetworkrequest_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/bearer/qbearerengine.cpp b/src/network/bearer/qbearerengine.cpp
index 5cf52af744..99d885f2c2 100644
--- a/src/network/bearer/qbearerengine.cpp
+++ b/src/network/bearer/qbearerengine.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/bearer/qbearerengine_p.h b/src/network/bearer/qbearerengine_p.h
index 42481fcd15..aa8117139c 100644
--- a/src/network/bearer/qbearerengine_p.h
+++ b/src/network/bearer/qbearerengine_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/bearer/qbearerplugin.cpp b/src/network/bearer/qbearerplugin.cpp
index 02f6e36807..f022f7b838 100644
--- a/src/network/bearer/qbearerplugin.cpp
+++ b/src/network/bearer/qbearerplugin.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/bearer/qbearerplugin_p.h b/src/network/bearer/qbearerplugin_p.h
index 6533cebf4f..b89d17d235 100644
--- a/src/network/bearer/qbearerplugin_p.h
+++ b/src/network/bearer/qbearerplugin_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -64,14 +64,13 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
struct Q_NETWORK_EXPORT QBearerEngineFactoryInterface : public QFactoryInterface
{
virtual QBearerEngine *create(const QString &key) const = 0;
};
-#define QBearerEngineFactoryInterface_iid "com.trolltech.Qt.QBearerEngineFactoryInterface"
+#define QBearerEngineFactoryInterface_iid "org.qt-project.Qt.QBearerEngineFactoryInterface"
Q_DECLARE_INTERFACE(QBearerEngineFactoryInterface, QBearerEngineFactoryInterface_iid)
class Q_NETWORK_EXPORT QBearerEnginePlugin : public QObject, public QBearerEngineFactoryInterface
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp
index 1a96ba77a9..511bec8f23 100644
--- a/src/network/bearer/qnetworkconfigmanager.cpp
+++ b/src/network/bearer/qnetworkconfigmanager.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -55,13 +55,13 @@
QT_BEGIN_NAMESPACE
static QBasicAtomicPointer<QNetworkConfigurationManagerPrivate> connManager_ptr;
-Q_GLOBAL_STATIC(QMutex, connManager_mutex)
static void connManager_cleanup()
{
// this is not atomic or thread-safe!
- delete connManager_ptr.load();
- connManager_ptr.store(0);
+ QNetworkConfigurationManagerPrivate *cmp = connManager_ptr.fetchAndStoreAcquire(0);
+ if (cmp)
+ cmp->cleanup();
}
void QNetworkConfigurationManagerPrivate::addPostRoutine()
@@ -69,23 +69,24 @@ void QNetworkConfigurationManagerPrivate::addPostRoutine()
qAddPostRoutine(connManager_cleanup);
}
-static QNetworkConfigurationManagerPrivate *connManager()
+QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
{
QNetworkConfigurationManagerPrivate *ptr = connManager_ptr.loadAcquire();
if (!ptr) {
- QMutexLocker locker(connManager_mutex());
+ static QBasicMutex connManager_mutex;
+ QMutexLocker locker(&connManager_mutex);
if (!(ptr = connManager_ptr.loadAcquire())) {
ptr = new QNetworkConfigurationManagerPrivate;
if (QCoreApplicationPrivate::mainThread() == QThread::currentThread()) {
// right thread or no main thread yet
ptr->addPostRoutine();
- ptr->updateConfigurations();
+ ptr->initialize();
} else {
// wrong thread, we need to make the main thread do this
QObject *obj = new QObject;
QObject::connect(obj, SIGNAL(destroyed()), ptr, SLOT(addPostRoutine()), Qt::DirectConnection);
- ptr->updateConfigurations(); // this moves us to the main thread
+ ptr->initialize(); // this moves us to the right thread
obj->moveToThread(QCoreApplicationPrivate::mainThread());
obj->deleteLater();
}
@@ -96,11 +97,6 @@ static QNetworkConfigurationManagerPrivate *connManager()
return ptr;
}
-QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
-{
- return connManager();
-}
-
/*!
\class QNetworkConfigurationManager
@@ -246,7 +242,7 @@ QNetworkConfigurationManager::QNetworkConfigurationManager(QObject *parent)
*/
QNetworkConfigurationManager::~QNetworkConfigurationManager()
{
- QNetworkConfigurationManagerPrivate *priv = connManager();
+ QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
if (priv)
priv->disablePolling();
}
@@ -263,7 +259,7 @@ QNetworkConfigurationManager::~QNetworkConfigurationManager()
*/
QNetworkConfiguration QNetworkConfigurationManager::defaultConfiguration() const
{
- QNetworkConfigurationManagerPrivate *priv = connManager();
+ QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
if (priv)
return priv->defaultConfiguration();
@@ -297,7 +293,7 @@ QNetworkConfiguration QNetworkConfigurationManager::defaultConfiguration() const
*/
QList<QNetworkConfiguration> QNetworkConfigurationManager::allConfigurations(QNetworkConfiguration::StateFlags filter) const
{
- QNetworkConfigurationManagerPrivate *priv = connManager();
+ QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
if (priv)
return priv->allConfigurations(filter);
@@ -312,7 +308,7 @@ QList<QNetworkConfiguration> QNetworkConfigurationManager::allConfigurations(QNe
*/
QNetworkConfiguration QNetworkConfigurationManager::configurationFromIdentifier(const QString &identifier) const
{
- QNetworkConfigurationManagerPrivate *priv = connManager();
+ QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
if (priv)
return priv->configurationFromIdentifier(identifier);
@@ -331,7 +327,7 @@ QNetworkConfiguration QNetworkConfigurationManager::configurationFromIdentifier(
*/
bool QNetworkConfigurationManager::isOnline() const
{
- QNetworkConfigurationManagerPrivate *priv = connManager();
+ QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
if (priv)
return priv->isOnline();
@@ -343,7 +339,7 @@ bool QNetworkConfigurationManager::isOnline() const
*/
QNetworkConfigurationManager::Capabilities QNetworkConfigurationManager::capabilities() const
{
- QNetworkConfigurationManagerPrivate *priv = connManager();
+ QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
if (priv)
return priv->capabilities();
@@ -366,7 +362,7 @@ QNetworkConfigurationManager::Capabilities QNetworkConfigurationManager::capabil
*/
void QNetworkConfigurationManager::updateConfigurations()
{
- QNetworkConfigurationManagerPrivate *priv = connManager();
+ QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
if (priv)
priv->performAsyncConfigurationUpdate();
}
diff --git a/src/network/bearer/qnetworkconfigmanager.h b/src/network/bearer/qnetworkconfigmanager.h
index 5f4e64b957..6c160404d1 100644
--- a/src/network/bearer/qnetworkconfigmanager.h
+++ b/src/network/bearer/qnetworkconfigmanager.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -50,7 +50,6 @@
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QNetworkConfigurationManagerPrivate;
class Q_NETWORK_EXPORT QNetworkConfigurationManager : public QObject
@@ -90,6 +89,9 @@ Q_SIGNALS:
void configurationChanged(const QNetworkConfiguration &config);
void onlineStateChanged(bool isOnline);
void updateCompleted();
+
+private:
+ Q_DISABLE_COPY(QNetworkConfigurationManager)
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkConfigurationManager::Capabilities)
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp
index 5f8f0dff53..25bf21e7b9 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.cpp
+++ b/src/network/bearer/qnetworkconfigmanager_p.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -66,11 +66,31 @@ QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate()
qRegisterMetaType<QNetworkConfigurationPrivatePointer>("QNetworkConfigurationPrivatePointer");
}
+void QNetworkConfigurationManagerPrivate::initialize()
+{
+ //Two stage construction, because we only want to do this heavyweight work for the winner of the Q_GLOBAL_STATIC race.
+ bearerThread = new QThread();
+ bearerThread->moveToThread(QCoreApplicationPrivate::mainThread()); // because cleanup() is called in main thread context.
+ moveToThread(bearerThread);
+ bearerThread->start();
+ updateConfigurations();
+}
+
QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate()
{
QMutexLocker locker(&mutex);
qDeleteAll(sessionEngines);
+ if (bearerThread)
+ bearerThread->quit();
+}
+
+void QNetworkConfigurationManagerPrivate::cleanup()
+{
+ QThread* thread = bearerThread;
+ deleteLater();
+ if (thread->wait(5000))
+ delete thread;
}
QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration() const
@@ -350,13 +370,6 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
if (qobject_cast<QBearerEngine *>(sender()))
return;
- if (thread() != QCoreApplicationPrivate::mainThread()) {
- if (thread() != QThread::currentThread())
- return;
-
- moveToThread(QCoreApplicationPrivate::mainThread());
- }
-
updating = false;
#ifndef QT_NO_LIBRARY
@@ -375,7 +388,7 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
else
sessionEngines.append(engine);
- engine->moveToThread(QCoreApplicationPrivate::mainThread());
+ engine->moveToThread(bearerThread);
connect(engine, SIGNAL(updateCompleted()),
this, SLOT(updateConfigurations()));
@@ -411,14 +424,9 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
if (firstUpdate) {
firstUpdate = false;
QList<QBearerEngine*> enginesToInitialize = sessionEngines; //shallow copy the list in case it is modified when we unlock mutex
- Qt::ConnectionType connectionType;
- if (QCoreApplicationPrivate::mainThread() == QThread::currentThread())
- connectionType = Qt::DirectConnection;
- else
- connectionType = Qt::BlockingQueuedConnection;
locker.unlock();
foreach (QBearerEngine* engine, enginesToInitialize) {
- QMetaObject::invokeMethod(engine, "initialize", connectionType);
+ QMetaObject::invokeMethod(engine, "initialize", Qt::BlockingQueuedConnection);
}
}
}
diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h
index dcd736cc6e..92406ae8f0 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.h
+++ b/src/network/bearer/qnetworkconfigmanager_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -89,6 +89,8 @@ public:
void enablePolling();
void disablePolling();
+ void initialize();
+ void cleanup();
public Q_SLOTS:
void updateConfigurations();
@@ -112,6 +114,7 @@ private Q_SLOTS:
private:
Q_INVOKABLE void startPolling();
QTimer *pollTimer;
+ QThread *bearerThread;
private:
mutable QMutex mutex;
diff --git a/src/network/bearer/qnetworkconfiguration.cpp b/src/network/bearer/qnetworkconfiguration.cpp
index 150e1cf715..037a7fdbf3 100644
--- a/src/network/bearer/qnetworkconfiguration.cpp
+++ b/src/network/bearer/qnetworkconfiguration.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -397,14 +397,6 @@ QList<QNetworkConfiguration> QNetworkConfiguration::children() const
}
/*!
- \fn QString QNetworkConfiguration::bearerName() const
- \deprecated
-
- This function is deprecated. It is equivalent to calling bearerTypeName(), however
- bearerType() should be used in preference.
-*/
-
-/*!
Returns the type of bearer used by this network configuration.
If the bearer type is \l {QNetworkConfiguration::BearerUnknown}{unknown} the bearerTypeName()
@@ -483,27 +475,26 @@ QString QNetworkConfiguration::bearerTypeName() const
return QString();
switch (d->bearerType) {
- case BearerUnknown:
- return d->bearerTypeName();
case BearerEthernet:
- return QLatin1String("Ethernet");
+ return QStringLiteral("Ethernet");
case BearerWLAN:
- return QLatin1String("WLAN");
+ return QStringLiteral("WLAN");
case Bearer2G:
- return QLatin1String("2G");
+ return QStringLiteral("2G");
case BearerCDMA2000:
- return QLatin1String("CDMA2000");
+ return QStringLiteral("CDMA2000");
case BearerWCDMA:
- return QLatin1String("WCDMA");
+ return QStringLiteral("WCDMA");
case BearerHSPA:
- return QLatin1String("HSPA");
+ return QStringLiteral("HSPA");
case BearerBluetooth:
- return QLatin1String("Bluetooth");
+ return QStringLiteral("Bluetooth");
case BearerWiMAX:
- return QLatin1String("WiMAX");
+ return QStringLiteral("WiMAX");
+ case BearerUnknown:
+ break;
}
-
- return QLatin1String("Unknown");
+ return QStringLiteral("Unknown");
}
QT_END_NAMESPACE
diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h
index 5b650d0303..2feb3d2394 100644
--- a/src/network/bearer/qnetworkconfiguration.h
+++ b/src/network/bearer/qnetworkconfiguration.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -48,14 +48,9 @@
#include <QtCore/qstring.h>
#include <QtCore/qlist.h>
-#if defined(Q_OS_WIN) && defined(interface)
-#undef interface
-#endif
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QNetworkConfigurationPrivate;
class Q_NETWORK_EXPORT QNetworkConfiguration
@@ -108,10 +103,6 @@ public:
Type type() const;
Purpose purpose() const;
-#ifdef QT_DEPRECATED
- // Required to maintain source compatibility with Qt Mobility.
- QT_DEPRECATED inline QString bearerName() const { return bearerTypeName(); }
-#endif
BearerType bearerType() const;
QString bearerTypeName() const;
diff --git a/src/network/bearer/qnetworkconfiguration_p.h b/src/network/bearer/qnetworkconfiguration_p.h
index 9acda9210b..47174a1eab 100644
--- a/src/network/bearer/qnetworkconfiguration_p.h
+++ b/src/network/bearer/qnetworkconfiguration_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -78,11 +78,6 @@ public:
serviceNetworkMembers.clear();
}
- virtual QString bearerTypeName() const
- {
- return QLatin1String("Unknown");
- }
-
QMap<unsigned int, QNetworkConfigurationPrivatePointer> serviceNetworkMembers;
mutable QMutex mutex;
diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp
index 7f76fde4f0..3f8cabe26e 100644
--- a/src/network/bearer/qnetworksession.cpp
+++ b/src/network/bearer/qnetworksession.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -575,8 +575,6 @@ void QNetworkSession::migrate()
*/
void QNetworkSession::ignore()
{
- // Needed on mobile platforms (was needed for Symbian/S60): the roaming must be explicitly
- // ignore()'d or migrate()'d
if (d)
d->ignore();
}
diff --git a/src/network/bearer/qnetworksession.h b/src/network/bearer/qnetworksession.h
index 5321875078..21d568ca13 100644
--- a/src/network/bearer/qnetworksession.h
+++ b/src/network/bearer/qnetworksession.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -58,7 +58,6 @@ QT_BEGIN_HEADER
#include <QtCore/qshareddata.h>
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QNetworkSessionPrivate;
class Q_NETWORK_EXPORT QNetworkSession : public QObject
@@ -129,6 +128,7 @@ protected:
virtual void disconnectNotify(const char *signal);
private:
+ Q_DISABLE_COPY(QNetworkSession)
friend class QNetworkSessionPrivate;
QNetworkSessionPrivate *d;
};
diff --git a/src/network/bearer/qnetworksession_p.h b/src/network/bearer/qnetworksession_p.h
index c43762136d..0eea06b085 100644
--- a/src/network/bearer/qnetworksession_p.h
+++ b/src/network/bearer/qnetworksession_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/bearer/qsharednetworksession.cpp b/src/network/bearer/qsharednetworksession.cpp
index 358bc95377..54ff32460e 100644
--- a/src/network/bearer/qsharednetworksession.cpp
+++ b/src/network/bearer/qsharednetworksession.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/bearer/qsharednetworksession_p.h b/src/network/bearer/qsharednetworksession_p.h
index 86946955a1..846f35fe58 100644
--- a/src/network/bearer/qsharednetworksession_p.h
+++ b/src/network/bearer/qsharednetworksession_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri
index d6e099701d..ea937da518 100644
--- a/src/network/kernel/kernel.pri
+++ b/src/network/kernel/kernel.pri
@@ -5,6 +5,8 @@ INCLUDEPATH += $$PWD
HEADERS += kernel/qauthenticator.h \
kernel/qauthenticator_p.h \
+ kernel/qdnslookup.h \
+ kernel/qdnslookup_p.h \
kernel/qhostaddress.h \
kernel/qhostinfo.h \
kernel/qhostinfo_p.h \
@@ -14,15 +16,16 @@ HEADERS += kernel/qauthenticator.h \
kernel/qnetworkinterface_p.h
SOURCES += kernel/qauthenticator.cpp \
+ kernel/qdnslookup.cpp \
kernel/qhostaddress.cpp \
kernel/qhostinfo.cpp \
kernel/qurlinfo.cpp \
kernel/qnetworkproxy.cpp \
kernel/qnetworkinterface.cpp
-unix:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp
-win32:SOURCES += kernel/qhostinfo_win.cpp kernel/qnetworkinterface_win.cpp
-integrity:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp
+unix:SOURCES += kernel/qdnslookup_unix.cpp kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp
+win32:SOURCES += kernel/qdnslookup_win.cpp kernel/qhostinfo_win.cpp kernel/qnetworkinterface_win.cpp
+integrity:SOURCES += kernel/qdnslookup_unix.cpp kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp
mac:LIBS_PRIVATE += -framework SystemConfiguration -framework CoreFoundation
mac:SOURCES += kernel/qnetworkproxy_mac.cpp
diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp
index 0a3dddbe28..36f47eb5b4 100644
--- a/src/network/kernel/qauthenticator.cpp
+++ b/src/network/kernel/qauthenticator.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -45,7 +45,6 @@
#include <qhash.h>
#include <qbytearray.h>
#include <qcryptographichash.h>
-#include <private/qhttpheader_p.h>
#include <qiodevice.h>
#include <qdatastream.h>
#include <qendian.h>
@@ -339,21 +338,6 @@ QAuthenticatorPrivate::QAuthenticatorPrivate()
nonceCount = 0;
}
-#ifndef QT_NO_HTTP
-void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header, bool isProxy)
-{
- const QList<QPair<QString, QString> > values = header.values();
- QList<QPair<QByteArray, QByteArray> > rawValues;
-
- QList<QPair<QString, QString> >::const_iterator it, end;
- for (it = values.constBegin(), end = values.constEnd(); it != end; ++it)
- rawValues.append(qMakePair(it->first.toLatin1(), it->second.toUtf8()));
-
- // continue in byte array form
- parseHttpResponse(rawValues, isProxy);
-}
-#endif
-
void QAuthenticatorPrivate::parseHttpResponse(const QList<QPair<QByteArray, QByteArray> > &values, bool isProxy)
{
const char *search = isProxy ? "proxy-authenticate" : "www-authenticate";
diff --git a/src/network/kernel/qauthenticator.h b/src/network/kernel/qauthenticator.h
index 958532e9dc..9e5422a0bb 100644
--- a/src/network/kernel/qauthenticator.h
+++ b/src/network/kernel/qauthenticator.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -49,7 +49,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QAuthenticatorPrivate;
class QUrl;
diff --git a/src/network/kernel/qauthenticator_p.h b/src/network/kernel/qauthenticator_p.h
index 4b79202d92..a41b31d333 100644
--- a/src/network/kernel/qauthenticator_p.h
+++ b/src/network/kernel/qauthenticator_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -103,9 +103,6 @@ public:
QByteArray digestMd5Response(const QByteArray &challenge, const QByteArray &method, const QByteArray &path);
static QHash<QByteArray, QByteArray> parseDigestAuthenticationChallenge(const QByteArray &challenge);
-#ifndef QT_NO_HTTP
- void parseHttpResponse(const QHttpResponseHeader &, bool isProxy);
-#endif
void parseHttpResponse(const QList<QPair<QByteArray, QByteArray> >&, bool isProxy);
};
diff --git a/src/network/kernel/qdnslookup.cpp b/src/network/kernel/qdnslookup.cpp
new file mode 100644
index 0000000000..f4b143a5fc
--- /dev/null
+++ b/src/network/kernel/qdnslookup.cpp
@@ -0,0 +1,988 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org>
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdnslookup.h"
+#include "qdnslookup_p.h"
+
+#include <qcoreapplication.h>
+#include <qdatetime.h>
+#include <qthreadstorage.h>
+#include <qurl.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_GLOBAL_STATIC(QDnsLookupThreadPool, theDnsLookupThreadPool);
+Q_GLOBAL_STATIC(QThreadStorage<bool *>, theDnsLookupSeedStorage);
+
+static bool qt_qdnsmailexchangerecord_less_than(const QDnsMailExchangeRecord &r1, const QDnsMailExchangeRecord &r2)
+{
+ // Lower numbers are more preferred than higher ones.
+ return r1.preference() < r2.preference();
+}
+
+/*!
+ Sorts a list of QDnsMailExchangeRecord objects according to RFC 5321.
+*/
+
+static void qt_qdnsmailexchangerecord_sort(QList<QDnsMailExchangeRecord> &records)
+{
+ // If we have no more than one result, we are done.
+ if (records.size() <= 1)
+ return;
+
+ // Order the records by preference.
+ qSort(records.begin(), records.end(), qt_qdnsmailexchangerecord_less_than);
+
+ int i = 0;
+ while (i < records.size()) {
+
+ // Determine the slice of records with the current preference.
+ QList<QDnsMailExchangeRecord> slice;
+ const quint16 slicePreference = records[i].preference();
+ for (int j = i; j < records.size(); ++j) {
+ if (records[j].preference() != slicePreference)
+ break;
+ slice << records[j];
+ }
+
+ // Randomize the slice of records.
+ while (!slice.isEmpty()) {
+ const unsigned int pos = qrand() % slice.size();
+ records[i++] = slice.takeAt(pos);
+ }
+ }
+}
+
+static bool qt_qdnsservicerecord_less_than(const QDnsServiceRecord &r1, const QDnsServiceRecord &r2)
+{
+ // Order by priority, or if the priorities are equal,
+ // put zero weight records first.
+ return r1.priority() < r2.priority()
+ || (r1.priority() == r2.priority()
+ && r1.weight() == 0 && r2.weight() > 0);
+}
+
+/*!
+ Sorts a list of QDnsServiceRecord objects according to RFC 2782.
+*/
+
+static void qt_qdnsservicerecord_sort(QList<QDnsServiceRecord> &records)
+{
+ // If we have no more than one result, we are done.
+ if (records.size() <= 1)
+ return;
+
+ // Order the records by priority, and for records with an equal
+ // priority, put records with a zero weight first.
+ qSort(records.begin(), records.end(), qt_qdnsservicerecord_less_than);
+
+ int i = 0;
+ while (i < records.size()) {
+
+ // Determine the slice of records with the current priority.
+ QList<QDnsServiceRecord> slice;
+ const quint16 slicePriority = records[i].priority();
+ unsigned int sliceWeight = 0;
+ for (int j = i; j < records.size(); ++j) {
+ if (records[j].priority() != slicePriority)
+ break;
+ sliceWeight += records[j].weight();
+ slice << records[j];
+ }
+#ifdef QDNSLOOKUP_DEBUG
+ qDebug("qt_qdnsservicerecord_sort() : priority %i (size: %i, total weight: %i)",
+ slicePriority, slice.size(), sliceWeight);
+#endif
+
+ // Order the slice of records.
+ while (!slice.isEmpty()) {
+ const unsigned int weightThreshold = qrand() % (sliceWeight + 1);
+ unsigned int summedWeight = 0;
+ for (int j = 0; j < slice.size(); ++j) {
+ summedWeight += slice[j].weight();
+ if (summedWeight >= weightThreshold) {
+#ifdef QDNSLOOKUP_DEBUG
+ qDebug("qt_qdnsservicerecord_sort() : adding %s %i (weight: %i)",
+ qPrintable(slice[j].target()), slice[j].port(),
+ slice[j].weight());
+#endif
+ // Adjust the slice weight and take the current record.
+ sliceWeight -= slice[j].weight();
+ records[i++] = slice.takeAt(j);
+ break;
+ }
+ }
+ }
+ }
+}
+
+/*!
+ \class QDnsLookup
+ \brief The QDnsLookup class represents a DNS lookup.
+
+ \inmodule QtNetwork
+ \ingroup network
+
+ QDnsLookup uses the mechanisms provided by the operating system to perform
+ DNS lookups. To perform a lookup you need to specify a \l name and \l type
+ then invoke the \l{QDnsLookup::lookup()}{lookup()} slot. The
+ \l{QDnsLookup::finished()}{finished()} signal will be emitted upon
+ completion.
+
+ For example, you can determine which servers an XMPP chat client should
+ connect to for a given domain with:
+
+ \snippet doc/src/snippets/code/src_network_kernel_qdnslookup.cpp 0
+
+ Once the request finishes you can handle the results with:
+
+ \snippet doc/src/snippets/code/src_network_kernel_qdnslookup.cpp 1
+
+ \note If you simply want to find the IP address(es) associated with a host
+ name, or the host name associated with an IP address you should use
+ QHostInfo instead.
+*/
+
+/*!
+ \enum QDnsLookup::Error
+
+ Indicates all possible error conditions found during the
+ processing of the DNS lookup.
+
+ \value NoError no error condition.
+
+ \value ResolverError there was an error initializing the system's
+ DNS resolver.
+
+ \value OperationCancelledError the lookup was aborted using the abort()
+ method.
+
+ \value InvalidRequestError the requested DNS lookup was invalid.
+
+ \value InvalidReplyError the reply returned by the server was invalid.
+
+ \value ServerFailureError the server encountered an internal failure
+ while processing the request (SERVFAIL).
+
+ \value ServerRefusedError the server refused to process the request for
+ security or policy reasons (REFUSED).
+
+ \value NotFoundError the requested domain name does not exist
+ (NXDOMAIN).
+*/
+
+/*!
+ \enum QDnsLookup::Type
+
+ Indicates the type of DNS lookup that was performed.
+
+ \value A IPv4 address records.
+
+ \value AAAA IPv6 address records.
+
+ \value ANY any records.
+
+ \value CNAME canonical name records.
+
+ \value MX mail exchange records.
+
+ \value NS name server records.
+
+ \value PTR pointer records.
+
+ \value SRV service records.
+
+ \value TXT text records.
+*/
+
+/*!
+ \fn void QDnsLookup::finished()
+
+ This signal is emitted when the reply has finished processing.
+*/
+
+/*!
+ \fn void QDnsLookup::nameChanged(const QString &name)
+
+ This signal is emitted when the lookup \l name changes.
+ \a name is the new lookup name.
+*/
+
+/*!
+ \fn void QDnsLookup::typeChanged(Type type)
+
+ This signal is emitted when the lookup \l type changes.
+ \a type is the new lookup type.
+*/
+
+/*!
+ Constructs a QDnsLookup object and sets \a parent as the parent object.
+
+ The \l type property will default to QDnsLookup::A.
+*/
+
+QDnsLookup::QDnsLookup(QObject *parent)
+ : QObject(*new QDnsLookupPrivate, parent)
+{
+ qRegisterMetaType<QDnsLookupReply>();
+}
+/*!
+ Constructs a QDnsLookup object for the given \a type and \a name and sets
+ \a parent as the parent object.
+*/
+
+QDnsLookup::QDnsLookup(Type type, const QString &name, QObject *parent)
+ : QObject(*new QDnsLookupPrivate, parent)
+{
+ Q_D(QDnsLookup);
+ qRegisterMetaType<QDnsLookupReply>();
+ d->name = name;
+ d->type = type;
+}
+
+/*!
+ Destroys the QDnsLookup object.
+
+ It is safe to delete a QDnsLookup object even if it is not finished, you
+ will simply never receive its results.
+*/
+
+QDnsLookup::~QDnsLookup()
+{
+}
+
+/*!
+ \property QDnsLookup::error
+ \brief the type of error that occurred if the DNS lookup failed, or NoError.
+*/
+
+QDnsLookup::Error QDnsLookup::error() const
+{
+ return d_func()->reply.error;
+}
+
+/*!
+ \property QDnsLookup::errorString
+ \brief a human-readable description of the error if the DNS lookup failed.
+*/
+
+QString QDnsLookup::errorString() const
+{
+ return d_func()->reply.errorString;
+}
+
+/*!
+ \property QDnsLookup::finished
+ \brief whether the reply has finished or was aborted.
+*/
+
+bool QDnsLookup::isFinished() const
+{
+ return d_func()->isFinished;
+}
+
+/*!
+ \property QDnsLookup::name
+ \brief the name to lookup.
+
+ \note The name will be encoded using IDNA, which means it's unsuitable for
+ querying SRV records compatible with the DNS-SD specification.
+*/
+
+QString QDnsLookup::name() const
+{
+ return d_func()->name;
+}
+
+void QDnsLookup::setName(const QString &name)
+{
+ Q_D(QDnsLookup);
+ if (name != d->name) {
+ d->name = name;
+ emit nameChanged(name);
+ }
+}
+
+/*!
+ \property QDnsLookup::type
+ \brief the type of DNS lookup.
+*/
+
+QDnsLookup::Type QDnsLookup::type() const
+{
+ return d_func()->type;
+}
+
+void QDnsLookup::setType(Type type)
+{
+ Q_D(QDnsLookup);
+ if (type != d->type) {
+ d->type = type;
+ emit typeChanged(type);
+ }
+}
+
+/*!
+ Returns the list of canonical name records associated with this lookup.
+*/
+
+QList<QDnsDomainNameRecord> QDnsLookup::canonicalNameRecords() const
+{
+ return d_func()->reply.canonicalNameRecords;
+}
+
+/*!
+ Returns the list of host address records associated with this lookup.
+*/
+
+QList<QDnsHostAddressRecord> QDnsLookup::hostAddressRecords() const
+{
+ return d_func()->reply.hostAddressRecords;
+}
+
+/*!
+ Returns the list of mail exchange records associated with this lookup.
+
+ The records are sorted according to
+ \l{http://www.rfc-editor.org/rfc/rfc5321.txt}{RFC 5321}, so if you use them
+ to connect to servers, you should try them in the order they are listed.
+*/
+
+QList<QDnsMailExchangeRecord> QDnsLookup::mailExchangeRecords() const
+{
+ return d_func()->reply.mailExchangeRecords;
+}
+
+/*!
+ Returns the list of name server records associated with this lookup.
+*/
+
+QList<QDnsDomainNameRecord> QDnsLookup::nameServerRecords() const
+{
+ return d_func()->reply.nameServerRecords;
+}
+
+/*!
+ Returns the list of pointer records associated with this lookup.
+*/
+
+QList<QDnsDomainNameRecord> QDnsLookup::pointerRecords() const
+{
+ return d_func()->reply.pointerRecords;
+}
+
+/*!
+ Returns the list of service records associated with this lookup.
+
+ The records are sorted according to
+ \l{http://www.rfc-editor.org/rfc/rfc2782.txt}{RFC 2782}, so if you use them
+ to connect to servers, you should try them in the order they are listed.
+*/
+
+QList<QDnsServiceRecord> QDnsLookup::serviceRecords() const
+{
+ return d_func()->reply.serviceRecords;
+}
+
+/*!
+ Returns the list of text records associated with this lookup.
+*/
+
+QList<QDnsTextRecord> QDnsLookup::textRecords() const
+{
+ return d_func()->reply.textRecords;
+}
+
+/*!
+ Aborts the DNS lookup operation.
+
+ If the lookup is already finished, does nothing.
+*/
+
+void QDnsLookup::abort()
+{
+ Q_D(QDnsLookup);
+ if (d->runnable) {
+ d->runnable = 0;
+ d->reply = QDnsLookupReply();
+ d->reply.error = QDnsLookup::OperationCancelledError;
+ d->reply.errorString = tr("Operation cancelled");
+ d->isFinished = true;
+ emit finished();
+ }
+}
+
+/*!
+ Performs the DNS lookup.
+
+ The \l{QDnsLookup::finished()}{finished()} signal is emitted upon completion.
+*/
+
+void QDnsLookup::lookup()
+{
+ Q_D(QDnsLookup);
+ d->isFinished = false;
+ d->reply = QDnsLookupReply();
+ d->runnable = new QDnsLookupRunnable(d->type, QUrl::toAce(d->name));
+ connect(d->runnable, SIGNAL(finished(QDnsLookupReply)),
+ this, SLOT(_q_lookupFinished(QDnsLookupReply)),
+ Qt::BlockingQueuedConnection);
+ theDnsLookupThreadPool()->start(d->runnable);
+}
+
+/*!
+ \class QDnsDomainNameRecord
+ \brief The QDnsDomainNameRecord class stores information about a domain
+ name record.
+
+ \inmodule QtNetwork
+ \ingroup network
+
+ When performing a name server lookup, zero or more records will be returned.
+ Each record is represented by a QDnsDomainNameRecord instance.
+
+ \sa QDnsLookup
+*/
+
+/*!
+ Constructs an empty domain name record object.
+*/
+
+QDnsDomainNameRecord::QDnsDomainNameRecord()
+ : d(new QDnsDomainNameRecordPrivate)
+{
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+
+QDnsDomainNameRecord::QDnsDomainNameRecord(const QDnsDomainNameRecord &other)
+ : d(other.d)
+{
+}
+
+/*!
+ Destroys a domain name record.
+*/
+
+QDnsDomainNameRecord::~QDnsDomainNameRecord()
+{
+}
+
+/*!
+ Returns the name for this record.
+*/
+
+QString QDnsDomainNameRecord::name() const
+{
+ return d->name;
+}
+
+/*!
+ Returns the duration in seconds for which this record is valid.
+*/
+
+quint32 QDnsDomainNameRecord::timeToLive() const
+{
+ return d->timeToLive;
+}
+
+/*!
+ Returns the value for this domain name record.
+*/
+
+QString QDnsDomainNameRecord::value() const
+{
+ return d->value;
+}
+
+/*!
+ Assigns the data of the \a other object to this record object,
+ and returns a reference to it.
+*/
+
+QDnsDomainNameRecord &QDnsDomainNameRecord::operator=(const QDnsDomainNameRecord &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ \class QDnsHostAddressRecord
+ \brief The QDnsHostAddressRecord class stores information about a host
+ address record.
+
+ \inmodule QtNetwork
+ \ingroup network
+
+ When performing an address lookup, zero or more records will be
+ returned. Each record is represented by a QDnsHostAddressRecord instance.
+
+ \sa QDnsLookup
+*/
+
+/*!
+ Constructs an empty host address record object.
+*/
+
+QDnsHostAddressRecord::QDnsHostAddressRecord()
+ : d(new QDnsHostAddressRecordPrivate)
+{
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+
+QDnsHostAddressRecord::QDnsHostAddressRecord(const QDnsHostAddressRecord &other)
+ : d(other.d)
+{
+}
+
+/*!
+ Destroys a host address record.
+*/
+
+QDnsHostAddressRecord::~QDnsHostAddressRecord()
+{
+}
+
+/*!
+ Returns the name for this record.
+*/
+
+QString QDnsHostAddressRecord::name() const
+{
+ return d->name;
+}
+
+/*!
+ Returns the duration in seconds for which this record is valid.
+*/
+
+quint32 QDnsHostAddressRecord::timeToLive() const
+{
+ return d->timeToLive;
+}
+
+/*!
+ Returns the value for this host address record.
+*/
+
+QHostAddress QDnsHostAddressRecord::value() const
+{
+ return d->value;
+}
+
+/*!
+ Assigns the data of the \a other object to this record object,
+ and returns a reference to it.
+*/
+
+QDnsHostAddressRecord &QDnsHostAddressRecord::operator=(const QDnsHostAddressRecord &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ \class QDnsMailExchangeRecord
+ \brief The QDnsMailExchangeRecord class stores information about a DNS MX record.
+
+ \inmodule QtNetwork
+ \ingroup network
+
+ When performing a lookup on a service, zero or more records will be
+ returned. Each record is represented by a QDnsMailExchangeRecord instance.
+
+ The meaning of the fields is defined in
+ \l{http://www.rfc-editor.org/rfc/rfc1035.txt}{RFC 1035}.
+
+ \sa QDnsLookup
+*/
+
+/*!
+ Constructs an empty mail exchange record object.
+*/
+
+QDnsMailExchangeRecord::QDnsMailExchangeRecord()
+ : d(new QDnsMailExchangeRecordPrivate)
+{
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+
+QDnsMailExchangeRecord::QDnsMailExchangeRecord(const QDnsMailExchangeRecord &other)
+ : d(other.d)
+{
+}
+
+/*!
+ Destroys a mail exchange record.
+*/
+
+QDnsMailExchangeRecord::~QDnsMailExchangeRecord()
+{
+}
+
+/*!
+ Returns the domain name of the mail exchange for this record.
+*/
+
+QString QDnsMailExchangeRecord::exchange() const
+{
+ return d->exchange;
+}
+
+/*!
+ Returns the name for this record.
+*/
+
+QString QDnsMailExchangeRecord::name() const
+{
+ return d->name;
+}
+
+/*!
+ Returns the preference for this record.
+*/
+
+quint16 QDnsMailExchangeRecord::preference() const
+{
+ return d->preference;
+}
+
+/*!
+ Returns the duration in seconds for which this record is valid.
+*/
+
+quint32 QDnsMailExchangeRecord::timeToLive() const
+{
+ return d->timeToLive;
+}
+
+/*!
+ Assigns the data of the \a other object to this record object,
+ and returns a reference to it.
+*/
+
+QDnsMailExchangeRecord &QDnsMailExchangeRecord::operator=(const QDnsMailExchangeRecord &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ \class QDnsServiceRecord
+ \brief The QDnsServiceRecord class stores information about a DNS SRV record.
+
+ \inmodule QtNetwork
+ \ingroup network
+
+ When performing a lookup on a service, zero or more records will be
+ returned. Each record is represented by a QDnsServiceRecord instance.
+
+ The meaning of the fields is defined in
+ \l{http://www.rfc-editor.org/rfc/rfc2782.txt}{RFC 2782}.
+
+ \sa QDnsLookup
+*/
+
+/*!
+ Constructs an empty service record object.
+*/
+
+QDnsServiceRecord::QDnsServiceRecord()
+ : d(new QDnsServiceRecordPrivate)
+{
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+
+QDnsServiceRecord::QDnsServiceRecord(const QDnsServiceRecord &other)
+ : d(other.d)
+{
+}
+
+/*!
+ Destroys a service record.
+*/
+
+QDnsServiceRecord::~QDnsServiceRecord()
+{
+}
+
+/*!
+ Returns the name for this record.
+*/
+
+QString QDnsServiceRecord::name() const
+{
+ return d->name;
+}
+
+/*!
+ Returns the port on the target host for this service record.
+*/
+
+quint16 QDnsServiceRecord::port() const
+{
+ return d->port;
+}
+
+/*!
+ Returns the priority for this service record.
+
+ A client must attempt to contact the target host with the lowest-numbered
+ priority.
+*/
+
+quint16 QDnsServiceRecord::priority() const
+{
+ return d->priority;
+}
+
+/*!
+ Returns the domain name of the target host for this service record.
+*/
+
+QString QDnsServiceRecord::target() const
+{
+ return d->target;
+}
+
+/*!
+ Returns the duration in seconds for which this record is valid.
+*/
+
+quint32 QDnsServiceRecord::timeToLive() const
+{
+ return d->timeToLive;
+}
+
+/*!
+ Returns the weight for this service record.
+
+ The weight field specifies a relative weight for entries with the same
+ priority. Entries with higher weights should be selected with a higher
+ probability.
+*/
+
+quint16 QDnsServiceRecord::weight() const
+{
+ return d->weight;
+}
+
+/*!
+ Assigns the data of the \a other object to this record object,
+ and returns a reference to it.
+*/
+
+QDnsServiceRecord &QDnsServiceRecord::operator=(const QDnsServiceRecord &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ \class QDnsTextRecord
+ \brief The QDnsTextRecord class stores information about a DNS TXT record.
+
+ \inmodule QtNetwork
+ \ingroup network
+
+ When performing a text lookup, zero or more records will be
+ returned. Each record is represented by a QDnsTextRecord instance.
+
+ The meaning of the fields is defined in
+ \l{http://www.rfc-editor.org/rfc/rfc1035.txt}{RFC 1035}.
+
+ \sa QDnsLookup
+*/
+
+/*!
+ Constructs an empty text record object.
+*/
+
+QDnsTextRecord::QDnsTextRecord()
+ : d(new QDnsTextRecordPrivate)
+{
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+
+QDnsTextRecord::QDnsTextRecord(const QDnsTextRecord &other)
+ : d(other.d)
+{
+}
+
+/*!
+ Destroys a text record.
+*/
+
+QDnsTextRecord::~QDnsTextRecord()
+{
+}
+
+/*!
+ Returns the name for this text record.
+*/
+
+QString QDnsTextRecord::name() const
+{
+ return d->name;
+}
+
+/*!
+ Returns the duration in seconds for which this record is valid.
+*/
+
+quint32 QDnsTextRecord::timeToLive() const
+{
+ return d->timeToLive;
+}
+
+/*!
+ Returns the values for this text record.
+*/
+
+QList<QByteArray> QDnsTextRecord::values() const
+{
+ return d->values;
+}
+
+/*!
+ Assigns the data of the \a other object to this record object,
+ and returns a reference to it.
+*/
+
+QDnsTextRecord &QDnsTextRecord::operator=(const QDnsTextRecord &other)
+{
+ d = other.d;
+ return *this;
+}
+
+void QDnsLookupPrivate::_q_lookupFinished(const QDnsLookupReply &_reply)
+{
+ Q_Q(QDnsLookup);
+ if (runnable == q->sender()) {
+#ifdef QDNSLOOKUP_DEBUG
+ qDebug("DNS reply for %s: %i (%s)", qPrintable(name), _reply.error, qPrintable(_reply.errorString));
+#endif
+ reply = _reply;
+ runnable = 0;
+ isFinished = true;
+ emit q->finished();
+ }
+}
+
+void QDnsLookupRunnable::run()
+{
+ QDnsLookupReply reply;
+
+ // Validate input.
+ if (requestName.isEmpty()) {
+ reply.error = QDnsLookup::InvalidRequestError;
+ reply.errorString = tr("Invalid domain name");
+ emit finished(reply);
+ return;
+ }
+
+ // Perform request.
+ query(requestType, requestName, &reply);
+
+ // Sort results.
+ if (!theDnsLookupSeedStorage()->hasLocalData()) {
+ qsrand(QTime(0,0,0).msecsTo(QTime::currentTime()) ^ reinterpret_cast<quintptr>(this));
+ theDnsLookupSeedStorage()->setLocalData(new bool(true));
+ }
+ qt_qdnsmailexchangerecord_sort(reply.mailExchangeRecords);
+ qt_qdnsservicerecord_sort(reply.serviceRecords);
+
+ emit finished(reply);
+}
+
+QDnsLookupThreadPool::QDnsLookupThreadPool()
+ : signalsConnected(false)
+{
+ // Run up to 5 lookups in parallel.
+ setMaxThreadCount(5);
+}
+
+void QDnsLookupThreadPool::start(QRunnable *runnable)
+{
+ // Ensure threads complete at application destruction.
+ if (!signalsConnected) {
+ QMutexLocker signalsLocker(&signalsMutex);
+ if (!signalsConnected) {
+ QCoreApplication *app = QCoreApplication::instance();
+ if (!app) {
+ qWarning("QDnsLookup requires a QCoreApplication");
+ delete runnable;
+ return;
+ }
+
+ moveToThread(app->thread());
+ connect(app, SIGNAL(destroyed()),
+ SLOT(_q_applicationDestroyed()), Qt::DirectConnection);
+ signalsConnected = true;
+ }
+ }
+
+ QThreadPool::start(runnable);
+}
+
+void QDnsLookupThreadPool::_q_applicationDestroyed()
+{
+ waitForDone();
+ signalsConnected = false;
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qdnslookup.cpp"
diff --git a/src/network/kernel/qdnslookup.h b/src/network/kernel/qdnslookup.h
new file mode 100644
index 0000000000..198b19d8a8
--- /dev/null
+++ b/src/network/kernel/qdnslookup.h
@@ -0,0 +1,235 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org>
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDNSLOOKUP_H
+#define QDNSLOOKUP_H
+
+#include <QtCore/qlist.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qshareddata.h>
+#include <QtCore/qsharedpointer.h>
+#include <QtCore/qstring.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Network)
+
+class QHostAddress;
+class QDnsLookupPrivate;
+class QDnsDomainNameRecordPrivate;
+class QDnsHostAddressRecordPrivate;
+class QDnsMailExchangeRecordPrivate;
+class QDnsServiceRecordPrivate;
+class QDnsTextRecordPrivate;
+
+class Q_NETWORK_EXPORT QDnsDomainNameRecord
+{
+public:
+ QDnsDomainNameRecord();
+ QDnsDomainNameRecord(const QDnsDomainNameRecord &other);
+ ~QDnsDomainNameRecord();
+
+ QString name() const;
+ quint32 timeToLive() const;
+ QString value() const;
+
+ QDnsDomainNameRecord &operator=(const QDnsDomainNameRecord &other);
+
+private:
+ QSharedDataPointer<QDnsDomainNameRecordPrivate> d;
+ friend class QDnsLookupRunnable;
+};
+
+class Q_NETWORK_EXPORT QDnsHostAddressRecord
+{
+public:
+ QDnsHostAddressRecord();
+ QDnsHostAddressRecord(const QDnsHostAddressRecord &other);
+ ~QDnsHostAddressRecord();
+
+ QString name() const;
+ quint32 timeToLive() const;
+ QHostAddress value() const;
+
+ QDnsHostAddressRecord &operator=(const QDnsHostAddressRecord &other);
+
+private:
+ QSharedDataPointer<QDnsHostAddressRecordPrivate> d;
+ friend class QDnsLookupRunnable;
+};
+
+class Q_NETWORK_EXPORT QDnsMailExchangeRecord
+{
+public:
+ QDnsMailExchangeRecord();
+ QDnsMailExchangeRecord(const QDnsMailExchangeRecord &other);
+ ~QDnsMailExchangeRecord();
+
+ QString exchange() const;
+ QString name() const;
+ quint16 preference() const;
+ quint32 timeToLive() const;
+
+ QDnsMailExchangeRecord &operator=(const QDnsMailExchangeRecord &other);
+
+private:
+ QSharedDataPointer<QDnsMailExchangeRecordPrivate> d;
+ friend class QDnsLookupRunnable;
+};
+
+class Q_NETWORK_EXPORT QDnsServiceRecord
+{
+public:
+ QDnsServiceRecord();
+ QDnsServiceRecord(const QDnsServiceRecord &other);
+ ~QDnsServiceRecord();
+
+ QString name() const;
+ quint16 port() const;
+ quint16 priority() const;
+ QString target() const;
+ quint32 timeToLive() const;
+ quint16 weight() const;
+
+ QDnsServiceRecord &operator=(const QDnsServiceRecord &other);
+
+private:
+ QSharedDataPointer<QDnsServiceRecordPrivate> d;
+ friend class QDnsLookupRunnable;
+};
+
+class Q_NETWORK_EXPORT QDnsTextRecord
+{
+public:
+ QDnsTextRecord();
+ QDnsTextRecord(const QDnsTextRecord &other);
+ ~QDnsTextRecord();
+
+ QString name() const;
+ quint32 timeToLive() const;
+ QList<QByteArray> values() const;
+
+ QDnsTextRecord &operator=(const QDnsTextRecord &other);
+
+private:
+ QSharedDataPointer<QDnsTextRecordPrivate> d;
+ friend class QDnsLookupRunnable;
+};
+
+class Q_NETWORK_EXPORT QDnsLookup : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(Error Type)
+ Q_PROPERTY(Error error READ error NOTIFY finished)
+ Q_PROPERTY(QString errorString READ errorString NOTIFY finished)
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(Type type READ type WRITE setType NOTIFY typeChanged)
+
+public:
+ enum Error
+ {
+ NoError = 0,
+ ResolverError,
+ OperationCancelledError,
+ InvalidRequestError,
+ InvalidReplyError,
+ ServerFailureError,
+ ServerRefusedError,
+ NotFoundError
+ };
+
+ enum Type
+ {
+ A = 1,
+ AAAA = 28,
+ ANY = 255,
+ CNAME = 5,
+ MX = 15,
+ NS = 2,
+ PTR = 12,
+ SRV = 33,
+ TXT = 16
+ };
+
+ QDnsLookup(QObject *parent = 0);
+ QDnsLookup(Type type, const QString &name, QObject *parent = 0);
+ ~QDnsLookup();
+
+ Error error() const;
+ QString errorString() const;
+ bool isFinished() const;
+
+ QString name() const;
+ void setName(const QString &name);
+
+ Type type() const;
+ void setType(QDnsLookup::Type);
+
+ QList<QDnsDomainNameRecord> canonicalNameRecords() const;
+ QList<QDnsHostAddressRecord> hostAddressRecords() const;
+ QList<QDnsMailExchangeRecord> mailExchangeRecords() const;
+ QList<QDnsDomainNameRecord> nameServerRecords() const;
+ QList<QDnsDomainNameRecord> pointerRecords() const;
+ QList<QDnsServiceRecord> serviceRecords() const;
+ QList<QDnsTextRecord> textRecords() const;
+
+
+public Q_SLOTS:
+ void abort();
+ void lookup();
+
+Q_SIGNALS:
+ void finished();
+ void nameChanged(const QString &name);
+ void typeChanged(Type type);
+
+private:
+ Q_DECLARE_PRIVATE(QDnsLookup)
+ Q_PRIVATE_SLOT(d_func(), void _q_lookupFinished(const QDnsLookupReply &reply))
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDNSLOOKUP_H
diff --git a/src/network/kernel/qdnslookup_p.h b/src/network/kernel/qdnslookup_p.h
new file mode 100644
index 0000000000..8515620a93
--- /dev/null
+++ b/src/network/kernel/qdnslookup_p.h
@@ -0,0 +1,213 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org>
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDNSLOOKUP_P_H
+#define QDNSLOOKUP_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the QDnsLookup class. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtCore/qmutex.h"
+#include "QtCore/qrunnable.h"
+#include "QtCore/qsharedpointer.h"
+#include "QtCore/qthreadpool.h"
+#include "QtNetwork/qdnslookup.h"
+#include "QtNetwork/qhostaddress.h"
+#include "private/qobject_p.h"
+
+QT_BEGIN_NAMESPACE
+
+//#define QDNSLOOKUP_DEBUG
+
+class QDnsLookupRunnable;
+
+class QDnsLookupReply
+{
+public:
+ QDnsLookupReply()
+ : error(QDnsLookup::NoError)
+ { }
+
+ QDnsLookup::Error error;
+ QString errorString;
+
+ QList<QDnsDomainNameRecord> canonicalNameRecords;
+ QList<QDnsHostAddressRecord> hostAddressRecords;
+ QList<QDnsMailExchangeRecord> mailExchangeRecords;
+ QList<QDnsDomainNameRecord> nameServerRecords;
+ QList<QDnsDomainNameRecord> pointerRecords;
+ QList<QDnsServiceRecord> serviceRecords;
+ QList<QDnsTextRecord> textRecords;
+};
+
+class QDnsLookupPrivate : public QObjectPrivate
+{
+public:
+ QDnsLookupPrivate()
+ : isFinished(false)
+ , type(QDnsLookup::A)
+ , runnable(0)
+ { }
+
+ void _q_lookupFinished(const QDnsLookupReply &reply);
+
+ bool isFinished;
+ QString name;
+ QDnsLookup::Type type;
+ QDnsLookupReply reply;
+ QDnsLookupRunnable *runnable;
+
+ Q_DECLARE_PUBLIC(QDnsLookup)
+};
+
+class QDnsLookupRunnable : public QObject, public QRunnable
+{
+ Q_OBJECT
+
+public:
+ QDnsLookupRunnable(QDnsLookup::Type type, const QByteArray &name)
+ : requestType(type)
+ , requestName(name)
+ { }
+ void run();
+
+signals:
+ void finished(const QDnsLookupReply &reply);
+
+private:
+ static void query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply);
+ QDnsLookup::Type requestType;
+ QByteArray requestName;
+};
+
+class QDnsLookupThreadPool : public QThreadPool
+{
+ Q_OBJECT
+
+public:
+ QDnsLookupThreadPool();
+ void start(QRunnable *runnable);
+
+private slots:
+ void _q_applicationDestroyed();
+
+private:
+ QMutex signalsMutex;
+ bool signalsConnected;
+};
+
+class QDnsRecordPrivate : public QSharedData
+{
+public:
+ QDnsRecordPrivate()
+ : timeToLive(0)
+ { }
+
+ QString name;
+ quint32 timeToLive;
+};
+
+class QDnsDomainNameRecordPrivate : public QDnsRecordPrivate
+{
+public:
+ QDnsDomainNameRecordPrivate()
+ { }
+
+ QString value;
+};
+
+class QDnsHostAddressRecordPrivate : public QDnsRecordPrivate
+{
+public:
+ QDnsHostAddressRecordPrivate()
+ { }
+
+ QHostAddress value;
+};
+
+class QDnsMailExchangeRecordPrivate : public QDnsRecordPrivate
+{
+public:
+ QDnsMailExchangeRecordPrivate()
+ : preference(0)
+ { }
+
+ QString exchange;
+ quint16 preference;
+};
+
+class QDnsServiceRecordPrivate : public QDnsRecordPrivate
+{
+public:
+ QDnsServiceRecordPrivate()
+ : port(0),
+ priority(0),
+ weight(0)
+ { }
+
+ QString target;
+ quint16 port;
+ quint16 priority;
+ quint16 weight;
+};
+
+class QDnsTextRecordPrivate : public QDnsRecordPrivate
+{
+public:
+ QDnsTextRecordPrivate()
+ { }
+
+ QList<QByteArray> values;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QDnsLookupReply)
+
+#endif // QDNSLOOKUP_P_H
diff --git a/src/network/kernel/qdnslookup_unix.cpp b/src/network/kernel/qdnslookup_unix.cpp
new file mode 100644
index 0000000000..7767dac45a
--- /dev/null
+++ b/src/network/kernel/qdnslookup_unix.cpp
@@ -0,0 +1,322 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org>
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdnslookup_p.h"
+
+#include <qlibrary.h>
+#include <qscopedpointer.h>
+#include <qurl.h>
+#include <private/qmutexpool_p.h>
+
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <arpa/nameser_compat.h>
+#include <resolv.h>
+
+QT_BEGIN_NAMESPACE
+
+typedef int (*dn_expand_proto)(const unsigned char *, const unsigned char *, const unsigned char *, char *, int);
+static dn_expand_proto local_dn_expand = 0;
+typedef void (*res_nclose_proto)(res_state);
+static res_nclose_proto local_res_nclose = 0;
+typedef int (*res_ninit_proto)(res_state);
+static res_ninit_proto local_res_ninit = 0;
+typedef int (*res_nquery_proto)(res_state, const char *, int, int, unsigned char *, int);
+static res_nquery_proto local_res_nquery = 0;
+
+// Custom deleter to close resolver state.
+
+struct QDnsLookupStateDeleter
+{
+ static inline void cleanup(struct __res_state *pointer)
+ {
+ local_res_nclose(pointer);
+ }
+};
+
+static void resolveLibrary()
+{
+ QLibrary lib(QLatin1String("resolv"));
+ if (!lib.load())
+ return;
+
+ local_dn_expand = dn_expand_proto(lib.resolve("__dn_expand"));
+ if (!local_dn_expand)
+ local_dn_expand = dn_expand_proto(lib.resolve("dn_expand"));
+
+ local_res_nclose = res_nclose_proto(lib.resolve("__res_nclose"));
+ if (!local_res_nclose)
+ local_res_nclose = res_nclose_proto(lib.resolve("res_9_nclose"));
+ if (!local_res_nclose)
+ local_res_nclose = res_nclose_proto(lib.resolve("res_nclose"));
+
+ local_res_ninit = res_ninit_proto(lib.resolve("__res_ninit"));
+ if (!local_res_ninit)
+ local_res_ninit = res_ninit_proto(lib.resolve("res_9_ninit"));
+ if (!local_res_ninit)
+ local_res_ninit = res_ninit_proto(lib.resolve("res_ninit"));
+
+ local_res_nquery = res_nquery_proto(lib.resolve("__res_nquery"));
+ if (!local_res_nquery)
+ local_res_nquery = res_nquery_proto(lib.resolve("res_9_nquery"));
+ if (!local_res_nquery)
+ local_res_nquery = res_nquery_proto(lib.resolve("res_nquery"));
+}
+
+void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply)
+{
+ // Load dn_expand, res_ninit and res_nquery on demand.
+ static volatile bool triedResolve = false;
+ if (!triedResolve) {
+ QMutexLocker locker(QMutexPool::globalInstanceGet(&local_res_ninit));
+ if (!triedResolve) {
+ resolveLibrary();
+ triedResolve = true;
+ }
+ }
+
+ // If dn_expand, res_ninit or res_nquery is missing, fail.
+ if (!local_dn_expand || !local_res_nclose || !local_res_ninit || !local_res_nquery) {
+ reply->error = QDnsLookup::ResolverError;
+ reply->errorString = tr("Resolver functions not found");
+ return;
+ }
+
+ // Initialize state.
+ struct __res_state state;
+ memset(&state, 0, sizeof(state));
+ if (local_res_ninit(&state) < 0) {
+ reply->error = QDnsLookup::ResolverError;
+ reply->errorString = tr("Resolver initialization failed");
+ return;
+ }
+#ifdef QDNSLOOKUP_DEBUG
+ state.options |= RES_DEBUG;
+#endif
+ QScopedPointer<struct __res_state, QDnsLookupStateDeleter> state_ptr(&state);
+
+ // Perform DNS query.
+ unsigned char response[PACKETSZ];
+ memset(response, 0, sizeof(response));
+ const int responseLength = local_res_nquery(&state, requestName, C_IN, requestType, response, sizeof(response));
+
+ // Check the response header.
+ HEADER *header = (HEADER*)response;
+ const int answerCount = ntohs(header->ancount);
+ switch (header->rcode) {
+ case NOERROR:
+ break;
+ case FORMERR:
+ reply->error = QDnsLookup::InvalidRequestError;
+ reply->errorString = tr("Server could not process query");
+ return;
+ case SERVFAIL:
+ reply->error = QDnsLookup::ServerFailureError;
+ reply->errorString = tr("Server failure");
+ return;
+ case NXDOMAIN:
+ reply->error = QDnsLookup::NotFoundError;
+ reply->errorString = tr("Non existent domain");
+ return;
+ case REFUSED:
+ reply->error = QDnsLookup::ServerRefusedError;
+ reply->errorString = tr("Server refused to answer");
+ return;
+ default:
+ reply->error = QDnsLookup::InvalidReplyError;
+ reply->errorString = tr("Invalid reply received");
+ return;
+ }
+
+ // Check the reply is valid.
+ if (responseLength < int(sizeof(HEADER))) {
+ reply->error = QDnsLookup::InvalidReplyError;
+ reply->errorString = tr("Invalid reply received");
+ return;
+ }
+
+ // Skip the query host, type (2 bytes) and class (2 bytes).
+ char host[PACKETSZ], answer[PACKETSZ];
+ unsigned char *p = response + sizeof(HEADER);
+ int status = local_dn_expand(response, response + responseLength, p, host, sizeof(host));
+ if (status < 0) {
+ reply->error = QDnsLookup::InvalidReplyError;
+ reply->errorString = tr("Could not expand domain name");
+ return;
+ }
+ p += status + 4;
+
+ // Extract results.
+ int answerIndex = 0;
+ while ((p < response + responseLength) && (answerIndex < answerCount)) {
+ status = local_dn_expand(response, response + responseLength, p, host, sizeof(host));
+ if (status < 0) {
+ reply->error = QDnsLookup::InvalidReplyError;
+ reply->errorString = tr("Could not expand domain name");
+ return;
+ }
+ const QString name = QUrl::fromAce(host);
+
+ p += status;
+ const quint16 type = (p[0] << 8) | p[1];
+ p += 2; // RR type
+ p += 2; // RR class
+ const quint32 ttl = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
+ p += 4;
+ const quint16 size = (p[0] << 8) | p[1];
+ p += 2;
+
+ if (type == QDnsLookup::A) {
+ if (size != 4) {
+ reply->error = QDnsLookup::InvalidReplyError;
+ reply->errorString = tr("Invalid IPv4 address record");
+ return;
+ }
+ const quint32 addr = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
+ QDnsHostAddressRecord record;
+ record.d->name = name;
+ record.d->timeToLive = ttl;
+ record.d->value = QHostAddress(addr);
+ reply->hostAddressRecords.append(record);
+ } else if (type == QDnsLookup::AAAA) {
+ if (size != 16) {
+ reply->error = QDnsLookup::InvalidReplyError;
+ reply->errorString = tr("Invalid IPv6 address record");
+ return;
+ }
+ QDnsHostAddressRecord record;
+ record.d->name = name;
+ record.d->timeToLive = ttl;
+ record.d->value = QHostAddress(p);
+ reply->hostAddressRecords.append(record);
+ } else if (type == QDnsLookup::CNAME) {
+ status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer));
+ if (status < 0) {
+ reply->error = QDnsLookup::InvalidReplyError;
+ reply->errorString = tr("Invalid canonical name record");
+ return;
+ }
+ QDnsDomainNameRecord record;
+ record.d->name = name;
+ record.d->timeToLive = ttl;
+ record.d->value = QUrl::fromAce(answer);
+ reply->canonicalNameRecords.append(record);
+ } else if (type == QDnsLookup::NS) {
+ status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer));
+ if (status < 0) {
+ reply->error = QDnsLookup::InvalidReplyError;
+ reply->errorString = tr("Invalid name server record");
+ return;
+ }
+ QDnsDomainNameRecord record;
+ record.d->name = name;
+ record.d->timeToLive = ttl;
+ record.d->value = QUrl::fromAce(answer);
+ reply->nameServerRecords.append(record);
+ } else if (type == QDnsLookup::PTR) {
+ status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer));
+ if (status < 0) {
+ reply->error = QDnsLookup::InvalidReplyError;
+ reply->errorString = tr("Invalid pointer record");
+ return;
+ }
+ QDnsDomainNameRecord record;
+ record.d->name = name;
+ record.d->timeToLive = ttl;
+ record.d->value = QUrl::fromAce(answer);
+ reply->pointerRecords.append(record);
+ } else if (type == QDnsLookup::MX) {
+ const quint16 preference = (p[0] << 8) | p[1];
+ status = local_dn_expand(response, response + responseLength, p + 2, answer, sizeof(answer));
+ if (status < 0) {
+ reply->error = QDnsLookup::InvalidReplyError;
+ reply->errorString = tr("Invalid mail exchange record");
+ return;
+ }
+ QDnsMailExchangeRecord record;
+ record.d->exchange = QUrl::fromAce(answer);
+ record.d->name = name;
+ record.d->preference = preference;
+ record.d->timeToLive = ttl;
+ reply->mailExchangeRecords.append(record);
+ } else if (type == QDnsLookup::SRV) {
+ const quint16 priority = (p[0] << 8) | p[1];
+ const quint16 weight = (p[2] << 8) | p[3];
+ const quint16 port = (p[4] << 8) | p[5];
+ status = local_dn_expand(response, response + responseLength, p + 6, answer, sizeof(answer));
+ if (status < 0) {
+ reply->error = QDnsLookup::InvalidReplyError;
+ reply->errorString = tr("Invalid service record");
+ return;
+ }
+ QDnsServiceRecord record;
+ record.d->name = name;
+ record.d->target = QUrl::fromAce(answer);
+ record.d->port = port;
+ record.d->priority = priority;
+ record.d->timeToLive = ttl;
+ record.d->weight = weight;
+ reply->serviceRecords.append(record);
+ } else if (type == QDnsLookup::TXT) {
+ unsigned char *txt = p;
+ QDnsTextRecord record;
+ record.d->name = name;
+ record.d->timeToLive = ttl;
+ while (txt < p + size) {
+ const unsigned char length = *txt;
+ txt++;
+ if (txt + length > p + size) {
+ reply->error = QDnsLookup::InvalidReplyError;
+ reply->errorString = tr("Invalid text record");
+ return;
+ }
+ record.d->values << QByteArray((char*)txt, length);
+ txt += length;
+ }
+ reply->textRecords.append(record);
+ }
+ p += size;
+ answerIndex++;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/network/kernel/qdnslookup_win.cpp b/src/network/kernel/qdnslookup_win.cpp
new file mode 100644
index 0000000000..ba97e64942
--- /dev/null
+++ b/src/network/kernel/qdnslookup_win.cpp
@@ -0,0 +1,177 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org>
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdnslookup_p.h"
+
+#include <qurl.h>
+#include <private/qmutexpool_p.h>
+#include <private/qsystemlibrary_p.h>
+
+#include <qt_windows.h>
+#include <windns.h>
+
+QT_BEGIN_NAMESPACE
+
+typedef DNS_STATUS (*dns_query_utf8_proto)(PCSTR,WORD,DWORD,PIP4_ARRAY,PDNS_RECORD*,PVOID*);
+static dns_query_utf8_proto local_dns_query_utf8 = 0;
+typedef void (*dns_record_list_free_proto)(PDNS_RECORD,DNS_FREE_TYPE);
+static dns_record_list_free_proto local_dns_record_list_free = 0;
+
+static void resolveLibrary()
+{
+ local_dns_query_utf8 = (dns_query_utf8_proto) QSystemLibrary::resolve(QLatin1String("dnsapi"), "DnsQuery_UTF8");
+ local_dns_record_list_free = (dns_record_list_free_proto) QSystemLibrary::resolve(QLatin1String("dnsapi"), "DnsRecordListFree");
+}
+
+void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply)
+{
+ // Load DnsQuery_UTF8 and DnsRecordListFree on demand.
+ static volatile bool triedResolve = false;
+ if (!triedResolve) {
+ QMutexLocker locker(QMutexPool::globalInstanceGet(&local_dns_query_utf8));
+ if (!triedResolve) {
+ resolveLibrary();
+ triedResolve = true;
+ }
+ }
+
+ // If DnsQuery_UTF8 or DnsRecordListFree is missing, fail.
+ if (!local_dns_query_utf8 || !local_dns_record_list_free) {
+ reply->error = QDnsLookup::ResolverError,
+ reply->errorString = tr("Resolver functions not found");
+ return;
+ }
+
+ // Perform DNS query.
+ PDNS_RECORD dns_records;
+ const DNS_STATUS status = local_dns_query_utf8(requestName, requestType, DNS_QUERY_STANDARD, NULL, &dns_records, NULL);
+ switch (status) {
+ case ERROR_SUCCESS:
+ break;
+ case DNS_ERROR_RCODE_FORMAT_ERROR:
+ reply->error = QDnsLookup::InvalidRequestError;
+ reply->errorString = tr("Server could not process query");
+ return;
+ case DNS_ERROR_RCODE_SERVER_FAILURE:
+ reply->error = QDnsLookup::ServerFailureError;
+ reply->errorString = tr("Server failure");
+ return;
+ case DNS_ERROR_RCODE_NAME_ERROR:
+ reply->error = QDnsLookup::NotFoundError;
+ reply->errorString = tr("Non existent domain");
+ return;
+ case DNS_ERROR_RCODE_REFUSED:
+ reply->error = QDnsLookup::ServerRefusedError;
+ reply->errorString = tr("Server refused to answer");
+ return;
+ default:
+ reply->error = QDnsLookup::InvalidReplyError;
+ reply->errorString = tr("Invalid reply received");
+ return;
+ }
+
+ // Extract results.
+ for (PDNS_RECORD ptr = dns_records; ptr != NULL; ptr = ptr->pNext) {
+ const QString name = QUrl::fromAce((char*)ptr->pName);
+ if (ptr->wType == QDnsLookup::A) {
+ QDnsHostAddressRecord record;
+ record.d->name = name;
+ record.d->timeToLive = ptr->dwTtl;
+ record.d->value = QHostAddress(ntohl(ptr->Data.A.IpAddress));
+ reply->hostAddressRecords.append(record);
+ } else if (ptr->wType == QDnsLookup::AAAA) {
+ Q_IPV6ADDR addr;
+ memcpy(&addr, &ptr->Data.AAAA.Ip6Address, sizeof(Q_IPV6ADDR));
+
+ QDnsHostAddressRecord record;
+ record.d->name = name;
+ record.d->timeToLive = ptr->dwTtl;
+ record.d->value = QHostAddress(addr);
+ reply->hostAddressRecords.append(record);
+ } else if (ptr->wType == QDnsLookup::CNAME) {
+ QDnsDomainNameRecord record;
+ record.d->name = name;
+ record.d->timeToLive = ptr->dwTtl;
+ record.d->value = QUrl::fromAce((char*)ptr->Data.Cname.pNameHost);
+ reply->canonicalNameRecords.append(record);
+ } else if (ptr->wType == QDnsLookup::MX) {
+ QDnsMailExchangeRecord record;
+ record.d->name = name;
+ record.d->exchange = QUrl::fromAce((char*)ptr->Data.Mx.pNameExchange);
+ record.d->preference = ptr->Data.Mx.wPreference;
+ record.d->timeToLive = ptr->dwTtl;
+ reply->mailExchangeRecords.append(record);
+ } else if (ptr->wType == QDnsLookup::NS) {
+ QDnsDomainNameRecord record;
+ record.d->name = name;
+ record.d->timeToLive = ptr->dwTtl;
+ record.d->value = QUrl::fromAce((char*)ptr->Data.Ns.pNameHost);
+ reply->nameServerRecords.append(record);
+ } else if (ptr->wType == QDnsLookup::PTR) {
+ QDnsDomainNameRecord record;
+ record.d->name = name;
+ record.d->timeToLive = ptr->dwTtl;
+ record.d->value = QUrl::fromAce((char*)ptr->Data.Ptr.pNameHost);
+ reply->pointerRecords.append(record);
+ } else if (ptr->wType == QDnsLookup::SRV) {
+ QDnsServiceRecord record;
+ record.d->name = name;
+ record.d->target = QUrl::fromAce((char*)ptr->Data.Srv.pNameTarget);
+ record.d->port = ptr->Data.Srv.wPort;
+ record.d->priority = ptr->Data.Srv.wPriority;
+ record.d->timeToLive = ptr->dwTtl;
+ record.d->weight = ptr->Data.Srv.wWeight;
+ reply->serviceRecords.append(record);
+ } else if (ptr->wType == QDnsLookup::TXT) {
+ QDnsTextRecord record;
+ record.d->name = name;
+ record.d->timeToLive = ptr->dwTtl;
+ for (unsigned int i = 0; i < ptr->Data.Txt.dwStringCount; ++i) {
+ record.d->values << QByteArray((char*)ptr->Data.Txt.pStringArray[i]);
+ }
+ reply->textRecords.append(record);
+ }
+ }
+
+ local_dns_record_list_free(dns_records, DnsFreeRecordList);
+}
+
+QT_END_NAMESPACE
diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp
index 3bda5410d0..b68335314f 100644
--- a/src/network/kernel/qhostaddress.cpp
+++ b/src/network/kernel/qhostaddress.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h
index 4747499e38..fdf09ecc82 100644
--- a/src/network/kernel/qhostaddress.h
+++ b/src/network/kernel/qhostaddress.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -53,7 +53,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QHostAddressPrivate;
diff --git a/src/network/kernel/qhostaddress_p.h b/src/network/kernel/qhostaddress_p.h
index bc863a8562..26dbf861f2 100644
--- a/src/network/kernel/qhostaddress_p.h
+++ b/src/network/kernel/qhostaddress_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp
index 45073f6ad1..085f2f6651 100644
--- a/src/network/kernel/qhostinfo.cpp
+++ b/src/network/kernel/qhostinfo.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/kernel/qhostinfo.h b/src/network/kernel/qhostinfo.h
index d84d6d72fa..df377872c8 100644
--- a/src/network/kernel/qhostinfo.h
+++ b/src/network/kernel/qhostinfo.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -50,7 +50,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QObject;
class QHostInfoPrivate;
diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h
index 35de89c1e9..57a5050172 100644
--- a/src/network/kernel/qhostinfo_p.h
+++ b/src/network/kernel/qhostinfo_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index 73882dd54f..71eb240812 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -63,10 +63,7 @@
#endif
#if defined (QT_NO_GETADDRINFO)
-#include <qmutex.h>
-QT_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC(QMutex, getHostByNameMutex)
-QT_END_NAMESPACE
+static QBasicMutex getHostByNameMutex;
#endif
QT_BEGIN_NAMESPACE
@@ -267,7 +264,7 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
// reentrant on all platforms. For now this is okay since we only
// use one QHostInfoAgent, but if more agents are introduced, locking
// must be provided.
- QMutexLocker locker(::getHostByNameMutex());
+ QMutexLocker locker(&getHostByNameMutex);
hostent *result = gethostbyname(aceHostname.constData());
if (result) {
if (result->h_addrtype == AF_INET) {
@@ -348,7 +345,7 @@ QString QHostInfo::localDomainName()
#if defined(QT_NO_GETADDRINFO)
// We have to call res_init to be sure that _res was initialized
// So, for systems without getaddrinfo (which is thread-safe), we lock the mutex too
- QMutexLocker locker(::getHostByNameMutex());
+ QMutexLocker locker(&getHostByNameMutex);
#endif
local_res_init();
QString domainName = QUrl::fromAce(local_res->defdname);
diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp
index fc3724f879..a00389e3ed 100644
--- a/src/network/kernel/qhostinfo_win.cpp
+++ b/src/network/kernel/qhostinfo_win.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -95,15 +95,11 @@ static void resolveLibrary()
#endif
}
-#if defined(Q_OS_WINCE)
-#include <qmutex.h>
-Q_GLOBAL_STATIC(QMutex, qPrivCEMutex)
-#endif
-
QHostInfo QHostInfoAgent::fromName(const QString &hostName)
{
#if defined(Q_OS_WINCE)
- QMutexLocker locker(qPrivCEMutex());
+ static QBasicMutex qPrivCEMutex;
+ QMutexLocker locker(&qPrivCEMutex);
#endif
QWindowsSockInit winSock;
diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp
index 1f69d9fa1b..7b68ed6c12 100644
--- a/src/network/kernel/qnetworkinterface.cpp
+++ b/src/network/kernel/qnetworkinterface.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/kernel/qnetworkinterface.h b/src/network/kernel/qnetworkinterface.h
index 17a8e09cee..dfdbb789fa 100644
--- a/src/network/kernel/qnetworkinterface.h
+++ b/src/network/kernel/qnetworkinterface.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -52,7 +52,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
template<typename T> class QList;
diff --git a/src/network/kernel/qnetworkinterface_p.h b/src/network/kernel/qnetworkinterface_p.h
index a964f9bc54..a80a8c4b01 100644
--- a/src/network/kernel/qnetworkinterface_p.h
+++ b/src/network/kernel/qnetworkinterface_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp
index 8bd7e32766..d5520e4917 100644
--- a/src/network/kernel/qnetworkinterface_unix.cpp
+++ b/src/network/kernel/qnetworkinterface_unix.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp
index da9fa80efc..a311af7686 100644
--- a/src/network/kernel/qnetworkinterface_win.cpp
+++ b/src/network/kernel/qnetworkinterface_win.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/kernel/qnetworkinterface_win_p.h b/src/network/kernel/qnetworkinterface_win_p.h
index 0445e512d2..73e5c625ec 100644
--- a/src/network/kernel/qnetworkinterface_win_p.h
+++ b/src/network/kernel/qnetworkinterface_win_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp
index a8873d3be9..4070c8f014 100644
--- a/src/network/kernel/qnetworkproxy.cpp
+++ b/src/network/kernel/qnetworkproxy.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/kernel/qnetworkproxy.h b/src/network/kernel/qnetworkproxy.h
index 472c220e62..8f961c43ac 100644
--- a/src/network/kernel/qnetworkproxy.h
+++ b/src/network/kernel/qnetworkproxy.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -52,7 +52,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QUrl;
class QNetworkConfiguration;
diff --git a/src/network/kernel/qnetworkproxy_generic.cpp b/src/network/kernel/qnetworkproxy_generic.cpp
index 9328eb379a..c0c6b9fe42 100644
--- a/src/network/kernel/qnetworkproxy_generic.cpp
+++ b/src/network/kernel/qnetworkproxy_generic.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/kernel/qnetworkproxy_mac.cpp b/src/network/kernel/qnetworkproxy_mac.cpp
index a994976860..75ed17048c 100644
--- a/src/network/kernel/qnetworkproxy_mac.cpp
+++ b/src/network/kernel/qnetworkproxy_mac.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/kernel/qnetworkproxy_p.h b/src/network/kernel/qnetworkproxy_p.h
index 2d452d75b4..5b390a573e 100644
--- a/src/network/kernel/qnetworkproxy_p.h
+++ b/src/network/kernel/qnetworkproxy_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 David Faure <dfaure@kdab.net>
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/kernel/qnetworkproxy_win.cpp b/src/network/kernel/qnetworkproxy_win.cpp
index 84b2b79c11..6969a9effd 100644
--- a/src/network/kernel/qnetworkproxy_win.cpp
+++ b/src/network/kernel/qnetworkproxy_win.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -47,11 +47,11 @@
#include <qstringlist.h>
#include <qregexp.h>
#include <qurl.h>
+#include <private/qsystemlibrary_p.h>
#include <string.h>
#include <qt_windows.h>
#include <wininet.h>
-#include <private/qsystemlibrary_p.h>
/*
* Information on the WinHTTP DLL:
diff --git a/src/network/kernel/qurlinfo.cpp b/src/network/kernel/qurlinfo.cpp
index 8b320a9e03..a446f03b85 100644
--- a/src/network/kernel/qurlinfo.cpp
+++ b/src/network/kernel/qurlinfo.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/kernel/qurlinfo.h b/src/network/kernel/qurlinfo.h
index 3bcdff6a9c..7fbf860c31 100644
--- a/src/network/kernel/qurlinfo.h
+++ b/src/network/kernel/qurlinfo.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -50,7 +50,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
#ifndef QT_NO_URLINFO
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index e1a2449593..2e54a2d3ca 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -317,6 +317,10 @@
because the response from the proxy server could not be understood.
\value OperationError An operation was attempted while the socket was in a state that
did not permit it.
+ \value SslInternalError The SSL library being used reported a internal error, this is
+ probably the result of a bad installation or misconfiguration of the library.
+ \value SslInvalidUserDataError Invalid data(certificate, key, cypher, etc.) was
+ provided and its use resulted in an error in the SSL library.
\value UnknownSocketError An unidentified error occurred.
\sa QAbstractSocket::error()
@@ -425,6 +429,19 @@
+ ReuseAddressHint), and on Windows, its equivalent to ShareAddress.
*/
+/*! \enum QAbstractSocket::PauseMode
+ \since 5.0
+
+ This enum describes the behavior of when the socket should hold
+ back with continuing data transfer.
+
+ \value PauseNever Do not pause data transfer on the socket. This is the
+ default and matches the behaviour of Qt 4.
+ \value PauseOnNotify Pause data transfer on the socket upon receiving a
+ notification. The only notification currently supported is
+ QSslSocket::sslErrors().
+*/
+
#include "qabstractsocket.h"
#include "qabstractsocket_p.h"
@@ -529,6 +546,7 @@ QAbstractSocketPrivate::QAbstractSocketPrivate()
abortCalled(false),
closeCalled(false),
pendingClose(false),
+ pauseMode(QAbstractSocket::PauseNever),
port(0),
localPort(0),
peerPort(0),
@@ -797,7 +815,7 @@ bool QAbstractSocketPrivate::flush()
&& socketEngine->bytesToWrite() == 0)) {
#if defined (QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocketPrivate::flush() nothing to do: valid ? %s, writeBuffer.isEmpty() ? %s",
- socketEngine->isValid() ? "yes" : "no", writeBuffer.isEmpty() ? "yes" : "no");
+ (socketEngine && socketEngine->isValid()) ? "yes" : "no", writeBuffer.isEmpty() ? "yes" : "no");
#endif
// this covers the case when the buffer was empty, but we had to wait for the socket engine to finish
@@ -1354,6 +1372,55 @@ QAbstractSocket::~QAbstractSocket()
/*!
\since 5.0
+ Continues data transfer on the socket. This method should only be used
+ after the socket has been set to pause upon notifications and a
+ notification has been received.
+ The only notification currently supported is QSslSocket::sslErrors().
+ Calling this method if the socket is not paused results in undefined
+ behavior.
+
+ \sa pauseMode(), setPauseMode()
+*/
+void QAbstractSocket::resume()
+{
+ Q_D(QAbstractSocket);
+ d->resumeSocketNotifiers(this);
+}
+
+/*!
+ \since 5.0
+
+ Returns the pause mode of this socket.
+
+ \sa setPauseMode(), resume()
+*/
+QAbstractSocket::PauseModes QAbstractSocket::pauseMode() const
+{
+ return d_func()->pauseMode;
+}
+
+
+/*!
+ \since 5.0
+
+ Controls whether to pause upon receiving a notification. The only notification
+ currently supported is QSslSocket::sslErrors(). If set to PauseOnNotify,
+ data transfer on the socket will be paused and needs to be enabled explicitly
+ again by calling resume().
+ By default this option is set to PauseNever.
+ This option must be called before connecting to the server, otherwise it will
+ result in undefined behavior.
+
+ \sa pauseMode(), resume()
+*/
+void QAbstractSocket::setPauseMode(PauseModes pauseMode)
+{
+ d_func()->pauseMode = pauseMode;
+}
+
+/*!
+ \since 5.0
+
Binds to \a address on port \a port, using the BindMode \a mode.
Binds this socket to the address \a address and the port \a port.
@@ -1734,10 +1801,6 @@ bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState
OpenMode openMode)
{
Q_D(QAbstractSocket);
-#ifndef QT_NO_OPENSSL
- if (QSslSocket *socket = qobject_cast<QSslSocket *>(this))
- return socket->setSocketDescriptor(socketDescriptor, socketState, openMode);
-#endif
d->resetSocketLayer();
d->socketEngine = QAbstractSocketEngine::createSocketEngine(socketDescriptor, this);
@@ -1786,13 +1849,6 @@ bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState
*/
void QAbstractSocket::setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value)
{
-#ifndef QT_NO_OPENSSL
- if (QSslSocket *sslSocket = qobject_cast<QSslSocket*>(this)) {
- sslSocket->setSocketOption(option, value);
- return;
- }
-#endif
-
if (!d_func()->socketEngine)
return;
@@ -1827,12 +1883,6 @@ void QAbstractSocket::setSocketOption(QAbstractSocket::SocketOption option, cons
*/
QVariant QAbstractSocket::socketOption(QAbstractSocket::SocketOption option)
{
-#ifndef QT_NO_OPENSSL
- if (QSslSocket *sslSocket = qobject_cast<QSslSocket*>(this)) {
- return sslSocket->socketOption(option);
- }
-#endif
-
if (!d_func()->socketEngine)
return QVariant();
@@ -1913,13 +1963,6 @@ bool QAbstractSocket::waitForConnected(int msecs)
return true;
}
-#ifndef QT_NO_OPENSSL
- // Manual polymorphism; this function is not virtual, but has an overload
- // in QSslSocket.
- if (QSslSocket *socket = qobject_cast<QSslSocket *>(this))
- return socket->waitForConnected(msecs);
-#endif
-
bool wasPendingClose = d->pendingClose;
d->pendingClose = false;
QElapsedTimer stopWatch;
@@ -2139,12 +2182,6 @@ bool QAbstractSocket::waitForBytesWritten(int msecs)
bool QAbstractSocket::waitForDisconnected(int msecs)
{
Q_D(QAbstractSocket);
-#ifndef QT_NO_OPENSSL
- // Manual polymorphism; this function is not virtual, but has an overload
- // in QSslSocket.
- if (QSslSocket *socket = qobject_cast<QSslSocket *>(this))
- return socket->waitForDisconnected(msecs);
-#endif
// require calling connectToHost() before waitForDisconnected()
if (state() == UnconnectedState) {
@@ -2756,15 +2793,6 @@ void QAbstractSocket::setReadBufferSize(qint64 size)
{
Q_D(QAbstractSocket);
-#ifndef QT_NO_OPENSSL
- // Manual polymorphism; setReadBufferSize() isn't virtual, but QSslSocket overloads
- // it.
- if (QSslSocket *socket = qobject_cast<QSslSocket *>(this)) {
- socket->setReadBufferSize(size);
- return;
- }
-#endif
-
if (d->readBufferMaxSize == size)
return;
d->readBufferMaxSize = size;
diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h
index e821f3ddb2..7a9f70b47e 100644
--- a/src/network/socket/qabstractsocket.h
+++ b/src/network/socket/qabstractsocket.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -52,7 +52,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QHostAddress;
#ifndef QT_NO_NETWORKPROXY
@@ -98,6 +97,8 @@ public:
ProxyNotFoundError,
ProxyProtocolError,
OperationError,
+ SslInternalError, /* 20 */
+ SslInvalidUserDataError,
UnknownSocketError = -1
};
@@ -124,10 +125,19 @@ public:
ReuseAddressHint = 0x4
};
Q_DECLARE_FLAGS(BindMode, BindFlag)
+ enum PauseMode {
+ PauseNever = 0x0,
+ PauseOnNotify = 0x1
+ };
+ Q_DECLARE_FLAGS(PauseModes, PauseMode)
QAbstractSocket(SocketType socketType, QObject *parent);
virtual ~QAbstractSocket();
+ virtual void resume(); // to continue after proxy authentication required, SSL errors etc.
+ PauseModes pauseMode() const;
+ void setPauseMode(PauseModes pauseMode);
+
bool bind(const QHostAddress &address, quint16 port = 0, BindMode mode = DefaultForPlatform);
bool bind(quint16 port = 0, BindMode mode = DefaultForPlatform);
@@ -148,20 +158,17 @@ public:
QHostAddress peerAddress() const;
QString peerName() const;
- // ### Qt 5: Make setReadBufferSize() virtual
qint64 readBufferSize() const;
- void setReadBufferSize(qint64 size);
+ virtual void setReadBufferSize(qint64 size);
void abort();
- // ### Qt 5: Make socketDescriptor() and setSocketDescriptor() virtual.
- qintptr socketDescriptor() const;
- bool setSocketDescriptor(qintptr socketDescriptor, SocketState state = ConnectedState,
+ virtual qintptr socketDescriptor() const;
+ virtual bool setSocketDescriptor(qintptr socketDescriptor, SocketState state = ConnectedState,
OpenMode openMode = ReadWrite);
- // ### Qt 5: Make virtual?
- void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value);
- QVariant socketOption(QAbstractSocket::SocketOption option);
+ virtual void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value);
+ virtual QVariant socketOption(QAbstractSocket::SocketOption option);
SocketType socketType() const;
SocketState state() const;
@@ -174,11 +181,10 @@ public:
bool flush();
// for synchronous access
- // ### Qt 5: Make waitForConnected() and waitForDisconnected() virtual.
- bool waitForConnected(int msecs = 30000);
+ virtual bool waitForConnected(int msecs = 30000);
bool waitForReadyRead(int msecs = 30000);
bool waitForBytesWritten(int msecs = 30000);
- bool waitForDisconnected(int msecs = 30000);
+ virtual bool waitForDisconnected(int msecs = 30000);
#ifndef QT_NO_NETWORKPROXY
void setProxy(const QNetworkProxy &networkProxy);
@@ -223,6 +229,7 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractSocket::BindMode)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractSocket::PauseModes)
#ifndef QT_NO_DEBUG_STREAM
Q_NETWORK_EXPORT QDebug operator<<(QDebug, QAbstractSocket::SocketError);
diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h
index 49e7c82e21..578213f6de 100644
--- a/src/network/socket/qabstractsocket_p.h
+++ b/src/network/socket/qabstractsocket_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -106,6 +106,8 @@ public:
bool closeCalled;
bool pendingClose;
+ QAbstractSocket::PauseModes pauseMode;
+
QString hostName;
quint16 port;
QHostAddress host;
diff --git a/src/network/socket/qabstractsocketengine.cpp b/src/network/socket/qabstractsocketengine.cpp
index 8c1ee88ce1..e9e49d41ec 100644
--- a/src/network/socket/qabstractsocketengine.cpp
+++ b/src/network/socket/qabstractsocketengine.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qabstractsocketengine_p.h b/src/network/socket/qabstractsocketengine_p.h
index e365eb8b5e..92d795408f 100644
--- a/src/network/socket/qabstractsocketengine_p.h
+++ b/src/network/socket/qabstractsocketengine_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp
index e882f77dcd..93c5aaf7bd 100644
--- a/src/network/socket/qhttpsocketengine.cpp
+++ b/src/network/socket/qhttpsocketengine.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -43,7 +43,7 @@
#include "qtcpsocket.h"
#include "qhostaddress.h"
#include "qurl.h"
-#include "private/qhttpheader_p.h"
+#include "private/qhttpnetworkreply_p.h"
#include "qelapsedtimer.h"
#include "qnetworkinterface.h"
@@ -72,6 +72,7 @@ bool QHttpSocketEngine::initialize(QAbstractSocket::SocketType type, QAbstractSo
setProtocol(protocol);
setSocketType(type);
d->socket = new QTcpSocket(this);
+ d->reply = new QHttpNetworkReply(QUrl(), this);
#ifndef QT_NO_BEARERMANAGEMENT
d->socket->setProperty("_q_networkSession", property("_q_networkSession"));
#endif
@@ -214,7 +215,7 @@ void QHttpSocketEngine::close()
qint64 QHttpSocketEngine::bytesAvailable() const
{
Q_D(const QHttpSocketEngine);
- return d->readBuffer.size() + (d->socket ? d->socket->bytesAvailable() : 0);
+ return d->socket ? d->socket->bytesAvailable() : 0;
}
qint64 QHttpSocketEngine::read(char *data, qint64 maxlen)
@@ -567,20 +568,21 @@ void QHttpSocketEngine::slotSocketReadNotification()
return;
}
- // Still in handshake mode. Wait until we've got a full response.
- bool done = false;
- do {
- d->readBuffer += d->socket->readLine();
- } while (!(done = d->readBuffer.endsWith("\r\n\r\n")) && d->socket->canReadLine());
-
- if (!done) {
- // Wait for more.
- return;
+ bool ok = true;
+ if (d->reply->d_func()->state == QHttpNetworkReplyPrivate::NothingDoneState)
+ d->reply->d_func()->state = QHttpNetworkReplyPrivate::ReadingStatusState;
+ if (d->reply->d_func()->state == QHttpNetworkReplyPrivate::ReadingStatusState) {
+ ok = d->reply->d_func()->readStatus(d->socket) != -1;
+ if (ok && d->reply->d_func()->state == QHttpNetworkReplyPrivate::ReadingStatusState)
+ return; //Not done parsing headers yet, wait for more data
}
-
- if (!d->readBuffer.startsWith("HTTP/1.")) {
+ if (ok && d->reply->d_func()->state == QHttpNetworkReplyPrivate::ReadingHeaderState) {
+ ok = d->reply->d_func()->readHeader(d->socket) != -1;
+ if (ok && d->reply->d_func()->state == QHttpNetworkReplyPrivate::ReadingHeaderState)
+ return; //Not done parsing headers yet, wait for more data
+ }
+ if (!ok) {
// protocol error, this isn't HTTP
- d->readBuffer.clear();
d->socket->close();
setState(QAbstractSocket::UnconnectedState);
setError(QAbstractSocket::ProxyProtocolError, tr("Did not receive HTTP response from proxy"));
@@ -588,10 +590,7 @@ void QHttpSocketEngine::slotSocketReadNotification()
return;
}
- QHttpResponseHeader responseHeader(QString::fromLatin1(d->readBuffer));
- d->readBuffer.clear(); // we parsed the proxy protocol response. from now on direct socket reading will be done
-
- int statusCode = responseHeader.statusCode();
+ int statusCode = d->reply->statusCode();
QAuthenticatorPrivate *priv = 0;
if (statusCode == 200) {
d->state = Connected;
@@ -613,7 +612,7 @@ void QHttpSocketEngine::slotSocketReadNotification()
d->authenticator.detach();
priv = QAuthenticatorPrivate::getPrivate(d->authenticator);
- priv->parseHttpResponse(responseHeader, true);
+ priv->parseHttpResponse(d->reply->header(), true);
if (priv->phase == QAuthenticatorPrivate::Invalid) {
// problem parsing the reply
@@ -625,21 +624,21 @@ void QHttpSocketEngine::slotSocketReadNotification()
}
bool willClose;
- QString proxyConnectionHeader = responseHeader.value(QLatin1String("Proxy-Connection"));
+ QByteArray proxyConnectionHeader = d->reply->headerField("Proxy-Connection");
// Although most proxies use the unofficial Proxy-Connection header, the Connection header
// from http spec is also allowed.
if (proxyConnectionHeader.isEmpty())
- proxyConnectionHeader = responseHeader.value(QLatin1String("Connection"));
+ proxyConnectionHeader = d->reply->headerField("Connection");
proxyConnectionHeader = proxyConnectionHeader.toLower();
- if (proxyConnectionHeader == QLatin1String("close")) {
+ if (proxyConnectionHeader == "close") {
willClose = true;
- } else if (proxyConnectionHeader == QLatin1String("keep-alive")) {
+ } else if (proxyConnectionHeader == "keep-alive") {
willClose = false;
} else {
// no Proxy-Connection header, so use the default
// HTTP 1.1's default behaviour is to keep persistent connections
// HTTP 1.0 or earlier, so we expect the server to close
- willClose = (responseHeader.majorVersion() * 0x100 + responseHeader.minorVersion()) <= 0x0100;
+ willClose = (d->reply->majorVersion() * 0x100 + d->reply->minorVersion()) <= 0x0100;
}
if (willClose) {
@@ -647,6 +646,9 @@ void QHttpSocketEngine::slotSocketReadNotification()
// especially since the signal below may trigger a new event loop
d->socket->disconnectFromHost();
d->socket->readAll();
+ //We're done with the reply and need to reset it for the next connection
+ delete d->reply;
+ d->reply = new QHttpNetworkReply;
}
if (priv->phase == QAuthenticatorPrivate::Done)
@@ -662,7 +664,7 @@ void QHttpSocketEngine::slotSocketReadNotification()
d->socket->connectToHost(d->proxy.hostName(), d->proxy.port());
} else {
bool ok;
- int contentLength = responseHeader.value(QLatin1String("Content-Length")).toInt(&ok);
+ int contentLength = d->reply->headerField("Content-Length").toInt(&ok);
if (ok && contentLength > 0) {
d->state = ReadResponseContent;
d->pendingResponseData = contentLength;
@@ -708,7 +710,6 @@ void QHttpSocketEngine::slotSocketBytesWritten()
void QHttpSocketEngine::slotSocketError(QAbstractSocket::SocketError error)
{
Q_D(QHttpSocketEngine);
- d->readBuffer.clear();
if (d->state != Connected) {
// we are in proxy handshaking stages
@@ -811,6 +812,7 @@ QHttpSocketEnginePrivate::QHttpSocketEnginePrivate()
, pendingResponseData(0)
{
socket = 0;
+ reply = 0;
state = QHttpSocketEngine::None;
}
diff --git a/src/network/socket/qhttpsocketengine_p.h b/src/network/socket/qhttpsocketengine_p.h
index 1a93956bd2..a6e8b99310 100644
--- a/src/network/socket/qhttpsocketengine_p.h
+++ b/src/network/socket/qhttpsocketengine_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -63,6 +63,7 @@ QT_BEGIN_NAMESPACE
#if !defined(QT_NO_NETWORKPROXY) && !defined(QT_NO_HTTP)
class QTcpSocket;
+class QHttpNetworkReply;
class QHttpSocketEnginePrivate;
class Q_AUTOTEST_EXPORT QHttpSocketEngine : public QAbstractSocketEngine
@@ -171,7 +172,7 @@ public:
QNetworkProxy proxy;
QString peerName;
QTcpSocket *socket;
- QByteArray readBuffer; // only used for parsing the proxy response
+ QHttpNetworkReply *reply; // only used for parsing the proxy response
QHttpSocketEngine::HttpState state;
QAuthenticator authenticator;
bool readNotificationEnabled;
diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp
index fc5fe3443e..b3fe4ac448 100644
--- a/src/network/socket/qlocalserver.cpp
+++ b/src/network/socket/qlocalserver.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qlocalserver.h b/src/network/socket/qlocalserver.h
index 6887c16056..f694131953 100644
--- a/src/network/socket/qlocalserver.h
+++ b/src/network/socket/qlocalserver.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -48,7 +48,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
#ifndef QT_NO_LOCALSERVER
diff --git a/src/network/socket/qlocalserver_p.h b/src/network/socket/qlocalserver_p.h
index d762818692..6e39136dd4 100644
--- a/src/network/socket/qlocalserver_p.h
+++ b/src/network/socket/qlocalserver_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qlocalserver_tcp.cpp b/src/network/socket/qlocalserver_tcp.cpp
index cb4ee53f6a..d6c6a1af92 100644
--- a/src/network/socket/qlocalserver_tcp.cpp
+++ b/src/network/socket/qlocalserver_tcp.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp
index 5859ab0080..c4482dadfc 100644
--- a/src/network/socket/qlocalserver_unix.cpp
+++ b/src/network/socket/qlocalserver_unix.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qlocalserver_win.cpp b/src/network/socket/qlocalserver_win.cpp
index bdbe4d74f1..67e319cdbb 100644
--- a/src/network/socket/qlocalserver_win.cpp
+++ b/src/network/socket/qlocalserver_win.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp
index e311f6a060..3097eaa96c 100644
--- a/src/network/socket/qlocalsocket.cpp
+++ b/src/network/socket/qlocalsocket.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qlocalsocket.h b/src/network/socket/qlocalsocket.h
index bb39b0f4c8..f8bb556413 100644
--- a/src/network/socket/qlocalsocket.h
+++ b/src/network/socket/qlocalsocket.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -49,7 +49,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
#ifndef QT_NO_LOCALSOCKET
diff --git a/src/network/socket/qlocalsocket_p.h b/src/network/socket/qlocalsocket_p.h
index 3541d950e8..cb21a7f3e7 100644
--- a/src/network/socket/qlocalsocket_p.h
+++ b/src/network/socket/qlocalsocket_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp
index 3b83d0ee01..fb9011f0f2 100644
--- a/src/network/socket/qlocalsocket_tcp.cpp
+++ b/src/network/socket/qlocalsocket_tcp.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp
index 5bd929d477..52d8b05a6f 100644
--- a/src/network/socket/qlocalsocket_unix.cpp
+++ b/src/network/socket/qlocalsocket_unix.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp
index 99942a6138..35b0130afc 100644
--- a/src/network/socket/qlocalsocket_win.cpp
+++ b/src/network/socket/qlocalsocket_win.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -108,8 +108,8 @@ void QLocalSocketPrivate::_q_winError(ulong windowsError, const QString &functio
QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(),
handle(INVALID_HANDLE_VALUE),
- pipeReader(0),
pipeWriter(0),
+ pipeReader(0),
error(QLocalSocket::UnknownSocketError),
state(QLocalSocket::UnconnectedState)
{
diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp
index cae2469328..a34b19f7ef 100644
--- a/src/network/socket/qnativesocketengine.cpp
+++ b/src/network/socket/qnativesocketengine.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h
index 60c13c1258..a48fcfa769 100644
--- a/src/network/socket/qnativesocketengine_p.h
+++ b/src/network/socket/qnativesocketengine_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 324705d998..b7c149c18d 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
index ee15702b76..e57bfcb52b 100644
--- a/src/network/socket/qnativesocketengine_win.cpp
+++ b/src/network/socket/qnativesocketengine_win.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -732,6 +732,8 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &a, quint16 port)
ipv6only = 1;
ipv6only = ::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&ipv6only, sizeof(ipv6only) );
}
+#else
+ Q_UNUSED(ipv6only)
#endif
break;
case QAbstractSocket::IPv4Protocol:
@@ -1335,10 +1337,10 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxLength)
#if defined (QNATIVESOCKETENGINE_DEBUG)
if (ret != -2) {
- qDebug("QNativeSocketEnginePrivate::nativeRead(%p \"%s\", %l) == %li",
+ qDebug("QNativeSocketEnginePrivate::nativeRead(%p \"%s\", %li) == %li",
data, qt_prettyDebug(data, qMin((int)bytesRead, 16), (int)bytesRead).data(), (int)maxLength, (int)ret);
} else {
- qDebug("QNativeSocketEnginePrivate::nativeRead(%p, %l) == -2 (WOULD BLOCK)",
+ qDebug("QNativeSocketEnginePrivate::nativeRead(%p, %li) == -2 (WOULD BLOCK)",
data, int(maxLength));
}
#endif
diff --git a/src/network/socket/qnet_unix_p.h b/src/network/socket/qnet_unix_p.h
index 7b2ba54648..651bd1816d 100644
--- a/src/network/socket/qnet_unix_p.h
+++ b/src/network/socket/qnet_unix_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp
index 919bdea2e0..76b00bc4a9 100644
--- a/src/network/socket/qsocks5socketengine.cpp
+++ b/src/network/socket/qsocks5socketengine.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qsocks5socketengine_p.h b/src/network/socket/qsocks5socketengine_p.h
index 386e4856a1..662ce0d347 100644
--- a/src/network/socket/qsocks5socketengine_p.h
+++ b/src/network/socket/qsocks5socketengine_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp
index 857827facc..42f0056524 100644
--- a/src/network/socket/qtcpserver.cpp
+++ b/src/network/socket/qtcpserver.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qtcpserver.h b/src/network/socket/qtcpserver.h
index a322294f58..71ccefa496 100644
--- a/src/network/socket/qtcpserver.h
+++ b/src/network/socket/qtcpserver.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -50,7 +50,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QTcpServerPrivate;
#ifndef QT_NO_NETWORKPROXY
diff --git a/src/network/socket/qtcpsocket.cpp b/src/network/socket/qtcpsocket.cpp
index f900ca752c..706f5721b2 100644
--- a/src/network/socket/qtcpsocket.cpp
+++ b/src/network/socket/qtcpsocket.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qtcpsocket.h b/src/network/socket/qtcpsocket.h
index aa2e89d840..0150205198 100644
--- a/src/network/socket/qtcpsocket.h
+++ b/src/network/socket/qtcpsocket.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -49,7 +49,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
class QTcpSocketPrivate;
diff --git a/src/network/socket/qtcpsocket_p.h b/src/network/socket/qtcpsocket_p.h
index 33672539cc..92d8418acf 100644
--- a/src/network/socket/qtcpsocket_p.h
+++ b/src/network/socket/qtcpsocket_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/socket/qudpsocket.cpp b/src/network/socket/qudpsocket.cpp
index f378fea7b9..a31b16e97d 100644
--- a/src/network/socket/qudpsocket.cpp
+++ b/src/network/socket/qudpsocket.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -318,9 +318,6 @@ qint64 QUdpSocket::pendingDatagramSize() const
fragmented by the IP layer before arriving at their final
destination.
- \warning In S60 5.0 and earlier versions, the writeDatagram return
- value is not reliable for large datagrams.
-
\warning Calling this function on a connected UDP socket may
result in an error and no packet being sent. If you are using a
connected socket, use write() to send datagrams.
diff --git a/src/network/socket/qudpsocket.h b/src/network/socket/qudpsocket.h
index ed5f539732..d1023f57c5 100644
--- a/src/network/socket/qudpsocket.h
+++ b/src/network/socket/qudpsocket.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -49,7 +49,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
#ifndef QT_NO_UDPSOCKET
diff --git a/src/network/ssl/qssl.cpp b/src/network/ssl/qssl.cpp
index 7bb68956ee..b68265f1aa 100644
--- a/src/network/ssl/qssl.cpp
+++ b/src/network/ssl/qssl.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/ssl/qssl.h b/src/network/ssl/qssl.h
index 7da5a78c56..7387b0214c 100644
--- a/src/network/ssl/qssl.h
+++ b/src/network/ssl/qssl.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -50,7 +50,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
namespace QSsl {
enum KeyType {
diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp
index 5a4702d992..966497be2e 100644
--- a/src/network/ssl/qsslcertificate.cpp
+++ b/src/network/ssl/qsslcertificate.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/ssl/qsslcertificate.h b/src/network/ssl/qsslcertificate.h
index 3aa7075eb3..b15d6e97bb 100644
--- a/src/network/ssl/qsslcertificate.h
+++ b/src/network/ssl/qsslcertificate.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -56,7 +56,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
#ifndef QT_NO_SSL
@@ -84,8 +83,7 @@ public:
};
QSslCertificate(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem);
- QSslCertificate( // ### s/encoded/data (to be consistent with signature in .cpp file) ?
- const QByteArray &encoded = QByteArray(), QSsl::EncodingFormat format = QSsl::Pem);
+ QSslCertificate(const QByteArray &data = QByteArray(), QSsl::EncodingFormat format = QSsl::Pem);
QSslCertificate(const QSslCertificate &other);
~QSslCertificate();
QSslCertificate &operator=(const QSslCertificate &other);
diff --git a/src/network/ssl/qsslcertificate_p.h b/src/network/ssl/qsslcertificate_p.h
index 031165b267..cee0ebe9c0 100644
--- a/src/network/ssl/qsslcertificate_p.h
+++ b/src/network/ssl/qsslcertificate_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/ssl/qsslcertificateextension.cpp b/src/network/ssl/qsslcertificateextension.cpp
index b4d002ead1..2b5c57e3f0 100644
--- a/src/network/ssl/qsslcertificateextension.cpp
+++ b/src/network/ssl/qsslcertificateextension.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2011 Richard J. Moore <rich@kde.org>
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/ssl/qsslcertificateextension.h b/src/network/ssl/qsslcertificateextension.h
index 6c1d219a3b..1ba294ba1b 100644
--- a/src/network/ssl/qsslcertificateextension.h
+++ b/src/network/ssl/qsslcertificateextension.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2011 Richard J. Moore <rich@kde.org>
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -51,7 +51,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
#ifndef QT_NO_SSL
diff --git a/src/network/ssl/qsslcertificateextension_p.h b/src/network/ssl/qsslcertificateextension_p.h
index 877175b666..ccd95655b0 100644
--- a/src/network/ssl/qsslcertificateextension_p.h
+++ b/src/network/ssl/qsslcertificateextension_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2011 Richard J. Moore <rich@kde.org>
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/ssl/qsslcipher.cpp b/src/network/ssl/qsslcipher.cpp
index 3c59a8ebf9..ae24e9e3e2 100644
--- a/src/network/ssl/qsslcipher.cpp
+++ b/src/network/ssl/qsslcipher.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/ssl/qsslcipher.h b/src/network/ssl/qsslcipher.h
index 8d58fa50ba..78989b7cb8 100644
--- a/src/network/ssl/qsslcipher.h
+++ b/src/network/ssl/qsslcipher.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -51,7 +51,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
#ifndef QT_NO_SSL
diff --git a/src/network/ssl/qsslcipher_p.h b/src/network/ssl/qsslcipher_p.h
index d4117abe3a..eadb4eacf3 100644
--- a/src/network/ssl/qsslcipher_p.h
+++ b/src/network/ssl/qsslcipher_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/ssl/qsslconfiguration.cpp b/src/network/ssl/qsslconfiguration.cpp
index f29bb02813..dc530dae88 100644
--- a/src/network/ssl/qsslconfiguration.cpp
+++ b/src/network/ssl/qsslconfiguration.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/ssl/qsslconfiguration.h b/src/network/ssl/qsslconfiguration.h
index 37df073ae9..0ef6a6b4f3 100644
--- a/src/network/ssl/qsslconfiguration.h
+++ b/src/network/ssl/qsslconfiguration.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -65,7 +65,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
#ifndef QT_NO_SSL
@@ -87,7 +86,7 @@ public:
inline bool operator!=(const QSslConfiguration &other) const
{ return !(*this == other); }
- bool isNull() const; // ### Qt 5: remove; who would need this?
+ bool isNull() const;
QSsl::SslProtocol protocol() const;
void setProtocol(QSsl::SslProtocol protocol);
diff --git a/src/network/ssl/qsslconfiguration_p.h b/src/network/ssl/qsslconfiguration_p.h
index d9f41d6351..eab266d83b 100644
--- a/src/network/ssl/qsslconfiguration_p.h
+++ b/src/network/ssl/qsslconfiguration_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/ssl/qsslerror.cpp b/src/network/ssl/qsslerror.cpp
index 39e6d6114e..acb8d70d09 100644
--- a/src/network/ssl/qsslerror.cpp
+++ b/src/network/ssl/qsslerror.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/ssl/qsslerror.h b/src/network/ssl/qsslerror.h
index 0bdc230b2e..a84010adbe 100644
--- a/src/network/ssl/qsslerror.h
+++ b/src/network/ssl/qsslerror.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -50,7 +50,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
#ifndef QT_NO_SSL
diff --git a/src/network/ssl/qsslkey.cpp b/src/network/ssl/qsslkey.cpp
index cb038d726f..f422952870 100644
--- a/src/network/ssl/qsslkey.cpp
+++ b/src/network/ssl/qsslkey.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/ssl/qsslkey.h b/src/network/ssl/qsslkey.h
index d7d52fa992..e64df5fce7 100644
--- a/src/network/ssl/qsslkey.h
+++ b/src/network/ssl/qsslkey.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -52,7 +52,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
#ifndef QT_NO_SSL
diff --git a/src/network/ssl/qsslkey_p.h b/src/network/ssl/qsslkey_p.h
index 1beb2a608a..aac5a8c223 100644
--- a/src/network/ssl/qsslkey_p.h
+++ b/src/network/ssl/qsslkey_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index b428316a77..ffc9f3f9fe 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -356,6 +356,24 @@ QSslSocket::~QSslSocket()
}
/*!
+ \reimp
+
+ \since 5.0
+
+ Continues data transfer on the socket after it has been paused. If
+ "setPauseMode(QAbstractSocket::PauseOnNotify);" has been called on
+ this socket and a sslErrors() signal is received, calling this method
+ is necessary for the socket to continue.
+
+ \sa QAbstractSocket::pauseMode(), QAbstractSocket::setPauseMode()
+*/
+void QSslSocket::resume()
+{
+ // continuing might emit signals, rather do this through the event loop
+ QMetaObject::invokeMethod(this, "_q_resumeImplementation", Qt::QueuedConnection);
+}
+
+/*!
Starts an encrypted connection to the device \a hostName on \a
port, using \a mode as the \l OpenMode. This is equivalent to
calling connectToHost() to establish the connection, followed by a
@@ -1860,6 +1878,7 @@ QSslSocketPrivate::QSslSocketPrivate()
, readyReadEmittedPointer(0)
, allowRootCertOnDemandLoading(true)
, plainSocket(0)
+ , paused(false)
{
QSslConfigurationPrivate::deepCopyDefaultConfiguration(&configuration);
}
@@ -1935,7 +1954,6 @@ void QSslSocketPrivate::setDefaultSupportedCiphers(const QList<QSslCipher> &ciph
*/
QList<QSslCertificate> QSslSocketPrivate::defaultCaCertificates()
{
- // ### Qt5: rename everything containing "caCertificates" to "rootCertificates" or similar
QSslSocketPrivate::ensureInitialized();
QMutexLocker locker(&globalData()->mutex);
return globalData()->config->caCertificates;
@@ -2114,6 +2132,11 @@ void QSslSocketPrivate::resumeSocketNotifiers(QSslSocket *socket)
QAbstractSocketPrivate::resumeSocketNotifiers(socket->d_func()->plainSocket);
}
+bool QSslSocketPrivate::isPaused() const
+{
+ return paused;
+}
+
/*!
\internal
*/
@@ -2260,6 +2283,55 @@ void QSslSocketPrivate::_q_flushReadBuffer()
/*!
\internal
*/
+void QSslSocketPrivate::_q_resumeImplementation()
+{
+ Q_Q(QSslSocket);
+ if (plainSocket)
+ plainSocket->resume();
+ paused = false;
+ if (!connectionEncrypted) {
+ if (verifyErrorsHaveBeenIgnored()) {
+ continueHandshake();
+ } else {
+ q->setErrorString(sslErrors.first().errorString());
+ q->setSocketError(QAbstractSocket::SslHandshakeFailedError);
+ emit q->error(QAbstractSocket::SslHandshakeFailedError);
+ plainSocket->disconnectFromHost();
+ return;
+ }
+ }
+ transmit();
+}
+
+/*!
+ \internal
+*/
+bool QSslSocketPrivate::verifyErrorsHaveBeenIgnored()
+{
+ bool doEmitSslError;
+ if (!ignoreErrorsList.empty()) {
+ // check whether the errors we got are all in the list of expected errors
+ // (applies only if the method QSslSocket::ignoreSslErrors(const QList<QSslError> &errors)
+ // was called)
+ doEmitSslError = false;
+ for (int a = 0; a < sslErrors.count(); a++) {
+ if (!ignoreErrorsList.contains(sslErrors.at(a))) {
+ doEmitSslError = true;
+ break;
+ }
+ }
+ } else {
+ // if QSslSocket::ignoreSslErrors(const QList<QSslError> &errors) was not called and
+ // we get an SSL error, emit a signal unless we ignored all errors (by calling
+ // QSslSocket::ignoreSslErrors() )
+ doEmitSslError = !ignoreAllSslErrors;
+ }
+ return !doEmitSslError;
+}
+
+/*!
+ \internal
+*/
QList<QByteArray> QSslSocketPrivate::unixRootCertDirectories()
{
return QList<QByteArray>() << "/etc/ssl/certs/" // (K)ubuntu, OpenSUSE, Mandriva, MeeGo ...
diff --git a/src/network/ssl/qsslsocket.h b/src/network/ssl/qsslsocket.h
index 936f27905a..bdc9c4b4cf 100644
--- a/src/network/ssl/qsslsocket.h
+++ b/src/network/ssl/qsslsocket.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -54,7 +54,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Network)
#ifndef QT_NO_SSL
@@ -83,6 +82,7 @@ public:
QSslSocket(QObject *parent = 0);
~QSslSocket();
+ void resume(); // to continue after proxy authentication required, SSL errors etc.
// Autostarting the SSL client handshake.
void connectToHostEncrypted(const QString &hostName, quint16 port, OpenMode mode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol);
@@ -90,12 +90,12 @@ public:
bool setSocketDescriptor(qintptr socketDescriptor, SocketState state = ConnectedState,
OpenMode openMode = ReadWrite);
+ using QAbstractSocket::connectToHost;
void connectToHost(const QString &hostName, quint16 port, OpenMode openMode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol);
void disconnectFromHost();
- // ### Qt 5: Make virtual
- void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value);
- QVariant socketOption(QAbstractSocket::SocketOption option);
+ virtual void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value);
+ virtual QVariant socketOption(QAbstractSocket::SocketOption option);
SslMode mode() const;
bool isEncrypted() const;
@@ -212,6 +212,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_bytesWrittenSlot(qint64))
Q_PRIVATE_SLOT(d_func(), void _q_flushWriteBuffer())
Q_PRIVATE_SLOT(d_func(), void _q_flushReadBuffer())
+ Q_PRIVATE_SLOT(d_func(), void _q_resumeImplementation())
friend class QSslSocketBackendPrivate;
};
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index 96b2c8170b..f62f3c1229 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -172,6 +172,7 @@ QSslSocketBackendPrivate::QSslSocketBackendPrivate()
QSslSocketBackendPrivate::~QSslSocketBackendPrivate()
{
+ destroySslContext();
}
QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSL_CIPHER(SSL_CIPHER *cipher)
@@ -295,6 +296,7 @@ bool QSslSocketBackendPrivate::initSslContext()
bool client = (mode == QSslSocket::SslClientMode);
bool reinitialized = false;
+
init_context:
switch (configuration.protocol) {
case QSsl::SslV2:
@@ -326,10 +328,9 @@ init_context:
goto init_context;
}
- // ### Bad error code
q->setErrorString(QSslSocket::tr("Error creating SSL context (%1)").arg(getErrorsFromOpenSsl()));
- q->setSocketError(QAbstractSocket::UnknownSocketError);
- emit q->error(QAbstractSocket::UnknownSocketError);
+ q->setSocketError(QAbstractSocket::SslInternalError);
+ emit q->error(QAbstractSocket::SslInternalError);
return false;
}
@@ -352,10 +353,9 @@ init_context:
}
if (!q_SSL_CTX_set_cipher_list(ctx, cipherString.data())) {
- // ### Bad error code
q->setErrorString(QSslSocket::tr("Invalid or empty cipher list (%1)").arg(getErrorsFromOpenSsl()));
- q->setSocketError(QAbstractSocket::UnknownSocketError);
- emit q->error(QAbstractSocket::UnknownSocketError);
+ q->setSocketError(QAbstractSocket::SslInvalidUserDataError);
+ emit q->error(QAbstractSocket::SslInvalidUserDataError);
return false;
}
@@ -398,14 +398,16 @@ init_context:
// Require a private key as well.
if (configuration.privateKey.isNull()) {
q->setErrorString(QSslSocket::tr("Cannot provide a certificate with no key, %1").arg(getErrorsFromOpenSsl()));
- emit q->error(QAbstractSocket::UnknownSocketError);
+ q->setSocketError(QAbstractSocket::SslInvalidUserDataError);
+ emit q->error(QAbstractSocket::SslInvalidUserDataError);
return false;
}
// Load certificate
if (!q_SSL_CTX_use_certificate(ctx, reinterpret_cast<X509 *>(configuration.localCertificate.handle()))) {
q->setErrorString(QSslSocket::tr("Error loading local certificate, %1").arg(getErrorsFromOpenSsl()));
- emit q->error(QAbstractSocket::UnknownSocketError);
+ q->setSocketError(QAbstractSocket::SslInternalError);
+ emit q->error(QAbstractSocket::SslInternalError);
return false;
}
@@ -425,7 +427,8 @@ init_context:
if (!q_SSL_CTX_use_PrivateKey(ctx, pkey)) {
q->setErrorString(QSslSocket::tr("Error loading private key, %1").arg(getErrorsFromOpenSsl()));
- emit q->error(QAbstractSocket::UnknownSocketError);
+ q->setSocketError(QAbstractSocket::SslInternalError);
+ emit q->error(QAbstractSocket::SslInternalError);
return false;
}
if (configuration.privateKey.algorithm() == QSsl::Opaque)
@@ -434,7 +437,8 @@ init_context:
// Check if the certificate matches the private key.
if (!q_SSL_CTX_check_private_key(ctx)) {
q->setErrorString(QSslSocket::tr("Private key does not certify public key, %1").arg(getErrorsFromOpenSsl()));
- emit q->error(QAbstractSocket::UnknownSocketError);
+ q->setSocketError(QAbstractSocket::SslInvalidUserDataError);
+ emit q->error(QAbstractSocket::SslInvalidUserDataError);
return false;
}
}
@@ -454,8 +458,8 @@ init_context:
if (!(ssl = q_SSL_new(ctx))) {
// ### Bad error code
q->setErrorString(QSslSocket::tr("Error creating SSL session, %1").arg(getErrorsFromOpenSsl()));
- q->setSocketError(QAbstractSocket::UnknownSocketError);
- emit q->error(QAbstractSocket::UnknownSocketError);
+ q->setSocketError(QAbstractSocket::SslInternalError);
+ emit q->error(QAbstractSocket::SslInternalError);
return false;
}
@@ -488,10 +492,9 @@ init_context:
readBio = q_BIO_new(q_BIO_s_mem());
writeBio = q_BIO_new(q_BIO_s_mem());
if (!readBio || !writeBio) {
- // ### Bad error code
q->setErrorString(QSslSocket::tr("Error creating SSL session: %1").arg(getErrorsFromOpenSsl()));
- q->setSocketError(QAbstractSocket::UnknownSocketError);
- emit q->error(QAbstractSocket::UnknownSocketError);
+ q->setSocketError(QAbstractSocket::SslInternalError);
+ emit q->error(QAbstractSocket::SslInternalError);
return false;
}
@@ -506,6 +509,22 @@ init_context:
return true;
}
+void QSslSocketBackendPrivate::destroySslContext()
+{
+ if (ssl) {
+ q_SSL_free(ssl);
+ ssl = 0;
+ }
+ if (ctx) {
+ q_SSL_CTX_free(ctx);
+ ctx = 0;
+ }
+ if (pkey) {
+ q_EVP_PKEY_free(pkey);
+ pkey = 0;
+ }
+}
+
/*!
\internal
*/
@@ -804,8 +823,11 @@ QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates()
void QSslSocketBackendPrivate::startClientEncryption()
{
+ Q_Q(QSslSocket);
if (!initSslContext()) {
- // ### report error: internal OpenSSL failure
+ q->setErrorString(QSslSocket::tr("Unable to init Ssl Context: %1").arg(getErrorsFromOpenSsl()));
+ q->setSocketError(QAbstractSocket::SslInternalError);
+ emit q->error(QAbstractSocket::SslInternalError);
return;
}
@@ -817,8 +839,11 @@ void QSslSocketBackendPrivate::startClientEncryption()
void QSslSocketBackendPrivate::startServerEncryption()
{
+ Q_Q(QSslSocket);
if (!initSslContext()) {
- // ### report error: internal OpenSSL failure
+ q->setErrorString(QSslSocket::tr("Unable to init Ssl Context: %1").arg(getErrorsFromOpenSsl()));
+ q->setSocketError(QAbstractSocket::SslInternalError);
+ emit q->error(QAbstractSocket::SslInternalError);
return;
}
@@ -855,8 +880,8 @@ void QSslSocketBackendPrivate::transmit()
if (writtenBytes <= 0) {
// ### Better error handling.
q->setErrorString(QSslSocket::tr("Unable to write data: %1").arg(getErrorsFromOpenSsl()));
- q->setSocketError(QAbstractSocket::UnknownSocketError);
- emit q->error(QAbstractSocket::UnknownSocketError);
+ q->setSocketError(QAbstractSocket::SslInternalError);
+ emit q->error(QAbstractSocket::SslInternalError);
return;
}
#ifdef QSSLSOCKET_DEBUG
@@ -925,8 +950,8 @@ void QSslSocketBackendPrivate::transmit()
} else {
// ### Better error handling.
q->setErrorString(QSslSocket::tr("Unable to decrypt data: %1").arg(getErrorsFromOpenSsl()));
- q->setSocketError(QAbstractSocket::UnknownSocketError);
- emit q->error(QAbstractSocket::UnknownSocketError);
+ q->setSocketError(QAbstractSocket::SslInternalError);
+ emit q->error(QAbstractSocket::SslInternalError);
return;
}
@@ -950,6 +975,9 @@ void QSslSocketBackendPrivate::transmit()
qDebug() << "QSslSocketBackendPrivate::transmit: connection lost";
#endif
break;
+ } else if (paused) {
+ // just wait until the user continues
+ return;
} else {
#ifdef QSSLSOCKET_DEBUG
qDebug() << "QSslSocketBackendPrivate::transmit: encryption not done yet";
@@ -1003,8 +1031,8 @@ void QSslSocketBackendPrivate::transmit()
// we do not know exactly what the error is, nor whether we can recover from it,
// so just return to prevent an endless loop in the outer "while" statement
q->setErrorString(QSslSocket::tr("Error while reading: %1").arg(getErrorsFromOpenSsl()));
- q->setSocketError(QAbstractSocket::UnknownSocketError);
- emit q->error(QAbstractSocket::UnknownSocketError);
+ q->setSocketError(QAbstractSocket::SslInternalError);
+ emit q->error(QAbstractSocket::SslInternalError);
return;
default:
// SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT: can only happen with a
@@ -1013,8 +1041,8 @@ void QSslSocketBackendPrivate::transmit()
// SSL_CTX_set_client_cert_cb(), which we do not call.
// So this default case should never be triggered.
q->setErrorString(QSslSocket::tr("Error while reading: %1").arg(getErrorsFromOpenSsl()));
- q->setSocketError(QAbstractSocket::UnknownSocketError);
- emit q->error(QAbstractSocket::UnknownSocketError);
+ q->setSocketError(QAbstractSocket::SslInternalError);
+ emit q->error(QAbstractSocket::SslInternalError);
break;
}
} while (ssl && readBytes > 0);
@@ -1188,46 +1216,25 @@ bool QSslSocketBackendPrivate::startHandshake()
sslErrors = errors;
emit q->sslErrors(errors);
- bool doEmitSslError;
- if (!ignoreErrorsList.empty()) {
- // check whether the errors we got are all in the list of expected errors
- // (applies only if the method QSslSocket::ignoreSslErrors(const QList<QSslError> &errors)
- // was called)
- doEmitSslError = false;
- for (int a = 0; a < errors.count(); a++) {
- if (!ignoreErrorsList.contains(errors.at(a))) {
- doEmitSslError = true;
- break;
- }
- }
- } else {
- // if QSslSocket::ignoreSslErrors(const QList<QSslError> &errors) was not called and
- // we get an SSL error, emit a signal unless we ignored all errors (by calling
- // QSslSocket::ignoreSslErrors() )
- doEmitSslError = !ignoreAllSslErrors;
- }
+ bool doEmitSslError = !verifyErrorsHaveBeenIgnored();
// check whether we need to emit an SSL handshake error
if (doVerifyPeer && doEmitSslError) {
- q->setErrorString(sslErrors.first().errorString());
- q->setSocketError(QAbstractSocket::SslHandshakeFailedError);
- emit q->error(QAbstractSocket::SslHandshakeFailedError);
- plainSocket->disconnectFromHost();
+ if (q->pauseMode() & QAbstractSocket::PauseOnNotify) {
+ pauseSocketNotifiers(q);
+ paused = true;
+ } else {
+ q->setErrorString(sslErrors.first().errorString());
+ q->setSocketError(QAbstractSocket::SslHandshakeFailedError);
+ emit q->error(QAbstractSocket::SslHandshakeFailedError);
+ plainSocket->disconnectFromHost();
+ }
return false;
}
} else {
sslErrors.clear();
}
- // if we have a max read buffer size, reset the plain socket's to 1k
- if (readBufferMaxSize)
- plainSocket->setReadBufferSize(1024);
-
- connectionEncrypted = true;
- emit q->encrypted();
- if (autoStartHandshake && pendingClose) {
- pendingClose = false;
- q->disconnectFromHost();
- }
+ continueHandshake();
return true;
}
@@ -1242,18 +1249,10 @@ void QSslSocketBackendPrivate::disconnectFromHost()
void QSslSocketBackendPrivate::disconnected()
{
- if (ssl) {
- q_SSL_free(ssl);
- ssl = 0;
- }
- if (ctx) {
- q_SSL_CTX_free(ctx);
- ctx = 0;
- }
- if (pkey) {
- q_EVP_PKEY_free(pkey);
- pkey = 0;
- }
+ if (plainSocket->bytesAvailable() <= 0)
+ destroySslContext();
+ //if there is still buffered data in the plain socket, don't destroy the ssl context yet.
+ //it will be destroyed when the socket is deleted.
}
QSslCipher QSslSocketBackendPrivate::sessionCipher() const
@@ -1271,6 +1270,21 @@ QSslCipher QSslSocketBackendPrivate::sessionCipher() const
return sessionCipher ? QSslCipher_from_SSL_CIPHER(sessionCipher) : QSslCipher();
}
+void QSslSocketBackendPrivate::continueHandshake()
+{
+ Q_Q(QSslSocket);
+ // if we have a max read buffer size, reset the plain socket's to match
+ if (readBufferMaxSize)
+ plainSocket->setReadBufferSize(readBufferMaxSize);
+
+ connectionEncrypted = true;
+ emit q->encrypted();
+ if (autoStartHandshake && pendingClose) {
+ pendingClose = false;
+ q->disconnectFromHost();
+ }
+}
+
QList<QSslCertificate> QSslSocketBackendPrivate::STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509)
{
ensureInitialized();
diff --git a/src/network/ssl/qsslsocket_openssl_p.h b/src/network/ssl/qsslsocket_openssl_p.h
index 4d1ed9e681..b31eae9c97 100644
--- a/src/network/ssl/qsslsocket_openssl_p.h
+++ b/src/network/ssl/qsslsocket_openssl_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -99,6 +99,7 @@ public:
// SSL context
bool initSslContext();
+ void destroySslContext();
SSL *ssl;
SSL_CTX *ctx;
EVP_PKEY *pkey;
@@ -115,6 +116,7 @@ public:
void disconnectFromHost();
void disconnected();
QSslCipher sessionCipher() const;
+ void continueHandshake();
Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
static QSslCipher QSslCipher_from_SSL_CIPHER(SSL_CIPHER *cipher);
diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
index c3bee3edd2..aa25215755 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h
index 1f1e842c13..758763523f 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols_p.h
+++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h
index 6fa443d0c7..44114481df 100644
--- a/src/network/ssl/qsslsocket_p.h
+++ b/src/network/ssl/qsslsocket_p.h
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE
typedef OSStatus (*PtrSecTrustSettingsCopyCertificates)(int, CFArrayRef*);
typedef OSStatus (*PtrSecTrustCopyAnchorCertificates)(CFArrayRef*);
#elif defined(Q_OS_WIN)
-#include <windows.h>
+#include <QtCore/qt_windows.h>
#include <wincrypt.h>
#ifndef HCRYPTPROV_LEGACY
#define HCRYPTPROV_LEGACY HCRYPTPROV
@@ -149,6 +149,7 @@ public:
void createPlainSocket(QIODevice::OpenMode openMode);
static void pauseSocketNotifiers(QSslSocket*);
static void resumeSocketNotifiers(QSslSocket*);
+ bool isPaused() const;
void _q_connectedSlot();
void _q_hostFoundSlot();
void _q_disconnectedSlot();
@@ -158,6 +159,7 @@ public:
void _q_bytesWrittenSlot(qint64);
void _q_flushWriteBuffer();
void _q_flushReadBuffer();
+ void _q_resumeImplementation();
// Platform specific functions
virtual void startClientEncryption() = 0;
@@ -166,6 +168,7 @@ public:
virtual void disconnectFromHost() = 0;
virtual void disconnected() = 0;
virtual QSslCipher sessionCipher() const = 0;
+ virtual void continueHandshake() = 0;
private:
static bool ensureLibraryLoaded();
@@ -174,8 +177,10 @@ private:
static bool s_libraryLoaded;
static bool s_loadedCiphersAndCerts;
protected:
+ bool verifyErrorsHaveBeenIgnored();
static bool s_loadRootCertsOnDemand;
static QList<QByteArray> unixRootCertDirectories();
+ bool paused;
};
QT_END_NAMESPACE
diff --git a/src/network/ssl/ssl.pri b/src/network/ssl/ssl.pri
index 7a8694ca62..87bcc9378a 100644
--- a/src/network/ssl/ssl.pri
+++ b/src/network/ssl/ssl.pri
@@ -1,9 +1,5 @@
# OpenSSL support; compile in QSslSocket.
contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) {
-
-
-include($$QT_SOURCE_TREE/config.tests/unix/openssl/openssl.pri)
-
HEADERS += ssl/qssl.h \
ssl/qsslcertificate.h \
ssl/qsslcertificate_p.h \