diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-09-07 13:58:08 +1000 |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-09-07 13:58:08 +1000 |
commit | 579e54d588bb435ecead39c38111747e948a7824 (patch) | |
tree | 4f63ee59adb8eb123902a7f5e0574da38a22a178 /src | |
parent | d77ee9ad223c90cb5c690526632d978c0901d226 (diff) | |
parent | 3113a91f50f12c8ee53f2e84f6b46fde6c2c1693 (diff) | |
download | qt4-tools-579e54d588bb435ecead39c38111747e948a7824.tar.gz |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src')
36 files changed, 2241 insertions, 403 deletions
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog b/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog index 93431dfa85..fbaf5d2798 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog +++ b/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog @@ -1,3 +1,39 @@ +2010-06-18 Tucker Jay <jay.tucker@nokia.com> + + Reviewed by NOBODY (OOPS!). + + [Symbian] Lazy commit of memory required in JSC register file + https://bugs.webkit.org/show_bug.cgi?id=34349 + + * JavaScriptCore.pro: Added 1 new Symbian source file + * interpreter/RegisterFile.cpp: + (JSC::RegisterFile::~RegisterFile): + * interpreter/RegisterFile.h: + (JSC::RegisterFile::): + (JSC::RegisterFile::start): + (JSC::RegisterFile::end): + (JSC::RegisterFile::size): + (JSC::RegisterFile::setNumGlobals): + (JSC::RegisterFile::numGlobals): + (JSC::RegisterFile::maxGlobals): + (JSC::RegisterFile::lastGlobal): + (JSC::RegisterFile::markGlobals): + (JSC::RegisterFile::markCallFrames): + (JSC::isPageAligned): + (JSC::RegisterFile::RegisterFile): + (JSC::RegisterFile::shrink): + (JSC::RegisterFile::grow): + * wtf/symbian/RegisterFileAllocatorSymbian.cpp: Added. + (WTF::RegisterFileAllocator::RegisterFileAllocator): + Helper class to allocate memory required by RegisterFile + more efficiently. + (WTF::RegisterFileAllocator::~RegisterFileAllocator): + (WTF::RegisterFileAllocator::buffer): + (WTF::RegisterFileAllocator::grow): + (WTF::RegisterFileAllocator::shrink): + * wtf/symbian/RegisterFileAllocatorSymbian.h: Added. + * wtf/symbian/SymbianDefines.h: Added. + 2010-06-19 Thiago Macieira <thiago.macieira@nokia.com> Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri b/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri index 75737aed66..d75bd31198 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri +++ b/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri @@ -211,6 +211,7 @@ SOURCES += \ wtf/qt/ThreadingQt.cpp \ wtf/RandomNumber.cpp \ wtf/RefCountedLeakCounter.cpp \ + wtf/symbian/RegisterFileAllocatorSymbian.cpp \ wtf/ThreadingNone.cpp \ wtf/Threading.cpp \ wtf/TypeTraits.cpp \ diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/RegisterFile.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/RegisterFile.cpp index 939573b404..293fc385eb 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/RegisterFile.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/RegisterFile.cpp @@ -40,6 +40,8 @@ RegisterFile::~RegisterFile() VirtualFree(m_buffer, DWORD(m_commitEnd) - DWORD(m_buffer), MEM_DECOMMIT); #endif VirtualFree(m_buffer, 0, MEM_RELEASE); +#elif OS(SYMBIAN) + delete m_registerFileAllocator; #else fastFree(m_buffer); #endif diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/RegisterFile.h b/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/RegisterFile.h index 34e25042e0..49304d9b60 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/RegisterFile.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/RegisterFile.h @@ -41,6 +41,10 @@ #include <sys/mman.h> #endif +#if OS(SYMBIAN) +#include <wtf/symbian/RegisterFileAllocatorSymbian.h> +#endif + namespace JSC { /* @@ -152,12 +156,21 @@ namespace JSC { #if HAVE(VIRTUALALLOC) Register* m_commitEnd; #endif +#if OS(SYMBIAN) + // Commits and frees a continguous chunk of memory as required + WTF::RegisterFileAllocator* m_registerFileAllocator; +#endif JSGlobalObject* m_globalObject; // The global object whose vars are currently stored in the register file. }; // FIXME: Add a generic getpagesize() to WTF, then move this function to WTF as well. - inline bool isPageAligned(size_t size) { return size != 0 && size % (8 * 1024) == 0; } + // This is still a hack that should be fixed later. We know that a Symbian page size is 4K. + #if OS(SYMBIAN) + inline bool isPageAligned(size_t size) { return size && !(size % (4 * 1024)); } + #else + inline bool isPageAligned(size_t size) { return size && !(size % (8 * 1024)); } + #endif inline RegisterFile::RegisterFile(size_t capacity, size_t maxGlobals) : m_numGlobals(0) @@ -204,7 +217,13 @@ namespace JSC { CRASH(); } m_commitEnd = reinterpret_cast<Register*>(reinterpret_cast<char*>(m_buffer) + committedSize); - #else + #elif OS(SYMBIAN) + m_registerFileAllocator = new WTF::RegisterFileAllocator(bufferLength); + m_buffer = (Register*)(m_registerFileAllocator->buffer()); + // start by committing enough space to hold maxGlobals + void* newEnd = (void*)((int)m_buffer + (maxGlobals * sizeof(Register))); + m_registerFileAllocator->grow(newEnd); + #else /* * If neither MMAP nor VIRTUALALLOC are available - use fastMalloc instead. * @@ -226,8 +245,13 @@ namespace JSC { if (newEnd >= m_end) return; m_end = newEnd; - if (m_end == m_start && (m_maxUsed - m_start) > maxExcessCapacity) + if (m_end == m_start && (m_maxUsed - m_start) > maxExcessCapacity) { +#if OS(SYMBIAN) + m_registerFileAllocator->shrink(newEnd); +#endif + releaseExcessCapacity(); + } } inline bool RegisterFile::grow(Register* newEnd) @@ -252,6 +276,9 @@ namespace JSC { m_commitEnd = reinterpret_cast<Register*>(reinterpret_cast<char*>(m_commitEnd) + size); } #endif +#if OS(SYMBIAN) + m_registerFileAllocator->grow((void*)newEnd); +#endif if (newEnd > m_maxUsed) m_maxUsed = newEnd; diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/RegisterFileAllocatorSymbian.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/RegisterFileAllocatorSymbian.cpp new file mode 100644 index 0000000000..baa7841a2d --- /dev/null +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/RegisterFileAllocatorSymbian.cpp @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if OS(SYMBIAN) + +#include "RegisterFileAllocatorSymbian.h" + +namespace WTF { + +/** Efficiently allocates memory pools of size poolSize. + * Primarily designed for JSC RegisterFile's needs. + * Not thread-safe. + */ +RegisterFileAllocator::RegisterFileAllocator(TUint32 reservationSize, TUint32 poolSize) : + m_reserved(reservationSize), m_poolSize(poolSize) +{ + // Get system's page size value. + SYMBIAN_PAGESIZE(m_pageSize); + + // We only accept multiples of system page size for both initial reservation + // and the alignment/pool size + m_reserved = SYMBIAN_ROUNDUPTOMULTIPLE(m_reserved, m_pageSize); + __ASSERT_ALWAYS(SYMBIAN_ROUNDUPTOMULTIPLE(m_poolSize, m_pageSize), + User::Panic(_L("RegisterFileAllocator1"), KErrArgument)); + + // Open a Symbian RChunk, and reserve requested virtual address range + // Any thread in this process can operate this RChunk due to EOwnerProcess access rights. + TInt ret = m_chunk.CreateDisconnectedLocal(0 , 0, (TInt)m_reserved , EOwnerProcess); + if (ret != KErrNone) + User::Panic(_L("RegisterFileAllocator2"), ret); + + m_buffer = (void*)m_chunk.Base(); + m_resEnd = (void*)(m_chunk.Base() + m_chunk.MaxSize()); + m_comEnd = m_buffer; +} + +RegisterFileAllocator::~RegisterFileAllocator() +{ + // release everything! + m_chunk.Decommit(0, m_chunk.MaxSize()); + m_chunk.Close(); +} + +void* RegisterFileAllocator::buffer() const +{ + return m_buffer; +} + +void RegisterFileAllocator::grow(void* newEnd) +{ + // trying to commit more memory than reserved! + if (newEnd > m_resEnd) + return; + + if (newEnd > m_comEnd) { + TInt nBytes = (TInt)(newEnd) - (TInt)(m_comEnd); + nBytes = SYMBIAN_ROUNDUPTOMULTIPLE(nBytes, m_poolSize); + TInt offset = (TInt)m_comEnd - (TInt)m_buffer; + + TInt ret = m_chunk.Commit(offset, nBytes); + if (ret == KErrNone) + m_comEnd = (void*)(m_chunk.Base() + m_chunk.Size()); + } +} + +void RegisterFileAllocator::shrink(void* newEnd) +{ + if (newEnd < m_comEnd) { + TInt nBytes = (TInt)newEnd - (TInt)m_comEnd; + if (nBytes >= m_poolSize) { + TInt offset = SYMBIAN_ROUNDUPTOMULTIPLE((TUint)newEnd, m_poolSize) - (TInt)m_buffer; + nBytes = (TInt)m_comEnd - offset - (TInt)m_buffer; + if (nBytes > 0) { + TInt ret = m_chunk.Decommit(offset, nBytes); + if (ret == KErrNone) + m_comEnd = (void*)(m_chunk.Base() + m_chunk.Size()); + } + } + } +} + +} // end of namespace + +#endif // SYMBIAN diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/RegisterFileAllocatorSymbian.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/RegisterFileAllocatorSymbian.h new file mode 100644 index 0000000000..4cfc8c5de6 --- /dev/null +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/RegisterFileAllocatorSymbian.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef RegisterFileAllocatorSymbian_h +#define RegisterFileAllocatorSymbian_h + +#include "SymbianDefines.h" + +namespace WTF { + +/** + * Allocates contiguous regions of size poolSize. + * poolSize must be a multiple of system page size (typically 4K on Symbian/ARM) + * + * @param reservationSize Virtual address range to be reserved upon creation of chunk (bytes). + * @param poolSize Size of a single allocation. + */ +class RegisterFileAllocator { + +public: + RegisterFileAllocator( + TUint32 reservationSize, TUint32 poolSize = SYMBIAN_REGFILEALLOC_DEFAULTPOOLSIZE); + ~RegisterFileAllocator(); + void* buffer() const; + void grow(void* newEnd); + void shrink(void* newEnd); + +private: + RChunk m_chunk; // Symbian chunk that lets us reserve/commit/decommit + + // all following values are in numbers of bytes + TInt m_pageSize; // cached value of system page size, typically 4K on Symbian + TUint32 m_reserved; // total number of reserved bytes in virtual memory + TUint32 m_poolSize; // size of one memory pool, set by default to 64K in wtf/symbian/SymbianDefines.h + + void* m_buffer; // pointer to base of the chunk + void* m_comEnd; // pointer to end of currently committed memory + void* m_resEnd; // pointer to end of reserved memory + +}; + +} // end of namespace + +#endif // RegisterFileAllocatorSymbian_h diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/SymbianDefines.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/SymbianDefines.h new file mode 100644 index 0000000000..43e22b389a --- /dev/null +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/SymbianDefines.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SymbianDefines_h +#define SymbianDefines_h + +#include <e32cmn.h> +#include <e32std.h> +#include <hal.h> + +#define SYMBIAN_PAGESIZE(x) (HAL::Get(HALData::EMemoryPageSize, x)); +#define SYMBIAN_FREERAM(x) (HAL::Get(HALData::EMemoryRAMFree, x)); +#define SYMBIAN_ROUNDUPTOMULTIPLE(x, multipleof) ( (x + multipleof - 1) & ~(multipleof - 1) ) + +#define SYMBIAN_REGFILEALLOC_DEFAULTPOOLSIZE 65536 // 64K + +#endif // SymbianDefines_h diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 537cdd39df..5ea1e778a2 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -2857,13 +2857,13 @@ contains(DEFINES, ENABLE_SYMBIAN_DIALOG_PROVIDERS) { } } -!symbian { +!symbian-abld:!symbian-sbsv2 { modfile.files = $$moduleFile modfile.path = $$[QMAKE_MKSPECS]/modules INSTALLS += modfile } else { - # INSTALLS is not implemented in qmake's s60 generators, copy headers manually + # INSTALLS is not implemented in qmake's mmp generators, copy headers manually inst_modfile.commands = $$QMAKE_COPY ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT} inst_modfile.input = moduleFile diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 79a8ce40be..56a03c9bfc 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -4958,6 +4958,10 @@ void QUrl::setEncodedQuery(const QByteArray &query) pairDelimiter(), and the key and value are delimited by valueDelimiter(). + \note This method does not encode spaces (ASCII 0x20) as plus (+) signs, + like HTML forms do. If you need that kind of encoding, you must encode + the value yourself and use QUrl::setEncodedQueryItems. + \sa setQueryDelimiters(), queryItems(), setEncodedQueryItems() */ void QUrl::setQueryItems(const QList<QPair<QString, QString> > &query) @@ -5028,6 +5032,10 @@ void QUrl::setEncodedQueryItems(const QList<QPair<QByteArray, QByteArray> > &que character returned by valueDelimiter(). Each key/value pair is delimited by the character returned by pairDelimiter(). + \note This method does not encode spaces (ASCII 0x20) as plus (+) signs, + like HTML forms do. If you need that kind of encoding, you must encode + the value yourself and use QUrl::addEncodedQueryItem. + \sa addEncodedQueryItem() */ void QUrl::addQueryItem(const QString &key, const QString &value) @@ -5084,6 +5092,10 @@ void QUrl::addEncodedQueryItem(const QByteArray &key, const QByteArray &value) /*! Returns the query string of the URL, as a map of keys and values. + \note This method does not decode spaces plus (+) signs as spaces (ASCII + 0x20), like HTML forms do. If you need that kind of decoding, you must + use QUrl::encodedQueryItems and decode the data yourself. + \sa setQueryItems(), setEncodedQuery() */ QList<QPair<QString, QString> > QUrl::queryItems() const @@ -5188,6 +5200,10 @@ bool QUrl::hasEncodedQueryItem(const QByteArray &key) const Returns the first query string value whose key is equal to \a key from the URL. + \note This method does not decode spaces plus (+) signs as spaces (ASCII + 0x20), like HTML forms do. If you need that kind of decoding, you must + use QUrl::encodedQueryItemValue and decode the data yourself. + \sa allQueryItemValues() */ QString QUrl::queryItemValue(const QString &key) const @@ -5232,6 +5248,10 @@ QByteArray QUrl::encodedQueryItemValue(const QByteArray &key) const Returns the a list of query string values whose key is equal to \a key from the URL. + \note This method does not decode spaces plus (+) signs as spaces (ASCII + 0x20), like HTML forms do. If you need that kind of decoding, you must + use QUrl::allEncodedQueryItemValues and decode the data yourself. + \sa queryItemValue() */ QStringList QUrl::allQueryItemValues(const QString &key) const @@ -5610,7 +5630,7 @@ QString QUrl::toString(FormattingOptions options) const if ((options & QUrl::RemoveAuthority) != QUrl::RemoveAuthority) { bool doFileScheme = d->scheme == QLatin1String("file") && ourPath.startsWith(QLatin1Char('/')); QString tmp = d->authority(options); - if (!tmp.isEmpty() || doFileScheme) { + if (!tmp.isNull() || doFileScheme) { if (doFileScheme && !ourPath.startsWith(QLatin1Char('/'))) url += QLatin1Char('/'); url += QLatin1String("//"); diff --git a/src/corelib/tools/qelapsedtimer_unix.cpp b/src/corelib/tools/qelapsedtimer_unix.cpp index 2c4ea584ea..633fa00d95 100644 --- a/src/corelib/tools/qelapsedtimer_unix.cpp +++ b/src/corelib/tools/qelapsedtimer_unix.cpp @@ -40,22 +40,58 @@ ****************************************************************************/ #include "qelapsedtimer.h" -#include "qpair.h" #include <sys/time.h> #include <time.h> #include <unistd.h> -#if !defined(QT_NO_CLOCK_MONOTONIC) -# if defined(QT_BOOTSTRAPPED) -# define QT_NO_CLOCK_MONOTONIC +#if defined(QT_NO_CLOCK_MONOTONIC) || defined(QT_BOOTSTRAPPED) +// turn off the monotonic clock +# ifdef _POSIX_MONOTONIC_CLOCK +# undef _POSIX_MONOTONIC_CLOCK # endif +# define _POSIX_MONOTONIC_CLOCK -1 #endif QT_BEGIN_NAMESPACE -static qint64 fractionAdjustment() +#if (_POSIX_MONOTONIC_CLOCK-0 != 0) +static const bool monotonicClockChecked = true; +static const bool monotonicClockAvailable = _POSIX_MONOTONIC_CLOCK > 0; +#else +static int monotonicClockChecked = false; +static int monotonicClockAvailable = false; +#endif + +#ifdef Q_CC_GNU +# define is_likely(x) __builtin_expect((x), 1) +#else +# define is_likely(x) (x) +#endif +#define load_acquire(x) ((volatile const int&)(x)) +#define store_release(x,v) ((volatile int&)(x) = (v)) + +static void unixCheckClockType() +{ +#if (_POSIX_MONOTONIC_CLOCK-0 == 0) + if (is_likely(load_acquire(monotonicClockChecked))) + return; + +# if defined(_SC_MONOTONIC_CLOCK) + // detect if the system support monotonic timers + long x = sysconf(_SC_MONOTONIC_CLOCK); + store_release(monotonicClockAvailable, x >= 200112L); +# endif + + store_release(monotonicClockChecked, true); +#endif +} + +static inline qint64 fractionAdjustment() { - if (QElapsedTimer::isMonotonic()) { + // disabled, but otherwise indicates bad usage of QElapsedTimer + //Q_ASSERT(monotonicClockChecked); + + if (monotonicClockAvailable) { // the monotonic timer is measured in nanoseconds // 1 ms = 1000000 ns return 1000*1000ull; @@ -68,90 +104,73 @@ static qint64 fractionAdjustment() bool QElapsedTimer::isMonotonic() { -#if (_POSIX_MONOTONIC_CLOCK-0 > 0) - return true; -#else - static int returnValue = 0; - - if (returnValue == 0) { -# if (_POSIX_MONOTONIC_CLOCK-0 < 0) || !defined(_SC_MONOTONIC_CLOCK) - returnValue = -1; -# elif (_POSIX_MONOTONIC_CLOCK == 0) - // detect if the system support monotonic timers - long x = sysconf(_SC_MONOTONIC_CLOCK); - returnValue = (x >= 200112L) ? 1 : -1; -# endif - } - - return returnValue != -1; -#endif + unixCheckClockType(); + return monotonicClockAvailable; } QElapsedTimer::ClockType QElapsedTimer::clockType() { - return isMonotonic() ? MonotonicClock : SystemTime; + unixCheckClockType(); + return monotonicClockAvailable ? MonotonicClock : SystemTime; } -static inline QPair<long, long> do_gettime() +static inline void do_gettime(qint64 *sec, qint64 *frac) { -#if (_POSIX_MONOTONIC_CLOCK-0 > 0) - timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return qMakePair<long,long>(ts.tv_sec, ts.tv_nsec); -#else -# if !defined(QT_NO_CLOCK_MONOTONIC) && !defined(QT_BOOTSTRAPPED) - if (QElapsedTimer::isMonotonic()) { +#if (_POSIX_MONOTONIC_CLOCK-0 >= 0) + unixCheckClockType(); + if (is_likely(monotonicClockAvailable)) { timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); - return qMakePair<long,long>(ts.tv_sec, ts.tv_nsec); + *sec = ts.tv_sec; + *frac = ts.tv_nsec; + return; } -# endif +#endif // use gettimeofday timeval tv; ::gettimeofday(&tv, 0); - return qMakePair<long,long>(tv.tv_sec, tv.tv_usec); -#endif + *sec = tv.tv_sec; + *frac = tv.tv_usec; } // used in qcore_unix.cpp and qeventdispatcher_unix.cpp timeval qt_gettime() { - QPair<long, long> r = do_gettime(); + qint64 sec, frac; + do_gettime(&sec, &frac); timeval tv; - tv.tv_sec = r.first; - tv.tv_usec = r.second; - if (QElapsedTimer::isMonotonic()) + tv.tv_sec = sec; + tv.tv_usec = frac; + if (monotonicClockAvailable) tv.tv_usec /= 1000; return tv; } +static qint64 elapsedAndRestart(qint64 sec, qint64 frac, + qint64 *nowsec, qint64 *nowfrac) +{ + do_gettime(nowsec, nowfrac); + sec = *nowsec - sec; + frac = *nowfrac - frac; + return sec * Q_INT64_C(1000) + frac / fractionAdjustment(); +} + void QElapsedTimer::start() { - QPair<long, long> r = do_gettime(); - t1 = r.first; - t2 = r.second; + do_gettime(&t1, &t2); } qint64 QElapsedTimer::restart() { - QPair<long, long> r = do_gettime(); - qint64 oldt1 = t1; - qint64 oldt2 = t2; - t1 = r.first; - t2 = r.second; - - r.first -= oldt1; - r.second -= oldt2; - return r.first * Q_INT64_C(1000) + r.second / fractionAdjustment(); + return elapsedAndRestart(t1, t2, &t1, &t2); } qint64 QElapsedTimer::elapsed() const { - QElapsedTimer now; - now.start(); - return msecsTo(now); + qint64 sec, frac; + return elapsedAndRestart(t1, t2, &sec, &frac); } qint64 QElapsedTimer::msecsSinceReference() const diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index 68ab0331d9..a9c33f16ff 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -54,8 +54,20 @@ #if defined(Q_OS_LINUX) && defined(__arm__) #include "private/qcore_unix_p.h" -#include <asm/hwcap.h> -#include <linux/auxvec.h> +// the kernel header definitions for HWCAP_* +// (the ones we need/may need anyway) + +// copied from <asm/hwcap.h> (ARM) +#define HWCAP_IWMMXT 512 +#define HWCAP_CRUNCH 1024 +#define HWCAP_THUMBEE 2048 +#define HWCAP_NEON 4096 +#define HWCAP_VFPv3 8192 +#define HWCAP_VFPv3D16 16384 + +// copied from <linux/auxvec.h> +#define AT_HWCAP 16 /* arch dependent hints at CPU capabilities */ + #endif QT_BEGIN_NAMESPACE @@ -140,56 +152,41 @@ static inline uint detectProcessorFeatures() uint result = 0; /* see p. 118 of amd64 instruction set manual Vol3 */ #if defined(Q_CC_GNU) - asm ("push %%ebx\n" - "pushf\n" - "pop %%eax\n" - "mov %%eax, %%ebx\n" - "xor $0x00200000, %%eax\n" - "push %%eax\n" - "popf\n" - "pushf\n" - "pop %%eax\n" - "xor %%edx, %%edx\n" - "xor %%ebx, %%eax\n" - "jz 1f\n" - - "mov $0x00000001, %%eax\n" - "cpuid\n" - "1:\n" - "pop %%ebx\n" - "mov %%edx, %0\n" - "mov %%ecx, %1\n" - : "=r" (result), "=r" (feature_result) - : - : "%eax", "%ecx", "%edx" - ); - - asm ("push %%ebx\n" - "pushf\n" - "pop %%eax\n" - "mov %%eax, %%ebx\n" - "xor $0x00200000, %%eax\n" - "push %%eax\n" + long cpuid_supported, tmp1; + asm ("pushf\n" + "pop %0\n" + "mov %0, %1\n" + "xor $0x00200000, %0\n" + "push %0\n" "popf\n" "pushf\n" - "pop %%eax\n" - "xor %%edx, %%edx\n" - "xor %%ebx, %%eax\n" - "jz 2f\n" - - "mov $0x80000000, %%eax\n" - "cpuid\n" - "cmp $0x80000000, %%eax\n" - "jbe 2f\n" - "mov $0x80000001, %%eax\n" - "cpuid\n" - "2:\n" - "pop %%ebx\n" - "mov %%edx, %0\n" - : "=r" (extended_result) - : - : "%eax", "%ecx", "%edx" - ); + "pop %0\n" + "xor %1, %0\n" // %eax is now 0 if CPUID is not supported + : "=a" (cpuid_supported), "=r" (tmp1) + ); + if (cpuid_supported) { + asm ("xchg %%ebx, %2\n" + "cpuid\n" + "xchg %%ebx, %2\n" + : "=c" (feature_result), "=d" (result), "=&r" (tmp1) + : "a" (1)); + + asm ("xchg %%ebx, %1\n" + "cpuid\n" + "cmp $0x80000000, %%eax\n" + "jnbe 1f\n" + "xor %0, %0\n" + "jmp 2f\n" + "1:\n" + "mov $0x80000001, %%eax\n" + "cpuid\n" + "2:\n" + "xchg %%ebx, %1\n" + : "=d" (extended_result), "=&r" (tmp1) + : "a" (0x80000000) + : "%ecx" + ); + } #elif defined (Q_OS_WIN) _asm { @@ -289,27 +286,10 @@ static inline uint detectProcessorFeatures() uint feature_result = 0; #if defined(Q_CC_GNU) - asm ("push %%rbx\n" - "pushf\n" - "pop %%rax\n" - "mov %%eax, %%ebx\n" - "xor $0x00200000, %%eax\n" - "push %%rax\n" - "popf\n" - "pushf\n" - "pop %%rax\n" - "xor %%edx, %%edx\n" - "xor %%ebx, %%eax\n" - "jz 1f\n" - - "mov $0x00000001, %%eax\n" - "cpuid\n" - "1:\n" - "pop %%rbx\n" - "mov %%ecx, %0\n" - : "=r" (feature_result) - : - : "%eax", "%ecx", "%edx" + asm ("cpuid" + : "=c" (feature_result) + : "a" (1) + : "%ebx", "%edx" ); #elif defined (Q_OS_WIN64) { diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index d940bf8c40..2813b290d4 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -173,19 +173,6 @@ static int ucstricmp(const ushort *a, const ushort *ae, const uchar *b) return 1; } -// Unicode case-sensitive comparison -static int ucstrcmp(const QChar *a, int alen, const QChar *b, int blen) -{ - if (a == b && alen == blen) - return 0; - int l = qMin(alen, blen); - while (l-- && *a == *b) - a++,b++; - if (l == -1) - return (alen-blen); - return a->unicode() - b->unicode(); -} - // Unicode case-sensitive compare two same-sized strings static int ucstrncmp(const QChar *a, const QChar *b, int l) { @@ -196,6 +183,16 @@ static int ucstrncmp(const QChar *a, const QChar *b, int l) return a->unicode() - b->unicode(); } +// Unicode case-sensitive comparison +static int ucstrcmp(const QChar *a, int alen, const QChar *b, int blen) +{ + if (a == b && alen == blen) + return 0; + int l = qMin(alen, blen); + int cmp = ucstrncmp(a, b, l); + return cmp ? cmp : (alen-blen); +} + // Unicode case-insensitive compare two same-sized strings static int ucstrnicmp(const ushort *a, const ushort *b, int l) { diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 7951177fab..3833874aaf 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -714,6 +714,9 @@ QDBusCallDeliveryEvent* QDBusConnectionPrivate::prepareReply(QDBusConnectionPriv if (metaTypes[n] == QDBusMetaTypeId::message) --n; + if (msg.arguments().count() < n) + return 0; // too few arguments + // check that types match for (int i = 0; i < n; ++i) if (metaTypes.at(i + 1) != msg.arguments().at(i).userType() && diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 6e6f0cb80b..845b3da7af 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -1427,6 +1427,7 @@ void QDeclarativeAnchorChanges::clearBindings() if (!d->target) return; + //### should this (saving "from" values) be moved to saveCurrentValues()? d->fromX = d->target->x(); d->fromY = d->target->y(); d->fromWidth = d->target->width(); @@ -1486,22 +1487,8 @@ void QDeclarativeAnchorChanges::rewind() return; QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); - //restore previous anchors - if (d->rewindLeft.anchorLine != QDeclarativeAnchorLine::Invalid) - targetPrivate->anchors()->setLeft(d->rewindLeft); - if (d->rewindRight.anchorLine != QDeclarativeAnchorLine::Invalid) - targetPrivate->anchors()->setRight(d->rewindRight); - if (d->rewindHCenter.anchorLine != QDeclarativeAnchorLine::Invalid) - targetPrivate->anchors()->setHorizontalCenter(d->rewindHCenter); - if (d->rewindTop.anchorLine != QDeclarativeAnchorLine::Invalid) - targetPrivate->anchors()->setTop(d->rewindTop); - if (d->rewindBottom.anchorLine != QDeclarativeAnchorLine::Invalid) - targetPrivate->anchors()->setBottom(d->rewindBottom); - if (d->rewindVCenter.anchorLine != QDeclarativeAnchorLine::Invalid) - targetPrivate->anchors()->setVerticalCenter(d->rewindVCenter); - if (d->rewindBaseline.anchorLine != QDeclarativeAnchorLine::Invalid) - targetPrivate->anchors()->setBaseline(d->rewindBaseline); + //restore previous values (but not previous bindings, i.e. anchors) d->target->setX(d->rewindX); d->target->setY(d->rewindY); if (targetPrivate->widthValid) { diff --git a/src/declarative/util/qdeclarativetransitionmanager.cpp b/src/declarative/util/qdeclarativetransitionmanager.cpp index 9f198e4f31..d82c4bb89f 100644 --- a/src/declarative/util/qdeclarativetransitionmanager.cpp +++ b/src/declarative/util/qdeclarativetransitionmanager.cpp @@ -176,7 +176,7 @@ void QDeclarativeTransitionManager::transition(const QList<QDeclarativeAction> & if (action.event->isReversable()) { action.event->clearBindings(); action.event->rewind(); - action.event->clearBindings(); + action.event->clearBindings(); //### shouldn't be needed } continue; } diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index 9d571b518d..dbdf0bc27c 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -63,6 +63,42 @@ QT_BEGIN_NAMESPACE const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; +static bool cleanup_function_registered = false; +static QS60PixmapData *firstPixmap = 0; + +static void qt_symbian_register_pixmap(QS60PixmapData *pd) +{ + if(!cleanup_function_registered) { + qAddPostRoutine(qt_symbian_release_pixmaps); + cleanup_function_registered = true; + } + + pd->next = firstPixmap; + pd->prev = 0; + if (firstPixmap) + firstPixmap->prev = pd; + firstPixmap = pd; +} + +static void qt_symbian_unregister_pixmap(QS60PixmapData *pd) +{ + if (pd->next) + pd->next->prev = pd->prev; + if (pd->prev) + pd->prev->next = pd->next; + else + firstPixmap = pd->next; +} + +static void qt_symbian_release_pixmaps() +{ + // Scan all QS60PixmapData objects in the system and destroy them. + QS60PixmapData *pd = firstPixmap; + while (pd != 0) { + pd->release(); + pd = pd->next; + } +} /* \class QSymbianFbsClient @@ -356,15 +392,18 @@ QS60PixmapData::QS60PixmapData(PixelType type) : QRasterPixmapData(type), cfbsBitmap(0), pengine(0), bytes(0), - formatLocked(false) + formatLocked(false), + next(0), + prev(0) { - + qt_symbian_register_pixmap(this); } QS60PixmapData::~QS60PixmapData() { release(); delete symbianBitmapDataAccess; + qt_symbian_unregister_pixmap(this); } void QS60PixmapData::resize(int width, int height) diff --git a/src/gui/image/qpixmap_s60_p.h b/src/gui/image/qpixmap_s60_p.h index 85c9ebe751..a82f5c27ef 100644 --- a/src/gui/image/qpixmap_s60_p.h +++ b/src/gui/image/qpixmap_s60_p.h @@ -63,6 +63,11 @@ class CFbsBitGc; class QSymbianBitmapDataAccess; +class QS60PixmapData; +void qt_symbian_register_pixmap(QS60PixmapData *pd); +void qt_symbian_unregister_pixmap(QS60PixmapData *pd); +void qt_symbian_release_pixmaps(); + class QSymbianFbsHeapLock { public: @@ -120,6 +125,13 @@ private: bool formatLocked; + QS60PixmapData *next; + QS60PixmapData *prev; + + friend void qt_symbian_register_pixmap(QS60PixmapData *pd); + friend void qt_symbian_unregister_pixmap(QS60PixmapData *pd); + friend void qt_symbian_release_pixmaps(); + friend class QPixmap; friend class QS60WindowSurface; friend class QS60PaintEngine; diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index 321492dfde..dd819e5ce3 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -737,9 +737,6 @@ static void qt_post_window_change_event(QWidget *widget) */ static void qt_mac_update_child_gl_widgets(QWidget *widget) { - if (widget->isWindow()) - return; - // Update all OpenGL child widgets for the given widget. QList<QWidgetPrivate::GlWidgetInfo> &glWidgets = qt_widget_private(widget)->glWidgets; QList<QWidgetPrivate::GlWidgetInfo>::iterator end = glWidgets.end(); diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h index 679514946c..ddf1a2738f 100644 --- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h +++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h @@ -58,6 +58,8 @@ QT_BEGIN_NAMESPACE extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp extern const QStringList& qEnabledDraggedTypes(); // qmime_mac.cpp +extern void qt_event_request_window_change(QWidget *); // qapplication_mac.mm +extern void qt_mac_send_posted_gl_updates(QWidget *widget); // qapplication_mac.mm Q_GLOBAL_STATIC(QPointer<QWidget>, currentDragTarget); @@ -227,6 +229,19 @@ QT_END_NAMESPACE [self release]; } +- (void)setInitialFirstResponder:(NSView *)view +{ + // This method is called the first time the window is placed on screen and + // is the earliest point in time we can connect OpenGL contexts to NSViews. + QWidget *qwidget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self]; + if (qwidget) { + qt_event_request_window_change(qwidget); + qt_mac_send_posted_gl_updates(qwidget); + } + + [super setInitialFirstResponder:view]; +} + - (BOOL)makeFirstResponder:(NSResponder *)responder { // For some reason Cocoa wants to flip the first responder diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index cf487b56a5..03ed597d5a 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -1485,7 +1485,7 @@ static const uint L2CacheLineLengthInInts = L2CacheLineLength/sizeof(uint); }\ } -static void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_alpha) +void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_alpha) { comp_func_Clear_impl(dest, length, const_alpha); } @@ -1499,7 +1499,7 @@ void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint cons result = s dest = s * ca + d * cia */ -static void QT_FASTCALL comp_func_solid_Source(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_Source(uint *dest, int length, uint color, uint const_alpha) { if (const_alpha == 255) { QT_MEMFILL_UINT(dest, length, color); @@ -1528,7 +1528,7 @@ void QT_FASTCALL comp_func_Source(uint *dest, const uint *src, int length, uint } } -static void QT_FASTCALL comp_func_solid_Destination(uint *, int, uint, uint) +void QT_FASTCALL comp_func_solid_Destination(uint *, int, uint, uint) { } @@ -1542,7 +1542,7 @@ void QT_FASTCALL comp_func_Destination(uint *, const uint *, int, uint) = s * ca + d * (sia * ca + cia) = s * ca + d * (1 - sa*ca) */ -static void QT_FASTCALL comp_func_solid_SourceOver(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_SourceOver(uint *dest, int length, uint color, uint const_alpha) { if ((const_alpha & qAlpha(color)) == 255) { QT_MEMFILL_UINT(dest, length, color); @@ -1583,7 +1583,7 @@ void QT_FASTCALL comp_func_SourceOver(uint *dest, const uint *src, int length, u dest = (d + s * dia) * ca + d * cia = d + s * dia * ca */ -static void QT_FASTCALL comp_func_solid_DestinationOver(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_DestinationOver(uint *dest, int length, uint color, uint const_alpha) { if (const_alpha != 255) color = BYTE_MUL(color, const_alpha); @@ -1618,7 +1618,7 @@ void QT_FASTCALL comp_func_DestinationOver(uint *dest, const uint *src, int leng result = s * da dest = s * da * ca + d * cia */ -static void QT_FASTCALL comp_func_solid_SourceIn(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_SourceIn(uint *dest, int length, uint color, uint const_alpha) { PRELOAD_INIT(dest) if (const_alpha == 255) { @@ -1661,7 +1661,7 @@ void QT_FASTCALL comp_func_SourceIn(uint *dest, const uint *src, int length, uin dest = d * sa * ca + d * cia = d * (sa * ca + cia) */ -static void QT_FASTCALL comp_func_solid_DestinationIn(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_DestinationIn(uint *dest, int length, uint color, uint const_alpha) { uint a = qAlpha(color); if (const_alpha != 255) { @@ -1697,7 +1697,7 @@ void QT_FASTCALL comp_func_DestinationIn(uint *dest, const uint *src, int length dest = s * dia * ca + d * cia */ -static void QT_FASTCALL comp_func_solid_SourceOut(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_SourceOut(uint *dest, int length, uint color, uint const_alpha) { PRELOAD_INIT(dest) if (const_alpha == 255) { @@ -1740,7 +1740,7 @@ void QT_FASTCALL comp_func_SourceOut(uint *dest, const uint *src, int length, ui dest = d * sia * ca + d * cia = d * (sia * ca + cia) */ -static void QT_FASTCALL comp_func_solid_DestinationOut(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_DestinationOut(uint *dest, int length, uint color, uint const_alpha) { uint a = qAlpha(~color); if (const_alpha != 255) @@ -1776,7 +1776,7 @@ void QT_FASTCALL comp_func_DestinationOut(uint *dest, const uint *src, int lengt = s*ca * da + d * (sia*ca + cia) = s*ca * da + d * (1 - sa*ca) */ -static void QT_FASTCALL comp_func_solid_SourceAtop(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_SourceAtop(uint *dest, int length, uint color, uint const_alpha) { if (const_alpha != 255) { color = BYTE_MUL(color, const_alpha); @@ -1814,7 +1814,7 @@ void QT_FASTCALL comp_func_SourceAtop(uint *dest, const uint *src, int length, u dest = d*sa*ca + s*dia*ca + d *cia = s*ca * dia + d * (sa*ca + cia) */ -static void QT_FASTCALL comp_func_solid_DestinationAtop(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_DestinationAtop(uint *dest, int length, uint color, uint const_alpha) { uint a = qAlpha(color); if (const_alpha != 255) { @@ -1857,7 +1857,7 @@ void QT_FASTCALL comp_func_DestinationAtop(uint *dest, const uint *src, int leng = s*ca * dia + d * (sia*ca + cia) = s*ca * dia + d * (1 - sa*ca) */ -static void QT_FASTCALL comp_func_solid_XOR(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_XOR(uint *dest, int length, uint color, uint const_alpha) { if (const_alpha != 255) color = BYTE_MUL(color, const_alpha); @@ -1938,7 +1938,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Plus_impl(uint *dest, int } } -static void QT_FASTCALL comp_func_solid_Plus(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_Plus(uint *dest, int length, uint color, uint const_alpha) { if (const_alpha == 255) comp_func_solid_Plus_impl(dest, length, color, QFullCoverage()); @@ -2002,7 +2002,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Multiply_impl(uint *dest, } } -static void QT_FASTCALL comp_func_solid_Multiply(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_Multiply(uint *dest, int length, uint color, uint const_alpha) { if (const_alpha == 255) comp_func_solid_Multiply_impl(dest, length, color, QFullCoverage()); @@ -2070,7 +2070,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Screen_impl(uint *dest, i } } -static void QT_FASTCALL comp_func_solid_Screen(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_Screen(uint *dest, int length, uint color, uint const_alpha) { if (const_alpha == 255) comp_func_solid_Screen_impl(dest, length, color, QFullCoverage()); @@ -2149,7 +2149,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Overlay_impl(uint *dest, } } -static void QT_FASTCALL comp_func_solid_Overlay(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_Overlay(uint *dest, int length, uint color, uint const_alpha) { if (const_alpha == 255) comp_func_solid_Overlay_impl(dest, length, color, QFullCoverage()); @@ -2222,7 +2222,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Darken_impl(uint *dest, i } } -static void QT_FASTCALL comp_func_solid_Darken(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_Darken(uint *dest, int length, uint color, uint const_alpha) { if (const_alpha == 255) comp_func_solid_Darken_impl(dest, length, color, QFullCoverage()); @@ -2295,7 +2295,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Lighten_impl(uint *dest, } } -static void QT_FASTCALL comp_func_solid_Lighten(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_Lighten(uint *dest, int length, uint color, uint const_alpha) { if (const_alpha == 255) comp_func_solid_Lighten_impl(dest, length, color, QFullCoverage()); @@ -2378,7 +2378,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorDodge_impl(uint *des } } -static void QT_FASTCALL comp_func_solid_ColorDodge(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_ColorDodge(uint *dest, int length, uint color, uint const_alpha) { if (const_alpha == 255) comp_func_solid_ColorDodge_impl(dest, length, color, QFullCoverage()); @@ -2461,7 +2461,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorBurn_impl(uint *dest } } -static void QT_FASTCALL comp_func_solid_ColorBurn(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_ColorBurn(uint *dest, int length, uint color, uint const_alpha) { if (const_alpha == 255) comp_func_solid_ColorBurn_impl(dest, length, color, QFullCoverage()); @@ -2541,7 +2541,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_HardLight_impl(uint *dest } } -static void QT_FASTCALL comp_func_solid_HardLight(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_HardLight(uint *dest, int length, uint color, uint const_alpha) { if (const_alpha == 255) comp_func_solid_HardLight_impl(dest, length, color, QFullCoverage()); @@ -2632,7 +2632,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_SoftLight_impl(uint *dest } } -static void QT_FASTCALL comp_func_solid_SoftLight(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_SoftLight(uint *dest, int length, uint color, uint const_alpha) { if (const_alpha == 255) comp_func_solid_SoftLight_impl(dest, length, color, QFullCoverage()); @@ -2705,7 +2705,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Difference_impl(uint *des } } -static void QT_FASTCALL comp_func_solid_Difference(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_Difference(uint *dest, int length, uint color, uint const_alpha) { if (const_alpha == 255) comp_func_solid_Difference_impl(dest, length, color, QFullCoverage()); @@ -2772,7 +2772,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void QT_FASTCALL comp_func_solid_Exclusion_imp } } -static void QT_FASTCALL comp_func_solid_Exclusion(uint *dest, int length, uint color, uint const_alpha) +void QT_FASTCALL comp_func_solid_Exclusion(uint *dest, int length, uint color, uint const_alpha) { if (const_alpha == 255) comp_func_solid_Exclusion_impl(dest, length, color, QFullCoverage()); @@ -2816,10 +2816,10 @@ void QT_FASTCALL comp_func_Exclusion(uint *dest, const uint *src, int length, ui # pragma pop #endif -static void QT_FASTCALL rasterop_solid_SourceOrDestination(uint *dest, - int length, - uint color, - uint const_alpha) +void QT_FASTCALL rasterop_solid_SourceOrDestination(uint *dest, + int length, + uint color, + uint const_alpha) { Q_UNUSED(const_alpha); while (length--) @@ -2836,10 +2836,10 @@ void QT_FASTCALL rasterop_SourceOrDestination(uint *dest, *dest++ |= *src++; } -static void QT_FASTCALL rasterop_solid_SourceAndDestination(uint *dest, - int length, - uint color, - uint const_alpha) +void QT_FASTCALL rasterop_solid_SourceAndDestination(uint *dest, + int length, + uint color, + uint const_alpha) { Q_UNUSED(const_alpha); color |= 0xff000000; @@ -2859,10 +2859,10 @@ void QT_FASTCALL rasterop_SourceAndDestination(uint *dest, } } -static void QT_FASTCALL rasterop_solid_SourceXorDestination(uint *dest, - int length, - uint color, - uint const_alpha) +void QT_FASTCALL rasterop_solid_SourceXorDestination(uint *dest, + int length, + uint color, + uint const_alpha) { Q_UNUSED(const_alpha); color &= 0x00ffffff; @@ -2882,10 +2882,10 @@ void QT_FASTCALL rasterop_SourceXorDestination(uint *dest, } } -static void QT_FASTCALL rasterop_solid_NotSourceAndNotDestination(uint *dest, - int length, - uint color, - uint const_alpha) +void QT_FASTCALL rasterop_solid_NotSourceAndNotDestination(uint *dest, + int length, + uint color, + uint const_alpha) { Q_UNUSED(const_alpha); color = ~color; @@ -2907,10 +2907,10 @@ void QT_FASTCALL rasterop_NotSourceAndNotDestination(uint *dest, } } -static void QT_FASTCALL rasterop_solid_NotSourceOrNotDestination(uint *dest, - int length, - uint color, - uint const_alpha) +void QT_FASTCALL rasterop_solid_NotSourceOrNotDestination(uint *dest, + int length, + uint color, + uint const_alpha) { Q_UNUSED(const_alpha); color = ~color | 0xff000000; @@ -2932,10 +2932,10 @@ void QT_FASTCALL rasterop_NotSourceOrNotDestination(uint *dest, } } -static void QT_FASTCALL rasterop_solid_NotSourceXorDestination(uint *dest, - int length, - uint color, - uint const_alpha) +void QT_FASTCALL rasterop_solid_NotSourceXorDestination(uint *dest, + int length, + uint color, + uint const_alpha) { Q_UNUSED(const_alpha); color = ~color & 0x00ffffff; @@ -2957,8 +2957,8 @@ void QT_FASTCALL rasterop_NotSourceXorDestination(uint *dest, } } -static void QT_FASTCALL rasterop_solid_NotSource(uint *dest, int length, - uint color, uint const_alpha) +void QT_FASTCALL rasterop_solid_NotSource(uint *dest, int length, + uint color, uint const_alpha) { Q_UNUSED(const_alpha); qt_memfill(dest, ~color | 0xff000000, length); @@ -2972,10 +2972,10 @@ void QT_FASTCALL rasterop_NotSource(uint *dest, const uint *src, *dest++ = ~(*src++) | 0xff000000; } -static void QT_FASTCALL rasterop_solid_NotSourceAndDestination(uint *dest, - int length, - uint color, - uint const_alpha) +void QT_FASTCALL rasterop_solid_NotSourceAndDestination(uint *dest, + int length, + uint color, + uint const_alpha) { Q_UNUSED(const_alpha); color = ~color | 0xff000000; @@ -2997,10 +2997,10 @@ void QT_FASTCALL rasterop_NotSourceAndDestination(uint *dest, } } -static void QT_FASTCALL rasterop_solid_SourceAndNotDestination(uint *dest, - int length, - uint color, - uint const_alpha) +void QT_FASTCALL rasterop_solid_SourceAndNotDestination(uint *dest, + int length, + uint color, + uint const_alpha) { Q_UNUSED(const_alpha); while (length--) { @@ -7739,6 +7739,55 @@ void qInitDrawhelperAsm() #ifdef QT_HAVE_SSE if (features & SSE) { + extern void qt_blend_rgb32_on_rgb32_sse(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + extern void qt_blend_argb32_on_argb32_sse(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + + qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse; + qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse; + qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse; + qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse; + } +#endif // SSE + +#ifdef QT_HAVE_SSE2 + if (features & SSE2) { + extern void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + extern void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + + qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2; + qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2; + qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2; + qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2; + } + +#ifdef QT_HAVE_SSSE3 + if (features & SSSE3) { + extern void qt_blend_argb32_on_argb32_ssse3(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + + qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; + qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; + } +#endif // SSSE3 + +#endif // SSE2 + +#ifdef QT_HAVE_SSE + if (features & SSE) { functionForModeAsm = qt_functionForMode_SSE; functionForModeSolidAsm = qt_functionForModeSolid_SSE; qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_sse; @@ -7754,9 +7803,9 @@ void qInitDrawhelperAsm() #ifdef QT_HAVE_SSE2 if (features & SSE2) { extern void QT_FASTCALL comp_func_SourceOver_sse2(uint *destPixels, - const uint *srcPixels, - int length, - uint const_alpha); + const uint *srcPixels, + int length, + uint const_alpha); extern void QT_FASTCALL comp_func_solid_SourceOver_sse2(uint *destPixels, int length, uint color, uint const_alpha); extern void QT_FASTCALL comp_func_Plus_sse2(uint *dst, const uint *src, int length, uint const_alpha); extern void QT_FASTCALL comp_func_Source_sse2(uint *dst, const uint *src, int length, uint const_alpha); @@ -7765,51 +7814,16 @@ void qInitDrawhelperAsm() functionForModeAsm[QPainter::CompositionMode_Source] = comp_func_Source_sse2; functionForModeAsm[QPainter::CompositionMode_Plus] = comp_func_Plus_sse2; functionForModeSolidAsm[0] = comp_func_solid_SourceOver_sse2; - - extern void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, - const uchar *srcPixels, int sbpl, - int w, int h, - int const_alpha); - extern void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl, - const uchar *srcPixels, int sbpl, - int w, int h, - int const_alpha); - - qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2; - qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2; - qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2; - qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2; - -#if defined(QT_HAVE_SSSE3) - if (features & SSSE3) { - extern void qt_blend_argb32_on_argb32_ssse3(uchar *destPixels, int dbpl, - const uchar *srcPixels, int sbpl, - int w, int h, - int const_alpha); - qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; - qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; - } -#endif // QT_HAVE_SSSE3 - } else -#endif - { - extern void qt_blend_rgb32_on_rgb32_sse(uchar *destPixels, int dbpl, - const uchar *srcPixels, int sbpl, - int w, int h, - int const_alpha); - extern void qt_blend_argb32_on_argb32_sse(uchar *destPixels, int dbpl, - const uchar *srcPixels, int sbpl, - int w, int h, - int const_alpha); - - - qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse; - qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse; - qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse; - qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse; } -} -#endif // SSE +#endif + } +#elif defined(QT_HAVE_SSE2) + // this is the special case when SSE2 is usable but MMX/SSE is not usable (e.g.: Windows x64 + visual studio) + if (features & SSE2) { + functionForModeAsm = qt_functionForMode_onlySSE2; + functionForModeSolidAsm = qt_functionForModeSolid_onlySSE2; + } +#endif #ifdef QT_HAVE_IWMMXT if (features & IWMMXT) { diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 5747da5a7d..0cc2e409e1 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -1997,6 +1997,41 @@ void QT_FASTCALL rasterop_NotSource(uint *dest, const uint *src, int length, uin void QT_FASTCALL rasterop_NotSourceAndDestination(uint *dest, const uint *src, int length, uint const_alpha); void QT_FASTCALL rasterop_SourceAndNotDestination(uint *dest, const uint *src, int length, uint const_alpha); +// prototypes of all the solid composition functions +void QT_FASTCALL comp_func_solid_SourceOver(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_DestinationOver(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_Source(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_Destination(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_SourceIn(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_DestinationIn(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_SourceOut(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_DestinationOut(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_SourceAtop(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_DestinationAtop(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_XOR(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_Plus(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_Multiply(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_Screen(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_Overlay(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_Darken(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_Lighten(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_ColorDodge(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_ColorBurn(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_HardLight(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_SoftLight(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_Difference(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_solid_Exclusion(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL rasterop_solid_SourceOrDestination(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL rasterop_solid_SourceAndDestination(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL rasterop_solid_SourceXorDestination(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL rasterop_solid_NotSourceAndNotDestination(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL rasterop_solid_NotSourceOrNotDestination(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL rasterop_solid_NotSourceXorDestination(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL rasterop_solid_NotSource(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL rasterop_solid_NotSourceAndDestination(uint *dest, int length, uint color, uint const_alpha); +void QT_FASTCALL rasterop_solid_SourceAndNotDestination(uint *dest, int length, uint color, uint const_alpha); + QT_END_NAMESPACE #endif // QDRAWHELPER_P_H diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp index 5b674b5aef..ba2ba323f9 100644 --- a/src/gui/painting/qdrawhelper_sse2.cpp +++ b/src/gui/painting/qdrawhelper_sse2.cpp @@ -311,6 +311,78 @@ void QT_FASTCALL comp_func_solid_SourceOver_sse2(uint *destPixels, int length, u } } +CompositionFunctionSolid qt_functionForModeSolid_onlySSE2[numCompositionFunctions] = { + comp_func_solid_SourceOver_sse2, + comp_func_solid_DestinationOver, + comp_func_solid_Clear, + comp_func_solid_Source, + comp_func_solid_Destination, + comp_func_solid_SourceIn, + comp_func_solid_DestinationIn, + comp_func_solid_SourceOut, + comp_func_solid_DestinationOut, + comp_func_solid_SourceAtop, + comp_func_solid_DestinationAtop, + comp_func_solid_XOR, + comp_func_solid_Plus, + comp_func_solid_Multiply, + comp_func_solid_Screen, + comp_func_solid_Overlay, + comp_func_solid_Darken, + comp_func_solid_Lighten, + comp_func_solid_ColorDodge, + comp_func_solid_ColorBurn, + comp_func_solid_HardLight, + comp_func_solid_SoftLight, + comp_func_solid_Difference, + comp_func_solid_Exclusion, + rasterop_solid_SourceOrDestination, + rasterop_solid_SourceAndDestination, + rasterop_solid_SourceXorDestination, + rasterop_solid_NotSourceAndNotDestination, + rasterop_solid_NotSourceOrNotDestination, + rasterop_solid_NotSourceXorDestination, + rasterop_solid_NotSource, + rasterop_solid_NotSourceAndDestination, + rasterop_solid_SourceAndNotDestination +}; + +CompositionFunction qt_functionForMode_onlySSE2[numCompositionFunctions] = { + comp_func_SourceOver_sse2, + comp_func_DestinationOver, + comp_func_Clear, + comp_func_Source_sse2, + comp_func_Destination, + comp_func_SourceIn, + comp_func_DestinationIn, + comp_func_SourceOut, + comp_func_DestinationOut, + comp_func_SourceAtop, + comp_func_DestinationAtop, + comp_func_XOR, + comp_func_Plus_sse2, + comp_func_Multiply, + comp_func_Screen, + comp_func_Overlay, + comp_func_Darken, + comp_func_Lighten, + comp_func_ColorDodge, + comp_func_ColorBurn, + comp_func_HardLight, + comp_func_SoftLight, + comp_func_Difference, + comp_func_Exclusion, + rasterop_SourceOrDestination, + rasterop_SourceAndDestination, + rasterop_SourceXorDestination, + rasterop_NotSourceAndNotDestination, + rasterop_NotSourceOrNotDestination, + rasterop_NotSourceXorDestination, + rasterop_NotSource, + rasterop_NotSourceAndDestination, + rasterop_SourceAndNotDestination +}; + void qt_memfill16_sse2(quint16 *dest, quint16 value, int count) { if (count < 3) { diff --git a/src/gui/painting/qdrawhelper_x86_p.h b/src/gui/painting/qdrawhelper_x86_p.h index d7282a7fc3..09ccd77f52 100644 --- a/src/gui/painting/qdrawhelper_x86_p.h +++ b/src/gui/painting/qdrawhelper_x86_p.h @@ -122,6 +122,9 @@ void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, int const_alpha); + +extern CompositionFunction qt_functionForMode_onlySSE2[]; +extern CompositionFunctionSolid qt_functionForModeSolid_onlySSE2[]; #endif // QT_HAVE_SSE2 #ifdef QT_HAVE_IWMMXT diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 119217a8ea..05de8f5ad8 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2263,6 +2263,9 @@ bool QTextEngine::atWordSeparator(int position) const case ',': case '?': case '!': + case '@': + case '#': + case '$': case ':': case ';': case '-': @@ -2283,6 +2286,7 @@ bool QTextEngine::atWordSeparator(int position) const case '*': case '\'': case '"': + case '`': case '~': case '|': return true; diff --git a/src/opengl/qgl_mac.mm b/src/opengl/qgl_mac.mm index 66fe7d33ed..f023a97c75 100644 --- a/src/opengl/qgl_mac.mm +++ b/src/opengl/qgl_mac.mm @@ -697,9 +697,17 @@ void QGLContext::updatePaintDevice() QWidget *w = (QWidget *)d->paintDevice; NSView *view = qt_mac_nativeview_for(w); - // ideally we would use QWidget::isVisible(), but we get "invalid drawable" errors - if (![(NSWindow *)qt_mac_window_for(w) isVisible]) - return; + // Trying to attach the GL context to the NSView will fail with + // "invalid drawable" if done too soon, but we have to make sure + // the connection is made before the first paint event. Using + // the NSView do to this check fails as the NSView is visible + // before it's safe to connect, and using the NSWindow fails as + // the NSWindow will become visible after the first paint event. + // This leaves us with the QWidget, who's visible state seems + // to match the point in time when it's safe to connect. + if (!w || !w->isVisible()) + return; // Not safe to attach GL context to view yet + if ([static_cast<NSOpenGLContext *>(d->cx) view] != view && ![view isHidden]) [static_cast<NSOpenGLContext *>(d->cx) setView:view]; } else if (d->paintDevice->devType() == QInternal::Pixmap) { diff --git a/src/plugins/bearer/connman/connman.pro b/src/plugins/bearer/connman/connman.pro index 4be752bcca..dec408c724 100644 --- a/src/plugins/bearer/connman/connman.pro +++ b/src/plugins/bearer/connman/connman.pro @@ -4,12 +4,14 @@ include(../../qpluginbase.pri) QT = core network dbus HEADERS += qconnmanservice_linux_p.h \ + qofonoservice_linux_p.h \ qconnmanengine.h \ ../qnetworksession_impl.h \ ../qbearerengine_impl.h SOURCES += main.cpp \ qconnmanservice_linux.cpp \ + qofonoservice_linux.cpp \ qconnmanengine.cpp \ ../qnetworksession_impl.cpp diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp index 341f7cda2a..a8b8911176 100644 --- a/src/plugins/bearer/connman/qconnmanengine.cpp +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -41,6 +41,7 @@ #include "qconnmanengine.h" #include "qconnmanservice_linux_p.h" +#include "qofonoservice_linux_p.h" #include "../qnetworksession_impl.h" #include <QtNetwork/private/qnetworkconfiguration_p.h> @@ -109,7 +110,6 @@ void QConnmanEngine::initialize() QList<QNetworkConfigurationPrivate *> QConnmanEngine::getConfigurations() { QMutexLocker locker(&mutex); - // foundConfigurations.clear(); getNetworkListing(); QList<QNetworkConfigurationPrivate *> fetchedConfigurations; QNetworkConfigurationPrivate* cpPriv = 0; @@ -131,7 +131,6 @@ QList<QNetworkConfigurationPrivate *> QConnmanEngine::getConfigurations() delete config; } return fetchedConfigurations; -// return foundConfigurations; } void QConnmanEngine::getNetworkListing() @@ -149,7 +148,6 @@ void QConnmanEngine::getNetworkListing() } } - void QConnmanEngine::doRequestUpdate() { connmanManager->requestScan(""); @@ -184,11 +182,24 @@ void QConnmanEngine::connectToId(const QString &id) void QConnmanEngine::disconnectFromId(const QString &id) { QMutexLocker locker(&mutex); - QConnmanServiceInterface serv(serviceFromId(id)); + QString servicePath = serviceFromId(id); + QConnmanServiceInterface serv(servicePath); if(!serv.isValid()) { emit connectionError(id, DisconnectionError); } else { - serv.disconnect(); + if(serv.getType() != "cellular") { + serv.disconnect(); + } else { + QOfonoManagerInterface ofonoManager(0); + QString modemPath = ofonoManager.currentModem().path(); + QOfonoDataConnectionManagerInterface dc(modemPath,0); + foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) { + if(dcPath.path().contains(servicePath.section("_",-1))) { + QOfonoPrimaryDataContextInterface primaryContext(dcPath.path(),0); + primaryContext.setActive(false); + } + } + } } } @@ -324,7 +335,6 @@ QString QConnmanEngine::getServiceForNetwork(const QString &netPath) return QString(); } - void QConnmanEngine::propertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value) { Q_UNUSED(path); @@ -376,7 +386,7 @@ void QConnmanEngine::servicePropertyChangedContext(const QString &path,const QSt } } -void QConnmanEngine::networkPropertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value) +void QConnmanEngine::networkPropertyChangedContext(const QString &/*path*/,const QString &/*item*/, const QDBusVariant &/*value*/) { QMutexLocker locker(&mutex); } @@ -388,7 +398,6 @@ void QConnmanEngine::devicePropertyChangedContext(const QString &devpath,const Q QConnmanNetworkInterface network(devpath, this); - QDBusArgument arg = qvariant_cast<QDBusArgument>(value.variant()); QStringList remainingNetworks = qdbus_cast<QStringList>(arg); QString devicetype; @@ -502,10 +511,18 @@ QNetworkConfiguration::StateFlags QConnmanEngine::getStateForService(const QStri QMutexLocker locker(&mutex); QConnmanServiceInterface serv(service); QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined; - if(serv.isFavorite()) { - flag = ( flag | QNetworkConfiguration::Discovered); + if( serv.getType() == "cellular") { + if(serv.isSetupRequired()) { + flag = ( flag | QNetworkConfiguration::Defined); + } else { + flag = ( flag | QNetworkConfiguration::Discovered); + } } else { - flag = QNetworkConfiguration::Undefined; + if(serv.isFavorite()) { + flag = ( flag | QNetworkConfiguration::Discovered); + } else { + flag = QNetworkConfiguration::Undefined; + } } if(serv.getState() == "ready" || serv.getState() == "online") { @@ -524,8 +541,7 @@ QNetworkConfiguration::BearerType QConnmanEngine::typeToBearer(const QString &ty if (type == "bluetooth") return QNetworkConfiguration::BearerBluetooth; if (type == "cellular") { - return QNetworkConfiguration::Bearer2G; - // not handled: CDMA2000 HSPA + return ofonoTechToBearerType(type); } if (type == "wimax") return QNetworkConfiguration::BearerWiMAX; @@ -536,6 +552,51 @@ QNetworkConfiguration::BearerType QConnmanEngine::typeToBearer(const QString &ty return QNetworkConfiguration::BearerUnknown; } +QNetworkConfiguration::BearerType QConnmanEngine::ofonoTechToBearerType(const QString &/*type*/) +{ + QOfonoManagerInterface ofonoManager(this); + QOfonoNetworkRegistrationInterface ofonoNetwork(ofonoManager.currentModem().path(),this); + + if(ofonoNetwork.isValid()) { + foreach(const QDBusObjectPath op,ofonoNetwork.getOperators() ) { + QOfonoNetworkOperatorInterface opIface(op.path(),this); + + foreach(const QString opTech, opIface.getTechnologies()) { + + if(opTech == "gsm") { + return QNetworkConfiguration::Bearer2G; + } + if(opTech == "edge"){ + return QNetworkConfiguration::BearerCDMA2000; //wrong, I know + } + if(opTech == "umts"){ + return QNetworkConfiguration::BearerWCDMA; + } + if(opTech == "hspa"){ + return QNetworkConfiguration::BearerHSPA; + } + if(opTech == "lte"){ + return QNetworkConfiguration::BearerWiMAX; //not exact + } + } + } + } + return QNetworkConfiguration::BearerUnknown; +} + +bool QConnmanEngine::isRoamingAllowed(const QString &context) +{ + QOfonoManagerInterface ofonoManager(this); + QString modemPath = ofonoManager.currentModem().path(); + QOfonoDataConnectionManagerInterface dc(modemPath,this); + foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) { + if(dcPath.path().contains(context.section("_",-1))) { + return dc.isRoamingAllowed(); + } + } + return false; +} + void QConnmanEngine::removeConfiguration(const QString &id) { QMutexLocker locker(&mutex); @@ -564,7 +625,6 @@ void QConnmanEngine::removeConfiguration(const QString &id) void QConnmanEngine::addServiceConfiguration(const QString &servicePath) { - QMutexLocker locker(&mutex); QConnmanServiceInterface *serv; serv = new QConnmanServiceInterface(servicePath); @@ -589,36 +649,31 @@ void QConnmanEngine::addServiceConfiguration(const QString &servicePath) QString networkName = serv->getName(); - if(serv->getType() == "cellular") { - networkName = serv->getAPN(); - if(networkName.isEmpty()) { - networkName = serv->getName(); - } - } - - cpPriv->name = networkName; - cpPriv->isValid = true; - cpPriv->id = id; - cpPriv->type = QNetworkConfiguration::InternetAccessPoint; - - const QString connectionType = serv->getType(); if (connectionType == "ethernet") { cpPriv->bearerType = QNetworkConfiguration::BearerEthernet; } else if (connectionType == "wifi") { cpPriv->bearerType = QNetworkConfiguration::BearerWLAN; } else if (connectionType == "cellular") { - const QString mode = serv->getMode(); - if (mode == "gprs" || mode == "edge") - cpPriv->bearerType = QNetworkConfiguration::Bearer2G; - else if (mode == "umts") - cpPriv->bearerType = QNetworkConfiguration::BearerWCDMA; + cpPriv->bearerType = ofonoTechToBearerType("cellular"); + if(servicePath.isEmpty()) { + networkName = serv->getAPN(); + if(networkName.isEmpty()) { + networkName = serv->getName(); + } + } + cpPriv->roamingSupported = isRoamingAllowed(servicePath); } else if (connectionType == "wimax") { cpPriv->bearerType = QNetworkConfiguration::BearerWiMAX; } else { cpPriv->bearerType = QNetworkConfiguration::BearerUnknown; } + cpPriv->name = networkName; + cpPriv->isValid = true; + cpPriv->id = id; + cpPriv->type = QNetworkConfiguration::InternetAccessPoint; + if(serv->getSecurity() == "none") { cpPriv->purpose = QNetworkConfiguration::PublicPurpose; } else { @@ -635,7 +690,6 @@ void QConnmanEngine::addServiceConfiguration(const QString &servicePath) foundConfigurations.append(cpPriv); configInterfaces[cpPriv->id] = device.getInterface(); - locker.unlock(); emit configurationAdded(ptr); locker.relock(); @@ -646,7 +700,6 @@ void QConnmanEngine::addServiceConfiguration(const QString &servicePath) void QConnmanEngine::addNetworkConfiguration(const QString &networkPath) { QMutexLocker locker(&mutex); - if(networkPath.isNull()) return; @@ -662,10 +715,9 @@ void QConnmanEngine::addNetworkConfiguration(const QString &networkPath) id = QString::number(qHash(networkPath)); } else { id = QString::number(qHash(servicePath)); - serv = new QConnmanServiceInterface(servicePath,this); - connect(serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), - this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); - + serv = new QConnmanServiceInterface(servicePath,this); + connect(serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); } if (!id.isEmpty() && !accessPointConfigurations.contains(id)) { @@ -684,7 +736,6 @@ void QConnmanEngine::addNetworkConfiguration(const QString &networkPath) if(networkName.isEmpty()) networkName = "Hidden Network"; - QNetworkConfiguration::BearerType bearerType; if(servicePath.isEmpty()) { @@ -693,21 +744,14 @@ void QConnmanEngine::addNetworkConfiguration(const QString &networkPath) QConnmanDeviceInterface device(devicePath,this); bearerType = typeToBearer(device.getType()); } else { - bearerType = typeToBearer(serv->getType()); - } - - if (bearerType == QNetworkConfiguration::Bearer2G) { - QString mode = serv->getMode(); - if (mode == "gprs" || mode == "edge") { - bearerType = QNetworkConfiguration::Bearer2G; - } else if (mode == "umts") { - bearerType = QNetworkConfiguration::BearerWCDMA; - } - if(servicePath.isEmpty()) { - networkName = serv->getAPN(); - if(networkName.isEmpty()) { + if(serv->getType() == "cellular") { + bearerType = ofonoTechToBearerType("cellular"); + if(servicePath.isEmpty()) { networkName = serv->getName(); } + cpPriv->roamingSupported = isRoamingAllowed(servicePath); + } else { + bearerType = typeToBearer(serv->getType()); } } @@ -775,7 +819,19 @@ void QConnmanConnectThread::run() if(!serv.isValid()) { emit connectionError(identifier, QBearerEngineImpl::InterfaceLookupError); } else { - serv.connect(); + if(serv.getType() != "cellular") { + serv.connect(); + } else { + QOfonoManagerInterface ofonoManager(0); + QString modemPath = ofonoManager.currentModem().path(); + QOfonoDataConnectionManagerInterface dc(modemPath,0); + foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) { + if(dcPath.path().contains(servicePath.section("_",-1))) { + QOfonoPrimaryDataContextInterface primaryContext(dcPath.path(),0); + primaryContext.setActive(true); + } + } + } } } diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h index 2ee6da531c..569bbc7a73 100644 --- a/src/plugins/bearer/connman/qconnmanengine.h +++ b/src/plugins/bearer/connman/qconnmanengine.h @@ -137,7 +137,8 @@ private: QMap<QString,QStringList> deviceMap; //tech path, device path QMap<QString, QString> serviceNetworks; //service, network - + QNetworkConfiguration::BearerType ofonoTechToBearerType(const QString &type); + bool isRoamingAllowed(const QString &context); protected: bool requiresPolling() const; QConnmanConnectThread *connThread; diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp index 3722c43287..549a07a7a1 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp +++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp @@ -984,12 +984,17 @@ QConnmanCounterInterface::~QConnmanCounterInterface() quint32 QConnmanCounterInterface::getReceivedByteCount() { -return 0; + return 0; } quint32 QConnmanCounterInterface::getTransmittedByteCount() { -return 0; + return 0; +} + +quint64 QConnmanCounterInterface::getTimeOnline() +{ + return 0; } ///////////////////////////////////////// diff --git a/src/plugins/bearer/connman/qconnmanservice_linux_p.h b/src/plugins/bearer/connman/qconnmanservice_linux_p.h index a2b1e7338d..6e6b7020a7 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux_p.h +++ b/src/plugins/bearer/connman/qconnmanservice_linux_p.h @@ -331,6 +331,7 @@ public: QString getInterface(); quint32 getReceivedByteCount(); quint32 getTransmittedByteCount(); + quint64 getTimeOnline(); private: QConnmanCounterInterfacePrivate *d; diff --git a/src/plugins/bearer/connman/qofonoservice_linux.cpp b/src/plugins/bearer/connman/qofonoservice_linux.cpp new file mode 100644 index 0000000000..955f4b13c6 --- /dev/null +++ b/src/plugins/bearer/connman/qofonoservice_linux.cpp @@ -0,0 +1,940 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins 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 <QObject> +#include <QList> +#include <QtDBus/QtDBus> +#include <QtDBus/QDBusConnection> +#include <QtDBus/QDBusError> +#include <QtDBus/QDBusInterface> +#include <QtDBus/QDBusMessage> +#include <QtDBus/QDBusReply> +#include <QtDBus/QDBusPendingCallWatcher> +#include <QtDBus/QDBusObjectPath> +#include <QtDBus/QDBusPendingCall> + +#include "qofonoservice_linux_p.h" + + +QT_BEGIN_NAMESPACE +static QDBusConnection dbusConnection = QDBusConnection::systemBus(); + + +QOfonoManagerInterface::QOfonoManagerInterface( QObject *parent) + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + QLatin1String(OFONO_MANAGER_PATH), + OFONO_MANAGER_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QOfonoManagerInterface::~QOfonoManagerInterface() +{ +} + +QList <QDBusObjectPath> QOfonoManagerInterface::getModems() +{ + QVariant var = getProperty("Modems"); + return qdbus_cast<QList<QDBusObjectPath> >(var); +} + +QDBusObjectPath QOfonoManagerInterface::currentModem() +{ + QList<QDBusObjectPath> modems = getModems(); + foreach(const QDBusObjectPath modem, modems) { + QOfonoModemInterface device(modem.path()); + if(device.isPowered() && device.isOnline()) + return modem;; + } + return QDBusObjectPath(); +} + + +void QOfonoManagerInterface::connectNotify(const char *signal) +{ +if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + QLatin1String(OFONO_MANAGER_PATH), + QLatin1String(OFONO_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QOfonoDBusHelper *helper; + helper = new QOfonoDBusHelper(this); + + dbusConnection.connect(QLatin1String(OFONO_SERVICE), + QLatin1String(OFONO_MANAGER_PATH), + QLatin1String(OFONO_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QOfonoManagerInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QOfonoManagerInterface::getProperty(const QString &property) +{ + QVariantMap map = getProperties(); + if (map.contains(property)) { + return map.value(property); + } else { + qDebug() << Q_FUNC_INFO << "does not contain" << property; + } + return QVariant(); +} + +QVariantMap QOfonoManagerInterface::getProperties() +{ + QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); + if(reply.isValid()) + return reply.value(); + else + return QVariantMap(); +} + +QOfonoDBusHelper::QOfonoDBusHelper(QObject * parent) + : QObject(parent) +{ +} + +QOfonoDBusHelper::~QOfonoDBusHelper() +{ +} + +void QOfonoDBusHelper::propertyChanged(const QString &item, const QDBusVariant &var) +{ + QDBusMessage msg = this->message(); + Q_EMIT propertyChangedContext(msg.path() ,item, var); +} + + +QOfonoModemInterface::QOfonoModemInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + dbusPathName, + OFONO_MODEM_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QOfonoModemInterface::~QOfonoModemInterface() +{ +} + +bool QOfonoModemInterface::isPowered() +{ + QVariant var = getProperty("Powered"); + return qdbus_cast<bool>(var); +} + +bool QOfonoModemInterface::isOnline() +{ + QVariant var = getProperty("Online"); + return qdbus_cast<bool>(var); +} + +QString QOfonoModemInterface::getName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast<QString>(var); +} + +QString QOfonoModemInterface::getManufacturer() +{ + QVariant var = getProperty("Manufacturer"); + return qdbus_cast<QString>(var); + +} + +QString QOfonoModemInterface::getModel() +{ + + QVariant var = getProperty("Model"); + return qdbus_cast<QString>(var); +} + +QString QOfonoModemInterface::getRevision() +{ + QVariant var = getProperty("Revision"); + return qdbus_cast<QString>(var); + +} +QString QOfonoModemInterface::getSerial() +{ + QVariant var = getProperty("Serial"); + return qdbus_cast<QString>(var); + +} + +QStringList QOfonoModemInterface::getFeatures() +{ + //sms, sim + QVariant var = getProperty("Features"); + return qdbus_cast<QStringList>(var); +} + +QStringList QOfonoModemInterface::getInterfaces() +{ + QVariant var = getProperty("Interfaces"); + return qdbus_cast<QStringList>(var); +} + +QString QOfonoModemInterface::defaultInterface() +{ + foreach(const QString &modem,getInterfaces()) { + return modem; + } + return QString(); +} + + +void QOfonoModemInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_MODEM_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QOfonoDBusHelper *helper; + helper = new QOfonoDBusHelper(this); + + dbusConnection.connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_MODEM_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + }} + +void QOfonoModemInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariantMap QOfonoModemInterface::getProperties() +{ + QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QVariant QOfonoModemInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << Q_FUNC_INFO << "does not contain" << property; + } + return var; +} + + +QOfonoNetworkRegistrationInterface::QOfonoNetworkRegistrationInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + dbusPathName, + OFONO_NETWORK_REGISTRATION_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QOfonoNetworkRegistrationInterface::~QOfonoNetworkRegistrationInterface() +{ +} + +QString QOfonoNetworkRegistrationInterface::getStatus() +{ + /* + "unregistered" Not registered to any network + "registered" Registered to home network + "searching" Not registered, but searching + "denied" Registration has been denied + "unknown" Status is unknown + "roaming" Registered, but roaming*/ + QVariant var = getProperty("Status"); + return qdbus_cast<QString>(var); +} + +quint16 QOfonoNetworkRegistrationInterface::getLac() +{ + QVariant var = getProperty("LocationAreaCode"); + return var.value<quint16>(); +} + + +quint32 QOfonoNetworkRegistrationInterface::getCellId() +{ + QVariant var = getProperty("CellId"); + return var.value<quint32>(); +} + +QString QOfonoNetworkRegistrationInterface::getTechnology() +{ + // "gsm", "edge", "umts", "hspa","lte" + QVariant var = getProperty("Technology"); + return qdbus_cast<QString>(var); +} + +QString QOfonoNetworkRegistrationInterface::getOperatorName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast<QString>(var); +} + +int QOfonoNetworkRegistrationInterface::getSignalStrength() +{ + QVariant var = getProperty("Strength"); + return qdbus_cast<int>(var); + +} + +QString QOfonoNetworkRegistrationInterface::getBaseStation() +{ + QVariant var = getProperty("BaseStation"); + return qdbus_cast<QString>(var); +} + +QList <QDBusObjectPath> QOfonoNetworkRegistrationInterface::getOperators() +{ + QVariant var = getProperty("Operators"); + return qdbus_cast<QList <QDBusObjectPath> >(var); +} + +void QOfonoNetworkRegistrationInterface::connectNotify(const char *signal) +{ +if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_NETWORK_REGISTRATION_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QOfonoDBusHelper *helper; + helper = new QOfonoDBusHelper(this); + + dbusConnection.connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_NETWORK_REGISTRATION_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QOfonoNetworkRegistrationInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QOfonoNetworkRegistrationInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << Q_FUNC_INFO << "does not contain" << property; + } + return var; +} + +QVariantMap QOfonoNetworkRegistrationInterface::getProperties() +{ + QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + + + +QOfonoNetworkOperatorInterface::QOfonoNetworkOperatorInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + dbusPathName, + OFONO_NETWORK_OPERATOR_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QOfonoNetworkOperatorInterface::~QOfonoNetworkOperatorInterface() +{ +} + +QString QOfonoNetworkOperatorInterface::getName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast<QString>(var); +} + +QString QOfonoNetworkOperatorInterface::getStatus() +{ + // "unknown", "available", "current" and "forbidden" + QVariant var = getProperty("Status"); + return qdbus_cast<QString>(var); +} + +QString QOfonoNetworkOperatorInterface::getMcc() +{ + QVariant var = getProperty("MobileCountryCode"); + return qdbus_cast<QString>(var); +} + +QString QOfonoNetworkOperatorInterface::getMnc() +{ + QVariant var = getProperty("MobileNetworkCode"); + return qdbus_cast<QString>(var); +} + +QStringList QOfonoNetworkOperatorInterface::getTechnologies() +{ + QVariant var = getProperty("Technologies"); + return qdbus_cast<QStringList>(var); +} + +void QOfonoNetworkOperatorInterface::connectNotify(const char *signal) +{ +if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_NETWORK_OPERATOR_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QOfonoDBusHelper *helper; + helper = new QOfonoDBusHelper(this); + + dbusConnection.connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_NETWORK_OPERATOR_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QOfonoNetworkOperatorInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QOfonoNetworkOperatorInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << Q_FUNC_INFO << "does not contain" << property; + } + return var; +} + +QVariantMap QOfonoNetworkOperatorInterface::getProperties() +{ + QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QOfonoSimInterface::QOfonoSimInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + dbusPathName, + OFONO_SIM_MANAGER_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QOfonoSimInterface::~QOfonoSimInterface() +{ +} + +bool QOfonoSimInterface::isPresent() +{ + QVariant var = getProperty("Present"); + return qdbus_cast<bool>(var); +} + +QString QOfonoSimInterface::getHomeMcc() +{ + QVariant var = getProperty("MobileCountryCode"); + return qdbus_cast<QString>(var); +} + +QString QOfonoSimInterface::getHomeMnc() +{ + QVariant var = getProperty("MobileNetworkCode"); + return qdbus_cast<QString>(var); +} + +// QStringList subscriberNumbers(); +// QMap<QString,QString> serviceNumbers(); +QString QOfonoSimInterface::pinRequired() +{ + QVariant var = getProperty("PinRequired"); + return qdbus_cast<QString>(var); +} + +QString QOfonoSimInterface::lockedPins() +{ + QVariant var = getProperty("LockedPins"); + return qdbus_cast<QString>(var); +} + +QString QOfonoSimInterface::cardIdentifier() +{ + QVariant var = getProperty("CardIdentifier"); + return qdbus_cast<QString>(var); +} + +void QOfonoSimInterface::connectNotify(const char *signal) +{ +if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_SIM_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QOfonoDBusHelper *helper; + helper = new QOfonoDBusHelper(this); + + dbusConnection.connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_SIM_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QOfonoSimInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QOfonoSimInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << Q_FUNC_INFO << "does not contain" << property; + } + return var; +} + +QVariantMap QOfonoSimInterface::getProperties() +{ + QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QOfonoDataConnectionManagerInterface::QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + dbusPathName, + OFONO_DATA_CONNECTION_MANAGER_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QOfonoDataConnectionManagerInterface::~QOfonoDataConnectionManagerInterface() +{ +} + +QList<QDBusObjectPath> QOfonoDataConnectionManagerInterface::getPrimaryContexts() +{ + QVariant var = getProperty("PrimaryContexts"); + return qdbus_cast<QList<QDBusObjectPath> >(var); +} + +bool QOfonoDataConnectionManagerInterface::isAttached() +{ + QVariant var = getProperty("Attached"); + return qdbus_cast<bool>(var); +} + +bool QOfonoDataConnectionManagerInterface::isRoamingAllowed() +{ + QVariant var = getProperty("RoamingAllowed"); + return qdbus_cast<bool>(var); +} + +bool QOfonoDataConnectionManagerInterface::isPowered() +{ + QVariant var = getProperty("Powered"); + return qdbus_cast<bool>(var); +} + +void QOfonoDataConnectionManagerInterface::connectNotify(const char *signal) +{ +if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_DATA_CONNECTION_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QOfonoDBusHelper *helper; + helper = new QOfonoDBusHelper(this); + + dbusConnection.connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_DATA_CONNECTION_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QOfonoDataConnectionManagerInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QOfonoDataConnectionManagerInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << Q_FUNC_INFO << "does not contain" << property; + } + return var; +} + +QVariantMap QOfonoDataConnectionManagerInterface::getProperties() +{ + QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QOfonoPrimaryDataContextInterface::QOfonoPrimaryDataContextInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + dbusPathName, + OFONO_DATA_CONTEXT_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QOfonoPrimaryDataContextInterface::~QOfonoPrimaryDataContextInterface() +{ +} + +bool QOfonoPrimaryDataContextInterface::isActive() +{ + QVariant var = getProperty("Active"); + return qdbus_cast<bool>(var); +} + +QString QOfonoPrimaryDataContextInterface::getApName() +{ + QVariant var = getProperty("AccessPointName"); + return qdbus_cast<QString>(var); +} + +QString QOfonoPrimaryDataContextInterface::getType() +{ + QVariant var = getProperty("Type"); + return qdbus_cast<QString>(var); +} + +QString QOfonoPrimaryDataContextInterface::getName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast<QString>(var); +} + +QVariantMap QOfonoPrimaryDataContextInterface::getSettings() +{ + QVariant var = getProperty("Settings"); + return qdbus_cast<QVariantMap>(var); +} + +QString QOfonoPrimaryDataContextInterface::getInterface() +{ + QVariant var = getProperty("Interface"); + return qdbus_cast<QString>(var); +} + +QString QOfonoPrimaryDataContextInterface::getAddress() +{ + QVariant var = getProperty("Address"); + return qdbus_cast<QString>(var); +} + +bool QOfonoPrimaryDataContextInterface::setActive(bool on) +{ +// this->setProperty("Active", QVariant(on)); + + return setProp("Active", qVariantFromValue(on)); +} + +bool QOfonoPrimaryDataContextInterface::setApn(const QString &name) +{ + return setProp("AccessPointName", QVariant::fromValue(name)); +} + +void QOfonoPrimaryDataContextInterface::connectNotify(const char *signal) +{ +if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_DATA_CONTEXT_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QOfonoDBusHelper *helper; + helper = new QOfonoDBusHelper(this); + + dbusConnection.connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_DATA_CONTEXT_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QOfonoPrimaryDataContextInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QOfonoPrimaryDataContextInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << Q_FUNC_INFO << "does not contain" << property; + } + return var; +} + +QVariantMap QOfonoPrimaryDataContextInterface::getProperties() +{ + QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +bool QOfonoPrimaryDataContextInterface::setProp(const QString &property, const QVariant &var) +{ + QList<QVariant> args; + args << qVariantFromValue(property) << qVariantFromValue(QDBusVariant(var)); + + QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect, + QLatin1String("SetProperty"), + args); + bool ok = true; + if(reply.type() != QDBusMessage::ReplyMessage) { + qWarning() << reply.errorMessage(); + ok = false; + } + qWarning() << reply.errorMessage(); + return ok; +} + +QOfonoSmsInterface::QOfonoSmsInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + dbusPathName, + OFONO_SMS_MANAGER_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QOfonoSmsInterface::~QOfonoSmsInterface() +{ +} + +void QOfonoSmsInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_SMS_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QOfonoDBusHelper *helper; + helper = new QOfonoDBusHelper(this); + + dbusConnection.connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_SMS_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } + + if (QLatin1String(signal) == SIGNAL(immediateMessage(QString,QVariantMap))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_SMS_MANAGER_INTERFACE), + QLatin1String("ImmediateMessage"), + this,SIGNAL(immediateMessage(QString,QVariantMap )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(incomingMessage(QString,QVariantMap))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_SMS_MANAGER_INTERFACE), + QLatin1String("IncomingMessage"), + this,SIGNAL(incomingMessage(QString,QVariantMap)))) { + qWarning() << "PropertyCHanged not connected"; + } + } +} + +void QOfonoSmsInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QOfonoSmsInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << Q_FUNC_INFO << "does not contain" << property; + } + return var; +} + +QVariantMap QOfonoSmsInterface::getProperties() +{ + QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +void QOfonoSmsInterface::sendMessage(const QString &to, const QString &message) +{ + QDBusReply<QString> reply = this->call(QLatin1String("SendMessage"), + QVariant::fromValue(to), + QVariant::fromValue(message)); + bool ok = true; + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + ok = false; + } +} + +QT_END_NAMESPACE diff --git a/src/plugins/bearer/connman/qofonoservice_linux_p.h b/src/plugins/bearer/connman/qofonoservice_linux_p.h new file mode 100644 index 0000000000..48926664e0 --- /dev/null +++ b/src/plugins/bearer/connman/qofonoservice_linux_p.h @@ -0,0 +1,332 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins 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 QOFONOSERVICE_H +#define QOFONOSERVICE_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 <QtDBus/QtDBus> +#include <QtDBus/QDBusConnection> +#include <QtDBus/QDBusError> +#include <QtDBus/QDBusInterface> +#include <QtDBus/QDBusMessage> +#include <QtDBus/QDBusReply> + +#include <QtDBus/QDBusPendingCallWatcher> +#include <QtDBus/QDBusObjectPath> +#include <QtDBus/QDBusContext> +#include <QMap> + +#define OFONO_SERVICE "org.ofono" +#define OFONO_MANAGER_INTERFACE "org.ofono.Manager" +#define OFONO_MANAGER_PATH "/" +#define OFONO_MODEM_INTERFACE "org.ofono.Modem" +#define OFONO_NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration" +#define OFONO_NETWORK_OPERATOR_INTERFACE "org.ofono.NetworkOperator" +#define OFONO_DATA_CONNECTION_MANAGER_INTERFACE "org.ofono.DataConnectionManager" +#define OFONO_SIM_MANAGER_INTERFACE "org.ofono.SimManager" +#define OFONO_DATA_CONTEXT_INTERFACE "org.ofono.PrimaryDataContext" + +#define OFONO_SMS_MANAGER_INTERFACE "org.ofono.SmsManager" +#define OFONO_PHONEBOOK_INTERFACE "org.ofono.Phonebook" +#define OFONO_MESSAGE_WAITING_INTERFACE "org.ofono.MessageWaiting" + + + +QT_BEGIN_NAMESPACE + +QT_END_NAMESPACE + + +QT_BEGIN_NAMESPACE + +class QOfonoManagerInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QOfonoManagerInterface( QObject *parent = 0); + ~QOfonoManagerInterface(); + + QDBusObjectPath path() const; + + QVariantMap getProperties(); + bool setProperty(const QString &name, const QDBusVariant &value); + QList <QDBusObjectPath> getModems(); + QDBusObjectPath currentModem(); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); + +}; + + +class QOfonoDBusHelper: public QObject, protected QDBusContext + { + Q_OBJECT + public: + QOfonoDBusHelper(QObject *parent = 0); + ~QOfonoDBusHelper(); + + public slots: + void propertyChanged(const QString &, const QDBusVariant &); + Q_SIGNALS: + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); +}; + +class QOfonoModemInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QOfonoModemInterface(const QString &dbusModemPathName, QObject *parent = 0); + ~QOfonoModemInterface(); + + QVariantMap getProperties(); + //properties + bool isPowered(); + bool isOnline(); + QString getName(); + QString getManufacturer(); + QString getModel(); + QString getRevision(); + QString getSerial(); + + QStringList getFeatures(); //sms, sim + QStringList getInterfaces(); + QString defaultInterface(); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); +}; + + +class QOfonoNetworkRegistrationInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QOfonoNetworkRegistrationInterface(const QString &dbusModemPathName, QObject *parent = 0); + ~QOfonoNetworkRegistrationInterface(); + + QVariantMap getProperties(); + + //properties + QString getStatus(); + quint16 getLac(); + quint32 getCellId(); + QString getTechnology(); + QString getOperatorName(); + int getSignalStrength(); + QString getBaseStation(); + QList <QDBusObjectPath> getOperators(); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); + +}; + +class QOfonoNetworkOperatorInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: +//modem or operator paths + QOfonoNetworkOperatorInterface(const QString &dbusPathName, QObject *parent = 0); + ~QOfonoNetworkOperatorInterface(); + + QVariantMap getProperties(); + + //properties + QString getName(); + QString getStatus();// "unknown", "available", "current" and "forbidden" + QString getMcc(); + QString getMnc(); + QStringList getTechnologies(); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + +class QOfonoSimInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QOfonoSimInterface(const QString &dbusModemPathName, QObject *parent = 0); + ~QOfonoSimInterface(); + + QVariantMap getProperties(); + + //properties + bool isPresent(); + QString getHomeMcc(); + QString getHomeMnc(); +// QStringList subscriberNumbers(); +// QMap<QString,QString> serviceNumbers(); + QString pinRequired(); + QString lockedPins(); + QString cardIdentifier(); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + + +class QOfonoDataConnectionManagerInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent = 0); + ~QOfonoDataConnectionManagerInterface(); + + QVariantMap getProperties(); + + //properties + QList<QDBusObjectPath> getPrimaryContexts(); + bool isAttached(); + bool isRoamingAllowed(); + bool isPowered(); + + bool setPower(bool on); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + + +class QOfonoPrimaryDataContextInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QOfonoPrimaryDataContextInterface(const QString &dbusPathName, QObject *parent = 0); + ~QOfonoPrimaryDataContextInterface(); + + QVariantMap getProperties(); + + //properties + bool isActive(); + QString getApName(); + QString getType(); + QString getName(); + QVariantMap getSettings(); + QString getInterface(); + QString getAddress(); + + bool setActive(bool on); + bool setApn(const QString &name); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); + bool setProp(const QString &, const QVariant &var); +}; + +class QOfonoSmsInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QOfonoSmsInterface(const QString &dbusModemPathName, QObject *parent = 0); + ~QOfonoSmsInterface(); + + QVariantMap getProperties(); + void sendMessage(const QString &to, const QString &message); + + //properties + QString serviceCenterAddress(); + bool useDeliveryReports(); + QString bearer(); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); + void immediateMessage(const QString &message, const QVariantMap &info); + void incomingMessage(const QString &message, const QVariantMap &info); +}; + +#endif //QOFONOSERVICE_H diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm index 131f36d39e..844e38b103 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.mm +++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm @@ -305,50 +305,53 @@ void QScanThread::getUserConfigurations() SCDynamicStoreRef dynRef = SCDynamicStoreCreate(kCFAllocatorSystemDefault, (CFStringRef)@"Qt corewlan", nil, nil); NSDictionary * airportPlist = (NSDictionary *)SCDynamicStoreCopyValue(dynRef, (CFStringRef)[NSString stringWithFormat:@"Setup:/Network/Interface/%@/AirPort", nsInterfaceName]); CFRelease(dynRef); - - NSDictionary *prefNetDict = [airportPlist objectForKey:@"PreferredNetworks"]; - - NSArray *thisSsidarray = [prefNetDict valueForKey:@"SSID_STR"]; - for(NSString *ssidkey in thisSsidarray) { - QString thisSsid = qt_mac_NSStringToQString(ssidkey); - if(!userProfiles.contains(thisSsid)) { - QMap <QString,QString> map; - map.insert(thisSsid, qt_mac_NSStringToQString(nsInterfaceName)); - userProfiles.insert(thisSsid, map); + if(airportPlist != nil) { + NSDictionary *prefNetDict = [airportPlist objectForKey:@"PreferredNetworks"]; + + NSArray *thisSsidarray = [prefNetDict valueForKey:@"SSID_STR"]; + for(NSString *ssidkey in thisSsidarray) { + QString thisSsid = qt_mac_NSStringToQString(ssidkey); + if(!userProfiles.contains(thisSsid)) { + QMap <QString,QString> map; + map.insert(thisSsid, qt_mac_NSStringToQString(nsInterfaceName)); + userProfiles.insert(thisSsid, map); + } } + CFRelease(airportPlist); } - CFRelease(airportPlist); // 802.1X user profiles QString userProfilePath = QDir::homePath() + "/Library/Preferences/com.apple.eap.profiles.plist"; NSDictionary* eapDict = [[[NSDictionary alloc] initWithContentsOfFile:qt_mac_QStringToNSString(userProfilePath)] autorelease]; - NSString *profileStr= @"Profiles"; - NSString *nameStr = @"UserDefinedName"; - NSString *networkSsidStr = @"Wireless Network"; - for (id profileKey in eapDict) { - if ([profileStr isEqualToString:profileKey]) { - NSDictionary *itemDict = [eapDict objectForKey:profileKey]; - for (id itemKey in itemDict) { - - NSInteger dictSize = [itemKey count]; - id objects[dictSize]; - id keys[dictSize]; - - [itemKey getObjects:objects andKeys:keys]; - QString networkName; - QString ssid; - for(int i = 0; i < dictSize; i++) { - if([nameStr isEqualToString:keys[i]]) { - networkName = qt_mac_NSStringToQString(objects[i]); - } - if([networkSsidStr isEqualToString:keys[i]]) { - ssid = qt_mac_NSStringToQString(objects[i]); - } - if(!userProfiles.contains(networkName) - && !ssid.isEmpty()) { - QMap<QString,QString> map; - map.insert(ssid, qt_mac_NSStringToQString(nsInterfaceName)); - userProfiles.insert(networkName, map); + if(eapDict != nil) { + NSString *profileStr= @"Profiles"; + NSString *nameStr = @"UserDefinedName"; + NSString *networkSsidStr = @"Wireless Network"; + for (id profileKey in eapDict) { + if ([profileStr isEqualToString:profileKey]) { + NSDictionary *itemDict = [eapDict objectForKey:profileKey]; + for (id itemKey in itemDict) { + + NSInteger dictSize = [itemKey count]; + id objects[dictSize]; + id keys[dictSize]; + + [itemKey getObjects:objects andKeys:keys]; + QString networkName; + QString ssid; + for(int i = 0; i < dictSize; i++) { + if([nameStr isEqualToString:keys[i]]) { + networkName = qt_mac_NSStringToQString(objects[i]); + } + if([networkSsidStr isEqualToString:keys[i]]) { + ssid = qt_mac_NSStringToQString(objects[i]); + } + if(!userProfiles.contains(networkName) + && !ssid.isEmpty()) { + QMap<QString,QString> map; + map.insert(ssid, qt_mac_NSStringToQString(nsInterfaceName)); + userProfiles.insert(networkName, map); + } } } } @@ -855,6 +858,8 @@ quint64 QCoreWlanEngine::startTime(const QString &id) NSString *filePath = @"/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist"; NSDictionary* plistDict = [[[NSDictionary alloc] initWithContentsOfFile:filePath] autorelease]; + if(plistDict == nil) + return timestamp; NSString *input = @"KnownNetworks"; NSString *timeStampStr = @"_timeStamp"; @@ -864,9 +869,13 @@ quint64 QCoreWlanEngine::startTime(const QString &id) if ([input isEqualToString:key]) { NSDictionary *knownNetworksDict = [plistDict objectForKey:key]; + if(knownNetworksDict == nil) + return timestamp; for (id networkKey in knownNetworksDict) { bool isFound = false; NSDictionary *itemDict = [knownNetworksDict objectForKey:networkKey]; + if(itemDict == nil) + return timestamp; NSInteger dictSize = [itemDict count]; id objects[dictSize]; id keys[dictSize]; diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 19f13c25e9..7f81397dba 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -111,13 +111,15 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() Cancel(); iSocketServ.Close(); - // Restore default interface to system default - restoreDefaultIf(); + // Close global 'Open C' RConnection + // Clears also possible unsetdefaultif() flags. + setdefaultif(0); iConnectionMonitor.Close(); iOpenCLibrary.Close(); #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG - qDebug() << "QNS this : " << QString::number((uint)this) << " - destroyed (and restoreDefaultIf())"; + qDebug() << "QNS this : " << QString::number((uint)this) + << " - destroyed (and setdefaultif(0))"; #endif } @@ -533,8 +535,15 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) Cancel(); // closes iConnection iSocketServ.Close(); - // Restore default interface to system default - restoreDefaultIf(); + // Close global 'Open C' RConnection. If OpenC supports, + // close the defaultif for good to avoid difficult timing + // and bouncing issues of network going immediately back up + // because of e.g. select() thread etc. + if (iDynamicUnSetdefaultif) { + iDynamicUnSetdefaultif(); + } else { + setdefaultif(0); + } // If UserChoice, go down immediately. If some other configuration, // go down immediately if there is no reports expected from the platform; @@ -959,11 +968,17 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia } } else { #ifdef SNAP_FUNCTIONALITY_AVAILABLE - // On Symbian^3 (only, not earlier or Symbian^4) if the SNAP was not reachable, it triggers - // user choice type of activity (EasyWLAN). As a result, a new IAP may be created, and - // hence if was not found yet. Therefore update configurations and see if there is something new. + // On Symbian^3 (only, not earlier or Symbian^4) if the SNAP was not reachable, it + // triggers user choice type of activity (EasyWLAN). As a result, a new IAP may be + // created, and hence if was not found yet. Therefore update configurations and see if + // there is something new. + // 1. Update knowledge from the databases. - engine->requestUpdate(); + if (thread() != engine->thread()) + QMetaObject::invokeMethod(engine, "requestUpdate", Qt::BlockingQueuedConnection); + else + engine->requestUpdate(); + // 2. Check if new configuration was created during connection creation QList<QString> knownConfigs = engine->accessPointConfigurationIdentifiers(); #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG @@ -1016,7 +1031,12 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia } else { // Check if new (WLAN) IAP was created in IAP/SNAP dialog // 1. Sync internal configurations array to commsdb first - engine->updateConfigurations(); + if (thread() != engine->thread()) { + QMetaObject::invokeMethod(engine, "requestUpdate", + Qt::BlockingQueuedConnection); + } else { + engine->requestUpdate(); + } // 2. Check if new configuration was created during connection creation QStringList knownConfigs = engine->accessPointConfigurationIdentifiers(); if (knownConfigs.count() > iKnownConfigsBeforeConnectionStart.count()) { @@ -1459,29 +1479,6 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne } } -void QNetworkSessionPrivateImpl::restoreDefaultIf() -{ - QNetworkConfigurationPrivatePointer config = engine->defaultConfiguration(); - - QMutexLocker locker(&config->mutex); - - ifreq ifr; - memset(&ifr, 0, sizeof(ifreq)); - - switch (config->type) { - case QNetworkConfiguration::InternetAccessPoint: - strcpy(ifr.ifr_name, config->name.toUtf8().constData()); - break; - case QNetworkConfiguration::ServiceNetwork: - ifr.ifr_ifru.snap_id = toSymbianConfig(config)->numericId; - break; - default: - ; - }; - - setdefaultif(&ifr); -} - #if defined(SNAP_FUNCTIONALITY_AVAILABLE) bool QNetworkSessionPrivateImpl::easyWlanTrueIapId(TUint32 &trueIapId) const { diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h index 51f2e707c7..8e3e9976fd 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.h +++ b/src/plugins/bearer/symbian/qnetworksession_impl.h @@ -141,7 +141,6 @@ private: void handleSymbianConnectionStatusChange(TInt aConnectionStatus, TInt aError, TUint accessPointId = 0); QNetworkConfiguration bestConfigFromSNAP(const QNetworkConfiguration& snapConfig) const; QNetworkConfiguration activeConfiguration(TUint32 iapId = 0) const; - void restoreDefaultIf(); #ifndef QT_NO_NETWORKINTERFACE QNetworkInterface interface(TUint iapId) const; #endif diff --git a/src/script/script.pro b/src/script/script.pro index 55217e0024..4ee86d7bb1 100644 --- a/src/script/script.pro +++ b/src/script/script.pro @@ -79,7 +79,10 @@ INCLUDEPATH += $$PWD include(script.pri) -symbian:TARGET.UID3=0x2001B2E1 +symbian { + TARGET.UID3=0x2001B2E1 + LIBS += -lhal +} # WebKit doesn't compile in C++0x mode *-g++*:QMAKE_CXXFLAGS -= -std=c++0x -std=gnu++0x |