diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2011-03-25 14:08:28 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2011-03-25 14:08:28 (GMT) |
commit | 12fd077f71a8bc6f865e4e8a4ffe61d5d1b8a504 (patch) | |
tree | ba98e1ff32f288b47b0a05eb0fc293e3c3420889 /src/corelib/kernel | |
parent | be5e7924ec7bd6cccd626f931f55e2687910ad13 (diff) | |
parent | 116fed06f9ed561befb505d94b6b44dc71bf9e45 (diff) | |
download | Qt-12fd077f71a8bc6f865e4e8a4ffe61d5d1b8a504.zip Qt-12fd077f71a8bc6f865e4e8a4ffe61d5d1b8a504.tar.gz Qt-12fd077f71a8bc6f865e4e8a4ffe61d5d1b8a504.tar.bz2 |
Merge remote branch 'earth/master' into symbian-socket-engine
Conflicts:
src/network/access/qhttpnetworkconnectionchannel.cpp
src/network/socket/qlocalsocket.cpp
src/s60installs/bwins/QtCoreu.def
src/s60installs/bwins/QtGuiu.def
src/s60installs/bwins/QtTestu.def
src/s60installs/eabi/QtCoreu.def
src/s60installs/eabi/QtGuiu.def
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/kernel.pri | 23 | ||||
-rw-r--r-- | src/corelib/kernel/qcrashhandler.cpp | 3 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_unix.cpp | 4 | ||||
-rw-r--r-- | src/corelib/kernel/qfunctions_nacl.cpp | 156 | ||||
-rw-r--r-- | src/corelib/kernel/qfunctions_nacl.h | 97 | ||||
-rw-r--r-- | src/corelib/kernel/qfunctions_p.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qsystemerror.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qsystemerror_p.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qtranslator.cpp | 151 | ||||
-rw-r--r-- | src/corelib/kernel/qtranslator.h | 6 |
10 files changed, 441 insertions, 5 deletions
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index 93818d1..a3628b1 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -90,6 +90,13 @@ mac:!nacl { kernel/qcore_mac.cpp } +nacl { + SOURCES += \ + kernel/qfunctions_nacl.cpp + HEADERS += \ + kernel/qfunctions_nacl.h +} + unix:!symbian { SOURCES += \ kernel/qcore_unix.cpp \ @@ -139,3 +146,19 @@ vxworks { kernel/qfunctions_vxworks.h } + +integrity { + SOURCES += \ + kernel/qcore_unix.cpp \ + kernel/qcrashhandler.cpp \ + kernel/qsharedmemory_unix.cpp \ + kernel/qsystemsemaphore_unix.cpp \ + kernel/qeventdispatcher_unix.cpp + HEADERS += \ + kernel/qcore_unix_p.h \ + kernel/qcrashhandler_p.h \ + kernel/qeventdispatcher_unix_p.h + + contains(QT_CONFIG, clock-gettime):include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri) +} + diff --git a/src/corelib/kernel/qcrashhandler.cpp b/src/corelib/kernel/qcrashhandler.cpp index 59f3796..fbdbac0 100644 --- a/src/corelib/kernel/qcrashhandler.cpp +++ b/src/corelib/kernel/qcrashhandler.cpp @@ -339,6 +339,9 @@ static void print_backtrace(FILE *outb) "EOF\n", globalProgName, (int)getpid())) return; +#elif defined(Q_OS_INTEGRITY) + /* abort */ + CheckSuccess(Failure); #else /* All other platforms */ /* * TODO: SCO/UnixWare 7 must be something like (not tested) diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp index 25c02c4..dceb51d 100644 --- a/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -116,7 +116,7 @@ QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate() // do nothing. #elif defined(Q_OS_INTEGRITY) // INTEGRITY doesn't like a "select" on pipes, so use socketpair instead - if (socketpair(AF_INET, SOCK_STREAM, PF_INET, thread_pipe) == -1) { + if (socketpair(AF_INET, SOCK_STREAM, 0, thread_pipe) == -1) { perror("QEventDispatcherUNIXPrivate(): Unable to create socket pair"); pipefail = true; } else { @@ -343,7 +343,7 @@ timeval QTimerInfoList::updateCurrentTime() return (currentTime = qt_gettime()); } -#if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)) || defined(QT_BOOTSTRAPPED) +#if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC) && !defined(Q_OS_INTEGRITY)) || defined(QT_BOOTSTRAPPED) template <> timeval qAbs(const timeval &t) diff --git a/src/corelib/kernel/qfunctions_nacl.cpp b/src/corelib/kernel/qfunctions_nacl.cpp new file mode 100644 index 0000000..f3d85ef --- /dev/null +++ b/src/corelib/kernel/qfunctions_nacl.cpp @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** 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$ +** 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qfunctions_nacl.h" +#include <pthread.h> +#include <qglobal.h> + +/* + The purpose of this file is to stub out certain functions + that are not provided by the Native Client SDK. This is + done as an alterative to sprinkling the Qt sources with + NACL ifdefs. + + There are two main classes of functions: + + - Functions that are called but can have no effect: + For these we simply give an empty implementation + + - Functions that are referenced in the source code, but + is not/must not be called at run-time: + These we either leave undefined or implement with a + qFatal. + + This is a work in progress. +*/ + +extern "C" { + +void pthread_cleanup_push(void (*)(void *), void *) +{ + +} + +void pthread_cleanup_pop(int) +{ + +} + +int pthread_setcancelstate(int, int *) +{ + return 0; +} + +int pthread_setcanceltype(int, int *) +{ + return 0; +} + +void pthread_testcancel(void) +{ + +} + + +int pthread_cancel(pthread_t) +{ + return 0; +} + +int pthread_attr_setinheritsched(pthread_attr_t *,int) +{ + return 0; +} + + +int pthread_attr_getinheritsched(const pthread_attr_t *, int *) +{ + return 0; +} + +// event dispatcher, select +//struct fd_set; +//struct timeval; + +int fcntl(int, int, ...) +{ + return 0; +} + +int sigaction(int, const struct sigaction *, struct sigaction *) +{ + return 0; +} + +int open(const char *, int, ...) +{ + return 0; +} + +int open64(const char *, int, ...) +{ + return 0; +} + +int access(const char *, int) +{ + return 0; +} + +typedef long off64_t; +off64_t ftello64(void *) +{ + qFatal("ftello64 called"); + return 0; +} + +off64_t lseek64(int, off_t, int) +{ + qFatal("lseek64 called"); + return 0; +} + +} // Extern C + +int select(int, fd_set *, fd_set *, fd_set *, struct timeval *) +{ + return 0; +} diff --git a/src/corelib/kernel/qfunctions_nacl.h b/src/corelib/kernel/qfunctions_nacl.h new file mode 100644 index 0000000..db36ad5 --- /dev/null +++ b/src/corelib/kernel/qfunctions_nacl.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** 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$ +** 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QNACLUNIMPLEMENTED_H +#define QNACLUNIMPLEMENTED_H + +#ifdef Q_OS_NACL + +#include <sys/types.h> + +// pthread +#include <pthread.h> +#define PTHREAD_CANCEL_DISABLE 1 +#define PTHREAD_CANCEL_ENABLE 2 +#define PTHREAD_INHERIT_SCHED 3 + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Core) + +extern "C" { + +void pthread_cleanup_push(void (*handler)(void *), void *arg); +void pthread_cleanup_pop(int execute); + +int pthread_setcancelstate(int state, int *oldstate); +int pthread_setcanceltype(int type, int *oldtype); +void pthread_testcancel(void); +int pthread_cancel(pthread_t thread); + +int pthread_attr_setinheritsched(pthread_attr_t *attr, + int inheritsched); +int pthread_attr_getinheritsched(const pthread_attr_t *attr, + int *inheritsched); + +// event dispatcher, select +//struct fd_set; +//struct timeval; +int fcntl(int fildes, int cmd, ...); +int sigaction(int sig, const struct sigaction * act, struct sigaction * oact); + +typedef long off64_t; +off64_t ftello64(void *stream); +off64_t lseek64(int fildes, off_t offset, int whence); +int open64(const char *path, int oflag, ...); + +} + +int select(int nfds, fd_set * readfds, fd_set * writefds, fd_set * errorfds, struct timeval * timeout); + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif //Q_OS_NACL + +#endif //QNACLUNIMPLEMENTED_H diff --git a/src/corelib/kernel/qfunctions_p.h b/src/corelib/kernel/qfunctions_p.h index 3d41c0c..d27fec3 100644 --- a/src/corelib/kernel/qfunctions_p.h +++ b/src/corelib/kernel/qfunctions_p.h @@ -59,6 +59,8 @@ # include "QtCore/qfunctions_wince.h" #elif defined(Q_OS_VXWORKS) # include "QtCore/qfunctions_vxworks.h" +#elif defined(Q_OS_NACL) +# include "QtCore/qfunctions_nacl.h" #endif #ifdef Q_CC_RVCT diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp index 5cf8fc6..18622c7 100644 --- a/src/corelib/kernel/qsystemerror.cpp +++ b/src/corelib/kernel/qsystemerror.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/corelib/kernel/qsystemerror_p.h b/src/corelib/kernel/qsystemerror_p.h index c2a13a8..e96e85a 100644 --- a/src/corelib/kernel/qsystemerror_p.h +++ b/src/corelib/kernel/qsystemerror_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index d72c1ab..802cf1c 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -47,6 +47,7 @@ #include "qfileinfo.h" #include "qstring.h" +#include "qstringlist.h" #include "qcoreapplication.h" #include "qcoreapplication_p.h" #include "qdatastream.h" @@ -55,8 +56,9 @@ #include "qalgorithms.h" #include "qhash.h" #include "qtranslator_p.h" +#include "qlocale.h" -#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) +#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) && !defined(Q_OS_INTEGRITY) #define QT_USE_MMAP #include "private/qcore_unix_p.h" #endif @@ -236,6 +238,7 @@ public: uint contextLength; uint numerusRulesLength; + bool do_load(const QString &filename); bool do_load(const uchar *data, int len); QString do_translate(const char *context, const char *sourceText, const char *comment, int n) const; @@ -435,7 +438,12 @@ bool QTranslator::load(const QString & filename, const QString & directory, } // realname is now the fully qualified name of a readable file. + return d->do_load(realname); +} +bool QTranslatorPrivate::do_load(const QString &realname) +{ + QTranslatorPrivate *d = this; bool ok = false; #ifdef QT_USE_MMAP @@ -497,6 +505,147 @@ bool QTranslator::load(const QString & filename, const QString & directory, return d->do_load(reinterpret_cast<const uchar *>(d->unmapPointer), d->unmapLength); } +static QString find_translation(const QLocale & locale, + const QString & filename, + const QString & prefix, + const QString & directory, + const QString & suffix) +{ + QString path; + if (QFileInfo(filename).isRelative()) { + path = directory; + if (!path.isEmpty() && !path.endsWith(QLatin1Char('/'))) + path += QLatin1Char('/'); + } + + QFileInfo fi; + QString realname; + QStringList fuzzyLocales; + + // see http://www.unicode.org/reports/tr35/#LanguageMatching for inspiration + + QStringList languages = locale.uiLanguages(); +#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) + for (int i = languages.size()-1; i >= 0; --i) { + QString lang = languages.at(i); + QString lowerLang = lang.toLower(); + if (lang != lowerLang) + languages.insert(i+1, lowerLang); + } +#endif + + // try explicit locales names first + foreach (QString localeName, languages) { + localeName.replace(QLatin1Char('-'), QLatin1Char('_')); + + realname = path + filename + prefix + localeName + (suffix.isNull() ? QLatin1String(".qm") : suffix); + fi.setFile(realname); + if (fi.isReadable() && fi.isFile()) + return realname; + + realname = path + filename + prefix + localeName; + fi.setFile(realname); + if (fi.isReadable() && fi.isFile()) + return realname; + + fuzzyLocales.append(localeName); + } + + // start guessing + foreach (QString localeName, fuzzyLocales) { + for (;;) { + int rightmost = localeName.lastIndexOf(QLatin1Char('_')); + // no truncations? fail + if (rightmost <= 0) + break; + localeName.truncate(rightmost); + + realname = path + filename + prefix + localeName + (suffix.isNull() ? QLatin1String(".qm") : suffix); + fi.setFile(realname); + if (fi.isReadable() && fi.isFile()) + return realname; + + realname = path + filename + prefix + localeName; + fi.setFile(realname); + if (fi.isReadable() && fi.isFile()) + return realname; + } + } + + if (!suffix.isNull()) { + realname = path + filename + suffix; + fi.setFile(realname); + if (fi.isReadable() && fi.isFile()) + return realname; + } + + realname = path + filename + prefix; + fi.setFile(realname); + if (fi.isReadable() && fi.isFile()) + return realname; + + realname = path + filename; + fi.setFile(realname); + if (fi.isReadable() && fi.isFile()) + return realname; + + return QString(); +} + +/*! + \since 4.8 + + Loads \a filename + \a prefix + \a locale name + \a suffix (".qm" if the \a + suffix is not specified), which may be an absolute file name or relative to + \a directory. Returns true if the translation is successfully loaded; + otherwise returns false. + + The previous contents of this translator object are discarded. + + If the file name does not exist, other file names are tried + in the following order: + + \list 1 + \o File name without \a suffix appended. + \o File name with locale part after a "_" character stripped and \a suffix. + \o File name with locale part stripped without \a suffix appended. + \o File name with locale part stripped further, etc. + \endlist + + For example, an application running in the locale with the following + l{QLocale::uiLanguages()}{ui languages} - "es", "fr-CA", "de" might call + load(QLocale::system(), "foo", ".", "/opt/foolib", ".qm"). load() would + then try to open the first existing readable file from this list: + + \list 1 + \o \c /opt/foolib/foo.es.qm + \o \c /opt/foolib/foo.es + \o \c /opt/foolib/foo.fr_CA.qm + \o \c /opt/foolib/foo.fr_CA + \o \c /opt/foolib/foo.de.qm + \o \c /opt/foolib/foo.de + \o \c /opt/foolib/foo.fr.qm + \o \c /opt/foolib/foo.fr + \o \c /opt/foolib/foo.qm + \o \c /opt/foolib/foo. + \o \c /opt/foolib/foo + \endlist + + For OSs where file system is case sensitive, QTranslator also tries to load + a lower-cased version of the locale name. +*/ +bool QTranslator::load(const QLocale & locale, + const QString & filename, + const QString & prefix, + const QString & directory, + const QString & suffix) +{ + Q_D(QTranslator); + d->clear(); + QString fname = find_translation(locale, filename, prefix, directory, suffix); + return !fname.isEmpty() && d->do_load(fname); +} + /*! \overload load() \fn bool QTranslator::load(const uchar *data, int len) diff --git a/src/corelib/kernel/qtranslator.h b/src/corelib/kernel/qtranslator.h index 33e7f03..7a4fa00 100644 --- a/src/corelib/kernel/qtranslator.h +++ b/src/corelib/kernel/qtranslator.h @@ -53,6 +53,7 @@ QT_MODULE(Core) #ifndef QT_NO_TRANSLATION +class QLocale; class QTranslatorPrivate; class Q_CORE_EXPORT QTranslator : public QObject @@ -77,6 +78,11 @@ public: const QString & directory = QString(), const QString & search_delimiters = QString(), const QString & suffix = QString()); + bool load(const QLocale & locale, + const QString & filename, + const QString & prefix = QString(), + const QString & directory = QString(), + const QString & suffix = QString()); bool load(const uchar *data, int len); #ifdef QT3_SUPPORT |