diff options
Diffstat (limited to 'src/network/bearer')
-rw-r--r-- | src/network/bearer/qnetworksession.cpp | 31 | ||||
-rw-r--r-- | src/network/bearer/qnetworksession_p.h | 9 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp index 6106550..21e64d9 100644 --- a/src/network/bearer/qnetworksession.cpp +++ b/src/network/bearer/qnetworksession.cpp @@ -44,10 +44,16 @@ #include <QEventLoop> #include <QTimer> +#include <QThread> #include "qnetworkconfigmanager_p.h" #include "qnetworksession_p.h" +#ifdef Q_OS_SYMBIAN +#include <es_sock.h> +#include <private/qcore_symbian_p.h> +#endif + #ifndef QT_NO_BEARERMANAGEMENT QT_BEGIN_NAMESPACE @@ -710,8 +716,33 @@ RConnection* QNetworkSessionPrivate::nativeSession(QNetworkSession &s) { if (!s.d) return 0; + if (s.thread() != QThread::currentThread()) + qWarning("QNetworkSessionPrivate::nativeSession called in wrong thread"); return s.d->nativeSession(); } + +TInt QNetworkSessionPrivate::nativeOpenSocket(QNetworkSession& s, RSocket& sock, TUint family, TUint type, TUint protocol) +{ + if (!s.d) + return 0; + QMutexLocker lock(&(s.d->mutex)); + RConnection *con = s.d->nativeSession(); + if (!con || !con->SubSessionHandle()) + return KErrNotReady; + return sock.Open(qt_symbianGetSocketServer(), family, type, protocol, *con); +} + +TInt QNetworkSessionPrivate::nativeOpenHostResolver(QNetworkSession& s, RHostResolver& resolver, TUint family, TUint protocol) +{ + if (!s.d) + return 0; + QMutexLocker lock(&(s.d->mutex)); + RConnection *con = s.d->nativeSession(); + if (!con || !con->SubSessionHandle()) + return KErrNotReady; + return resolver.Open(qt_symbianGetSocketServer(), family, protocol, *con); +} + #endif #include "moc_qnetworksession.cpp" diff --git a/src/network/bearer/qnetworksession_p.h b/src/network/bearer/qnetworksession_p.h index e2fcfe6..b359f80 100644 --- a/src/network/bearer/qnetworksession_p.h +++ b/src/network/bearer/qnetworksession_p.h @@ -61,6 +61,8 @@ #ifdef Q_OS_SYMBIAN class RConnection; +class RSocket; +class RHostResolver; #endif QT_BEGIN_NAMESPACE @@ -108,8 +110,13 @@ public: virtual quint64 activeTime() const = 0; #ifdef Q_OS_SYMBIAN + // get internal RConnection (not thread safe, call only from thread that owns the QNetworkSession) static RConnection* nativeSession(QNetworkSession&); virtual RConnection* nativeSession() = 0; + // open socket using the internal RConnection (thread safe) + static TInt nativeOpenSocket(QNetworkSession& session, RSocket& socket, TUint family, TUint type, TUint protocol); + // open host resolver using the internal RConnection (thread safe) + static TInt nativeOpenHostResolver(QNetworkSession& session, RHostResolver& resolver, TUint family, TUint protocol); #endif protected: inline QNetworkConfigurationPrivatePointer privateConfiguration(const QNetworkConfiguration &config) const @@ -150,6 +157,8 @@ protected: QNetworkSession::State state; bool isOpen; + + QMutex mutex; }; QT_END_NAMESPACE |