summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qftp.cpp12
-rw-r--r--src/network/access/qhttp.cpp1
-rw-r--r--src/network/access/qhttp.h3
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp6
-rw-r--r--src/network/access/qhttpnetworkreply.cpp2
-rw-r--r--src/network/access/qnetworkaccesshttpbackend.cpp11
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp2
-rw-r--r--src/network/access/qnetworkcookie.cpp37
-rw-r--r--src/network/access/qnetworkcookie.h4
-rw-r--r--src/network/access/qnetworkdiskcache.cpp42
-rw-r--r--src/network/access/qnetworkrequest.cpp15
-rw-r--r--src/network/access/qnetworkrequest.h4
-rw-r--r--src/network/kernel/kernel.pri3
-rw-r--r--src/network/kernel/qhostaddress.cpp5
-rw-r--r--src/network/kernel/qhostaddress.h3
-rw-r--r--src/network/kernel/qhostinfo.cpp20
-rw-r--r--src/network/kernel/qhostinfo.h3
-rw-r--r--src/network/kernel/qhostinfo_unix.cpp5
-rw-r--r--src/network/kernel/qnetworkinterface.cpp10
-rw-r--r--src/network/kernel/qnetworkinterface.h3
-rw-r--r--src/network/kernel/qnetworkinterface_symbian.cpp203
-rw-r--r--src/network/kernel/qnetworkinterface_win.cpp11
-rw-r--r--src/network/network.pro14
-rw-r--r--src/network/socket/qabstractsocket.cpp3
-rw-r--r--src/network/socket/qlocalserver.cpp4
-rw-r--r--src/network/socket/qlocalserver_unix.cpp18
-rw-r--r--src/network/socket/qlocalsocket_unix.cpp21
-rw-r--r--src/network/socket/qnativesocketengine.cpp11
-rw-r--r--src/network/socket/qnativesocketengine_p.h138
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp173
-rw-r--r--src/network/socket/qsocks5socketengine.cpp8
-rw-r--r--src/network/socket/qtcpserver.cpp7
-rw-r--r--src/network/socket/qudpsocket.cpp20
-rw-r--r--src/network/socket/socket.pri2
-rw-r--r--src/network/ssl/qsslcertificate.cpp13
-rw-r--r--src/network/ssl/qsslcertificate.h2
-rw-r--r--src/network/ssl/qsslcipher.cpp5
-rw-r--r--src/network/ssl/qsslcipher.h3
-rw-r--r--src/network/ssl/qsslerror.cpp22
-rw-r--r--src/network/ssl/qsslerror.h10
-rw-r--r--src/network/ssl/qsslkey.cpp17
-rw-r--r--src/network/ssl/qsslkey.h3
-rw-r--r--src/network/ssl/qsslsocket_openssl_p.h4
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols.cpp145
-rw-r--r--src/network/ssl/ssl.pri8
45 files changed, 920 insertions, 136 deletions
diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp
index b00f4a4..8e72323 100644
--- a/src/network/access/qftp.cpp
+++ b/src/network/access/qftp.cpp
@@ -314,8 +314,10 @@ void QFtpDTP::connectToHost(const QString & host, quint16 port)
{
bytesFromSocket.clear();
- if (socket)
+ if (socket) {
delete socket;
+ socket = 0;
+ }
socket = new QTcpSocket(this);
socket->setObjectName(QLatin1String("QFtpDTP Passive state socket"));
connect(socket, SIGNAL(connected()), SLOT(socketConnected()));
@@ -1661,11 +1663,12 @@ QFtp::QFtp(QObject *parent, const char *name)
*/
int QFtp::connectToHost(const QString &host, quint16 port)
{
- d_func()->pi.transferConnectionExtended = true;
QStringList cmds;
cmds << host;
cmds << QString::number((uint)port);
- return d_func()->addCommand(new QFtpCommand(ConnectToHost, cmds));
+ int id = d_func()->addCommand(new QFtpCommand(ConnectToHost, cmds));
+ d_func()->pi.transferConnectionExtended = true;
+ return id;
}
/*!
@@ -1724,9 +1727,10 @@ int QFtp::close()
*/
int QFtp::setTransferMode(TransferMode mode)
{
+ int id = d_func()->addCommand(new QFtpCommand(SetTransferMode, QStringList()));
d_func()->pi.transferConnectionExtended = true;
d_func()->transferMode = mode;
- return d_func()->addCommand(new QFtpCommand(SetTransferMode, QStringList()));
+ return id;
}
/*!
diff --git a/src/network/access/qhttp.cpp b/src/network/access/qhttp.cpp
index faa2398..bb72f89 100644
--- a/src/network/access/qhttp.cpp
+++ b/src/network/access/qhttp.cpp
@@ -625,7 +625,6 @@ QHttpHeader::QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header)
*/
QHttpHeader::~QHttpHeader()
{
- delete d_ptr;
}
/*!
diff --git a/src/network/access/qhttp.h b/src/network/access/qhttp.h
index b1c5365..e524350 100644
--- a/src/network/access/qhttp.h
+++ b/src/network/access/qhttp.h
@@ -46,6 +46,7 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qmap.h>
#include <QtCore/qpair.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -108,7 +109,7 @@ protected:
QHttpHeader(QHttpHeaderPrivate &dd, const QString &str = QString());
QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header);
- QHttpHeaderPrivate *d_ptr;
+ QScopedPointer<QHttpHeaderPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QHttpHeader)
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index 75ab837..20e4802 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -81,8 +81,10 @@ QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(const QString &host
QHttpNetworkConnectionPrivate::~QHttpNetworkConnectionPrivate()
{
for (int i = 0; i < channelCount; ++i) {
- channels[i].socket->close();
- delete channels[i].socket;
+ if (channels[i].socket) {
+ channels[i].socket->close();
+ delete channels[i].socket;
+ }
}
delete []channels;
}
diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp
index a623999..c11b1a6 100644
--- a/src/network/access/qhttpnetworkreply.cpp
+++ b/src/network/access/qhttpnetworkreply.cpp
@@ -477,8 +477,6 @@ bool QHttpNetworkReplyPrivate::parseStatus(const QByteArray &status)
qint64 QHttpNetworkReplyPrivate::readHeader(QAbstractSocket *socket)
{
qint64 bytes = 0;
- char crlfcrlf[5];
- crlfcrlf[4] = '\0';
char c = 0;
bool allHeaders = false;
while (!allHeaders && socket->bytesAvailable()) {
diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp
index 5c85735..293f857 100644
--- a/src/network/access/qnetworkaccesshttpbackend.cpp
+++ b/src/network/access/qnetworkaccesshttpbackend.cpp
@@ -684,10 +684,15 @@ void QNetworkAccessHttpBackend::replyFinished()
// store the SSL configuration now
// once we call finished(), we won't have access to httpReply anymore
QSslConfiguration sslConfig = httpReply->sslConfiguration();
- if (pendingSslConfiguration)
+ if (pendingSslConfiguration) {
*pendingSslConfiguration = sslConfig;
- else if (!sslConfig.isNull())
- pendingSslConfiguration = new QSslConfiguration(sslConfig);
+ } else if (!sslConfig.isNull()) {
+ QT_TRY {
+ pendingSslConfiguration = new QSslConfiguration(sslConfig);
+ } QT_CATCH(...) {
+ qWarning("QNetworkAccess: could not allocate a QSslConfiguration object for a SSL connection.");
+ }
+ }
#endif
finished();
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index e1d6634..8569ecd 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -768,8 +768,8 @@ void QNetworkAccessManagerPrivate::createCookieJar() const
if (!cookieJarCreated) {
// keep the ugly hack in here
QNetworkAccessManagerPrivate *that = const_cast<QNetworkAccessManagerPrivate *>(this);
- that->cookieJarCreated = true;
that->cookieJar = new QNetworkCookieJar(that->q_func());
+ that->cookieJarCreated = true;
}
}
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp
index 854bd17..dd5edb0 100644
--- a/src/network/access/qnetworkcookie.cpp
+++ b/src/network/access/qnetworkcookie.cpp
@@ -97,6 +97,43 @@ QT_BEGIN_NAMESPACE
/*!
Create a new QNetworkCookie object, initializing the cookie name
+ and its value to empty QByteArray
+
+ A cookie is only valid if it has a name. However, the value is
+ opaque to the application and being empty may have significance to
+ the remote server.
+*/
+QNetworkCookie::QNetworkCookie()
+ : d(new QNetworkCookiePrivate)
+{
+ qRegisterMetaType<QNetworkCookie>();
+ qRegisterMetaType<QList<QNetworkCookie> >();
+
+ d->name = QByteArray();
+ d->value = QByteArray();
+}
+
+/*!
+ Create a new QNetworkCookie object, initializing the cookie name
+ to \a name and its value to empty QByteArray.
+
+ A cookie is only valid if it has a name. However, the value is
+ opaque to the application and being empty may have significance to
+ the remote server.
+*/
+QNetworkCookie::QNetworkCookie( const QByteArray &name )
+ : d(new QNetworkCookiePrivate)
+{
+ qRegisterMetaType<QNetworkCookie>();
+ qRegisterMetaType<QList<QNetworkCookie> >();
+
+ d->name = name;
+ d->value = QByteArray();
+}
+
+
+/*!
+ Create a new QNetworkCookie object, initializing the cookie name
to \a name and its value to \a value.
A cookie is only valid if it has a name. However, the value is
diff --git a/src/network/access/qnetworkcookie.h b/src/network/access/qnetworkcookie.h
index ef309a8..922a6f5 100644
--- a/src/network/access/qnetworkcookie.h
+++ b/src/network/access/qnetworkcookie.h
@@ -67,7 +67,9 @@ public:
Full
};
- QNetworkCookie(const QByteArray &name = QByteArray(), const QByteArray &value = QByteArray());
+ QNetworkCookie();
+ QNetworkCookie(const QByteArray &name );
+ QNetworkCookie(const QByteArray &name, const QByteArray &value );
QNetworkCookie(const QNetworkCookie &other);
~QNetworkCookie();
QNetworkCookie &operator=(const QNetworkCookie &other);
diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp
index 50aaa6a..3b00451 100644
--- a/src/network/access/qnetworkdiskcache.cpp
+++ b/src/network/access/qnetworkdiskcache.cpp
@@ -45,6 +45,7 @@
#include "qnetworkdiskcache.h"
#include "qnetworkdiskcache_p.h"
+#include "QtCore/qscopedpointer.h"
#include <qfile.h>
#include <qdir.h>
@@ -196,8 +197,7 @@ QIODevice *QNetworkDiskCache::prepare(const QNetworkCacheMetaData &metaData)
break;
}
}
-
- QCacheItem *cacheItem = new QCacheItem;
+ QScopedPointer<QCacheItem> cacheItem(new QCacheItem);
cacheItem->metaData = metaData;
QIODevice *device = 0;
@@ -206,16 +206,20 @@ QIODevice *QNetworkDiskCache::prepare(const QNetworkCacheMetaData &metaData)
device = &(cacheItem->data);
} else {
QString templateName = d->tmpCacheFileName();
- cacheItem->file = new QTemporaryFile(templateName, &cacheItem->data);
- if (!cacheItem->file->open()) {
+ QT_TRY {
+ cacheItem->file = new QTemporaryFile(templateName, &cacheItem->data);
+ } QT_CATCH(...) {
+ cacheItem->file = 0;
+ }
+ if (!cacheItem->file || !cacheItem->file->open()) {
qWarning() << "QNetworkDiskCache::prepare() unable to open temporary file";
- delete cacheItem;
+ cacheItem.reset();
return 0;
}
cacheItem->writeHeader(cacheItem->file);
device = cacheItem->file;
}
- d->inserting[device] = cacheItem;
+ d->inserting[device] = cacheItem.take();
return device;
}
@@ -374,31 +378,28 @@ QIODevice *QNetworkDiskCache::data(const QUrl &url)
qDebug() << "QNetworkDiskCache::data()" << url;
#endif
Q_D(QNetworkDiskCache);
- QBuffer *buffer = 0;
+ QScopedPointer<QBuffer> buffer;
if (!url.isValid())
- return buffer;
+ return 0;
if (d->lastItem.metaData.url() == url && d->lastItem.data.isOpen()) {
- buffer = new QBuffer;
+ buffer.reset(new QBuffer);
buffer->setData(d->lastItem.data.data());
} else {
- QFile *file = new QFile(d->cacheFileName(url));
- if (!file->open(QFile::ReadOnly | QIODevice::Unbuffered)) {
- delete file;
+ QScopedPointer<QFile> file(new QFile(d->cacheFileName(url)));
+ if (!file->open(QFile::ReadOnly | QIODevice::Unbuffered))
return 0;
- }
- if (!d->lastItem.read(file, true)) {
+
+ if (!d->lastItem.read(file.data(), true)) {
file->close();
remove(url);
- delete file;
return 0;
}
if (d->lastItem.data.isOpen()) {
// compressed
- buffer = new QBuffer;
+ buffer.reset(new QBuffer);
buffer->setData(d->lastItem.data.data());
- delete file;
} else {
- buffer = new QBuffer;
+ buffer.reset(new QBuffer);
// ### verify that QFile uses the fd size and not the file name
qint64 size = file->size() - file->pos();
const uchar *p = 0;
@@ -406,16 +407,15 @@ QIODevice *QNetworkDiskCache::data(const QUrl &url)
p = file->map(file->pos(), size);
#endif
if (p) {
- file->setParent(buffer);
buffer->setData((const char *)p, size);
+ file.take()->setParent(buffer.data());
} else {
buffer->setData(file->readAll());
- delete file;
}
}
}
buffer->open(QBuffer::ReadOnly);
- return buffer;
+ return buffer.take();
}
/*!
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index c1fc87d..caa8669 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -221,10 +221,9 @@ public:
url = other.url;
#ifndef QT_NO_OPENSSL
+ sslConfiguration = 0;
if (other.sslConfiguration)
sslConfiguration = new QSslConfiguration(*other.sslConfiguration);
- else
- sslConfiguration = 0;
#endif
}
@@ -243,6 +242,18 @@ public:
};
/*!
+ Constructs a QNetworkRequest object with empty QUrl.
+
+ \sa url(), setUrl()
+*/
+QNetworkRequest::QNetworkRequest()
+ : d(new QNetworkRequestPrivate)
+{
+ d->url = QUrl();
+}
+
+
+/*!
Constructs a QNetworkRequest object with \a url as the URL to be
requested.
diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h
index 1ea7934..a53aed3 100644
--- a/src/network/access/qnetworkrequest.h
+++ b/src/network/access/qnetworkrequest.h
@@ -87,7 +87,9 @@ public:
AlwaysCache
};
- explicit QNetworkRequest(const QUrl &url = QUrl());
+
+ explicit QNetworkRequest();
+ explicit QNetworkRequest(const QUrl &url);
QNetworkRequest(const QNetworkRequest &other);
~QNetworkRequest();
QNetworkRequest &operator=(const QNetworkRequest &other);
diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri
index 8aa6ff4..bf07aab 100644
--- a/src/network/kernel/kernel.pri
+++ b/src/network/kernel/kernel.pri
@@ -20,7 +20,8 @@ SOURCES += kernel/qauthenticator.cpp \
kernel/qnetworkproxy.cpp \
kernel/qnetworkinterface.cpp
-unix:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp
+symbian: SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_symbian.cpp
+unix:!symbian:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp
win32:SOURCES += kernel/qhostinfo_win.cpp kernel/qnetworkinterface_win.cpp
mac:LIBS+= -framework SystemConfiguration
diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp
index 9230b3a..634a9b8 100644
--- a/src/network/kernel/qhostaddress.cpp
+++ b/src/network/kernel/qhostaddress.cpp
@@ -523,7 +523,7 @@ QHostAddress::QHostAddress(const struct sockaddr *sockaddr)
Constructs a copy of the given \a address.
*/
QHostAddress::QHostAddress(const QHostAddress &address)
- : d(new QHostAddressPrivate(*address.d))
+ : d(new QHostAddressPrivate(*address.d.data()))
{
}
@@ -559,7 +559,6 @@ QHostAddress::QHostAddress(SpecialAddress address)
*/
QHostAddress::~QHostAddress()
{
- delete d;
}
/*!
@@ -568,7 +567,7 @@ QHostAddress::~QHostAddress()
*/
QHostAddress &QHostAddress::operator=(const QHostAddress &address)
{
- *d = *address.d;
+ *d.data() = *address.d.data();
return *this;
}
diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h
index e8e9d9a..e92ca14 100644
--- a/src/network/kernel/qhostaddress.h
+++ b/src/network/kernel/qhostaddress.h
@@ -44,6 +44,7 @@
#include <QtCore/qpair.h>
#include <QtCore/qstring.h>
+#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qabstractsocket.h>
struct sockaddr;
@@ -130,7 +131,7 @@ public:
static QPair<QHostAddress, int> parseSubnet(const QString &subnet);
protected:
- QHostAddressPrivate *d;
+ QScopedPointer<QHostAddressPrivate> d;
};
inline bool operator ==(QHostAddress::SpecialAddress address1, const QHostAddress &address2)
diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp
index de1a9e9..7d89d68 100644
--- a/src/network/kernel/qhostinfo.cpp
+++ b/src/network/kernel/qhostinfo.cpp
@@ -42,6 +42,7 @@
#include "qhostinfo.h"
#include "qhostinfo_p.h"
+#include "QtCore/qscopedpointer.h"
#include <qabstracteventdispatcher.h>
#include <private/qunicodetables_p.h>
#include <qcoreapplication.h>
@@ -165,24 +166,24 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver,
// Support for IDNA
QString lookup = QString::fromLatin1(QUrl::toAce(name));
- QHostInfoResult *result = new QHostInfoResult;
- result->autoDelete = false;
- QObject::connect(result, SIGNAL(resultsReady(QHostInfo)),
+ QScopedPointer<QHostInfoResult> result(new QHostInfoResult);
+ result.data()->autoDelete = false;
+ QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)),
receiver, member);
- int id = result->lookupId = theIdCounter.fetchAndAddRelaxed(1);
+ int id = result.data()->lookupId = theIdCounter.fetchAndAddRelaxed(1);
if (lookup.isEmpty()) {
QHostInfo info(id);
info.setError(QHostInfo::HostNotFound);
info.setErrorString(QObject::tr("No host name given"));
- QMetaObject::invokeMethod(result, "emitResultsReady", Qt::QueuedConnection,
+ QMetaObject::invokeMethod(result.data(), "emitResultsReady", Qt::QueuedConnection,
Q_ARG(QHostInfo, info));
- result->autoDelete = true;
+ result.take()->autoDelete = true;
return id;
}
QHostInfoAgent *agent = theAgent();
- agent->addHostName(lookup, result);
+ agent->addHostName(lookup, result.take());
#if !defined QT_NO_THREAD
if (!agent->isRunning())
@@ -327,7 +328,7 @@ QHostInfo::QHostInfo(int id)
Constructs a copy of \a other.
*/
QHostInfo::QHostInfo(const QHostInfo &other)
- : d(new QHostInfoPrivate(*other.d))
+ : d(new QHostInfoPrivate(*other.d.data()))
{
}
@@ -337,7 +338,7 @@ QHostInfo::QHostInfo(const QHostInfo &other)
*/
QHostInfo &QHostInfo::operator=(const QHostInfo &other)
{
- *d = *other.d;
+ *d.data() = *other.d.data();
return *this;
}
@@ -346,7 +347,6 @@ QHostInfo &QHostInfo::operator=(const QHostInfo &other)
*/
QHostInfo::~QHostInfo()
{
- delete d;
}
/*!
diff --git a/src/network/kernel/qhostinfo.h b/src/network/kernel/qhostinfo.h
index 2be809f..f33c87a 100644
--- a/src/network/kernel/qhostinfo.h
+++ b/src/network/kernel/qhostinfo.h
@@ -43,6 +43,7 @@
#define QHOSTINFO_H
#include <QtCore/qlist.h>
+#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qhostaddress.h>
QT_BEGIN_HEADER
@@ -91,7 +92,7 @@ public:
static QString localDomainName();
private:
- QHostInfoPrivate *d;
+ QScopedPointer<QHostInfoPrivate> d;
};
QT_END_NAMESPACE
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index 64e9e29..a63659e 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -41,8 +41,6 @@
//#define QHOSTINFO_DEBUG
-static const int RESOLVER_TIMEOUT = 2000;
-
#include "qplatformdefs.h"
#include "qhostinfo_p.h"
@@ -151,7 +149,7 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
if (address.setAddress(hostName)) {
// Reverse lookup
// Reverse lookups using getnameinfo are broken on darwin, use gethostbyaddr instead.
-#if !defined (QT_NO_GETADDRINFO) && !defined (Q_OS_DARWIN)
+#if !defined (QT_NO_GETADDRINFO) && !defined (Q_OS_DARWIN) && !defined (Q_OS_SYMBIAN)
sockaddr_in sa4;
#ifndef QT_NO_IPV6
sockaddr_in6 sa6;
@@ -326,6 +324,7 @@ QString QHostInfo::localDomainName()
if (local_res_ninit) {
// using thread-safe version
res_state_ptr state = res_state_ptr(qMalloc(sizeof(*state)));
+ Q_CHECK_PTR(state);
memset(state, 0, sizeof(*state));
local_res_ninit(state);
QString domainName = QUrl::fromAce(state->defdname);
diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp
index 9cab861..953722c 100644
--- a/src/network/kernel/qnetworkinterface.cpp
+++ b/src/network/kernel/qnetworkinterface.cpp
@@ -170,7 +170,7 @@ QNetworkAddressEntry::QNetworkAddressEntry()
object \a other.
*/
QNetworkAddressEntry::QNetworkAddressEntry(const QNetworkAddressEntry &other)
- : d(new QNetworkAddressEntryPrivate(*other.d))
+ : d(new QNetworkAddressEntryPrivate(*other.d.data()))
{
}
@@ -179,7 +179,7 @@ QNetworkAddressEntry::QNetworkAddressEntry(const QNetworkAddressEntry &other)
*/
QNetworkAddressEntry &QNetworkAddressEntry::operator=(const QNetworkAddressEntry &other)
{
- *d = *other.d;
+ *d.data() = *other.d.data();
return *this;
}
@@ -188,7 +188,6 @@ QNetworkAddressEntry &QNetworkAddressEntry::operator=(const QNetworkAddressEntry
*/
QNetworkAddressEntry::~QNetworkAddressEntry()
{
- delete d;
}
/*!
@@ -604,8 +603,13 @@ QDebug operator<<(QDebug debug, const QNetworkInterface &networkInterface)
<< ", hardware address = " << networkInterface.hardwareAddress()
<< ", flags = ";
flagsDebug(debug, networkInterface.flags());
+#if defined(Q_CC_RVCT)
+ // RVCT gets confused with << networkInterface.addressEntries(), reason unknown.
+ debug.nospace() << ")\n";
+#else
debug.nospace() << ", entries = " << networkInterface.addressEntries()
<< ")\n";
+#endif
return debug.space();
}
#endif
diff --git a/src/network/kernel/qnetworkinterface.h b/src/network/kernel/qnetworkinterface.h
index 93849a0..052ecd8 100644
--- a/src/network/kernel/qnetworkinterface.h
+++ b/src/network/kernel/qnetworkinterface.h
@@ -43,6 +43,7 @@
#define QNETWORKINTERFACE_H
#include <QtCore/qshareddata.h>
+#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qhostaddress.h>
#ifndef QT_NO_NETWORKINTERFACE
@@ -79,7 +80,7 @@ public:
void setBroadcast(const QHostAddress &newBroadcast);
private:
- QNetworkAddressEntryPrivate *d;
+ QScopedPointer<QNetworkAddressEntryPrivate> d;
};
class QNetworkInterfacePrivate;
diff --git a/src/network/kernel/qnetworkinterface_symbian.cpp b/src/network/kernel/qnetworkinterface_symbian.cpp
new file mode 100644
index 0000000..59f1c02
--- /dev/null
+++ b/src/network/kernel/qnetworkinterface_symbian.cpp
@@ -0,0 +1,203 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//#define QNETWORKINTERFACE_DEBUG
+
+//#include "qset.h"
+#include "qnetworkinterface.h"
+#include "qnetworkinterface_p.h"
+//#include <private/qnativesocketengine_p.h>
+//#include "qalgorithms.h"
+
+
+#ifndef QT_NO_NETWORKINTERFACE
+
+#include <in_sock.h>
+#include <in_iface.h>
+#include <es_sock.h>
+
+//#include <sys/types.h>
+//#include <sys/socket.h>
+//#include <errno.h>
+//#include <net/if.h>
+//#include <qplatformdefs.h>
+
+QT_BEGIN_NAMESPACE
+
+
+static QNetworkInterface::InterfaceFlags convertFlags( const TSoInetInterfaceInfo& aInfo )
+{
+ QNetworkInterface::InterfaceFlags flags = 0;
+ flags |= (aInfo.iState == EIfUp) ? QNetworkInterface::IsUp : QNetworkInterface::InterfaceFlag(0);
+ // We do not have separate flag for running in Symbian OS
+ flags |= (aInfo.iState == EIfUp) ? QNetworkInterface::IsRunning : QNetworkInterface::InterfaceFlag(0);
+ flags |= (aInfo.iFeatures&KIfCanBroadcast) ? QNetworkInterface::CanBroadcast : QNetworkInterface::InterfaceFlag(0);
+ flags |= (aInfo.iFeatures&KIfIsLoopback) ? QNetworkInterface::IsLoopBack : QNetworkInterface::InterfaceFlag(0);
+ flags |= (aInfo.iFeatures&KIfIsPointToPoint) ? QNetworkInterface::IsPointToPoint : QNetworkInterface::InterfaceFlag(0);
+ flags |= (aInfo.iFeatures&KIfCanMulticast) ? QNetworkInterface::CanMulticast : QNetworkInterface::InterfaceFlag(0);
+ return flags;
+}
+
+QString qstringFromDesc( const TDesC& aData )
+{
+ return QString::fromUtf16(aData.Ptr(), aData.Length());
+}
+
+static QList<QNetworkInterfacePrivate *> interfaceListing()
+{
+ TInt err( KErrNone );
+ QList<QNetworkInterfacePrivate *> interfaces;
+
+ // Connect to Native socket server
+ RSocketServ socketServ;
+ err = socketServ.Connect();
+ if( err )
+ return interfaces;
+
+ // Open dummy socket for interface queries
+ RSocket socket;
+ err = socket.Open( socketServ, _L("udp"));
+ if( err )
+ {
+ socketServ.Close();
+ return interfaces;
+ }
+
+ // Ask socket to start enumerating interfaces
+ err = socket.SetOpt( KSoInetEnumInterfaces, KSolInetIfCtrl );
+ if( err )
+ {
+ socket.Close();
+ socketServ.Close();
+ return interfaces;
+ }
+
+ int ifindex = 0;
+ TPckgBuf<TSoInetInterfaceInfo> infoPckg;
+ TSoInetInterfaceInfo &info = infoPckg();
+ while( socket.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, infoPckg) == KErrNone )
+ {
+ // Do not include IPv6 addresses because netmask and broadcast address cannot be determined correctly
+ if( info.iName != KNullDesC && info.iAddress.IsV4Mapped() )
+ {
+ TName address;
+ QNetworkAddressEntry entry;
+ QNetworkInterfacePrivate *iface = 0;
+
+ iface = new QNetworkInterfacePrivate;
+ iface->index = ifindex++;
+ interfaces << iface;
+ iface->name = qstringFromDesc( info.iName );
+ iface->flags = convertFlags( info );
+
+ if( /*info.iFeatures&KIfHasHardwareAddr &&*/ info.iHwAddr.Family() != KAFUnspec )
+ {
+ for ( TInt i = sizeof(SSockAddr); i < sizeof(SSockAddr) + info.iHwAddr.GetUserLen(); i++ )
+ {
+ address.AppendNumFixedWidth(info.iHwAddr[i], EHex, 2);
+ if( ( i + 1) < sizeof(SSockAddr) + info.iHwAddr.GetUserLen() )
+ address.Append( _L(":") );
+ }
+ address.UpperCase();
+ iface->hardwareAddress = qstringFromDesc( address );
+ }
+
+ // Get the address of the interface
+ info.iAddress.Output(address);
+ entry.setIp( QHostAddress( qstringFromDesc( address ) ) );
+
+ // Get the interface netmask
+ // TODO: For some reason netmask is always 0.0.0.0
+ //info.iNetMask.Output(address);
+ //entry.setNetmask( QHostAddress( qstringFromDesc( address ) ) );
+
+ // Workaround: Let Symbian determine netmask based on IP address class
+ // TODO: works only for IPv4
+ TInetAddr netmask;
+ netmask.NetMask( info.iAddress );
+ netmask.Output(address);
+ entry.setNetmask( QHostAddress( qstringFromDesc( address ) ) );
+
+ // Get the interface broadcast address
+ if (iface->flags & QNetworkInterface::CanBroadcast)
+ {
+ // For some reason broadcast address is always 0.0.0.0
+ // info.iBrdAddr.Output(address);
+ // entry.setBroadcast( QHostAddress( qstringFromDesc( address ) ) );
+
+ // Workaround: Let Symbian determine broadcast address based on IP address
+ // TODO: works only for IPv4
+ TInetAddr broadcast;
+ broadcast.NetBroadcast( info.iAddress );
+ broadcast.Output(address);
+ entry.setBroadcast( QHostAddress( qstringFromDesc( address ) ) );
+ }
+
+ // Add new entry to interface address entries
+ iface->addressEntries << entry;
+
+#if defined(QNETWORKINTERFACE_DEBUG)
+ qDebug("\n Found network interface %s, interface flags:\n\
+ IsUp = %d, IsRunning = %d, CanBroadcast = %d,\n\
+ IsLoopBack = %d, IsPointToPoint = %d, CanMulticast = %d, \n\
+ ip = %s, netmask = %s, broadcast = %s,\n\
+ hwaddress = %s",
+ iface->name.toLatin1().constData(),
+ iface->flags & QNetworkInterface::IsUp, iface->flags & QNetworkInterface::IsRunning, iface->flags & QNetworkInterface::CanBroadcast,
+ iface->flags & QNetworkInterface::IsLoopBack, iface->flags & QNetworkInterface::IsPointToPoint, iface->flags & QNetworkInterface::CanMulticast,
+ entry.ip().toString().toLatin1().constData(), entry.netmask().toString().toLatin1().constData(), entry.broadcast().toString().toLatin1().constData(),
+ iface->hardwareAddress.toLatin1().constData());
+#endif
+ }
+ }
+ socket.Close();
+ socketServ.Close();
+ return interfaces;
+}
+
+QList<QNetworkInterfacePrivate *> QNetworkInterfaceManager::scan()
+{
+ return interfaceListing();
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_NETWORKINTERFACE
diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp
index 87902c3..1d700c3 100644
--- a/src/network/kernel/qnetworkinterface_win.cpp
+++ b/src/network/kernel/qnetworkinterface_win.cpp
@@ -110,6 +110,8 @@ static QHash<QHostAddress, QHostAddress> ipv4Netmasks()
if (retval == ERROR_BUFFER_OVERFLOW) {
// need more memory
pAdapter = (IP_ADAPTER_INFO *)qMalloc(bufSize);
+ if (!pAdapter)
+ return ipv4netmasks;
// try again
if (ptrGetAdaptersInfo(pAdapter, &bufSize) != ERROR_SUCCESS) {
qFree(pAdapter);
@@ -151,7 +153,8 @@ static QList<QNetworkInterfacePrivate *> interfaceListingWinXP()
if (retval == ERROR_BUFFER_OVERFLOW) {
// need more memory
pAdapter = (IP_ADAPTER_ADDRESSES *)qMalloc(bufSize);
-
+ if (!pAdapter)
+ return interfaces;
// try again
if (ptrGetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAdapter, &bufSize) != ERROR_SUCCESS) {
qFree(pAdapter);
@@ -231,7 +234,8 @@ static QList<QNetworkInterfacePrivate *> interfaceListingWin2k()
if (retval == ERROR_BUFFER_OVERFLOW) {
// need more memory
pAdapter = (IP_ADAPTER_INFO *)qMalloc(bufSize);
-
+ if (!pAdapter)
+ return interfaces;
// try again
if (ptrGetAdaptersInfo(pAdapter, &bufSize) != ERROR_SUCCESS) {
qFree(pAdapter);
@@ -301,7 +305,8 @@ QString QHostInfo::localDomainName()
pinfo = &info;
if (ptrGetNetworkParams(pinfo, &bufSize) == ERROR_BUFFER_OVERFLOW) {
pinfo = (FIXED_INFO *)qMalloc(bufSize);
-
+ if (!pinfo)
+ return QString();
// try again
if (ptrGetNetworkParams(pinfo, &bufSize) != ERROR_SUCCESS) {
qFree(pinfo);
diff --git a/src/network/network.pro b/src/network/network.pro
index d476b56..59cffd0 100644
--- a/src/network/network.pro
+++ b/src/network/network.pro
@@ -3,6 +3,13 @@
TARGET = QtNetwork
QPRO_PWD = $$PWD
DEFINES += QT_BUILD_NETWORK_LIB QT_NO_USING_NAMESPACE
+#DEFINES += QLOCALSERVER_DEBUG QLOCALSOCKET_DEBUG
+#DEFINES += QNETWORKDISKCACHE_DEBUG
+#DEFINES += QSSLSOCKET_DEBUG
+#DEFINES += QHOSTINFO_DEBUG
+#DEFINES += QABSTRACTSOCKET_DEBUG QNATIVESOCKETENGINE_DEBUG
+#DEFINES += QTCPSOCKETENGINE_DEBUG QTCPSOCKET_DEBUG QTCPSERVER_DEBUG QSSLSOCKET_DEBUG
+#DEFINES += QUDPSOCKET_DEBUG QUDPSERVER_DEBUG
QT = core
win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x64000000
@@ -15,3 +22,10 @@ include(socket/socket.pri)
include(ssl/ssl.pri)
QMAKE_LIBS += $$QMAKE_LIBS_NETWORK
+
+
+symbian {
+ TARGET.UID3=0x2001B2DE
+ LIBS += -lesock -linsock
+}
+
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index c8ddce0..035d5b6 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -1067,8 +1067,9 @@ void QAbstractSocketPrivate::_q_abortConnectionAttempt()
#if defined(QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocketPrivate::_q_abortConnectionAttempt() (timed out)");
#endif
- if (socketEngine)
+ if (socketEngine) {
socketEngine->setWriteNotificationEnabled(false);
+ }
connectTimer->stop();
if (addresses.isEmpty()) {
diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp
index 1a50dc4..7bb0b01 100644
--- a/src/network/socket/qlocalserver.cpp
+++ b/src/network/socket/qlocalserver.cpp
@@ -274,6 +274,10 @@ QLocalSocket *QLocalServer::nextPendingConnection()
if (d->pendingConnections.isEmpty())
return 0;
QLocalSocket *nextSocket = d->pendingConnections.dequeue();
+#ifdef Q_OS_SYMBIAN
+ if(!d->socketNotifier)
+ return nextSocket;
+#endif
#ifndef QT_LOCALSOCKET_TCP
if (d->pendingConnections.size() <= d->maxPendingConnections)
#ifndef Q_OS_WIN
diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp
index 3df6b6a..14a0c78 100644
--- a/src/network/socket/qlocalserver_unix.cpp
+++ b/src/network/socket/qlocalserver_unix.cpp
@@ -111,6 +111,24 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
::memcpy(addr.sun_path, fullServerName.toLatin1().data(),
fullServerName.toLatin1().size() + 1);
+#ifdef Q_OS_SYMBIAN
+ // In SYMBIAN OS it can currently happen that accept is called twice,
+ // once from waitForNewConnection and once via QSocketNotfier activity
+ //
+ // As an workaround, we set the socket to non blocking so possible
+ // subsequent call to accept will not block in any case
+ //
+ // This change can be removed once more generic fix to select thread
+ // syncronization problem is implemented.
+ int flags = fcntl(listenSocket, F_GETFL, 0);
+ if (-1 == flags
+ || -1 == (fcntl(listenSocket, F_SETFL, flags | O_NONBLOCK))) {
+ setError(QLatin1String("QLocalServer::listen"));
+ closeServer();
+ return false;
+ }
+#endif
+
// bind
if(-1 == QT_SOCKET_BIND(listenSocket, (sockaddr *)&addr, sizeof(sockaddr_un))) {
setError(QLatin1String("QLocalServer::listen"));
diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp
index 08d94ef..835b922 100644
--- a/src/network/socket/qlocalsocket_unix.cpp
+++ b/src/network/socket/qlocalsocket_unix.cpp
@@ -242,7 +242,7 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode)
QLatin1String("QLocalSocket::connectToServer"));
return;
}
-
+#ifndef Q_OS_SYMBIAN
// set non blocking so we can try to connect and it wont wait
int flags = fcntl(d->connectingSocket, F_GETFL, 0);
if (-1 == flags
@@ -251,6 +251,7 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode)
QLatin1String("QLocalSocket::connectToServer"));
return;
}
+#endif
// _q_connectToSocket does the actual connecting
d->connectingName = name;
@@ -305,10 +306,11 @@ void QLocalSocketPrivate::_q_connectToSocket()
case ETIMEDOUT:
errorOccurred(QLocalSocket::SocketTimeoutError, function);
break;
+ case EINPROGRESS:
case EAGAIN:
// Try again later, all of the sockets listening are full
if (!delayConnect) {
- delayConnect = new QSocketNotifier(connectingSocket, QSocketNotifier::Write);
+ delayConnect = new QSocketNotifier(connectingSocket, QSocketNotifier::Write, q);
q->connect(delayConnect, SIGNAL(activated(int)), q, SLOT(_q_connectToSocket()));
}
if (!connectTimer) {
@@ -519,9 +521,9 @@ bool QLocalSocket::waitForConnected(int msec)
if (state() != ConnectingState)
return (state() == ConnectedState);
- fd_set readfds;
- FD_ZERO(&readfds);
- FD_SET(d->connectingSocket, &readfds);
+ fd_set fds;
+ FD_ZERO(&fds);
+ FD_SET(d->connectingSocket, &fds);
timeval timeout;
timeout.tv_sec = msec / 1000;
@@ -537,7 +539,14 @@ bool QLocalSocket::waitForConnected(int msec)
timer.start();
while (state() == ConnectingState
&& (-1 == msec || timer.elapsed() < msec)) {
- result = ::select(d->connectingSocket + 1, &readfds, 0, 0, &timeout);
+#ifdef Q_OS_SYMBIAN
+ // On Symbian, ready-to-write is signaled when non-blocking socket
+ // connect is finised. Is ready-to-read really used on other
+ // UNIX paltforms when using non-blocking AF_UNIX socket?
+ result = ::select(d->connectingSocket + 1, 0, &fds, 0, &timeout);
+#else
+ result = ::select(d->connectingSocket + 1, &fds, 0, 0, &timeout);
+#endif
if (-1 == result && errno != EINTR) {
d->errorOccurred( QLocalSocket::UnknownSocketError,
QLatin1String("QLocalSocket::waitForConnected"));
diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp
index aa70b0c..666c86e 100644
--- a/src/network/socket/qnativesocketengine.cpp
+++ b/src/network/socket/qnativesocketengine.cpp
@@ -381,11 +381,13 @@ bool QNativeSocketEngine::initialize(QAbstractSocket::SocketType socketType, QAb
return false;
}
+
// Make sure we receive out-of-band data
+ // On Symbian OS this works only with native IP stack, not with WinSock
if (socketType == QAbstractSocket::TcpSocket
&& !setOption(ReceiveOutOfBandData, 1)) {
qWarning("QNativeSocketEngine::initialize unable to inline out-of-band data");
- }
+ }
// Set the send and receive buffer sizes to a magic size, found
// most optimal for our platforms.
@@ -1086,10 +1088,13 @@ protected:
bool QExceptionNotifier::event(QEvent *e)
{
if (e->type() == QEvent::SockAct) {
- engine->exceptionNotification();
+ if (engine->state() == QAbstractSocket::ConnectingState)
+ engine->connectionNotification();
+ else
+ engine->exceptionNotification();
return true;
}
- return QSocketNotifier::event(e);
+ return QSocketNotifier::event(e);
}
void QNativeSocketEngine::setReadNotificationEnabled(bool enable)
diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h
index 24dc344..0a5c19d 100644
--- a/src/network/socket/qnativesocketengine_p.h
+++ b/src/network/socket/qnativesocketengine_p.h
@@ -52,7 +52,6 @@
//
// We mean it.
//
-
#include "QtNetwork/qhostaddress.h"
#include "private/qabstractsocketengine_p.h"
#ifndef Q_OS_WIN
@@ -61,8 +60,139 @@
# include <winsock2.h>
#endif
+#ifdef Q_OS_SYMBIAN
+#include <private/qeventdispatcher_symbian_p.h>
+#include<unistd.h>
+#endif
+
QT_BEGIN_NAMESPACE
+static inline int qt_socket_connect(int s, const struct sockaddr * addrptr, socklen_t namelen)
+{
+ return ::connect(s, addrptr, namelen);
+}
+#if defined(connect)
+# undef connect
+#endif
+
+static inline int qt_socket_bind(int s, const struct sockaddr * addrptr, socklen_t namelen)
+{
+ return ::bind(s, addrptr, namelen);
+}
+#if defined(bind)
+# undef bind
+#endif
+
+static inline int qt_socket_write(int socket, const char *data, qint64 len)
+{
+ return ::write(socket, data, len);
+}
+#if defined(write)
+# undef write
+#endif
+
+static inline int qt_socket_read(int socket, char *data, qint64 len)
+{
+ return ::read(socket, data, len);
+}
+#if defined(read)
+# undef read
+#endif
+
+static inline int qt_socket_recv(int socket, void *data, size_t length, int flags)
+{
+ return ::recv(socket, data, length, flags);
+}
+#if defined(recv)
+# undef recv
+#endif
+
+static inline int qt_socket_recvfrom(int socket, void *data, size_t length,
+ int flags, struct sockaddr *address,
+ socklen_t *address_length)
+{
+ return ::recvfrom(socket, data, length, flags, address, address_length);
+}
+#if defined(recvfrom)
+# undef recvfrom
+#endif
+
+static inline int qt_socket_sendto(int socket, const void *data, size_t length,
+ int flags, const struct sockaddr *dest_addr,
+ socklen_t dest_length)
+{
+ return ::sendto(socket, data, length, flags, dest_addr, dest_length);
+}
+#if defined(sendto)
+# undef sendto
+#endif
+static inline int qt_socket_close(int socket)
+{
+ return ::close(socket);
+}
+#if defined(close)
+# undef close
+#endif
+
+static inline int qt_socket_fcntl(int socket, int command, int option)
+{
+ return ::fcntl(socket, command, option);
+}
+#if defined(fcntl)
+# undef fcntl
+#endif
+
+static inline int qt_socket_ioctl(int socket, int command, char *option)
+{
+ return ::ioctl(socket, command, option);
+}
+#if defined(ioctl)
+# undef ioctl
+#endif
+
+static inline int qt_socket_getsockname(int socket, struct sockaddr *address, socklen_t *address_len)
+{
+ return ::getsockname(socket, address, address_len);
+}
+#if defined(getsockname)
+# undef getsockname
+#endif
+
+static inline int qt_socket_getpeername(int socket, struct sockaddr *address, socklen_t *address_len)
+{
+ return ::getpeername(socket, address, address_len);
+}
+#if defined(getpeername)
+# undef getpeername
+#endif
+
+static inline int qt_socket_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
+{
+ return ::select(nfds, readfds, writefds, exceptfds, timeout);
+}
+
+#if defined(select)
+# undef select
+#endif
+
+static inline int qt_socket_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlen)
+{
+ return ::getsockopt(socket, level, optname, optval, optlen);
+}
+
+#if defined(getsockopt)
+# undef getsockopt
+#endif
+
+static inline int qt_socket_setsockopt(int socket, int level, int optname, void *optval, socklen_t optlen)
+{
+ return ::setsockopt(socket, level, optname, optval, optlen);
+}
+
+#if defined(setsockopt)
+# undef setsockopt
+#endif
+
// Use our own defines and structs which we know are correct
# define QT_SS_MAXSIZE 128
# define QT_SS_ALIGNSIZE (sizeof(qint64))
@@ -183,6 +313,12 @@ public:
int socketDescriptor;
+#if !defined(QT_NO_IPV6)
+ struct sockaddr_storage aa;
+#else
+ struct sockaddr_in aa;
+#endif
+
QSocketNotifier *readNotifier, *writeNotifier, *exceptNotifier;
#ifdef Q_OS_WIN
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 6f9ee1a..7584357 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -40,7 +40,6 @@
****************************************************************************/
//#define QNATIVESOCKETENGINE_DEBUG
-
#include "qnativesocketengine_p.h"
#include "private/qnet_unix_p.h"
#include "qiodevice.h"
@@ -60,12 +59,21 @@
#include <arpa/inet.h>
#endif
+#ifdef Q_OS_SYMBIAN
+#include <private/qeventdispatcher_symbian_p.h>
+#endif
+
#if defined QNATIVESOCKETENGINE_DEBUG
#include <qstring.h>
#include <ctype.h>
#endif
+#ifdef Q_OS_SYMBIAN // ### TODO: Are these headers right?
+#include <sys/socket.h>
+#include <netinet/in.h>
+#else
#include <netinet/tcp.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -103,6 +111,7 @@ static QByteArray qt_prettyDebug(const char *data, int len, int maxSize)
static void qt_ignore_sigpipe()
{
+#ifndef Q_NO_POSIX_SIGNALS
// Set to ignore SIGPIPE once only.
static QBasicAtomicInt atom = Q_BASIC_ATOMIC_INITIALIZER(0);
if (atom.testAndSetRelaxed(0, 1)) {
@@ -111,6 +120,10 @@ static void qt_ignore_sigpipe()
noaction.sa_handler = SIG_IGN;
::sigaction(SIGPIPE, &noaction, 0);
}
+#else
+ // Posix signals are not supported by the underlying platform
+ // so we don't need to ignore sigpipe signal explicitly
+#endif
}
/*
@@ -129,7 +142,7 @@ static inline void qt_socket_getPortAndAddress(const qt_sockaddr *s, quint16 *po
*addr = tmpAddress;
#ifndef QT_NO_IPV6IFNAME
char scopeid[IFNAMSIZ];
- if (::if_indextoname(s->a6.sin6_scope_id, scopeid) > 0) {
+ if (::if_indextoname(s->a6.sin6_scope_id, scopeid)) {
addr->setScopeId(QLatin1String(scopeid));
} else
#endif
@@ -190,7 +203,8 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc
}
// Ensure that the socket is closed on exec*().
- ::fcntl(socket, F_SETFD, FD_CLOEXEC);
+ qt_socket_fcntl(socket, F_SETFD, FD_CLOEXEC);
+
socketDescriptor = socket;
return true;
}
@@ -237,8 +251,9 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co
int v = -1;
QT_SOCKOPTLEN_T len = sizeof(v);
- if (::getsockopt(socketDescriptor, level, n, (char *) &v, &len) != -1)
+ if (qt_socket_getsockopt(socketDescriptor, level, n, (char *) &v, &len) != -1)
return v;
+
return -1;
}
@@ -268,14 +283,14 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
case QNativeSocketEngine::NonBlockingSocketOption: {
// Make the socket nonblocking.
#if !defined(Q_OS_VXWORKS)
- int flags = ::fcntl(socketDescriptor, F_GETFL, 0);
+ int flags = qt_socket_fcntl(socketDescriptor, F_GETFL, 0);
if (flags == -1) {
#ifdef QNATIVESOCKETENGINE_DEBUG
perror("QNativeSocketEnginePrivate::setOption(): fcntl(F_GETFL) failed");
#endif
return false;
}
- if (::fcntl(socketDescriptor, F_SETFL, flags | O_NONBLOCK) == -1) {
+ if (qt_socket_fcntl(socketDescriptor, F_SETFL, flags | O_NONBLOCK) == -1) {
#ifdef QNATIVESOCKETENGINE_DEBUG
perror("QNativeSocketEnginePrivate::setOption(): fcntl(F_SETFL) failed");
#endif
@@ -293,7 +308,9 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
return true;
}
case QNativeSocketEngine::AddressReusable:
-#ifdef SO_REUSEPORT
+#ifdef Q_OS_SYMBIAN
+ n = SO_REUSEADDR;
+#elif SO_REUSEPORT
n = SO_REUSEPORT;
#else
n = SO_REUSEADDR;
@@ -313,11 +330,15 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
break;
}
- return ::setsockopt(socketDescriptor, level, n, (char *) &v, sizeof(v)) == 0;
+ return qt_socket_setsockopt(socketDescriptor, level, n, (char *) &v, sizeof(v)) == 0;
}
bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &addr, quint16 port)
{
+#ifdef QNATIVESOCKETENGINE_DEBUG
+ qDebug("QNativeSocketEnginePrivate::nativeConnect() : %d ", socketDescriptor);
+#endif
+
struct sockaddr_in sockAddrIPv4;
struct sockaddr *sockAddrPtr = 0;
QT_SOCKLEN_T sockAddrSize = 0;
@@ -356,7 +377,8 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &addr, quint16
// unreachable
}
- int connectResult = QT_SOCKET_CONNECT(socketDescriptor, sockAddrPtr, sockAddrSize);
+ int connectResult = qt_socket_connect(socketDescriptor, sockAddrPtr, sockAddrSize);
+
if (connectResult == -1) {
switch (errno) {
case EISCONN:
@@ -459,7 +481,8 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &address, quint16
// unreachable
}
- int bindResult = QT_SOCKET_BIND(socketDescriptor, sockAddrPtr, sockAddrSize);
+ int bindResult = qt_socket_bind(socketDescriptor, sockAddrPtr, sockAddrSize);
+
if (bindResult < 0) {
switch(errno) {
case EADDRINUSE:
@@ -527,8 +550,15 @@ int QNativeSocketEnginePrivate::nativeAccept()
#if defined (QNATIVESOCKETENGINE_DEBUG)
qDebug("QNativeSocketEnginePrivate::nativeAccept() == %i", acceptedDescriptor);
#endif
- // Ensure that the socket is closed on exec*()
- ::fcntl(acceptedDescriptor, F_SETFD, FD_CLOEXEC);
+
+ //check if we have vaild descriptor at all
+ if(acceptedDescriptor > 0) {
+ // Ensure that the socket is closed on exec*()
+ qt_socket_fcntl(acceptedDescriptor, F_SETFD, FD_CLOEXEC);
+ } else {
+ qWarning("QNativeSocketEnginePrivate::nativeAccept() - acceptedDescriptor <= 0");
+ }
+
return acceptedDescriptor;
}
@@ -558,7 +588,7 @@ bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const
ssize_t readBytes;
do {
char c;
- readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize);
+ readBytes = qt_socket_recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize);
} while (readBytes == -1 && errno == EINTR);
// If there's no error, or if our buffer was too small, there must be a
@@ -572,16 +602,25 @@ bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const
return result;
}
+#ifdef Q_OS_SYMBIAN
+qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const
+{
+ size_t nbytes = 0;
+ qt_socket_ioctl(socketDescriptor, E32IONREAD, (char *) &nbytes);
+ return qint64(nbytes-28);
+}
+#else
qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const
{
QVarLengthArray<char, 8192> udpMessagePeekBuffer(8192);
ssize_t recvResult = -1;
+
for (;;) {
// the data written to udpMessagePeekBuffer is discarded, so
// this function is still reentrant although it might not look
// so.
- recvResult = ::recv(socketDescriptor, udpMessagePeekBuffer.data(),
- udpMessagePeekBuffer.size(), MSG_PEEK);
+ recvResult = qt_socket_recv(socketDescriptor, udpMessagePeekBuffer.data(),
+ udpMessagePeekBuffer.size(), MSG_PEEK);
if (recvResult == -1 && errno == EINTR)
continue;
@@ -597,7 +636,7 @@ qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const
return qint64(recvResult);
}
-
+#endif
qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxSize,
QHostAddress *address, quint16 *port)
{
@@ -609,7 +648,7 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS
ssize_t recvFromResult = 0;
do {
char c;
- recvFromResult = ::recvfrom(socketDescriptor, maxSize ? data : &c, maxSize ? maxSize : 1,
+ recvFromResult = qt_socket_recvfrom(socketDescriptor, maxSize ? data : &c, maxSize ? maxSize : 1,
0, &aa.a, &sz);
} while (recvFromResult == -1 && errno == EINTR);
@@ -660,7 +699,6 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l
// ignore the SIGPIPE signal
qt_ignore_sigpipe();
-
ssize_t sentBytes = qt_safe_sendto(socketDescriptor, data, len,
0, sockAddrPtr, sockAddrSize);
@@ -698,7 +736,7 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
// Determine local address
memset(&sa, 0, sizeof(sa));
- if (::getsockname(socketDescriptor, &sa.a, &sockAddrSize) == 0) {
+ if (qt_socket_getsockname(socketDescriptor, &sa.a, &sockAddrSize) == 0) {
qt_socket_getPortAndAddress(&sa, &localPort, &localAddress);
// Determine protocol family
@@ -722,13 +760,13 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
}
// Determine the remote address
- if (!::getpeername(socketDescriptor, &sa.a, &sockAddrSize))
+ if (!qt_socket_getpeername(socketDescriptor, &sa.a, &sockAddrSize))
qt_socket_getPortAndAddress(&sa, &peerPort, &peerAddress);
// Determine the socket type (UDP/TCP)
int value = 0;
QT_SOCKOPTLEN_T valueSize = sizeof(int);
- if (::getsockopt(socketDescriptor, SOL_SOCKET, SO_TYPE, (char *) &value, &valueSize) == 0) {
+ if (qt_socket_getsockopt(socketDescriptor, SOL_SOCKET, SO_TYPE, &value, &valueSize) == 0) {
if (value == SOCK_STREAM)
socketType = QAbstractSocket::TcpSocket;
else if (value == SOCK_DGRAM)
@@ -759,7 +797,7 @@ void QNativeSocketEnginePrivate::nativeClose()
#if defined (QNATIVESOCKETENGINE_DEBUG)
qDebug("QNativeSocketEngine::nativeClose()");
#endif
- ::close(socketDescriptor);
+ qt_socket_close(socketDescriptor);
}
qint64 QNativeSocketEnginePrivate::nativeWrite(const char *data, qint64 len)
@@ -773,7 +811,8 @@ qint64 QNativeSocketEnginePrivate::nativeWrite(const char *data, qint64 len)
// of an interrupting signal.
ssize_t writtenBytes;
do {
- writtenBytes = QT_WRITE(socketDescriptor, data, len);
+ writtenBytes = qt_socket_write(socketDescriptor, data, len);
+ // writtenBytes = QT_WRITE(socketDescriptor, data, len); ### TODO S60: Should this line be removed or the one above it?
} while (writtenBytes < 0 && errno == EINTR);
if (writtenBytes < 0) {
@@ -815,7 +854,7 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxSize)
ssize_t r = 0;
do {
- r = ::read(socketDescriptor, data, maxSize);
+ r = qt_socket_read(socketDescriptor, data, maxSize);
} while (r == -1 && errno == EINTR);
if (r < 0) {
@@ -833,6 +872,9 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxSize)
case EIO:
setError(QAbstractSocket::NetworkError, ReadErrorString);
break;
+#ifdef Q_OS_SYMBIAN
+ case EPIPE:
+#endif
case ECONNRESET:
#if defined(Q_OS_VXWORKS)
case ESHUTDOWN:
@@ -863,11 +905,40 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) co
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
+#ifdef Q_OS_SYMBIAN
+ fd_set fdexec;
+ FD_ZERO(&fdexec);
+ FD_SET(socketDescriptor, &fdexec);
+#endif
+
int retval;
if (selectForRead)
+#ifndef Q_OS_SYMBIAN
retval = qt_safe_select(socketDescriptor + 1, &fds, 0, 0, timeout < 0 ? 0 : &tv);
+#else
+ retval = qt_safe_select(socketDescriptor + 1, &fds, 0, &fdexec, timeout < 0 ? 0 : &tv);
+#endif
else
+#ifndef Q_OS_SYMBIAN
retval = qt_safe_select(socketDescriptor + 1, 0, &fds, 0, timeout < 0 ? 0 : &tv);
+#else
+ retval = qt_safe_select(socketDescriptor + 1, 0, &fds, &fdexec, timeout < 0 ? 0 : &tv);
+#endif
+
+#ifdef Q_OS_SYMBIAN
+ bool selectForExec = false;
+ if(retval != 0) {
+ if(retval < 0) {
+ qWarning("nativeSelect(....) returned < 0 for socket %d", socketDescriptor);
+ }
+ selectForExec = FD_ISSET(socketDescriptor, &fdexec);
+ }
+ if(selectForExec) {
+ qWarning("nativeSelect (selectForRead %d, retVal %d, errno %d) Unexpected expectfds ready in fd %d",
+ selectForRead, retval, errno, socketDescriptor);
+ }
+#endif
+
return retval;
}
@@ -884,17 +955,69 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool c
if (checkWrite)
FD_SET(socketDescriptor, &fdwrite);
+#ifdef Q_OS_SYMBIAN
+ fd_set fdexec;
+ FD_ZERO(&fdexec);
+ FD_SET(socketDescriptor, &fdexec);
+#endif
+
struct timeval tv;
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
int ret;
+#ifndef Q_OS_SYMBIAN
ret = qt_safe_select(socketDescriptor + 1, &fdread, &fdwrite, 0, timeout < 0 ? 0 : &tv);
+#else
+ QTime timer;
+ timer.start();
+
+ do {
+ ret = qt_socket_select(socketDescriptor + 1, &fdread, &fdwrite, &fdexec, timeout < 0 ? 0 : &tv);
+ bool selectForExec = false;
+ if(ret != 0) {
+ if(ret < 0) {
+ qWarning("nativeSelect(....) returned < 0 for socket %d", socketDescriptor);
+ }
+ selectForExec = FD_ISSET(socketDescriptor, &fdexec);
+ }
+ if(selectForExec) {
+ qWarning("nativeSelect (checkRead %d, checkWrite %d, ret %d, errno %d): Unexpected expectfds ready in fd %d",
+ checkRead, checkWrite, ret, errno, socketDescriptor);
+ if (checkRead)
+ FD_SET(socketDescriptor, &fdread);
+ if (checkWrite)
+ FD_SET(socketDescriptor, &fdwrite);
+
+ if ((ret == -1) && ( errno == ECONNREFUSED || errno == EPIPE ))
+ ret = 1;
+
+ }
+
+ if (ret != -1 || errno != EINTR) {
+ break;
+ }
+
+ if (timeout > 0) {
+ // recalculate the timeout
+ int t = timeout - timer.elapsed();
+ if (t < 0) {
+ // oops, timeout turned negative?
+ ret = -1;
+ break;
+ }
+
+ tv.tv_sec = t / 1000;
+ tv.tv_usec = (t % 1000) * 1000;
+ }
+ } while (true);
+#endif
+
if (ret <= 0)
return ret;
-
*selectForRead = FD_ISSET(socketDescriptor, &fdread);
*selectForWrite = FD_ISSET(socketDescriptor, &fdwrite);
+
return ret;
}
diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp
index d226f21..25873c6 100644
--- a/src/network/socket/qsocks5socketengine.cpp
+++ b/src/network/socket/qsocks5socketengine.cpp
@@ -59,7 +59,11 @@
QT_BEGIN_NAMESPACE
+#ifdef Q_OS_SYMBIAN
+static const int MaxWriteBufferSize = 4*1024;
+#else
static const int MaxWriteBufferSize = 128*1024;
+#endif
//#define QSOCKS5SOCKETLAYER_DEBUG
@@ -1844,9 +1848,9 @@ QSocks5SocketEngineHandler::createSocketEngine(QAbstractSocket::SocketType socke
QSOCKS5_DEBUG << "not proxying";
return 0;
}
- QSocks5SocketEngine *engine = new QSocks5SocketEngine(parent);
+ QScopedPointer<QSocks5SocketEngine> engine(new QSocks5SocketEngine(parent));
engine->setProxy(proxy);
- return engine;
+ return engine.take();
}
QAbstractSocketEngine *QSocks5SocketEngineHandler::createSocketEngine(int socketDescriptor, QObject *parent)
diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp
index 2126fef..8bb92b7 100644
--- a/src/network/socket/qtcpserver.cpp
+++ b/src/network/socket/qtcpserver.cpp
@@ -354,7 +354,12 @@ void QTcpServer::close()
if (d->socketEngine) {
d->socketEngine->close();
- d->socketEngine->deleteLater();
+ QT_TRY {
+ d->socketEngine->deleteLater();
+ } QT_CATCH(const std::bad_alloc &) {
+ // in out of memory situations, the socketEngine
+ // will be deleted in ~QTcpServer (it's a child-object of this)
+ }
d->socketEngine = 0;
}
diff --git a/src/network/socket/qudpsocket.cpp b/src/network/socket/qudpsocket.cpp
index 797becb..32f72df 100644
--- a/src/network/socket/qudpsocket.cpp
+++ b/src/network/socket/qudpsocket.cpp
@@ -94,6 +94,13 @@
This enum describes the different flags you can pass to modify the
behavior of QUdpSocket::bind().
+
+ \note On Symbian OS bind flags behaviour depends on process capabilties.
+ If process has NetworkControl capability, the bind attempt with
+ ReuseAddressHint will always succeed even the address and port is already
+ bound by another socket with any flags. If process does not have
+ NetworkControl capability, the bind attempt to address and port already
+ bound by another socket will always fail.
\value ShareAddress Allow other services to bind to the same address
and port. This is useful when multiple processes share
@@ -349,6 +356,9 @@ qint64 QUdpSocket::pendingDatagramSize() const
as even if they are sent successfully, they are likely to be
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
@@ -368,6 +378,16 @@ qint64 QUdpSocket::writeDatagram(const char *data, qint64 size, const QHostAddre
return -1;
qint64 sent = d->socketEngine->writeDatagram(data, size, address, port);
+#ifdef Q_OS_SYMBIAN
+ if( QSysInfo::s60Version() <= QSysInfo::SV_S60_5_0 ) {
+ // This is evil hack, but for some reason native RSocket::SendTo returns 0,
+ // for large datagrams (such as 600 bytes). Based on comments from Open C team
+ // this should happen only in platforms <= S60 5.0.
+ // As an workaround, we just set sent = size
+ if( sent == 0 )
+ sent = size;
+ }
+#endif
d->cachedSocketDescriptor = d->socketEngine->socketDescriptor();
if (sent >= 0) {
diff --git a/src/network/socket/socket.pri b/src/network/socket/socket.pri
index 17e49d2..2bafe13 100644
--- a/src/network/socket/socket.pri
+++ b/src/network/socket/socket.pri
@@ -43,5 +43,3 @@ wince*: {
DEFINES += QT_LOCALSOCKET_TCP
}
-
-
diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp
index 9d8cfb0..018b2c2 100644
--- a/src/network/ssl/qsslcertificate.cpp
+++ b/src/network/ssl/qsslcertificate.cpp
@@ -159,7 +159,7 @@ QSslCertificate::QSslCertificate(const QByteArray &data, QSsl::EncodingFormat fo
/*!
Constructs an identical copy of \a other.
*/
-QSslCertificate::QSslCertificate(const QSslCertificate &other) : d(other.d)
+QSslCertificate::QSslCertificate(const QSslCertificate &other) : d(other.d.data())
{
d->ref.ref();
}
@@ -169,8 +169,6 @@ QSslCertificate::QSslCertificate(const QSslCertificate &other) : d(other.d)
*/
QSslCertificate::~QSslCertificate()
{
- if (!d->ref.deref())
- delete d;
}
/*!
@@ -179,7 +177,7 @@ QSslCertificate::~QSslCertificate()
*/
QSslCertificate &QSslCertificate::operator=(const QSslCertificate &other)
{
- qAtomicAssign(d, other.d);
+ d.assign(other.d.data());
return *this;
}
@@ -245,12 +243,7 @@ void QSslCertificate::clear()
{
if (isNull())
return;
- if (d->ref == 1)
- delete d;
- else
- d->ref.deref();
-
- d = new QSslCertificatePrivate;
+ d.reset(new QSslCertificatePrivate);
}
/*!
diff --git a/src/network/ssl/qsslcertificate.h b/src/network/ssl/qsslcertificate.h
index cdb9f15..ebb8319 100644
--- a/src/network/ssl/qsslcertificate.h
+++ b/src/network/ssl/qsslcertificate.h
@@ -118,7 +118,7 @@ public:
Qt::HANDLE handle() const;
private:
- QSslCertificatePrivate *d;
+ QScopedSharedPointer<QSslCertificatePrivate> d;
friend class QSslCertificatePrivate;
friend class QSslSocketBackendPrivate;
};
diff --git a/src/network/ssl/qsslcipher.cpp b/src/network/ssl/qsslcipher.cpp
index 504099f..ced5bfa 100644
--- a/src/network/ssl/qsslcipher.cpp
+++ b/src/network/ssl/qsslcipher.cpp
@@ -103,7 +103,7 @@ QSslCipher::QSslCipher(const QString &name, QSsl::SslProtocol protocol)
QSslCipher::QSslCipher(const QSslCipher &other)
: d(new QSslCipherPrivate)
{
- *d = *other.d;
+ *d.data() = *other.d.data();
}
/*!
@@ -111,7 +111,6 @@ QSslCipher::QSslCipher(const QSslCipher &other)
*/
QSslCipher::~QSslCipher()
{
- delete d;
}
/*!
@@ -120,7 +119,7 @@ QSslCipher::~QSslCipher()
*/
QSslCipher &QSslCipher::operator=(const QSslCipher &other)
{
- *d = *other.d;
+ *d.data() = *other.d.data();
return *this;
}
diff --git a/src/network/ssl/qsslcipher.h b/src/network/ssl/qsslcipher.h
index 94e5c7e..aecc6f3 100644
--- a/src/network/ssl/qsslcipher.h
+++ b/src/network/ssl/qsslcipher.h
@@ -44,6 +44,7 @@
#define QSSLCIPHER_H
#include <QtCore/qstring.h>
+#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qssl.h>
QT_BEGIN_HEADER
@@ -78,7 +79,7 @@ public:
QSsl::SslProtocol protocol() const;
private:
- QSslCipherPrivate *d;
+ QScopedPointer<QSslCipherPrivate> d;
friend class QSslSocketBackendPrivate;
};
diff --git a/src/network/ssl/qsslerror.cpp b/src/network/ssl/qsslerror.cpp
index 8b14d32..78ebc33 100644
--- a/src/network/ssl/qsslerror.cpp
+++ b/src/network/ssl/qsslerror.cpp
@@ -110,6 +110,23 @@ public:
\sa QSslCertificate
*/
+
+// RVCT compiler in debug build does not like about default values in const-
+// So as an workaround we define all constructor overloads here explicitly
+QSslError::QSslError()
+ : d(new QSslErrorPrivate)
+{
+ d->error = QSslError::NoError;
+ d->certificate = QSslCertificate();
+}
+
+QSslError::QSslError(SslError error)
+ : d(new QSslErrorPrivate)
+{
+ d->error = error;
+ d->certificate = QSslCertificate();
+}
+
QSslError::QSslError(SslError error, const QSslCertificate &certificate)
: d(new QSslErrorPrivate)
{
@@ -123,7 +140,7 @@ QSslError::QSslError(SslError error, const QSslCertificate &certificate)
QSslError::QSslError(const QSslError &other)
: d(new QSslErrorPrivate)
{
- *d = *other.d;
+ *d.data() = *other.d.data();
}
/*!
@@ -131,7 +148,6 @@ QSslError::QSslError(const QSslError &other)
*/
QSslError::~QSslError()
{
- delete d;
}
/*!
@@ -141,7 +157,7 @@ QSslError::~QSslError()
*/
QSslError &QSslError::operator=(const QSslError &other)
{
- *d = *other.d;
+ *d.data() = *other.d.data();
return *this;
}
diff --git a/src/network/ssl/qsslerror.h b/src/network/ssl/qsslerror.h
index dcf694a..c3e91a6 100644
--- a/src/network/ssl/qsslerror.h
+++ b/src/network/ssl/qsslerror.h
@@ -86,8 +86,14 @@ public:
UnspecifiedError = -1
};
- QSslError(SslError error = NoError, const QSslCertificate &certificate = QSslCertificate());
+ // RVCT compiler in debug build does not like about default values in const-
+ // So as an workaround we define all constructor overloads here explicitly
+ QSslError();
+ QSslError(SslError error);
+ QSslError(SslError error, const QSslCertificate &certificate);
+
QSslError(const QSslError &other);
+
~QSslError();
QSslError &operator=(const QSslError &other);
bool operator==(const QSslError &other) const;
@@ -99,7 +105,7 @@ public:
QSslCertificate certificate() const;
private:
- QSslErrorPrivate *d;
+ QScopedPointer<QSslErrorPrivate> d;
};
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/network/ssl/qsslkey.cpp b/src/network/ssl/qsslkey.cpp
index c7eb692..7087339 100644
--- a/src/network/ssl/qsslkey.cpp
+++ b/src/network/ssl/qsslkey.cpp
@@ -269,7 +269,7 @@ QSslKey::QSslKey(QIODevice *device, QSsl::KeyAlgorithm algorithm, QSsl::Encoding
/*!
Constructs an identical copy of \a other.
*/
-QSslKey::QSslKey(const QSslKey &other) : d(other.d)
+QSslKey::QSslKey(const QSslKey &other) : d(other.d.data())
{
d->ref.ref();
}
@@ -279,8 +279,6 @@ QSslKey::QSslKey(const QSslKey &other) : d(other.d)
*/
QSslKey::~QSslKey()
{
- if (!d->ref.deref())
- delete d;
}
/*!
@@ -291,7 +289,7 @@ QSslKey::~QSslKey()
*/
QSslKey &QSslKey::operator=(const QSslKey &other)
{
- qAtomicAssign(d, other.d);
+ d.assign(other.d.data());
return *this;
}
@@ -312,10 +310,13 @@ bool QSslKey::isNull() const
*/
void QSslKey::clear()
{
- if (!d->ref.deref()) {
- delete d;
- d = new QSslKeyPrivate;
- }
+ d.reset(new QSslKeyPrivate);
+
+ //### old code: is this really correct???
+ //if (!d->ref.deref()) {
+ // delete d;
+ // d = new QSslKeyPrivate;
+ //}
}
/*!
diff --git a/src/network/ssl/qsslkey.h b/src/network/ssl/qsslkey.h
index 1efc7d5..a85691b 100644
--- a/src/network/ssl/qsslkey.h
+++ b/src/network/ssl/qsslkey.h
@@ -45,6 +45,7 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qbytearray.h>
+#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qssl.h>
QT_BEGIN_HEADER
@@ -92,7 +93,7 @@ public:
inline bool operator!=(const QSslKey &key) const { return !operator==(key); }
private:
- QSslKeyPrivate *d;
+ QScopedSharedPointer<QSslKeyPrivate> d;
friend class QSslCertificate;
};
diff --git a/src/network/ssl/qsslsocket_openssl_p.h b/src/network/ssl/qsslsocket_openssl_p.h
index 7dc9fab..f923924 100644
--- a/src/network/ssl/qsslsocket_openssl_p.h
+++ b/src/network/ssl/qsslsocket_openssl_p.h
@@ -77,6 +77,10 @@
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <openssl/x509_vfy.h>
+#ifdef Q_OS_SYMBIAN
+#include <openssl/dsa.h>
+#include <openssl/rsa.h>
+#endif
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
typedef _STACK STACK;
diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
index 0fea2df..6b777e3 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -254,10 +254,16 @@ DEFINEFUNC3(DSA *, d2i_DSAPrivateKey, DSA **a, a, unsigned char **b, b, long c,
DEFINEFUNC(void, OPENSSL_add_all_algorithms_noconf, void, DUMMYARG, return, DUMMYARG)
DEFINEFUNC(void, OPENSSL_add_all_algorithms_conf, void, DUMMYARG, return, DUMMYARG)
+#ifdef Q_OS_SYMBIAN
+#define RESOLVEFUNC(func, ordinal, lib) \
+ if (!(_q_##func = _q_PTR_##func(lib->resolve(#ordinal)))) \
+ qWarning("QSslSocket: cannot resolve "#func);
+#else
#define RESOLVEFUNC(func) \
if (!(_q_##func = _q_PTR_##func(libs.first->resolve(#func))) \
&& !(_q_##func = _q_PTR_##func(libs.second->resolve(#func)))) \
qWarning("QSslSocket: cannot resolve "#func);
+#endif
#if !defined QT_LINKED_OPENSSL
@@ -358,7 +364,24 @@ static QPair<QLibrary*, QLibrary*> loadOpenSsl()
pair.first = ssleay32;
pair.second = libeay32;
return pair;
+# elif defined(Q_OS_SYMBIAN)
+ QLibrary *libssl = new QLibrary(QLatin1String("libssl"));
+ if (!libssl->load()) {
+ // Cannot find ssleay32.dll
+ delete libssl;
+ return pair;
+ }
+ QLibrary *libcrypto = new QLibrary(QLatin1String("libcrypto"));
+ if (!libcrypto->load()) {
+ delete libcrypto;
+ delete libssl;
+ return pair;
+ }
+
+ pair.first = libssl;
+ pair.second = libcrypto;
+ return pair;
# elif defined(Q_OS_UNIX)
QLibrary *&libssl = pair.first;
QLibrary *&libcrypto = pair.second;
@@ -460,6 +483,127 @@ bool q_resolveOpenSslSymbols()
// failed to load them
return false;
+#ifdef Q_OS_SYMBIAN
+#ifdef SSLEAY_MACROS
+ RESOLVEFUNC(ASN1_dup, 125, libs.second )
+#endif
+ RESOLVEFUNC(ASN1_STRING_data, 71, libs.second )
+ RESOLVEFUNC(ASN1_STRING_length, 76, libs.second )
+ RESOLVEFUNC(BIO_ctrl, 184, libs.second )
+ RESOLVEFUNC(BIO_free, 209, libs.second )
+ RESOLVEFUNC(BIO_new, 222, libs.second )
+ RESOLVEFUNC(BIO_new_mem_buf, 230, libs.second )
+ RESOLVEFUNC(BIO_read, 244, libs.second )
+ RESOLVEFUNC(BIO_s_mem, 251, libs.second )
+ RESOLVEFUNC(BIO_write, 269, libs.second )
+ RESOLVEFUNC(BN_num_bits, 387, libs.second )
+ RESOLVEFUNC(CRYPTO_free, 469, libs.second )
+ RESOLVEFUNC(CRYPTO_num_locks, 500, libs.second )
+ RESOLVEFUNC(CRYPTO_set_id_callback, 513, libs.second )
+ RESOLVEFUNC(CRYPTO_set_locking_callback, 516, libs.second )
+ RESOLVEFUNC(DSA_free, 594, libs.second )
+ RESOLVEFUNC(ERR_error_string, 744, libs.second )
+ RESOLVEFUNC(ERR_get_error, 749, libs.second )
+ RESOLVEFUNC(EVP_des_ede3_cbc, 919, libs.second )
+ RESOLVEFUNC(EVP_PKEY_assign, 859, libs.second )
+ RESOLVEFUNC(EVP_PKEY_free, 867, libs.second )
+ RESOLVEFUNC(EVP_PKEY_get1_DSA, 869, libs.second )
+ RESOLVEFUNC(EVP_PKEY_get1_RSA, 870, libs.second )
+ RESOLVEFUNC(EVP_PKEY_new, 876, libs.second )
+ RESOLVEFUNC(EVP_PKEY_type, 882, libs.second )
+ RESOLVEFUNC(OBJ_nid2sn, 1036, libs.second )
+ RESOLVEFUNC(OBJ_obj2nid, 1037, libs.second )
+#ifdef SSLEAY_MACROS // ### verify
+ RESOLVEFUNC(PEM_ASN1_read_bio, 1180, libs.second )
+#else
+ RESOLVEFUNC(PEM_read_bio_DSAPrivateKey, 1219, libs.second )
+ RESOLVEFUNC(PEM_read_bio_RSAPrivateKey, 1228, libs.second )
+ RESOLVEFUNC(PEM_write_bio_DSAPrivateKey, 1260, libs.second )
+ RESOLVEFUNC(PEM_write_bio_RSAPrivateKey, 1271, libs.second )
+#endif
+ RESOLVEFUNC(PEM_read_bio_DSA_PUBKEY, 1220, libs.second )
+ RESOLVEFUNC(PEM_read_bio_RSA_PUBKEY, 1230, libs.second )
+ RESOLVEFUNC(PEM_write_bio_DSA_PUBKEY, 1261, libs.second )
+ RESOLVEFUNC(PEM_write_bio_RSA_PUBKEY, 1273, libs.second )
+ RESOLVEFUNC(RAND_seed, 1426, libs.second )
+ RESOLVEFUNC(RAND_status, 1429, libs.second )
+ RESOLVEFUNC(RSA_free, 1450, libs.second )
+ RESOLVEFUNC(sk_free, 2571, libs.second )
+ RESOLVEFUNC(sk_num, 2576, libs.second )
+ RESOLVEFUNC(sk_value, 2585, libs.second )
+ RESOLVEFUNC(SSL_CIPHER_description, 11, libs.first )
+ RESOLVEFUNC(SSL_CTX_check_private_key, 21, libs.first )
+ RESOLVEFUNC(SSL_CTX_ctrl, 22, libs.first )
+ RESOLVEFUNC(SSL_CTX_free, 24, libs.first )
+ RESOLVEFUNC(SSL_CTX_new, 35, libs.first )
+ RESOLVEFUNC(SSL_CTX_set_cipher_list, 40, libs.first )
+ RESOLVEFUNC(SSL_CTX_set_default_verify_paths, 44, libs.first )
+ RESOLVEFUNC(SSL_CTX_set_verify, 56, libs.first )
+ RESOLVEFUNC(SSL_CTX_set_verify_depth, 57, libs.first )
+ RESOLVEFUNC(SSL_CTX_use_certificate, 64, libs.first )
+ RESOLVEFUNC(SSL_CTX_use_certificate_file, 67, libs.first )
+ RESOLVEFUNC(SSL_CTX_use_PrivateKey, 58, libs.first )
+ RESOLVEFUNC(SSL_CTX_use_RSAPrivateKey, 61, libs.first )
+ RESOLVEFUNC(SSL_CTX_use_PrivateKey_file, 60, libs.first )
+ RESOLVEFUNC(SSL_accept, 82, libs.first )
+ RESOLVEFUNC(SSL_clear, 92, libs.first )
+ RESOLVEFUNC(SSL_connect, 93, libs.first )
+ RESOLVEFUNC(SSL_free, 99, libs.first )
+ RESOLVEFUNC(SSL_get_ciphers, 104, libs.first )
+ RESOLVEFUNC(SSL_get_current_cipher, 106, libs.first )
+ RESOLVEFUNC(SSL_get_error, 110, libs.first )
+ RESOLVEFUNC(SSL_get_peer_cert_chain, 117, libs.first )
+ RESOLVEFUNC(SSL_get_peer_certificate, 118, libs.first )
+ RESOLVEFUNC(SSL_get_verify_result, 132, libs.first )
+ RESOLVEFUNC(SSL_library_init, 137, libs.first )
+ RESOLVEFUNC(SSL_load_error_strings, 139, libs.first )
+ RESOLVEFUNC(SSL_new, 140, libs.first )
+ RESOLVEFUNC(SSL_read, 143, libs.first )
+ RESOLVEFUNC(SSL_set_accept_state, 148, libs.first )
+ RESOLVEFUNC(SSL_set_bio, 149, libs.first )
+ RESOLVEFUNC(SSL_set_connect_state, 152, libs.first )
+ RESOLVEFUNC(SSL_shutdown, 173, libs.first )
+ RESOLVEFUNC(SSL_write, 188, libs.first )
+ RESOLVEFUNC(SSLv2_client_method, 192, libs.first )
+ RESOLVEFUNC(SSLv3_client_method, 195, libs.first )
+ RESOLVEFUNC(SSLv23_client_method, 189, libs.first )
+ RESOLVEFUNC(TLSv1_client_method, 198, libs.first )
+ RESOLVEFUNC(SSLv2_server_method, 194, libs.first )
+ RESOLVEFUNC(SSLv3_server_method, 197, libs.first )
+ RESOLVEFUNC(SSLv23_server_method, 191, libs.first )
+ RESOLVEFUNC(TLSv1_server_method, 200, libs.first )
+ RESOLVEFUNC(X509_NAME_oneline, 1830, libs.second )
+ RESOLVEFUNC(X509_PUBKEY_get, 1844, libs.second )
+ RESOLVEFUNC(X509_STORE_free, 1939, libs.second )
+ RESOLVEFUNC(X509_STORE_new, 1942, libs.second )
+ RESOLVEFUNC(X509_STORE_add_cert, 1936, libs.second )
+ RESOLVEFUNC(X509_STORE_CTX_free, 1907, libs.second )
+ RESOLVEFUNC(X509_STORE_CTX_init, 1919, libs.second )
+ RESOLVEFUNC(X509_STORE_CTX_new, 1920, libs.second )
+ RESOLVEFUNC(X509_STORE_CTX_set_purpose, 1931, libs.second )
+ RESOLVEFUNC(X509_cmp, 1992, libs.second )
+#ifndef SSLEAY_MACROS
+ RESOLVEFUNC(X509_dup, 1997, libs.second )
+#endif
+ RESOLVEFUNC(X509_EXTENSION_get_object, 1785, libs.second )
+ RESOLVEFUNC(X509_free, 2001, libs.second )
+ RESOLVEFUNC(X509_get_ext, 2012, libs.second )
+ RESOLVEFUNC(X509_get_ext_count, 2016, libs.second )
+ RESOLVEFUNC(X509_get_ext_d2i, 2017, libs.second )
+ RESOLVEFUNC(X509_get_issuer_name, 2018, libs.second )
+ RESOLVEFUNC(X509_get_subject_name, 2022, libs.second )
+ RESOLVEFUNC(X509_verify_cert, 2069, libs.second )
+ RESOLVEFUNC(d2i_X509, 2309, libs.second )
+ RESOLVEFUNC(i2d_X509, 2489, libs.second )
+#ifdef SSLEAY_MACROS
+ RESOLVEFUNC(i2d_DSAPrivateKey, 2395, libs.second )
+ RESOLVEFUNC(i2d_RSAPrivateKey, 2476, libs.second )
+ RESOLVEFUNC(d2i_DSAPrivateKey, 2220, libs.second )
+ RESOLVEFUNC(d2i_RSAPrivateKey, 2296, libs.second )
+#endif
+ RESOLVEFUNC(OPENSSL_add_all_algorithms_noconf, 1153, libs.second )
+ RESOLVEFUNC(OPENSSL_add_all_algorithms_conf, 1152, libs.second )
+#else // Q_OS_SYMBIAN
#ifdef SSLEAY_MACROS
RESOLVEFUNC(ASN1_dup)
#endif
@@ -579,6 +723,7 @@ bool q_resolveOpenSslSymbols()
#endif
RESOLVEFUNC(OPENSSL_add_all_algorithms_noconf)
RESOLVEFUNC(OPENSSL_add_all_algorithms_conf)
+#endif // Q_OS_SYMBIAN
symbolsResolved = true;
delete libs.first;
delete libs.second;
diff --git a/src/network/ssl/ssl.pri b/src/network/ssl/ssl.pri
index 196e19d..6021d5d 100644
--- a/src/network/ssl/ssl.pri
+++ b/src/network/ssl/ssl.pri
@@ -1,6 +1,12 @@
# OpenSSL support; compile in QSslSocket.
contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) {
- include($$QT_SOURCE_TREE/config.tests/unix/openssl/openssl.pri)
+
+
+symbian {
+ INCLUDEPATH *= $$OS_LAYER_SSL_SYSTEMINCLUDE
+} else {
+ include($$QT_SOURCE_TREE/config.tests/unix/openssl/openssl.pri)
+}
HEADERS += ssl/qssl.h \
ssl/qsslcertificate.h \