summaryrefslogtreecommitdiffstats
path: root/src/network/socket
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2011-03-16 18:59:45 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2011-03-17 14:57:50 (GMT)
commit1adef92e1b1ba9872c9676efd701eb0fd0a3a907 (patch)
tree03bbbf809ce7e65474e39fd752de5147544940a8 /src/network/socket
parent13f415e7d54ef8e2aaccabfb04f29ccfde0520df (diff)
downloadQt-1adef92e1b1ba9872c9676efd701eb0fd0a3a907.zip
Qt-1adef92e1b1ba9872c9676efd701eb0fd0a3a907.tar.gz
Qt-1adef92e1b1ba9872c9676efd701eb0fd0a3a907.tar.bz2
Implement QEventLoop::ExcludeSocketNotifiers for symbian socket engine
As the symbian socket engine is driven by an active object in the QtNetwork dll, this needs to hook into the event dispatcher in the QtCore dll. The QActiveObject base class is now a private export from QtCore The method of deferring socket events now works with any kind of QActiveObject, and not only the QSocketActiveObject (which handles "open C" sockets) The base class has a new function, to check if socket events are blocked. If so, it adds the active object to the deferred queue. The derived class should return from it's RunL in this case, which will be called again later. (same usage as the maybeQueueForLater function) reactivateAndComplete function in the event dispatcher is changed to complete the active object again with the same status code as originally. Previously it always used KErrNone, which is not ok for QAsyncSelect as it needs to check the error code from the asynchronous call. Reviewed-by: Markus Goetz Reviewed-by: mread
Diffstat (limited to 'src/network/socket')
-rw-r--r--src/network/socket/qsymbiansocketengine.cpp28
-rw-r--r--src/network/socket/qsymbiansocketengine_p.h4
2 files changed, 20 insertions, 12 deletions
diff --git a/src/network/socket/qsymbiansocketengine.cpp b/src/network/socket/qsymbiansocketengine.cpp
index 688f724..07b2e5a 100644
--- a/src/network/socket/qsymbiansocketengine.cpp
+++ b/src/network/socket/qsymbiansocketengine.cpp
@@ -63,6 +63,7 @@
#include <QCoreApplication>
#include <qabstracteventdispatcher.h>
+#include <private/qeventdispatcher_symbian_p.h>
#include <qsocketnotifier.h>
#include <qnetworkinterface.h>
@@ -187,7 +188,6 @@ bool QSymbianSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType so
TUint protocol = (socketType == QAbstractSocket::UdpSocket) ? KProtocolInetUdp : KProtocolInetTcp;
//Check if there is a user specified session
- RConnection *connection = 0;
QVariant v(q->property("_q_networksession"));
TInt err;
if (v.isValid()) {
@@ -1437,7 +1437,9 @@ void QSymbianSocketEngine::setReadNotificationEnabled(bool enable)
#endif
d->readNotificationsEnabled = enable;
if (enable && d->threadData->eventDispatcher && !d->asyncSelect)
- d->asyncSelect = q_check_ptr(new QAsyncSelect(0, d->nativeSocket, this));
+ d->asyncSelect = q_check_ptr(
+ new QAsyncSelect(static_cast<QEventDispatcherSymbian*>(d->threadData->eventDispatcher),
+ d->nativeSocket, this));
// TODO: what do we do if event dispatcher doesn't exist yet?
if (d->asyncSelect)
d->asyncSelect->IssueRequest();
@@ -1459,7 +1461,9 @@ void QSymbianSocketEngine::setWriteNotificationEnabled(bool enable)
#endif
d->writeNotificationsEnabled = enable;
if (enable && d->threadData->eventDispatcher && !d->asyncSelect)
- d->asyncSelect = q_check_ptr(new QAsyncSelect(0, d->nativeSocket, this));
+ d->asyncSelect = q_check_ptr(
+ new QAsyncSelect(static_cast<QEventDispatcherSymbian*>(d->threadData->eventDispatcher),
+ d->nativeSocket, this));
// TODO: what do we do if event dispatcher doesn't exist yet?
if (d->asyncSelect)
d->asyncSelect->IssueRequest();
@@ -1483,7 +1487,9 @@ void QSymbianSocketEngine::setExceptionNotificationEnabled(bool enable)
#endif
d->exceptNotificationsEnabled = enable;
if (enable && d->threadData->eventDispatcher && !d->asyncSelect)
- d->asyncSelect = q_check_ptr(new QAsyncSelect(0, d->nativeSocket, this));
+ d->asyncSelect = q_check_ptr(
+ new QAsyncSelect(static_cast<QEventDispatcherSymbian*>(d->threadData->eventDispatcher),
+ d->nativeSocket, this));
if (d->asyncSelect)
d->asyncSelect->IssueRequest();
}
@@ -1597,15 +1603,17 @@ bool QSymbianSocketEngine::event(QEvent* ev)
qDebug() << "PostThreadChangeEvent" << d->readNotificationsEnabled << d->writeNotificationsEnabled << d->exceptNotificationsEnabled;
#endif
// recreate select in new thread
- d->asyncSelect = q_check_ptr(new QAsyncSelect(0, d->nativeSocket, this));
+ d->asyncSelect = q_check_ptr(
+ new QAsyncSelect(static_cast<QEventDispatcherSymbian*>(d->threadData->eventDispatcher),
+ d->nativeSocket, this));
d->asyncSelect->IssueRequest();
return true;
}
return QAbstractSocketEngine::event(ev);
}
-QAsyncSelect::QAsyncSelect(QAbstractEventDispatcher *dispatcher, RSocket& sock, QSymbianSocketEngine *parent)
- : CActive(CActive::EPriorityStandard),
+QAsyncSelect::QAsyncSelect(QEventDispatcherSymbian *dispatcher, RSocket& sock, QSymbianSocketEngine *parent)
+ : QActiveObject(CActive::EPriorityStandard, dispatcher),
m_inSocketEvent(false),
m_deleteLater(false),
m_socket(sock),
@@ -1652,9 +1660,9 @@ TInt QAsyncSelect::RunError(TInt aError)
void QAsyncSelect::run()
{
- //TODO: block when event loop demands it
- //if (maybeQueueForLater())
- // return;
+ //when event loop disabled socket events, defer until later
+ if (maybeDeferSocketEvent())
+ return;
m_inSocketEvent = true;
m_selectBuf() &= m_selectFlags; //the select ioctl reports everything, so mask to only what we requested
//KSockSelectReadContinuation is for reading datagrams in a mode that doesn't discard when the
diff --git a/src/network/socket/qsymbiansocketengine_p.h b/src/network/socket/qsymbiansocketengine_p.h
index 432e4dc..bbe1269 100644
--- a/src/network/socket/qsymbiansocketengine_p.h
+++ b/src/network/socket/qsymbiansocketengine_p.h
@@ -151,10 +151,10 @@ class QSocketNotifier;
class QReadNotifier;
class QWriteNotifier;
class QExceptionNotifier;
-class QAsyncSelect : public CActive
+class QAsyncSelect : public QActiveObject
{
public:
- QAsyncSelect(QAbstractEventDispatcher *dispatcher, RSocket& sock, QSymbianSocketEngine *parent);
+ QAsyncSelect(QEventDispatcherSymbian *dispatcher, RSocket& sock, QSymbianSocketEngine *parent);
~QAsyncSelect();
void deleteLater();