summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2011-03-08 18:17:25 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2011-03-08 18:17:25 (GMT)
commit1500707a35ec95571d3dc1573e54d44420ee9098 (patch)
tree32f4ef849e899c8ae54472c0b9842229e3b42056 /src/corelib/kernel
parentb6cc353adb0613ce41153181b4f08bb81b7acf68 (diff)
parent45531aceba4d0b2114942c49f4c256b70af58cf8 (diff)
downloadQt-1500707a35ec95571d3dc1573e54d44420ee9098.zip
Qt-1500707a35ec95571d3dc1573e54d44420ee9098.tar.gz
Qt-1500707a35ec95571d3dc1573e54d44420ee9098.tar.bz2
Merge branch 'symbian-socket-engine' of scm.dev.troll.no:qt/qt-symbian-network into symbian-socket-engine
Conflicts: src/network/access/qnetworkaccessmanager.cpp tests/auto/qsslsocket/tst_qsslsocket.cpp
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qcore_symbian_p.cpp18
-rw-r--r--src/corelib/kernel/qcore_symbian_p.h16
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp96
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian_p.h4
4 files changed, 127 insertions, 7 deletions
diff --git a/src/corelib/kernel/qcore_symbian_p.cpp b/src/corelib/kernel/qcore_symbian_p.cpp
index 872c0b6..c717cb9 100644
--- a/src/corelib/kernel/qcore_symbian_p.cpp
+++ b/src/corelib/kernel/qcore_symbian_p.cpp
@@ -217,13 +217,15 @@ Q_CORE_EXPORT RFs& qt_s60GetRFs()
}
QSymbianSocketManager::QSymbianSocketManager() :
- iNextSocket(0)
+ iNextSocket(0), iDefaultConnection(0)
{
TSessionPref preferences;
// ### In future this could be changed to KAfInet6 when that is more common than IPv4
preferences.iAddrFamily = KAfInet;
preferences.iProtocol = KProtocolInetIp;
- qt_symbian_throwIfError(iSocketServ.Connect(preferences));
+ //use global message pool, as we do not know how many sockets app will use
+ //TODO: is this the right choice?
+ qt_symbian_throwIfError(iSocketServ.Connect(preferences, -1));
qt_symbian_throwIfError(iSocketServ.ShareAuto());
}
@@ -283,13 +285,23 @@ int QSymbianSocketManager::lookupSocket(const RSocket& socket) const {
bool QSymbianSocketManager::lookupSocket(int fd, RSocket& socket) const {
QMutexLocker l(&iMutex);
- int id = fd + socket_offset;
+ int id = fd - socket_offset;
if(!reverseSocketMap.contains(id))
return false;
socket = reverseSocketMap.value(id);
return true;
}
+void QSymbianSocketManager::setDefaultConnection(RConnection* con)
+{
+ iDefaultConnection = con;
+}
+
+RConnection* QSymbianSocketManager::defaultConnection() const
+{
+ return iDefaultConnection;
+}
+
Q_GLOBAL_STATIC(QSymbianSocketManager, qt_symbianSocketManager);
QSymbianSocketManager& QSymbianSocketManager::instance()
diff --git a/src/corelib/kernel/qcore_symbian_p.h b/src/corelib/kernel/qcore_symbian_p.h
index c179501..cbe84a8 100644
--- a/src/corelib/kernel/qcore_symbian_p.h
+++ b/src/corelib/kernel/qcore_symbian_p.h
@@ -188,7 +188,7 @@ public:
}
bool operator<(const QHashableSocket &other) const
{
- if(Session().Handle() == other.Session().Handle())
+ if (Session().Handle() == other.Session().Handle())
return SubSessionHandle() < other.SubSessionHandle();
return Session().Handle() < other.Session().Handle();
}
@@ -246,6 +246,19 @@ public:
/*!
\internal
+ Set the default connection to use for new sockets
+ \param an open connection
+ */
+ void setDefaultConnection(RConnection* con);
+ /*!
+ \internal
+ Get the default connection to use for new sockets
+ \return the connection, or null pointer if there is none set
+ */
+ RConnection *defaultConnection() const;
+
+ /*!
+ \internal
Gets a reference to the singleton socket manager
*/
static QSymbianSocketManager& instance();
@@ -259,6 +272,7 @@ private:
QHash<int, RSocket> reverseSocketMap;
mutable QMutex iMutex;
RSocketServ iSocketServ;
+ RConnection *iDefaultConnection;
};
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
index 53796be..b074ab4 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian.cpp
+++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp
@@ -819,6 +819,14 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla
CActiveScheduler::Current()->WaitForAnyRequest();
} else {
if (thread.RequestCount() == 0) {
+#ifdef QT_SYMBIAN_PRIORITY_DROP
+ if (idleDetectorThread()->hasRun()) {
+ m_lastIdleRequestTimer.start();
+ idleDetectorThread()->kick();
+ } else if (m_lastIdleRequestTimer.elapsed() > maxBusyTime) {
+ User::AfterHighRes(m_delay);
+ }
+#endif
break;
}
// This one should return without delay.
@@ -1029,14 +1037,17 @@ bool QEventDispatcherSymbian::hasPendingEvents()
void QEventDispatcherSymbian::registerSocketNotifier ( QSocketNotifier * notifier )
{
- QSocketActiveObject *socketAO = new QSocketActiveObject(this, notifier);
+ //TODO: just need to be able to do something when event loop has sockets disabled
+/* QSocketActiveObject *socketAO = new QSocketActiveObject(this, notifier);
Q_CHECK_PTR(socketAO);
m_notifiers.insert(notifier, socketAO);
- selectThread().requestSocketEvents(notifier, &socketAO->iStatus);
+ selectThread().requestSocketEvents(notifier, &socketAO->iStatus);*/
}
void QEventDispatcherSymbian::unregisterSocketNotifier ( QSocketNotifier * notifier )
{
+ //TODO: just need to be able to do something when event loop has sockets disabled
+ /*
if (m_selectThread)
m_selectThread->cancelSocketEvents(notifier);
if (m_notifiers.contains(notifier)) {
@@ -1045,6 +1056,7 @@ void QEventDispatcherSymbian::unregisterSocketNotifier ( QSocketNotifier * notif
sockObj->deleteLater();
m_notifiers.remove(notifier);
}
+ */
}
void QEventDispatcherSymbian::reactivateSocketNotifier(QSocketNotifier *notifier)
@@ -1139,6 +1151,86 @@ void CQtActiveScheduler::Error(TInt aError) const
QT_CATCH (const std::bad_alloc&) {} // ignore alloc fails, nothing more can be done
}
+bool QActiveObject::wait(CActive* ao, int ms)
+{
+ if (!ao->IsActive())
+ return true; //request already complete
+ bool timedout = false;
+ if (ms > 0) {
+ TRequestStatus tstat;
+ RTimer t;
+ if (KErrNone != t.CreateLocal())
+ return false;
+ t.HighRes(tstat, ms*1000);
+ User::WaitForRequest(tstat, ao->iStatus);
+ if (tstat != KRequestPending) {
+ timedout = true;
+ } else {
+ t.Cancel();
+ //balance thread semaphore
+ User::WaitForRequest(tstat);
+ }
+ t.Close();
+ } else {
+ User::WaitForRequest(ao->iStatus);
+ }
+ if (timedout)
+ return false;
+
+ //evil cast to allow calling of protected virtual
+ ((QActiveObject*)ao)->RunL();
+
+ //clear active & pending flags
+ ao->iStatus = TRequestStatus();
+
+ return true;
+}
+
+bool QActiveObject::wait(QList<CActive*> aos, int ms)
+{
+ QVector<TRequestStatus*> stati;
+ stati.reserve(aos.count() + 1);
+ foreach (CActive* ao, aos) {
+ if (!ao->IsActive())
+ return true; //request already complete
+ stati.append(&(ao->iStatus));
+ }
+ bool timedout = false;
+ TRequestStatus tstat;
+ RTimer t;
+ if (ms > 0) {
+ if (KErrNone != t.CreateLocal())
+ return false;
+ t.HighRes(tstat, ms*1000);
+ stati.append(&tstat);
+ }
+ User::WaitForNRequest(stati.data(), stati.count());
+ if (ms > 0) {
+ if (tstat != KRequestPending) {
+ timedout = true;
+ } else {
+ t.Cancel();
+ //balance thread semaphore
+ User::WaitForRequest(tstat);
+ }
+ t.Close();
+ }
+ if (timedout)
+ return false;
+
+ foreach (CActive* ao, aos) {
+ if (ao->iStatus != KRequestPending) {
+ //evil cast to allow calling of protected virtual
+ ((QActiveObject*)ao)->RunL();
+
+ //clear active & pending flags
+ ao->iStatus = TRequestStatus();
+ break; //only call one
+ }
+ }
+ return true;
+}
+
QT_END_NAMESPACE
#include "moc_qeventdispatcher_symbian_p.cpp"
diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h
index bdb6dce..bf28144 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian_p.h
+++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h
@@ -77,7 +77,7 @@ QT_BEGIN_NAMESPACE
class QEventDispatcherSymbian;
class QTimerActiveObject;
-class QActiveObject : public CActive
+class Q_AUTOTEST_EXPORT QActiveObject : public CActive
{
public:
QActiveObject(TInt priority, QEventDispatcherSymbian *dispatcher);
@@ -87,6 +87,8 @@ public:
void reactivateAndComplete();
+ static bool wait(CActive* ao, int ms);
+ static bool wait(QList<CActive*> aos, int ms);
protected:
QEventDispatcherSymbian *m_dispatcher;