Remove Symbian support from /src/corelib/kernel/.

Change-Id: Ic4a1b4f074d2ffd4cdfcb44e47c9bfccc2378760
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
bb10
Robin Burchell 2011-12-10 16:00:15 +01:00 committed by Qt by Nokia
parent f405a57fa1
commit 1431679fb5
7 changed files with 1 additions and 2570 deletions

View File

@ -99,7 +99,7 @@ nacl {
kernel/qfunctions_nacl.h
}
unix:!symbian {
unix {
SOURCES += \
kernel/qcore_unix.cpp \
kernel/qcrashhandler.cpp \
@ -126,22 +126,6 @@ unix:!symbian {
contains(QT_CONFIG, clock-gettime):include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri)
}
symbian {
SOURCES += \
kernel/qcore_unix.cpp \
kernel/qcrashhandler.cpp \
kernel/qeventdispatcher_symbian.cpp \
kernel/qcore_symbian_p.cpp \
kernel/qsharedmemory_symbian.cpp \
kernel/qsystemsemaphore_symbian.cpp
HEADERS += \
kernel/qcore_unix_p.h \
kernel/qcrashhandler_p.h \
kernel/qeventdispatcher_symbian_p.h \
kernel/qcore_symbian_p.h
}
vxworks {
SOURCES += \
kernel/qfunctions_vxworks.cpp

View File

@ -1,317 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore 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 <exception>
#include <e32base.h>
#include <e32uid.h>
#include "qcore_symbian_p.h"
#include <string>
#include <in_sock.h>
QT_BEGIN_NAMESPACE
/*
Helper function for calling into Symbian classes that expect a TDes&.
This function converts a QString to a TDes by allocating memory that
must be deleted by the caller.
*/
Q_CORE_EXPORT HBufC* qt_QString2HBufC(const QString& aString)
{
HBufC *buffer;
#ifdef QT_NO_UNICODE
TPtrC8 ptr(reinterpret_cast<const TUint8*>(aString.toLocal8Bit().constData()));
#else
TPtrC16 ptr(qt_QString2TPtrC(aString));
#endif
buffer = HBufC::New(ptr.Length());
Q_CHECK_PTR(buffer);
buffer->Des().Copy(ptr);
return buffer;
}
Q_CORE_EXPORT QString qt_TDesC2QString(const TDesC& aDescriptor)
{
#ifdef QT_NO_UNICODE
return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length());
#else
return QString(reinterpret_cast<const QChar *>(aDescriptor.Ptr()), aDescriptor.Length());
#endif
}
QHBufC::QHBufC()
: m_hBufC(0)
{
}
QHBufC::QHBufC(const QHBufC &src)
: m_hBufC(src.m_hBufC->Alloc())
{
Q_CHECK_PTR(m_hBufC);
}
/*!
\internal
Constructs a QHBufC from an HBufC. Note that the QHBufC instance takes
ownership of the HBufC.
*/
QHBufC::QHBufC(HBufC *src)
: m_hBufC(src)
{
}
QHBufC::QHBufC(const QString &src)
{
m_hBufC = qt_QString2HBufC(src);
}
QHBufC::~QHBufC()
{
if (m_hBufC)
delete m_hBufC;
}
class QS60PluginResolver
{
public:
QS60PluginResolver()
: initTried(false) {}
~QS60PluginResolver() {
lib.Close();
}
TLibraryFunction resolve(int ordinal) {
if (!initTried) {
init();
initTried = true;
}
if (lib.Handle())
return lib.Lookup(ordinal);
else
return reinterpret_cast<TLibraryFunction>(NULL);
}
private:
void init()
{
_LIT(KLibName_3_1, "qts60plugin_3_1" QT_LIBINFIX_UNICODE L".dll");
_LIT(KLibName_3_2, "qts60plugin_3_2" QT_LIBINFIX_UNICODE L".dll");
_LIT(KLibName_5_0, "qts60plugin_5_0" QT_LIBINFIX_UNICODE L".dll");
TPtrC libName;
TInt uidValue;
switch (QSysInfo::s60Version()) {
case QSysInfo::SV_S60_3_1:
libName.Set(KLibName_3_1);
uidValue = 0x2001E620;
break;
case QSysInfo::SV_S60_3_2:
libName.Set(KLibName_3_2);
uidValue = 0x2001E621;
break;
case QSysInfo::SV_S60_5_0: // Fall through to default
default:
// Default to 5.0 version, as any unknown platform is likely to be newer than that
libName.Set(KLibName_5_0);
uidValue = 0x2001E622;
break;
}
TUidType libUid(KDynamicLibraryUid, KSharedLibraryUid, TUid::Uid(uidValue));
lib.Load(libName, libUid);
// Duplicate lib handle to enable process wide access to it. Since Duplicate overwrites
// existing handle without closing it, store original for subsequent closing.
RLibrary origHandleCloser = lib;
lib.Duplicate(RThread(), EOwnerProcess);
origHandleCloser.Close();
}
RLibrary lib;
bool initTried;
};
Q_GLOBAL_STATIC(QS60PluginResolver, qt_s60_plugin_resolver);
/*!
\internal
Resolves a platform version specific function from S60 plugin.
If plugin is missing or resolving fails for another reason, NULL is returned.
*/
Q_CORE_EXPORT TLibraryFunction qt_resolveS60PluginFunc(int ordinal)
{
return qt_s60_plugin_resolver()->resolve(ordinal);
}
class QS60RFsSession
{
public:
QS60RFsSession() {
qt_symbian_throwIfError(iFs.Connect());
qt_symbian_throwIfError(iFs.ShareProtected());
}
~QS60RFsSession() {
iFs.Close();
}
RFs& GetRFs() {
return iFs;
}
private:
RFs iFs;
};
uint qHash(const RSubSessionBase& key)
{
return qHash(key.SubSessionHandle());
}
Q_GLOBAL_STATIC(QS60RFsSession, qt_s60_RFsSession);
Q_CORE_EXPORT RFs& qt_s60GetRFs()
{
return qt_s60_RFsSession()->GetRFs();
}
QSymbianSocketManager::QSymbianSocketManager() :
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;
//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());
}
QSymbianSocketManager::~QSymbianSocketManager()
{
iSocketServ.Close();
if(!socketMap.isEmpty()) {
qWarning("leaked %d sockets on exit", socketMap.count());
}
}
RSocketServ& QSymbianSocketManager::getSocketServer() {
return iSocketServ;
}
int QSymbianSocketManager::addSocket(const RSocket& socket) {
QHashableSocket sock(static_cast<const QHashableSocket &>(socket));
QMutexLocker l(&iMutex);
Q_ASSERT(!socketMap.contains(sock));
if(socketMap.contains(sock))
return socketMap.value(sock);
// allocate socket number
int guard = 0;
while(reverseSocketMap.contains(iNextSocket)) {
iNextSocket++;
iNextSocket %= max_sockets;
guard++;
if(guard > max_sockets)
return -1;
}
int id = iNextSocket;
socketMap[sock] = id;
reverseSocketMap[id] = sock;
return id + socket_offset;
}
bool QSymbianSocketManager::removeSocket(const RSocket &socket) {
QHashableSocket sock(static_cast<const QHashableSocket &>(socket));
QMutexLocker l(&iMutex);
if(!socketMap.contains(sock))
return false;
int id = socketMap.value(sock);
socketMap.remove(sock);
reverseSocketMap.remove(id);
return true;
}
int QSymbianSocketManager::lookupSocket(const RSocket& socket) const {
QHashableSocket sock(static_cast<const QHashableSocket &>(socket));
QMutexLocker l(&iMutex);
if(!socketMap.contains(sock))
return -1;
int id = socketMap.value(sock);
return id + socket_offset;
}
bool QSymbianSocketManager::lookupSocket(int fd, RSocket& socket) const {
QMutexLocker l(&iMutex);
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()
{
return *(qt_symbianSocketManager());
}
Q_CORE_EXPORT RSocketServ& qt_symbianGetSocketServer()
{
return QSymbianSocketManager::instance().getSocketServer();
}
QT_END_NAMESPACE

View File

@ -1,282 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore 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 QCORE_SYMBIAN_P_H
#define QCORE_SYMBIAN_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of other Qt classes. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <e32std.h>
#include <QtCore/qglobal.h>
#include <QtCore/qmutex.h>
#include <qstring.h>
#include <qrect.h>
#include <qhash.h>
#include <f32file.h>
#include <es_sock.h>
#define QT_LSTRING2(x) L##x
#define QT_LSTRING(x) QT_LSTRING2(x)
#if defined(QT_LIBINFIX)
# define QT_LIBINFIX_UNICODE QT_LSTRING(QT_LIBINFIX)
#else
# define QT_LIBINFIX_UNICODE L""
#endif
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
Q_CORE_EXPORT HBufC* qt_QString2HBufC(const QString& aString);
Q_CORE_EXPORT QString qt_TDesC2QString(const TDesC& aDescriptor);
inline QString qt_TDes2QString(const TDes& aDescriptor) { return qt_TDesC2QString(aDescriptor); }
static inline QSize qt_TSize2QSize(const TSize& ts)
{
return QSize(ts.iWidth, ts.iHeight);
}
static inline TSize qt_QSize2TSize(const QSize& qs)
{
return TSize(qs.width(), qs.height());
}
static inline QRect qt_TRect2QRect(const TRect& tr)
{
return QRect(tr.iTl.iX, tr.iTl.iY, tr.Width(), tr.Height());
}
static inline TRect qt_QRect2TRect(const QRect& qr)
{
return TRect(TPoint(qr.left(), qr.top()), TSize(qr.width(), qr.height()));
}
// Returned TPtrC is valid as long as the given parameter is valid and unmodified
static inline TPtrC qt_QString2TPtrC( const QString& string )
{
return TPtrC16(static_cast<const TUint16*>(string.utf16()), string.length());
}
/*!
\internal
This class is a wrapper around the Symbian HBufC descriptor class.
It makes sure that the heap allocated HBufC class is freed when it is
destroyed.
*/
class Q_CORE_EXPORT QHBufC
{
public:
QHBufC();
QHBufC(const QHBufC &src);
QHBufC(HBufC *src);
QHBufC(const QString &src);
~QHBufC();
inline operator HBufC *() { return m_hBufC; }
inline operator const HBufC *() const { return m_hBufC; }
inline HBufC *data() { return m_hBufC; }
inline const HBufC *data() const { return m_hBufC; }
inline HBufC & operator*() { return *m_hBufC; }
inline const HBufC & operator*() const { return *m_hBufC; }
inline HBufC * operator->() { return m_hBufC; }
inline const HBufC * operator->() const { return m_hBufC; }
inline bool operator==(const QHBufC &param) const { return data() == param.data(); }
inline bool operator!=(const QHBufC &param) const { return data() != param.data(); }
private:
HBufC *m_hBufC;
};
inline uint qHash(TUid uid)
{
return qHash(uid.iUid);
}
// S60 version specific function ordinals that can be resolved
enum S60PluginFuncOrdinals
{
S60Plugin_TimeFormatL = 1,
S60Plugin_GetTimeFormatSpec = 2,
S60Plugin_GetLongDateFormatSpec = 3,
S60Plugin_GetShortDateFormatSpec = 4,
S60Plugin_LocalizedDirectoryName = 5,
S60Plugin_GetSystemDrive = 6
};
Q_CORE_EXPORT TLibraryFunction qt_resolveS60PluginFunc(int ordinal);
Q_CORE_EXPORT RFs& qt_s60GetRFs();
Q_CORE_EXPORT RSocketServ& qt_symbianGetSocketServer();
// Defined in qlocale_symbian.cpp.
Q_CORE_EXPORT QByteArray qt_symbianLocaleName(int code);
template <typename R>
struct QScopedPointerRCloser
{
static inline void cleanup(R *rPointer)
{
// Enforce a complete type.
// If you get a compile error here, read the section on forward declared
// classes in the QScopedPointer documentation.
typedef char IsIncompleteType[ sizeof(R) ? 1 : -1 ];
(void) sizeof(IsIncompleteType);
if (rPointer)
rPointer->Close();
}
};
//Wrapper for RSocket so it can be used as a key in QHash or QMap
class QHashableSocket : public RSocket
{
public:
bool operator==(const QHashableSocket &other) const
{
return SubSessionHandle() == other.SubSessionHandle()
&& Session().Handle() == other.Session().Handle();
}
bool operator<(const QHashableSocket &other) const
{
if (Session().Handle() == other.Session().Handle())
return SubSessionHandle() < other.SubSessionHandle();
return Session().Handle() < other.Session().Handle();
}
};
uint qHash(const RSubSessionBase& key);
/*!
\internal
This class exists in QtCore for the benefit of QSocketNotifier, which uses integer
file descriptors in its public API.
So we need a way to map between int and RSocket.
Additionally, it is used to host the global RSocketServ session
*/
class Q_CORE_EXPORT QSymbianSocketManager
{
public:
QSymbianSocketManager();
~QSymbianSocketManager();
/*!
\internal
\return handle to the socket server
*/
RSocketServ& getSocketServer();
/*!
\internal
Adds a symbian socket to the global map
\param an open socket
\return pseudo file descriptor, -1 if out of resources
*/
int addSocket(const RSocket &sock);
/*!
\internal
Removes a symbian socket from the global map
\param an open socket
\return true if the socket was in the map
*/
bool removeSocket(const RSocket &sock);
/*!
\internal
Get pseudo file descriptor for a socket
\param an open socket
\return integer handle, or -1 if not in map
*/
int lookupSocket(const RSocket &sock) const;
/*!
\internal
Get socket for a pseudo file descriptor
\param an open socket fd
\param sock (out) socket handle
\return true on success or false if not in map
*/
bool lookupSocket(int fd, RSocket& sock) const;
/*!
\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();
private:
int allocateSocket();
const static int max_sockets = 0x20000; //covers all TCP and UDP ports, probably run out of memory first
const static int socket_offset = 0x40000000; //hacky way of separating sockets from file descriptors
int iNextSocket;
QHash<QHashableSocket, int> socketMap;
QHash<int, RSocket> reverseSocketMap;
mutable QMutex iMutex;
RSocketServ iSocketServ;
RConnection *iDefaultConnection;
};
QT_END_NAMESPACE
QT_END_HEADER
#endif //QCORE_SYMBIAN_P_H

File diff suppressed because it is too large Load Diff

View File

@ -1,327 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore 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 QEVENTDISPATCHER_SYMBIAN_P_H
#define QEVENTDISPATCHER_SYMBIAN_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <qhash.h>
#include <qset.h>
#include <qshareddata.h>
#include <qabstracteventdispatcher.h>
#include <private/qabstracteventdispatcher_p.h>
#include <qthread.h>
#include <qmutex.h>
#include <qwaitcondition.h>
#include <qsocketnotifier.h>
#include <qdatetime.h>
#include <qelapsedtimer.h>
#include <e32base.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/select.h>
QT_BEGIN_NAMESPACE
class QEventDispatcherSymbian;
class QTimerActiveObject;
class Q_CORE_EXPORT QActiveObject : public CActive
{
public:
QActiveObject(TInt priority, QEventDispatcherSymbian *dispatcher);
~QActiveObject();
bool maybeQueueForLater();
bool maybeDeferSocketEvent();
void reactivateAndComplete();
static bool wait(CActive* ao, int ms);
static bool wait(QList<CActive*> aos, int ms);
protected:
QEventDispatcherSymbian *m_dispatcher;
private:
bool m_hasAlreadyRun : 1;
bool m_hasRunAgain : 1;
int m_iterationCount;
};
class QWakeUpActiveObject : public QActiveObject
{
public:
QWakeUpActiveObject(QEventDispatcherSymbian *dispatcher);
~QWakeUpActiveObject();
void Complete();
protected:
void DoCancel();
void RunL();
private:
TThreadId m_hostThreadId;
};
struct SymbianTimerInfo : public QSharedData
{
SymbianTimerInfo();
~SymbianTimerInfo();
int timerId;
int interval;
int msLeft;
bool inTimerEvent;
QObject *receiver;
QTimerActiveObject *timerAO;
QEventDispatcherSymbian *dispatcher;
};
typedef QExplicitlySharedDataPointer<SymbianTimerInfo> SymbianTimerInfoPtr;
// This is a bit of a proxy class. See comments in SetActive and Start for details.
class QTimerActiveObject : public QActiveObject
{
public:
QTimerActiveObject(QEventDispatcherSymbian *dispatcher, SymbianTimerInfo *timerInfo);
~QTimerActiveObject();
void Start();
protected:
void DoCancel();
void RunL();
private:
void Run();
void StartTimer();
private:
SymbianTimerInfo *m_timerInfo;
QElapsedTimer m_timeoutTimer;
int m_expectedTimeSinceLastEvent;
RTimer m_rTimer;
};
class QCompleteDeferredAOs : public CActive
{
public:
QCompleteDeferredAOs(QEventDispatcherSymbian *dispatcher);
~QCompleteDeferredAOs();
void complete();
protected:
void DoCancel();
void RunL();
private:
QEventDispatcherSymbian *m_dispatcher;
};
class QSocketActiveObject : public QActiveObject
{
public:
QSocketActiveObject(QEventDispatcherSymbian *dispatcher, QSocketNotifier *notifier);
~QSocketActiveObject();
void deleteLater();
protected:
void DoCancel();
void RunL();
void run();
private:
QSocketNotifier *m_notifier;
bool m_inSocketEvent;
bool m_deleteLater;
friend class QEventDispatcherSymbian;
};
class QSelectThread : public QThread
{
Q_DECLARE_PRIVATE(QThread)
public:
QSelectThread();
~QSelectThread();
void requestSocketEvents ( QSocketNotifier *notifier, TRequestStatus *status );
void cancelSocketEvents ( QSocketNotifier *notifier );
void restart();
void stop();
protected:
void run();
private:
int updateSocketSet(QSocketNotifier::Type type, fd_set *fds);
void updateActivatedNotifiers(QSocketNotifier::Type type, fd_set *fds);
private:
int m_pipeEnds[2];
QHash<QSocketNotifier *, TRequestStatus *> m_AOStatuses;
QMutex m_mutex;
QWaitCondition m_waitCond;
bool m_quit;
};
class Q_CORE_EXPORT CQtActiveScheduler : public CActiveScheduler
{
public: // from CActiveScheduler
virtual void Error(TInt aError) const;
};
class Q_CORE_EXPORT QEventDispatcherSymbian : public QAbstractEventDispatcher
{
Q_OBJECT
Q_DECLARE_PRIVATE(QAbstractEventDispatcher)
public:
QEventDispatcherSymbian(QObject *parent = 0);
~QEventDispatcherSymbian();
void flush();
bool hasPendingEvents();
void interrupt();
bool processEvents ( QEventLoop::ProcessEventsFlags flags );
void registerSocketNotifier ( QSocketNotifier * notifier );
void registerTimer ( int timerId, int interval, QObject * object );
QList<TimerInfo> registeredTimers ( QObject * object ) const;
void unregisterSocketNotifier ( QSocketNotifier * notifier );
bool unregisterTimer ( int timerId );
bool unregisterTimers ( QObject * object );
void wakeUp();
void startingUp();
void closingDown();
void timerFired(int timerId);
void wakeUpWasCalled();
void reactivateSocketNotifier(QSocketNotifier *notifier);
void addDeferredActiveObject(QActiveObject *object);
void removeDeferredActiveObject(QActiveObject *object);
void queueDeferredActiveObjectsCompletion();
// Can be overridden to activate local active objects too, but do call baseclass!
virtual void reactivateDeferredActiveObjects();
inline int iterationCount() const { return m_iterationCount; }
void addDeferredSocketActiveObject(QActiveObject *object);
inline bool areSocketEventsBlocked() const { return m_noSocketEvents; }
static void RequestComplete(TRequestStatus *&status, TInt reason);
static void RequestComplete(RThread &threadHandle, TRequestStatus *&status, TInt reason);
private:
bool sendPostedEvents();
bool sendDeferredSocketEvents();
QSelectThread& selectThread();
private:
QSelectThread *m_selectThread;
CQtActiveScheduler *m_activeScheduler;
QHash<int, SymbianTimerInfoPtr> m_timerList;
QHash<QSocketNotifier *, QSocketActiveObject *> m_notifiers;
QWakeUpActiveObject *m_wakeUpAO;
QCompleteDeferredAOs *m_completeDeferredAOs;
volatile bool m_interrupt;
QAtomicInt m_wakeUpDone;
unsigned char m_iterationCount;
bool m_insideTimerEvent;
bool m_noSocketEvents;
//deferred until socket events are enabled
QList<QActiveObject *> m_deferredSocketEvents;
//deferred until idle
QList<QActiveObject *> m_deferredActiveObjects;
int m_delay;
int m_avgEventTime;
QElapsedTimer m_lastIdleRequestTimer;
};
#ifdef QT_DEBUG
# define VERIFY_PENDING_REQUEST_STATUS \
Q_ASSERT(status->Int() == KRequestPending);
#else
# define VERIFY_PENDING_REQUEST_STATUS
#endif
// Convenience functions for doing some sanity checking on our own complete code.
// Unless QT_DEBUG is defined, it is exactly equivalent to the Symbian version.
inline void QEventDispatcherSymbian::RequestComplete(TRequestStatus *&status, TInt reason)
{
VERIFY_PENDING_REQUEST_STATUS
User::RequestComplete(status, reason);
}
inline void QEventDispatcherSymbian::RequestComplete(RThread &threadHandle, TRequestStatus *&status, TInt reason)
{
VERIFY_PENDING_REQUEST_STATUS
threadHandle.RequestComplete(status, reason);
}
#undef VERIFY_PENDING_REQUEST_STATUS
QT_END_NAMESPACE
#endif // QEVENTDISPATCHER_SYMBIAN_P_H

View File

@ -1,173 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore 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 "qsharedmemory.h"
#include "qsharedmemory_p.h"
#include "qsystemsemaphore.h"
#include "qcore_symbian_p.h"
#include <qdebug.h>
QT_BEGIN_NAMESPACE
#ifndef QT_NO_SHAREDMEMORY
#define QSHAREDMEMORY_DEBUG
QSharedMemoryPrivate::QSharedMemoryPrivate() : QObjectPrivate(),
memory(0), size(0), error(QSharedMemory::NoError),
systemSemaphore(QString()), lockedByMe(false)
{
}
void QSharedMemoryPrivate::setErrorString(const QString &function, TInt errorCode)
{
if (errorCode == KErrNone)
return;
switch (errorCode) {
case KErrAlreadyExists:
error = QSharedMemory::AlreadyExists;
errorString = QSharedMemory::tr("%1: already exists").arg(function);
break;
case KErrNotFound:
error = QSharedMemory::NotFound;
errorString = QSharedMemory::tr("%1: doesn't exists").arg(function);
break;
case KErrArgument:
error = QSharedMemory::InvalidSize;
errorString = QSharedMemory::tr("%1: invalid size").arg(function);
break;
case KErrNoMemory:
error = QSharedMemory::OutOfResources;
errorString = QSharedMemory::tr("%1: out of resources").arg(function);
break;
case KErrPermissionDenied:
error = QSharedMemory::PermissionDenied;
errorString = QSharedMemory::tr("%1: permission denied").arg(function);
break;
default:
errorString = QSharedMemory::tr("%1: unknown error %2").arg(function).arg(errorCode);
error = QSharedMemory::UnknownError;
#if defined QSHAREDMEMORY_DEBUG
qDebug() << errorString << "key" << key;
#endif
}
}
key_t QSharedMemoryPrivate::handle()
{
// Not really cost effective to check here if shared memory is attachable, as it requires
// exactly the same call as attaching, so always assume handle is valid and return failure
// from attach.
return 1;
}
bool QSharedMemoryPrivate::cleanHandle()
{
chunk.Close();
return true;
}
bool QSharedMemoryPrivate::create(int size)
{
QString function = QLatin1String("QSharedMemory::create");
if (nativeKey.isEmpty()) {
error = QSharedMemory::KeyError;
errorString = QSharedMemory::tr("%1: key error").arg(function);
return false;
}
TPtrC ptr(qt_QString2TPtrC(nativeKey));
TInt err = chunk.CreateGlobal(ptr, size, size);
setErrorString(function, err);
if (err != KErrNone)
return false;
// Zero out the created chunk
Mem::FillZ(chunk.Base(), chunk.Size());
return true;
}
bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode /* mode */)
{
// Grab a pointer to the memory block
if (!chunk.Handle()) {
QString function = QLatin1String("QSharedMemory::handle");
if (nativeKey.isEmpty()) {
error = QSharedMemory::KeyError;
errorString = QSharedMemory::tr("%1: unable to make key").arg(function);
return false;
}
TPtrC ptr(qt_QString2TPtrC(nativeKey));
TInt err = KErrNoMemory;
err = chunk.OpenGlobal(ptr, false);
if (err != KErrNone) {
setErrorString(function, err);
return false;
}
}
size = chunk.Size();
memory = chunk.Base();
return true;
}
bool QSharedMemoryPrivate::detach()
{
chunk.Close();
memory = 0;
size = 0;
return true;
}
#endif //QT_NO_SHAREDMEMORY
QT_END_NAMESPACE

View File

@ -1,138 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore 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 "qsystemsemaphore.h"
#include "qsystemsemaphore_p.h"
#include "qcoreapplication.h"
#include <qdebug.h>
#include "qcore_symbian_p.h"
#include <e32cmn.h>
QT_BEGIN_NAMESPACE
#ifndef QT_NO_SYSTEMSEMAPHORE
QSystemSemaphorePrivate::QSystemSemaphorePrivate() :
error(QSystemSemaphore::NoError)
{
}
void QSystemSemaphorePrivate::setErrorString(const QString &function, int err)
{
if (err == KErrNone){
return;
}
switch(err){
case KErrAlreadyExists:
errorString = QCoreApplication::tr("%1: already exists", "QSystemSemaphore").arg(function);
error = QSystemSemaphore::AlreadyExists;
break;
case KErrNotFound:
errorString = QCoreApplication::tr("%1: does not exist", "QSystemSemaphore").arg(function);
error = QSystemSemaphore::NotFound;
break;
case KErrNoMemory:
case KErrInUse:
errorString = QCoreApplication::tr("%1: out of resources", "QSystemSemaphore").arg(function);
error = QSystemSemaphore::OutOfResources;
break;
case KErrPermissionDenied:
errorString = QCoreApplication::tr("%1: permission denied", "QSystemSemaphore").arg(function);
error = QSystemSemaphore::PermissionDenied;
break;
default:
errorString = QCoreApplication::tr("%1: unknown error %2", "QSystemSemaphore").arg(function).arg(err);
error = QSystemSemaphore::UnknownError;
}
#if defined QSYSTEMSEMAPHORE_DEBUG
qDebug() << errorString << "key" << key;
#endif
}
int QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode)
{
if (semaphore.Handle()) {
return semaphore.Handle();
}
// don't allow making handles on empty keys
if (key.isEmpty())
return 0;
TPtrC name(qt_QString2TPtrC(fileName));
int err = KErrAlreadyExists;
int tryCount = 10;
// Sort out race conditions by retrying several times until existing handle is acquired.
// Sometimes opening can fail inexplicably with KErrPermissionDenied many times in a row.
while (err != KErrNoMemory && err != KErrNone && tryCount-- >= 0) {
err = semaphore.CreateGlobal(name, initialValue, EOwnerProcess);
if (err != KErrNoMemory && err != KErrNone)
err = semaphore.OpenGlobal(name,EOwnerProcess);
}
if (err){
setErrorString(QLatin1String("QSystemSemaphore::handle"),err);
return 0;
}
return semaphore.Handle();
}
void QSystemSemaphorePrivate::cleanHandle()
{
semaphore.Close();
}
bool QSystemSemaphorePrivate::modifySemaphore(int count)
{
if (0 == handle())
return false;
if (count > 0) {
semaphore.Signal(count);
} else {
semaphore.Wait();
}
return true;
}
#endif //QT_NO_SYSTEMSEMAPHORE
QT_END_NAMESPACE