From 85e940d2fa5e8d2caf0d157f214bb826fc392e7b Mon Sep 17 00:00:00 2001 From: Janne Koskinen Date: Wed, 20 May 2009 09:20:09 +0200 Subject: Removed accidental allocation in QRingBuffer::clear() --- src/corelib/tools/qringbuffer_p.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h index 3a0901d..99c89f8 100644 --- a/src/corelib/tools/qringbuffer_p.h +++ b/src/corelib/tools/qringbuffer_p.h @@ -62,8 +62,10 @@ class Q_CORE_EXPORT QRingBuffer { public: inline QRingBuffer(int growth = 4096) : basicBlockSize(growth) { + head = tail = 0; + tailBuffer = 0; + bufferSize = 0; buffers << QByteArray(); - clear(); } inline int nextDataBlockSize() const { @@ -104,8 +106,12 @@ public: } inline char *reserve(int bytes) { + if (isEmpty()) { + buffers[tailBuffer].resize(qMax(basicBlockSize, bytes)); + bufferSize = tail = bytes; + return buffers[tailBuffer].data(); + } bufferSize += bytes; - // if there is already enough space, simply return. if (tail + bytes <= buffers.at(tailBuffer).size()) { char *writePtr = buffers[tailBuffer].data() + tail; @@ -198,7 +204,7 @@ public: } inline void clear() { - if(!buffers.isEmpty()) { + if(!isEmpty()) { QByteArray tmp = buffers[0]; buffers.clear(); buffers << tmp; -- cgit v0.12 From ebeb366169bccde25e7c795fa4d98db5d966ef55 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 16 Jun 2009 16:09:34 +0200 Subject: compile without exception support --- src/network/kernel/qhostinfo_unix.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp index f5d7166..bdbf986 100644 --- a/src/network/kernel/qhostinfo_unix.cpp +++ b/src/network/kernel/qhostinfo_unix.cpp @@ -320,8 +320,7 @@ QString QHostInfo::localDomainName() if (local_res_ninit) { // using thread-safe version res_state_ptr state = res_state_ptr(qMalloc(sizeof(*state))); - if (!state) - qBadAlloc(); + Q_CHECK_PTR(state); memset(state, 0, sizeof(*state)); local_res_ninit(state); QString domainName = QUrl::fromAce(state->defdname); -- cgit v0.12 From 91c544615cfd8b570e26dacbd9711b4d0a4aac9a Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Tue, 16 Jun 2009 16:13:00 +0200 Subject: Remove extra bracket on stlportv5 detection. --- mkspecs/features/symbian/platform_paths.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/symbian/platform_paths.prf b/mkspecs/features/symbian/platform_paths.prf index 1e62c41..bec9811 100644 --- a/mkspecs/features/symbian/platform_paths.prf +++ b/mkspecs/features/symbian/platform_paths.prf @@ -216,7 +216,7 @@ exists($${EPOCROOT}epoc32/include/platform_paths.prf) { OS_LAYER_SSL_SYSTEMINCLUDE = $$OS_LAYER_PUBLIC_EXPORT_PATH(stdapis/openssl) # stlportv5 is preferred over stlport as it has the throwing version of operator new - exists($${EPOCROOT}epoc32/include/stdapis/stlportv5)) { + exists($${EPOCROOT}epoc32/include/stdapis/stlportv5) { OS_LAYER_STDCPP_SYSTEMINCLUDE = $$OS_LAYER_PUBLIC_EXPORT_PATH(stdapis/stlportv5) } else { OS_LAYER_STDCPP_SYSTEMINCLUDE = $$OS_LAYER_PUBLIC_EXPORT_PATH(stdapis/stlport) -- cgit v0.12 From 0736c37064a4e22c81f2190d8e2375c78b238944 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 16 Jun 2009 16:37:53 +0200 Subject: add object exception test as well --- .../tst_exceptionsafety_objects.cpp | 62 ++++++++++++++++++---- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index 31c8f0a..3c85306 100644 --- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -59,36 +59,80 @@ public slots: void initTestCase(); private slots: + void objects_data(); + void objects(); + void widgets_data(); void widgets(); }; void tst_ExceptionSafetyObjects::initTestCase() { + // sanity check whether OOM simulation works + AllocFailActivator allocFailActivator; + mallocFailIndex = 0; + + // malloc fail index is 0 -> this malloc should fail. + void *buf = malloc(42); + QVERIFY(!buf); } // helper structs to create an arbitrary widget -struct AbstractWidgetCreator +struct AbstractObjectCreator { - virtual QWidget *create(QWidget *parent) = 0; + virtual QObject *create(QObject *parent) = 0; }; -Q_DECLARE_METATYPE(AbstractWidgetCreator *) +Q_DECLARE_METATYPE(AbstractObjectCreator *) template -struct WidgetCreator : public AbstractWidgetCreator +struct ObjectCreator : public AbstractObjectCreator { - QWidget *create(QWidget *parent) + QObject *create(QObject *parent) { return parent ? new T(parent) : new T; } }; +void tst_ExceptionSafetyObjects::objects_data() +{ + QTest::addColumn("objectCreator"); + +#define NEWROW(T) QTest::newRow(#T) << static_cast(new ObjectCreator) + NEWROW(QObject); +} + +void tst_ExceptionSafetyObjects::objects() +{ + QFETCH(AbstractObjectCreator *, objectCreator); + + AllocFailActivator allocFailActivator; + int currentOOMIndex = 0; + do { + mallocFailIndex = ++currentOOMIndex; + + try { + QScopedPointer ptr(objectCreator->create(0)); + } catch (const std::bad_alloc &) { + } + } while (mallocFailIndex <= 0); +} + +template +struct WidgetCreator : public AbstractObjectCreator +{ + QObject *create(QObject *parent) + { + return parent ? new T(static_cast(parent)) : new T; + } +}; + void tst_ExceptionSafetyObjects::widgets_data() { - QTest::addColumn("widgetCreator"); + QTest::addColumn("widgetCreator"); -#define NEWROW(T) QTest::newRow(#T) << static_cast(new WidgetCreator) +#undef NEWROW +#define NEWROW(T) QTest::newRow(#T) << static_cast(new WidgetCreator) NEWROW(QWidget); NEWROW(QPushButton); NEWROW(QLabel); @@ -96,7 +140,7 @@ void tst_ExceptionSafetyObjects::widgets_data() void tst_ExceptionSafetyObjects::widgets() { - QFETCH(AbstractWidgetCreator *, widgetCreator); + QFETCH(AbstractObjectCreator *, widgetCreator); mallocCount = freeCount = 0; @@ -111,7 +155,7 @@ void tst_ExceptionSafetyObjects::widgets() // first, create without a parent try { - QScopedPointer ptr(widgetCreator->create(0)); + QScopedPointer ptr(widgetCreator->create(0)); // QScopedPointer deletes the widget again here. } catch (const std::bad_alloc &) { // ignore all std::bad_alloc - note: valgrind should show no leaks -- cgit v0.12 From 508f8680052bb8dd9ead1de7923481b31fef3f93 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 16 Jun 2009 18:47:01 +0200 Subject: Fix crash in case of out of memory RevBy: Robert Griebl --- src/gui/kernel/qlayout.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qlayout.cpp b/src/gui/kernel/qlayout.cpp index 4463aab..d8d8234 100644 --- a/src/gui/kernel/qlayout.cpp +++ b/src/gui/kernel/qlayout.cpp @@ -145,7 +145,12 @@ QLayout::QLayout(QLayoutPrivate &dd, QLayout *lay, QWidget *w) } else { d->topLevel = true; w->d_func()->layout = this; - invalidate(); + QT_TRY { + invalidate(); + } QT_CATCH(...) { + w->d_func()->layout = 0; + QT_RETHROW; + } } } } @@ -230,7 +235,12 @@ QLayout::QLayout(QWidget *parent, int margin, int spacing, const char *name) } else { d->topLevel = true; parent->d_func()->layout = this; - invalidate(); + QT_TRY { + invalidate(); + } QT_CATCH(...) { + parent->d_func()->layout = 0; + QT_RETHROW; + } } } } -- cgit v0.12 From 2863388626e3e2f98b8f5779f751bb0d834a612e Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 16 Jun 2009 18:50:15 +0200 Subject: major rewrite - make it valgrind friendly --- .../exceptionsafety_objects/3rdparty/memcheck.h | 319 ++ .../exceptionsafety_objects/3rdparty/valgrind.h | 3924 ++++++++++++++++++++ .../exceptionsafety_objects.pro | 2 +- tests/auto/exceptionsafety_objects/oomsimulator.h | 47 +- .../tst_exceptionsafety_objects.cpp | 161 +- 5 files changed, 4379 insertions(+), 74 deletions(-) create mode 100644 tests/auto/exceptionsafety_objects/3rdparty/memcheck.h create mode 100644 tests/auto/exceptionsafety_objects/3rdparty/valgrind.h diff --git a/tests/auto/exceptionsafety_objects/3rdparty/memcheck.h b/tests/auto/exceptionsafety_objects/3rdparty/memcheck.h new file mode 100644 index 0000000..72a02ca --- /dev/null +++ b/tests/auto/exceptionsafety_objects/3rdparty/memcheck.h @@ -0,0 +1,319 @@ + +/* + ---------------------------------------------------------------- + + Notice that the following BSD-style license applies to this one + file (memcheck.h) only. The rest of Valgrind is licensed under the + terms of the GNU General Public License, version 2, unless + otherwise indicated. See the COPYING file in the source + distribution for details. + + ---------------------------------------------------------------- + + This file is part of MemCheck, a heavyweight Valgrind tool for + detecting memory errors. + + Copyright (C) 2000-2008 Julian Seward. All rights reserved. + + 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. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + + 3. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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. + + ---------------------------------------------------------------- + + Notice that the above BSD-style license applies to this one file + (memcheck.h) only. The entire rest of Valgrind is licensed under + the terms of the GNU General Public License, version 2. See the + COPYING file in the source distribution for details. + + ---------------------------------------------------------------- +*/ + + +#ifndef __MEMCHECK_H +#define __MEMCHECK_H + + +/* This file is for inclusion into client (your!) code. + + You can use these macros to manipulate and query memory permissions + inside your own programs. + + See comment near the top of valgrind.h on how to use them. +*/ + +#include "valgrind.h" + +/* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !! + This enum comprises an ABI exported by Valgrind to programs + which use client requests. DO NOT CHANGE THE ORDER OF THESE + ENTRIES, NOR DELETE ANY -- add new ones at the end. */ +typedef + enum { + VG_USERREQ__MAKE_MEM_NOACCESS = VG_USERREQ_TOOL_BASE('M','C'), + VG_USERREQ__MAKE_MEM_UNDEFINED, + VG_USERREQ__MAKE_MEM_DEFINED, + VG_USERREQ__DISCARD, + VG_USERREQ__CHECK_MEM_IS_ADDRESSABLE, + VG_USERREQ__CHECK_MEM_IS_DEFINED, + VG_USERREQ__DO_LEAK_CHECK, + VG_USERREQ__COUNT_LEAKS, + + VG_USERREQ__GET_VBITS, + VG_USERREQ__SET_VBITS, + + VG_USERREQ__CREATE_BLOCK, + + VG_USERREQ__MAKE_MEM_DEFINED_IF_ADDRESSABLE, + + VG_USERREQ__ENABLE_OOM, + VG_USERREQ__GET_ALLOC_INDEX, + + /* This is just for memcheck's internal use - don't use it */ + _VG_USERREQ__MEMCHECK_RECORD_OVERLAP_ERROR + = VG_USERREQ_TOOL_BASE('M','C') + 256, + + /* This is just for memcheck's internal use - don't use it */ + _VG_USERREQ__EXCEPTION + = VG_USERREQ_TOOL_BASE('M','C') + 512, + } Vg_MemCheckClientRequest; + + + +/* Client-code macros to manipulate the state of memory. */ + +/* Mark memory at _qzz_addr as unaddressable for _qzz_len bytes. */ +#define VALGRIND_MAKE_MEM_NOACCESS(_qzz_addr,_qzz_len) \ + (__extension__({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \ + VG_USERREQ__MAKE_MEM_NOACCESS, \ + _qzz_addr, _qzz_len, 0, 0, 0); \ + _qzz_res; \ + })) + +/* Similarly, mark memory at _qzz_addr as addressable but undefined + for _qzz_len bytes. */ +#define VALGRIND_MAKE_MEM_UNDEFINED(_qzz_addr,_qzz_len) \ + (__extension__({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \ + VG_USERREQ__MAKE_MEM_UNDEFINED, \ + _qzz_addr, _qzz_len, 0, 0, 0); \ + _qzz_res; \ + })) + +/* Similarly, mark memory at _qzz_addr as addressable and defined + for _qzz_len bytes. */ +#define VALGRIND_MAKE_MEM_DEFINED(_qzz_addr,_qzz_len) \ + (__extension__({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \ + VG_USERREQ__MAKE_MEM_DEFINED, \ + _qzz_addr, _qzz_len, 0, 0, 0); \ + _qzz_res; \ + })) + +/* Similar to VALGRIND_MAKE_MEM_DEFINED except that addressability is + not altered: bytes which are addressable are marked as defined, + but those which are not addressable are left unchanged. */ +#define VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(_qzz_addr,_qzz_len) \ + (__extension__({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \ + VG_USERREQ__MAKE_MEM_DEFINED_IF_ADDRESSABLE, \ + _qzz_addr, _qzz_len, 0, 0, 0); \ + _qzz_res; \ + })) + +/* Create a block-description handle. The description is an ascii + string which is included in any messages pertaining to addresses + within the specified memory range. Has no other effect on the + properties of the memory range. */ +#define VALGRIND_CREATE_BLOCK(_qzz_addr,_qzz_len, _qzz_desc) \ + (__extension__({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \ + VG_USERREQ__CREATE_BLOCK, \ + _qzz_addr, _qzz_len, _qzz_desc, \ + 0, 0); \ + _qzz_res; \ + })) + +/* Discard a block-description-handle. Returns 1 for an + invalid handle, 0 for a valid handle. */ +#define VALGRIND_DISCARD(_qzz_blkindex) \ + (__extension__ ({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \ + VG_USERREQ__DISCARD, \ + 0, _qzz_blkindex, 0, 0, 0); \ + _qzz_res; \ + })) + + +/* Client-code macros to check the state of memory. */ + +/* Check that memory at _qzz_addr is addressable for _qzz_len bytes. + If suitable addressibility is not established, Valgrind prints an + error message and returns the address of the first offending byte. + Otherwise it returns zero. */ +#define VALGRIND_CHECK_MEM_IS_ADDRESSABLE(_qzz_addr,_qzz_len) \ + (__extension__({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__CHECK_MEM_IS_ADDRESSABLE,\ + _qzz_addr, _qzz_len, 0, 0, 0); \ + _qzz_res; \ + })) + +/* Check that memory at _qzz_addr is addressable and defined for + _qzz_len bytes. If suitable addressibility and definedness are not + established, Valgrind prints an error message and returns the + address of the first offending byte. Otherwise it returns zero. */ +#define VALGRIND_CHECK_MEM_IS_DEFINED(_qzz_addr,_qzz_len) \ + (__extension__({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__CHECK_MEM_IS_DEFINED, \ + _qzz_addr, _qzz_len, 0, 0, 0); \ + _qzz_res; \ + })) + +/* Use this macro to force the definedness and addressibility of an + lvalue to be checked. If suitable addressibility and definedness + are not established, Valgrind prints an error message and returns + the address of the first offending byte. Otherwise it returns + zero. */ +#define VALGRIND_CHECK_VALUE_IS_DEFINED(__lvalue) \ + VALGRIND_CHECK_MEM_IS_DEFINED( \ + (volatile unsigned char *)&(__lvalue), \ + (unsigned long)(sizeof (__lvalue))) + + +/* Do a memory leak check mid-execution. */ +#define VALGRIND_DO_LEAK_CHECK \ + {unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__DO_LEAK_CHECK, \ + 0, 0, 0, 0, 0); \ + } + +/* Just display summaries of leaked memory, rather than all the + details */ +#define VALGRIND_DO_QUICK_LEAK_CHECK \ + {unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__DO_LEAK_CHECK, \ + 1, 0, 0, 0, 0); \ + } + +/* Return number of leaked, dubious, reachable and suppressed bytes found by + all previous leak checks. They must be lvalues. */ +#define VALGRIND_COUNT_LEAKS(leaked, dubious, reachable, suppressed) \ + /* For safety on 64-bit platforms we assign the results to private + unsigned long variables, then assign these to the lvalues the user + specified, which works no matter what type 'leaked', 'dubious', etc + are. We also initialise '_qzz_leaked', etc because + VG_USERREQ__COUNT_LEAKS doesn't mark the values returned as + initialised. */ \ + {unsigned long _qzz_res; \ + unsigned long _qzz_leaked = 0, _qzz_dubious = 0; \ + unsigned long _qzz_reachable = 0, _qzz_suppressed = 0; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__COUNT_LEAKS, \ + &_qzz_leaked, &_qzz_dubious, \ + &_qzz_reachable, &_qzz_suppressed, 0); \ + leaked = _qzz_leaked; \ + dubious = _qzz_dubious; \ + reachable = _qzz_reachable; \ + suppressed = _qzz_suppressed; \ + } + + +/* Get the validity data for addresses [zza..zza+zznbytes-1] and copy it + into the provided zzvbits array. Return values: + 0 if not running on valgrind + 1 success + 2 [previously indicated unaligned arrays; these are now allowed] + 3 if any parts of zzsrc/zzvbits are not addressable. + The metadata is not copied in cases 0, 2 or 3 so it should be + impossible to segfault your system by using this call. +*/ +#define VALGRIND_GET_VBITS(zza,zzvbits,zznbytes) \ + (__extension__({unsigned long _qzz_res; \ + char* czza = (char*)zza; \ + char* czzvbits = (char*)zzvbits; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__GET_VBITS, \ + czza, czzvbits, zznbytes, 0, 0 ); \ + _qzz_res; \ + })) + +/* Set the validity data for addresses [zza..zza+zznbytes-1], copying it + from the provided zzvbits array. Return values: + 0 if not running on valgrind + 1 success + 2 [previously indicated unaligned arrays; these are now allowed] + 3 if any parts of zza/zzvbits are not addressable. + The metadata is not copied in cases 0, 2 or 3 so it should be + impossible to segfault your system by using this call. +*/ +#define VALGRIND_SET_VBITS(zza,zzvbits,zznbytes) \ + (__extension__({unsigned int _qzz_res; \ + char* czza = (char*)zza; \ + char* czzvbits = (char*)zzvbits; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__SET_VBITS, \ + czza, czzvbits, zznbytes, 0, 0 ); \ + _qzz_res; \ + })) + +/* Enable or disable OOM simulation. */ +#define VALGRIND_ENABLE_OOM_AT_ALLOC_INDEX(index) \ + (__extension__ ({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \ + VG_USERREQ__ENABLE_OOM, \ + 1, index, 0, 0, 0); \ + _qzz_res; \ + })) + +#define VALGRIND_DISABLE_OOM_AT_ALLOC_INDEX(index) \ + (__extension__ ({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \ + VG_USERREQ__ENABLE_OOM, \ + 0, index, 0, 0, 0); \ + _qzz_res; \ + })) + +/* Get the current allocation index. */ +#define VALGRIND_GET_ALLOC_INDEX \ + (__extension__ ({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, -1 /* default return */, \ + VG_USERREQ__GET_ALLOC_INDEX, \ + 0, 0, 0, 0, 0); \ + _qzz_res; \ + })) + + +#endif + diff --git a/tests/auto/exceptionsafety_objects/3rdparty/valgrind.h b/tests/auto/exceptionsafety_objects/3rdparty/valgrind.h new file mode 100644 index 0000000..577c59a --- /dev/null +++ b/tests/auto/exceptionsafety_objects/3rdparty/valgrind.h @@ -0,0 +1,3924 @@ +/* -*- c -*- + ---------------------------------------------------------------- + + Notice that the following BSD-style license applies to this one + file (valgrind.h) only. The rest of Valgrind is licensed under the + terms of the GNU General Public License, version 2, unless + otherwise indicated. See the COPYING file in the source + distribution for details. + + ---------------------------------------------------------------- + + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2008 Julian Seward. All rights reserved. + + 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. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + + 3. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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. + + ---------------------------------------------------------------- + + Notice that the above BSD-style license applies to this one file + (valgrind.h) only. The entire rest of Valgrind is licensed under + the terms of the GNU General Public License, version 2. See the + COPYING file in the source distribution for details. + + ---------------------------------------------------------------- +*/ + + +/* This file is for inclusion into client (your!) code. + + You can use these macros to manipulate and query Valgrind's + execution inside your own programs. + + The resulting executables will still run without Valgrind, just a + little bit more slowly than they otherwise would, but otherwise + unchanged. When not running on valgrind, each client request + consumes very few (eg. 7) instructions, so the resulting performance + loss is negligible unless you plan to execute client requests + millions of times per second. Nevertheless, if that is still a + problem, you can compile with the NVALGRIND symbol defined (gcc + -DNVALGRIND) so that client requests are not even compiled in. */ + +#ifndef __VALGRIND_H +#define __VALGRIND_H + +#include + +/* Nb: this file might be included in a file compiled with -ansi. So + we can't use C++ style "//" comments nor the "asm" keyword (instead + use "__asm__"). */ + +/* Derive some tags indicating what the target platform is. Note + that in this file we're using the compiler's CPP symbols for + identifying architectures, which are different to the ones we use + within the rest of Valgrind. Note, __powerpc__ is active for both + 32 and 64-bit PPC, whereas __powerpc64__ is only active for the + latter (on Linux, that is). */ +#undef PLAT_x86_linux +#undef PLAT_amd64_linux +#undef PLAT_ppc32_linux +#undef PLAT_ppc64_linux +#undef PLAT_ppc32_aix5 +#undef PLAT_ppc64_aix5 + +#if !defined(_AIX) && defined(__i386__) +# define PLAT_x86_linux 1 +#elif !defined(_AIX) && defined(__x86_64__) +# define PLAT_amd64_linux 1 +#elif !defined(_AIX) && defined(__powerpc__) && !defined(__powerpc64__) +# define PLAT_ppc32_linux 1 +#elif !defined(_AIX) && defined(__powerpc__) && defined(__powerpc64__) +# define PLAT_ppc64_linux 1 +#elif defined(_AIX) && defined(__64BIT__) +# define PLAT_ppc64_aix5 1 +#elif defined(_AIX) && !defined(__64BIT__) +# define PLAT_ppc32_aix5 1 +#endif + + +/* If we're not compiling for our target platform, don't generate + any inline asms. */ +#if !defined(PLAT_x86_linux) && !defined(PLAT_amd64_linux) \ + && !defined(PLAT_ppc32_linux) && !defined(PLAT_ppc64_linux) \ + && !defined(PLAT_ppc32_aix5) && !defined(PLAT_ppc64_aix5) +# if !defined(NVALGRIND) +# define NVALGRIND 1 +# endif +#endif + + +/* ------------------------------------------------------------------ */ +/* ARCHITECTURE SPECIFICS for SPECIAL INSTRUCTIONS. There is nothing */ +/* in here of use to end-users -- skip to the next section. */ +/* ------------------------------------------------------------------ */ + +#if defined(NVALGRIND) + +/* Define NVALGRIND to completely remove the Valgrind magic sequence + from the compiled code (analogous to NDEBUG's effects on + assert()) */ +#define VALGRIND_DO_CLIENT_REQUEST( \ + _zzq_rlval, _zzq_default, _zzq_request, \ + _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \ + { \ + (_zzq_rlval) = (_zzq_default); \ + } + +#else /* ! NVALGRIND */ + +/* The following defines the magic code sequences which the JITter + spots and handles magically. Don't look too closely at them as + they will rot your brain. + + The assembly code sequences for all architectures is in this one + file. This is because this file must be stand-alone, and we don't + want to have multiple files. + + For VALGRIND_DO_CLIENT_REQUEST, we must ensure that the default + value gets put in the return slot, so that everything works when + this is executed not under Valgrind. Args are passed in a memory + block, and so there's no intrinsic limit to the number that could + be passed, but it's currently five. + + The macro args are: + _zzq_rlval result lvalue + _zzq_default default value (result returned when running on real CPU) + _zzq_request request code + _zzq_arg1..5 request params + + The other two macros are used to support function wrapping, and are + a lot simpler. VALGRIND_GET_NR_CONTEXT returns the value of the + guest's NRADDR pseudo-register and whatever other information is + needed to safely run the call original from the wrapper: on + ppc64-linux, the R2 value at the divert point is also needed. This + information is abstracted into a user-visible type, OrigFn. + + VALGRIND_CALL_NOREDIR_* behaves the same as the following on the + guest, but guarantees that the branch instruction will not be + redirected: x86: call *%eax, amd64: call *%rax, ppc32/ppc64: + branch-and-link-to-r11. VALGRIND_CALL_NOREDIR is just text, not a + complete inline asm, since it needs to be combined with more magic + inline asm stuff to be useful. +*/ + +/* ------------------------- x86-linux ------------------------- */ + +#if defined(PLAT_x86_linux) + +typedef + struct { + unsigned int nraddr; /* where's the code? */ + } + OrigFn; + +#define __SPECIAL_INSTRUCTION_PREAMBLE \ + "roll $3, %%edi ; roll $13, %%edi\n\t" \ + "roll $29, %%edi ; roll $19, %%edi\n\t" + +#define VALGRIND_DO_CLIENT_REQUEST( \ + _zzq_rlval, _zzq_default, _zzq_request, \ + _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \ + { volatile unsigned int _zzq_args[6]; \ + volatile unsigned int _zzq_result; \ + _zzq_args[0] = (unsigned int)(_zzq_request); \ + _zzq_args[1] = (unsigned int)(_zzq_arg1); \ + _zzq_args[2] = (unsigned int)(_zzq_arg2); \ + _zzq_args[3] = (unsigned int)(_zzq_arg3); \ + _zzq_args[4] = (unsigned int)(_zzq_arg4); \ + _zzq_args[5] = (unsigned int)(_zzq_arg5); \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %EDX = client_request ( %EAX ) */ \ + "xchgl %%ebx,%%ebx" \ + : "=d" (_zzq_result) \ + : "a" (&_zzq_args[0]), "0" (_zzq_default) \ + : "cc", "memory" \ + ); \ + _zzq_rlval = _zzq_result; \ + } + +#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \ + { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \ + volatile unsigned int __addr; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %EAX = guest_NRADDR */ \ + "xchgl %%ecx,%%ecx" \ + : "=a" (__addr) \ + : \ + : "cc", "memory" \ + ); \ + _zzq_orig->nraddr = __addr; \ + } + +#define VALGRIND_CALL_NOREDIR_EAX \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* call-noredir *%EAX */ \ + "xchgl %%edx,%%edx\n\t" +#endif /* PLAT_x86_linux */ + +/* ------------------------ amd64-linux ------------------------ */ + +#if defined(PLAT_amd64_linux) + +typedef + struct { + unsigned long long int nraddr; /* where's the code? */ + } + OrigFn; + +#define __SPECIAL_INSTRUCTION_PREAMBLE \ + "rolq $3, %%rdi ; rolq $13, %%rdi\n\t" \ + "rolq $61, %%rdi ; rolq $51, %%rdi\n\t" + +#define VALGRIND_DO_CLIENT_REQUEST( \ + _zzq_rlval, _zzq_default, _zzq_request, \ + _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \ + { volatile unsigned long long int _zzq_args[6]; \ + volatile unsigned long long int _zzq_result; \ + _zzq_args[0] = (unsigned long long int)(_zzq_request); \ + _zzq_args[1] = (unsigned long long int)(_zzq_arg1); \ + _zzq_args[2] = (unsigned long long int)(_zzq_arg2); \ + _zzq_args[3] = (unsigned long long int)(_zzq_arg3); \ + _zzq_args[4] = (unsigned long long int)(_zzq_arg4); \ + _zzq_args[5] = (unsigned long long int)(_zzq_arg5); \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %RDX = client_request ( %RAX ) */ \ + "xchgq %%rbx,%%rbx" \ + : "=d" (_zzq_result) \ + : "a" (&_zzq_args[0]), "0" (_zzq_default) \ + : "cc", "memory" \ + ); \ + _zzq_rlval = _zzq_result; \ + } + +#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \ + { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \ + volatile unsigned long long int __addr; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %RAX = guest_NRADDR */ \ + "xchgq %%rcx,%%rcx" \ + : "=a" (__addr) \ + : \ + : "cc", "memory" \ + ); \ + _zzq_orig->nraddr = __addr; \ + } + +#define VALGRIND_CALL_NOREDIR_RAX \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* call-noredir *%RAX */ \ + "xchgq %%rdx,%%rdx\n\t" +#endif /* PLAT_amd64_linux */ + +/* ------------------------ ppc32-linux ------------------------ */ + +#if defined(PLAT_ppc32_linux) + +typedef + struct { + unsigned int nraddr; /* where's the code? */ + } + OrigFn; + +#define __SPECIAL_INSTRUCTION_PREAMBLE \ + "rlwinm 0,0,3,0,0 ; rlwinm 0,0,13,0,0\n\t" \ + "rlwinm 0,0,29,0,0 ; rlwinm 0,0,19,0,0\n\t" + +#define VALGRIND_DO_CLIENT_REQUEST( \ + _zzq_rlval, _zzq_default, _zzq_request, \ + _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \ + \ + { unsigned int _zzq_args[6]; \ + unsigned int _zzq_result; \ + unsigned int* _zzq_ptr; \ + _zzq_args[0] = (unsigned int)(_zzq_request); \ + _zzq_args[1] = (unsigned int)(_zzq_arg1); \ + _zzq_args[2] = (unsigned int)(_zzq_arg2); \ + _zzq_args[3] = (unsigned int)(_zzq_arg3); \ + _zzq_args[4] = (unsigned int)(_zzq_arg4); \ + _zzq_args[5] = (unsigned int)(_zzq_arg5); \ + _zzq_ptr = _zzq_args; \ + __asm__ volatile("mr 3,%1\n\t" /*default*/ \ + "mr 4,%2\n\t" /*ptr*/ \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = client_request ( %R4 ) */ \ + "or 1,1,1\n\t" \ + "mr %0,3" /*result*/ \ + : "=b" (_zzq_result) \ + : "b" (_zzq_default), "b" (_zzq_ptr) \ + : "cc", "memory", "r3", "r4"); \ + _zzq_rlval = _zzq_result; \ + } + +#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \ + { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \ + unsigned int __addr; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = guest_NRADDR */ \ + "or 2,2,2\n\t" \ + "mr %0,3" \ + : "=b" (__addr) \ + : \ + : "cc", "memory", "r3" \ + ); \ + _zzq_orig->nraddr = __addr; \ + } + +#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* branch-and-link-to-noredir *%R11 */ \ + "or 3,3,3\n\t" +#endif /* PLAT_ppc32_linux */ + +/* ------------------------ ppc64-linux ------------------------ */ + +#if defined(PLAT_ppc64_linux) + +typedef + struct { + unsigned long long int nraddr; /* where's the code? */ + unsigned long long int r2; /* what tocptr do we need? */ + } + OrigFn; + +#define __SPECIAL_INSTRUCTION_PREAMBLE \ + "rotldi 0,0,3 ; rotldi 0,0,13\n\t" \ + "rotldi 0,0,61 ; rotldi 0,0,51\n\t" + +#define VALGRIND_DO_CLIENT_REQUEST( \ + _zzq_rlval, _zzq_default, _zzq_request, \ + _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \ + \ + { unsigned long long int _zzq_args[6]; \ + register unsigned long long int _zzq_result __asm__("r3"); \ + register unsigned long long int* _zzq_ptr __asm__("r4"); \ + _zzq_args[0] = (unsigned long long int)(_zzq_request); \ + _zzq_args[1] = (unsigned long long int)(_zzq_arg1); \ + _zzq_args[2] = (unsigned long long int)(_zzq_arg2); \ + _zzq_args[3] = (unsigned long long int)(_zzq_arg3); \ + _zzq_args[4] = (unsigned long long int)(_zzq_arg4); \ + _zzq_args[5] = (unsigned long long int)(_zzq_arg5); \ + _zzq_ptr = _zzq_args; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = client_request ( %R4 ) */ \ + "or 1,1,1" \ + : "=r" (_zzq_result) \ + : "0" (_zzq_default), "r" (_zzq_ptr) \ + : "cc", "memory"); \ + _zzq_rlval = _zzq_result; \ + } + +#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \ + { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \ + register unsigned long long int __addr __asm__("r3"); \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = guest_NRADDR */ \ + "or 2,2,2" \ + : "=r" (__addr) \ + : \ + : "cc", "memory" \ + ); \ + _zzq_orig->nraddr = __addr; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = guest_NRADDR_GPR2 */ \ + "or 4,4,4" \ + : "=r" (__addr) \ + : \ + : "cc", "memory" \ + ); \ + _zzq_orig->r2 = __addr; \ + } + +#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* branch-and-link-to-noredir *%R11 */ \ + "or 3,3,3\n\t" + +#endif /* PLAT_ppc64_linux */ + +/* ------------------------ ppc32-aix5 ------------------------- */ + +#if defined(PLAT_ppc32_aix5) + +typedef + struct { + unsigned int nraddr; /* where's the code? */ + unsigned int r2; /* what tocptr do we need? */ + } + OrigFn; + +#define __SPECIAL_INSTRUCTION_PREAMBLE \ + "rlwinm 0,0,3,0,0 ; rlwinm 0,0,13,0,0\n\t" \ + "rlwinm 0,0,29,0,0 ; rlwinm 0,0,19,0,0\n\t" + +#define VALGRIND_DO_CLIENT_REQUEST( \ + _zzq_rlval, _zzq_default, _zzq_request, \ + _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \ + \ + { unsigned int _zzq_args[7]; \ + register unsigned int _zzq_result; \ + register unsigned int* _zzq_ptr; \ + _zzq_args[0] = (unsigned int)(_zzq_request); \ + _zzq_args[1] = (unsigned int)(_zzq_arg1); \ + _zzq_args[2] = (unsigned int)(_zzq_arg2); \ + _zzq_args[3] = (unsigned int)(_zzq_arg3); \ + _zzq_args[4] = (unsigned int)(_zzq_arg4); \ + _zzq_args[5] = (unsigned int)(_zzq_arg5); \ + _zzq_args[6] = (unsigned int)(_zzq_default); \ + _zzq_ptr = _zzq_args; \ + __asm__ volatile("mr 4,%1\n\t" \ + "lwz 3, 24(4)\n\t" \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = client_request ( %R4 ) */ \ + "or 1,1,1\n\t" \ + "mr %0,3" \ + : "=b" (_zzq_result) \ + : "b" (_zzq_ptr) \ + : "r3", "r4", "cc", "memory"); \ + _zzq_rlval = _zzq_result; \ + } + +#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \ + { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \ + register unsigned int __addr; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = guest_NRADDR */ \ + "or 2,2,2\n\t" \ + "mr %0,3" \ + : "=b" (__addr) \ + : \ + : "r3", "cc", "memory" \ + ); \ + _zzq_orig->nraddr = __addr; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = guest_NRADDR_GPR2 */ \ + "or 4,4,4\n\t" \ + "mr %0,3" \ + : "=b" (__addr) \ + : \ + : "r3", "cc", "memory" \ + ); \ + _zzq_orig->r2 = __addr; \ + } + +#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* branch-and-link-to-noredir *%R11 */ \ + "or 3,3,3\n\t" + +#endif /* PLAT_ppc32_aix5 */ + +/* ------------------------ ppc64-aix5 ------------------------- */ + +#if defined(PLAT_ppc64_aix5) + +typedef + struct { + unsigned long long int nraddr; /* where's the code? */ + unsigned long long int r2; /* what tocptr do we need? */ + } + OrigFn; + +#define __SPECIAL_INSTRUCTION_PREAMBLE \ + "rotldi 0,0,3 ; rotldi 0,0,13\n\t" \ + "rotldi 0,0,61 ; rotldi 0,0,51\n\t" + +#define VALGRIND_DO_CLIENT_REQUEST( \ + _zzq_rlval, _zzq_default, _zzq_request, \ + _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \ + \ + { unsigned long long int _zzq_args[7]; \ + register unsigned long long int _zzq_result; \ + register unsigned long long int* _zzq_ptr; \ + _zzq_args[0] = (unsigned int long long)(_zzq_request); \ + _zzq_args[1] = (unsigned int long long)(_zzq_arg1); \ + _zzq_args[2] = (unsigned int long long)(_zzq_arg2); \ + _zzq_args[3] = (unsigned int long long)(_zzq_arg3); \ + _zzq_args[4] = (unsigned int long long)(_zzq_arg4); \ + _zzq_args[5] = (unsigned int long long)(_zzq_arg5); \ + _zzq_args[6] = (unsigned int long long)(_zzq_default); \ + _zzq_ptr = _zzq_args; \ + __asm__ volatile("mr 4,%1\n\t" \ + "ld 3, 48(4)\n\t" \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = client_request ( %R4 ) */ \ + "or 1,1,1\n\t" \ + "mr %0,3" \ + : "=b" (_zzq_result) \ + : "b" (_zzq_ptr) \ + : "r3", "r4", "cc", "memory"); \ + _zzq_rlval = _zzq_result; \ + } + +#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \ + { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \ + register unsigned long long int __addr; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = guest_NRADDR */ \ + "or 2,2,2\n\t" \ + "mr %0,3" \ + : "=b" (__addr) \ + : \ + : "r3", "cc", "memory" \ + ); \ + _zzq_orig->nraddr = __addr; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = guest_NRADDR_GPR2 */ \ + "or 4,4,4\n\t" \ + "mr %0,3" \ + : "=b" (__addr) \ + : \ + : "r3", "cc", "memory" \ + ); \ + _zzq_orig->r2 = __addr; \ + } + +#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* branch-and-link-to-noredir *%R11 */ \ + "or 3,3,3\n\t" + +#endif /* PLAT_ppc64_aix5 */ + +/* Insert assembly code for other platforms here... */ + +#endif /* NVALGRIND */ + + +/* ------------------------------------------------------------------ */ +/* PLATFORM SPECIFICS for FUNCTION WRAPPING. This is all very */ +/* ugly. It's the least-worst tradeoff I can think of. */ +/* ------------------------------------------------------------------ */ + +/* This section defines magic (a.k.a appalling-hack) macros for doing + guaranteed-no-redirection macros, so as to get from function + wrappers to the functions they are wrapping. The whole point is to + construct standard call sequences, but to do the call itself with a + special no-redirect call pseudo-instruction that the JIT + understands and handles specially. This section is long and + repetitious, and I can't see a way to make it shorter. + + The naming scheme is as follows: + + CALL_FN_{W,v}_{v,W,WW,WWW,WWWW,5W,6W,7W,etc} + + 'W' stands for "word" and 'v' for "void". Hence there are + different macros for calling arity 0, 1, 2, 3, 4, etc, functions, + and for each, the possibility of returning a word-typed result, or + no result. +*/ + +/* Use these to write the name of your wrapper. NOTE: duplicates + VG_WRAP_FUNCTION_Z{U,Z} in pub_tool_redir.h. */ + +#define I_WRAP_SONAME_FNNAME_ZU(soname,fnname) \ + _vgwZU_##soname##_##fnname + +#define I_WRAP_SONAME_FNNAME_ZZ(soname,fnname) \ + _vgwZZ_##soname##_##fnname + +/* Use this macro from within a wrapper function to collect the + context (address and possibly other info) of the original function. + Once you have that you can then use it in one of the CALL_FN_ + macros. The type of the argument _lval is OrigFn. */ +#define VALGRIND_GET_ORIG_FN(_lval) VALGRIND_GET_NR_CONTEXT(_lval) + +/* Derivatives of the main macros below, for calling functions + returning void. */ + +#define CALL_FN_v_v(fnptr) \ + do { volatile unsigned long _junk; \ + CALL_FN_W_v(_junk,fnptr); } while (0) + +#define CALL_FN_v_W(fnptr, arg1) \ + do { volatile unsigned long _junk; \ + CALL_FN_W_W(_junk,fnptr,arg1); } while (0) + +#define CALL_FN_v_WW(fnptr, arg1,arg2) \ + do { volatile unsigned long _junk; \ + CALL_FN_W_WW(_junk,fnptr,arg1,arg2); } while (0) + +#define CALL_FN_v_WWW(fnptr, arg1,arg2,arg3) \ + do { volatile unsigned long _junk; \ + CALL_FN_W_WWW(_junk,fnptr,arg1,arg2,arg3); } while (0) + +/* ------------------------- x86-linux ------------------------- */ + +#if defined(PLAT_x86_linux) + +/* These regs are trashed by the hidden call. No need to mention eax + as gcc can already see that, plus causes gcc to bomb. */ +#define __CALLER_SAVED_REGS /*"eax"*/ "ecx", "edx" + +/* These CALL_FN_ macros assume that on x86-linux, sizeof(unsigned + long) == 4. */ + +#define CALL_FN_W_v(lval, orig) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[1]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + __asm__ volatile( \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_W(lval, orig, arg1) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[2]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + __asm__ volatile( \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $4, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WW(lval, orig, arg1,arg2) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + __asm__ volatile( \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $8, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[4]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + __asm__ volatile( \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $12, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[5]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + __asm__ volatile( \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $16, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[6]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + __asm__ volatile( \ + "pushl 20(%%eax)\n\t" \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $20, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[7]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + __asm__ volatile( \ + "pushl 24(%%eax)\n\t" \ + "pushl 20(%%eax)\n\t" \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $24, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[8]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + __asm__ volatile( \ + "pushl 28(%%eax)\n\t" \ + "pushl 24(%%eax)\n\t" \ + "pushl 20(%%eax)\n\t" \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $28, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[9]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + __asm__ volatile( \ + "pushl 32(%%eax)\n\t" \ + "pushl 28(%%eax)\n\t" \ + "pushl 24(%%eax)\n\t" \ + "pushl 20(%%eax)\n\t" \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $32, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[10]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + _argvec[9] = (unsigned long)(arg9); \ + __asm__ volatile( \ + "pushl 36(%%eax)\n\t" \ + "pushl 32(%%eax)\n\t" \ + "pushl 28(%%eax)\n\t" \ + "pushl 24(%%eax)\n\t" \ + "pushl 20(%%eax)\n\t" \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $36, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[11]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + _argvec[9] = (unsigned long)(arg9); \ + _argvec[10] = (unsigned long)(arg10); \ + __asm__ volatile( \ + "pushl 40(%%eax)\n\t" \ + "pushl 36(%%eax)\n\t" \ + "pushl 32(%%eax)\n\t" \ + "pushl 28(%%eax)\n\t" \ + "pushl 24(%%eax)\n\t" \ + "pushl 20(%%eax)\n\t" \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $40, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5, \ + arg6,arg7,arg8,arg9,arg10, \ + arg11) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[12]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + _argvec[9] = (unsigned long)(arg9); \ + _argvec[10] = (unsigned long)(arg10); \ + _argvec[11] = (unsigned long)(arg11); \ + __asm__ volatile( \ + "pushl 44(%%eax)\n\t" \ + "pushl 40(%%eax)\n\t" \ + "pushl 36(%%eax)\n\t" \ + "pushl 32(%%eax)\n\t" \ + "pushl 28(%%eax)\n\t" \ + "pushl 24(%%eax)\n\t" \ + "pushl 20(%%eax)\n\t" \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $44, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5, \ + arg6,arg7,arg8,arg9,arg10, \ + arg11,arg12) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[13]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + _argvec[9] = (unsigned long)(arg9); \ + _argvec[10] = (unsigned long)(arg10); \ + _argvec[11] = (unsigned long)(arg11); \ + _argvec[12] = (unsigned long)(arg12); \ + __asm__ volatile( \ + "pushl 48(%%eax)\n\t" \ + "pushl 44(%%eax)\n\t" \ + "pushl 40(%%eax)\n\t" \ + "pushl 36(%%eax)\n\t" \ + "pushl 32(%%eax)\n\t" \ + "pushl 28(%%eax)\n\t" \ + "pushl 24(%%eax)\n\t" \ + "pushl 20(%%eax)\n\t" \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $48, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#endif /* PLAT_x86_linux */ + +/* ------------------------ amd64-linux ------------------------ */ + +#if defined(PLAT_amd64_linux) + +/* ARGREGS: rdi rsi rdx rcx r8 r9 (the rest on stack in R-to-L order) */ + +/* These regs are trashed by the hidden call. */ +#define __CALLER_SAVED_REGS /*"rax",*/ "rcx", "rdx", "rsi", \ + "rdi", "r8", "r9", "r10", "r11" + +/* These CALL_FN_ macros assume that on amd64-linux, sizeof(unsigned + long) == 8. */ + +/* NB 9 Sept 07. There is a nasty kludge here in all these CALL_FN_ + macros. In order not to trash the stack redzone, we need to drop + %rsp by 128 before the hidden call, and restore afterwards. The + nastyness is that it is only by luck that the stack still appears + to be unwindable during the hidden call - since then the behaviour + of any routine using this macro does not match what the CFI data + says. Sigh. + + Why is this important? Imagine that a wrapper has a stack + allocated local, and passes to the hidden call, a pointer to it. + Because gcc does not know about the hidden call, it may allocate + that local in the redzone. Unfortunately the hidden call may then + trash it before it comes to use it. So we must step clear of the + redzone, for the duration of the hidden call, to make it safe. + + Probably the same problem afflicts the other redzone-style ABIs too + (ppc64-linux, ppc32-aix5, ppc64-aix5); but for those, the stack is + self describing (none of this CFI nonsense) so at least messing + with the stack pointer doesn't give a danger of non-unwindable + stack. */ + +#define CALL_FN_W_v(lval, orig) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[1]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_W(lval, orig, arg1) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[2]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WW(lval, orig, arg1,arg2) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[4]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[5]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[6]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "movq 40(%%rax), %%r8\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[7]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "movq 48(%%rax), %%r9\n\t" \ + "movq 40(%%rax), %%r8\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + "addq $128,%%rsp\n\t" \ + VALGRIND_CALL_NOREDIR_RAX \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[8]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "pushq 56(%%rax)\n\t" \ + "movq 48(%%rax), %%r9\n\t" \ + "movq 40(%%rax), %%r8\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $8, %%rsp\n" \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[9]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "pushq 64(%%rax)\n\t" \ + "pushq 56(%%rax)\n\t" \ + "movq 48(%%rax), %%r9\n\t" \ + "movq 40(%%rax), %%r8\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $16, %%rsp\n" \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[10]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + _argvec[9] = (unsigned long)(arg9); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "pushq 72(%%rax)\n\t" \ + "pushq 64(%%rax)\n\t" \ + "pushq 56(%%rax)\n\t" \ + "movq 48(%%rax), %%r9\n\t" \ + "movq 40(%%rax), %%r8\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $24, %%rsp\n" \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[11]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + _argvec[9] = (unsigned long)(arg9); \ + _argvec[10] = (unsigned long)(arg10); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "pushq 80(%%rax)\n\t" \ + "pushq 72(%%rax)\n\t" \ + "pushq 64(%%rax)\n\t" \ + "pushq 56(%%rax)\n\t" \ + "movq 48(%%rax), %%r9\n\t" \ + "movq 40(%%rax), %%r8\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $32, %%rsp\n" \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[12]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + _argvec[9] = (unsigned long)(arg9); \ + _argvec[10] = (unsigned long)(arg10); \ + _argvec[11] = (unsigned long)(arg11); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "pushq 88(%%rax)\n\t" \ + "pushq 80(%%rax)\n\t" \ + "pushq 72(%%rax)\n\t" \ + "pushq 64(%%rax)\n\t" \ + "pushq 56(%%rax)\n\t" \ + "movq 48(%%rax), %%r9\n\t" \ + "movq 40(%%rax), %%r8\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $40, %%rsp\n" \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11,arg12) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[13]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + _argvec[9] = (unsigned long)(arg9); \ + _argvec[10] = (unsigned long)(arg10); \ + _argvec[11] = (unsigned long)(arg11); \ + _argvec[12] = (unsigned long)(arg12); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "pushq 96(%%rax)\n\t" \ + "pushq 88(%%rax)\n\t" \ + "pushq 80(%%rax)\n\t" \ + "pushq 72(%%rax)\n\t" \ + "pushq 64(%%rax)\n\t" \ + "pushq 56(%%rax)\n\t" \ + "movq 48(%%rax), %%r9\n\t" \ + "movq 40(%%rax), %%r8\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $48, %%rsp\n" \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#endif /* PLAT_amd64_linux */ + +/* ------------------------ ppc32-linux ------------------------ */ + +#if defined(PLAT_ppc32_linux) + +/* This is useful for finding out about the on-stack stuff: + + extern int f9 ( int,int,int,int,int,int,int,int,int ); + extern int f10 ( int,int,int,int,int,int,int,int,int,int ); + extern int f11 ( int,int,int,int,int,int,int,int,int,int,int ); + extern int f12 ( int,int,int,int,int,int,int,int,int,int,int,int ); + + int g9 ( void ) { + return f9(11,22,33,44,55,66,77,88,99); + } + int g10 ( void ) { + return f10(11,22,33,44,55,66,77,88,99,110); + } + int g11 ( void ) { + return f11(11,22,33,44,55,66,77,88,99,110,121); + } + int g12 ( void ) { + return f12(11,22,33,44,55,66,77,88,99,110,121,132); + } +*/ + +/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */ + +/* These regs are trashed by the hidden call. */ +#define __CALLER_SAVED_REGS \ + "lr", "ctr", "xer", \ + "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \ + "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \ + "r11", "r12", "r13" + +/* These CALL_FN_ macros assume that on ppc32-linux, + sizeof(unsigned long) == 4. */ + +#define CALL_FN_W_v(lval, orig) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[1]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_W(lval, orig, arg1) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[2]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WW(lval, orig, arg1,arg2) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[4]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[5]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[6]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + _argvec[5] = (unsigned long)arg5; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 7,20(11)\n\t" \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[7]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + _argvec[5] = (unsigned long)arg5; \ + _argvec[6] = (unsigned long)arg6; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 7,20(11)\n\t" \ + "lwz 8,24(11)\n\t" \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[8]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + _argvec[5] = (unsigned long)arg5; \ + _argvec[6] = (unsigned long)arg6; \ + _argvec[7] = (unsigned long)arg7; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 7,20(11)\n\t" \ + "lwz 8,24(11)\n\t" \ + "lwz 9,28(11)\n\t" \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[9]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + _argvec[5] = (unsigned long)arg5; \ + _argvec[6] = (unsigned long)arg6; \ + _argvec[7] = (unsigned long)arg7; \ + _argvec[8] = (unsigned long)arg8; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 7,20(11)\n\t" \ + "lwz 8,24(11)\n\t" \ + "lwz 9,28(11)\n\t" \ + "lwz 10,32(11)\n\t" /* arg8->r10 */ \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[10]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + _argvec[5] = (unsigned long)arg5; \ + _argvec[6] = (unsigned long)arg6; \ + _argvec[7] = (unsigned long)arg7; \ + _argvec[8] = (unsigned long)arg8; \ + _argvec[9] = (unsigned long)arg9; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "addi 1,1,-16\n\t" \ + /* arg9 */ \ + "lwz 3,36(11)\n\t" \ + "stw 3,8(1)\n\t" \ + /* args1-8 */ \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 7,20(11)\n\t" \ + "lwz 8,24(11)\n\t" \ + "lwz 9,28(11)\n\t" \ + "lwz 10,32(11)\n\t" /* arg8->r10 */ \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "addi 1,1,16\n\t" \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[11]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + _argvec[5] = (unsigned long)arg5; \ + _argvec[6] = (unsigned long)arg6; \ + _argvec[7] = (unsigned long)arg7; \ + _argvec[8] = (unsigned long)arg8; \ + _argvec[9] = (unsigned long)arg9; \ + _argvec[10] = (unsigned long)arg10; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "addi 1,1,-16\n\t" \ + /* arg10 */ \ + "lwz 3,40(11)\n\t" \ + "stw 3,12(1)\n\t" \ + /* arg9 */ \ + "lwz 3,36(11)\n\t" \ + "stw 3,8(1)\n\t" \ + /* args1-8 */ \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 7,20(11)\n\t" \ + "lwz 8,24(11)\n\t" \ + "lwz 9,28(11)\n\t" \ + "lwz 10,32(11)\n\t" /* arg8->r10 */ \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "addi 1,1,16\n\t" \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[12]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + _argvec[5] = (unsigned long)arg5; \ + _argvec[6] = (unsigned long)arg6; \ + _argvec[7] = (unsigned long)arg7; \ + _argvec[8] = (unsigned long)arg8; \ + _argvec[9] = (unsigned long)arg9; \ + _argvec[10] = (unsigned long)arg10; \ + _argvec[11] = (unsigned long)arg11; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "addi 1,1,-32\n\t" \ + /* arg11 */ \ + "lwz 3,44(11)\n\t" \ + "stw 3,16(1)\n\t" \ + /* arg10 */ \ + "lwz 3,40(11)\n\t" \ + "stw 3,12(1)\n\t" \ + /* arg9 */ \ + "lwz 3,36(11)\n\t" \ + "stw 3,8(1)\n\t" \ + /* args1-8 */ \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 7,20(11)\n\t" \ + "lwz 8,24(11)\n\t" \ + "lwz 9,28(11)\n\t" \ + "lwz 10,32(11)\n\t" /* arg8->r10 */ \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "addi 1,1,32\n\t" \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11,arg12) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[13]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + _argvec[5] = (unsigned long)arg5; \ + _argvec[6] = (unsigned long)arg6; \ + _argvec[7] = (unsigned long)arg7; \ + _argvec[8] = (unsigned long)arg8; \ + _argvec[9] = (unsigned long)arg9; \ + _argvec[10] = (unsigned long)arg10; \ + _argvec[11] = (unsigned long)arg11; \ + _argvec[12] = (unsigned long)arg12; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "addi 1,1,-32\n\t" \ + /* arg12 */ \ + "lwz 3,48(11)\n\t" \ + "stw 3,20(1)\n\t" \ + /* arg11 */ \ + "lwz 3,44(11)\n\t" \ + "stw 3,16(1)\n\t" \ + /* arg10 */ \ + "lwz 3,40(11)\n\t" \ + "stw 3,12(1)\n\t" \ + /* arg9 */ \ + "lwz 3,36(11)\n\t" \ + "stw 3,8(1)\n\t" \ + /* args1-8 */ \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 7,20(11)\n\t" \ + "lwz 8,24(11)\n\t" \ + "lwz 9,28(11)\n\t" \ + "lwz 10,32(11)\n\t" /* arg8->r10 */ \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "addi 1,1,32\n\t" \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#endif /* PLAT_ppc32_linux */ + +/* ------------------------ ppc64-linux ------------------------ */ + +#if defined(PLAT_ppc64_linux) + +/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */ + +/* These regs are trashed by the hidden call. */ +#define __CALLER_SAVED_REGS \ + "lr", "ctr", "xer", \ + "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \ + "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \ + "r11", "r12", "r13" + +/* These CALL_FN_ macros assume that on ppc64-linux, sizeof(unsigned + long) == 8. */ + +#define CALL_FN_W_v(lval, orig) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+0]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_W(lval, orig, arg1) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+1]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WW(lval, orig, arg1,arg2) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+2]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+3]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+4]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+5]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+6]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+7]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+8]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+9]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "addi 1,1,-128\n\t" /* expand stack frame */ \ + /* arg9 */ \ + "ld 3,72(11)\n\t" \ + "std 3,112(1)\n\t" \ + /* args1-8 */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + "addi 1,1,128" /* restore frame */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+10]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "addi 1,1,-128\n\t" /* expand stack frame */ \ + /* arg10 */ \ + "ld 3,80(11)\n\t" \ + "std 3,120(1)\n\t" \ + /* arg9 */ \ + "ld 3,72(11)\n\t" \ + "std 3,112(1)\n\t" \ + /* args1-8 */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + "addi 1,1,128" /* restore frame */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+11]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + _argvec[2+11] = (unsigned long)arg11; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "addi 1,1,-144\n\t" /* expand stack frame */ \ + /* arg11 */ \ + "ld 3,88(11)\n\t" \ + "std 3,128(1)\n\t" \ + /* arg10 */ \ + "ld 3,80(11)\n\t" \ + "std 3,120(1)\n\t" \ + /* arg9 */ \ + "ld 3,72(11)\n\t" \ + "std 3,112(1)\n\t" \ + /* args1-8 */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + "addi 1,1,144" /* restore frame */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11,arg12) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+12]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + _argvec[2+11] = (unsigned long)arg11; \ + _argvec[2+12] = (unsigned long)arg12; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "addi 1,1,-144\n\t" /* expand stack frame */ \ + /* arg12 */ \ + "ld 3,96(11)\n\t" \ + "std 3,136(1)\n\t" \ + /* arg11 */ \ + "ld 3,88(11)\n\t" \ + "std 3,128(1)\n\t" \ + /* arg10 */ \ + "ld 3,80(11)\n\t" \ + "std 3,120(1)\n\t" \ + /* arg9 */ \ + "ld 3,72(11)\n\t" \ + "std 3,112(1)\n\t" \ + /* args1-8 */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + "addi 1,1,144" /* restore frame */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#endif /* PLAT_ppc64_linux */ + +/* ------------------------ ppc32-aix5 ------------------------- */ + +#if defined(PLAT_ppc32_aix5) + +/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */ + +/* These regs are trashed by the hidden call. */ +#define __CALLER_SAVED_REGS \ + "lr", "ctr", "xer", \ + "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \ + "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \ + "r11", "r12", "r13" + +/* Expand the stack frame, copying enough info that unwinding + still works. Trashes r3. */ + +#define VG_EXPAND_FRAME_BY_trashes_r3(_n_fr) \ + "addi 1,1,-" #_n_fr "\n\t" \ + "lwz 3," #_n_fr "(1)\n\t" \ + "stw 3,0(1)\n\t" + +#define VG_CONTRACT_FRAME_BY(_n_fr) \ + "addi 1,1," #_n_fr "\n\t" + +/* These CALL_FN_ macros assume that on ppc32-aix5, sizeof(unsigned + long) == 4. */ + +#define CALL_FN_W_v(lval, orig) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+0]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_W(lval, orig, arg1) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+1]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WW(lval, orig, arg1,arg2) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+2]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+3]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+4]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+5]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 7, 20(11)\n\t" /* arg5->r7 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+6]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 7, 20(11)\n\t" /* arg5->r7 */ \ + "lwz 8, 24(11)\n\t" /* arg6->r8 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+7]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 7, 20(11)\n\t" /* arg5->r7 */ \ + "lwz 8, 24(11)\n\t" /* arg6->r8 */ \ + "lwz 9, 28(11)\n\t" /* arg7->r9 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+8]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 7, 20(11)\n\t" /* arg5->r7 */ \ + "lwz 8, 24(11)\n\t" /* arg6->r8 */ \ + "lwz 9, 28(11)\n\t" /* arg7->r9 */ \ + "lwz 10, 32(11)\n\t" /* arg8->r10 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+9]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + VG_EXPAND_FRAME_BY_trashes_r3(64) \ + /* arg9 */ \ + "lwz 3,36(11)\n\t" \ + "stw 3,56(1)\n\t" \ + /* args1-8 */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 7, 20(11)\n\t" /* arg5->r7 */ \ + "lwz 8, 24(11)\n\t" /* arg6->r8 */ \ + "lwz 9, 28(11)\n\t" /* arg7->r9 */ \ + "lwz 10, 32(11)\n\t" /* arg8->r10 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(64) \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+10]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + VG_EXPAND_FRAME_BY_trashes_r3(64) \ + /* arg10 */ \ + "lwz 3,40(11)\n\t" \ + "stw 3,60(1)\n\t" \ + /* arg9 */ \ + "lwz 3,36(11)\n\t" \ + "stw 3,56(1)\n\t" \ + /* args1-8 */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 7, 20(11)\n\t" /* arg5->r7 */ \ + "lwz 8, 24(11)\n\t" /* arg6->r8 */ \ + "lwz 9, 28(11)\n\t" /* arg7->r9 */ \ + "lwz 10, 32(11)\n\t" /* arg8->r10 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(64) \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+11]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + _argvec[2+11] = (unsigned long)arg11; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + VG_EXPAND_FRAME_BY_trashes_r3(72) \ + /* arg11 */ \ + "lwz 3,44(11)\n\t" \ + "stw 3,64(1)\n\t" \ + /* arg10 */ \ + "lwz 3,40(11)\n\t" \ + "stw 3,60(1)\n\t" \ + /* arg9 */ \ + "lwz 3,36(11)\n\t" \ + "stw 3,56(1)\n\t" \ + /* args1-8 */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 7, 20(11)\n\t" /* arg5->r7 */ \ + "lwz 8, 24(11)\n\t" /* arg6->r8 */ \ + "lwz 9, 28(11)\n\t" /* arg7->r9 */ \ + "lwz 10, 32(11)\n\t" /* arg8->r10 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(72) \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11,arg12) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+12]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + _argvec[2+11] = (unsigned long)arg11; \ + _argvec[2+12] = (unsigned long)arg12; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + VG_EXPAND_FRAME_BY_trashes_r3(72) \ + /* arg12 */ \ + "lwz 3,48(11)\n\t" \ + "stw 3,68(1)\n\t" \ + /* arg11 */ \ + "lwz 3,44(11)\n\t" \ + "stw 3,64(1)\n\t" \ + /* arg10 */ \ + "lwz 3,40(11)\n\t" \ + "stw 3,60(1)\n\t" \ + /* arg9 */ \ + "lwz 3,36(11)\n\t" \ + "stw 3,56(1)\n\t" \ + /* args1-8 */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 7, 20(11)\n\t" /* arg5->r7 */ \ + "lwz 8, 24(11)\n\t" /* arg6->r8 */ \ + "lwz 9, 28(11)\n\t" /* arg7->r9 */ \ + "lwz 10, 32(11)\n\t" /* arg8->r10 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(72) \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#endif /* PLAT_ppc32_aix5 */ + +/* ------------------------ ppc64-aix5 ------------------------- */ + +#if defined(PLAT_ppc64_aix5) + +/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */ + +/* These regs are trashed by the hidden call. */ +#define __CALLER_SAVED_REGS \ + "lr", "ctr", "xer", \ + "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \ + "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \ + "r11", "r12", "r13" + +/* Expand the stack frame, copying enough info that unwinding + still works. Trashes r3. */ + +#define VG_EXPAND_FRAME_BY_trashes_r3(_n_fr) \ + "addi 1,1,-" #_n_fr "\n\t" \ + "ld 3," #_n_fr "(1)\n\t" \ + "std 3,0(1)\n\t" + +#define VG_CONTRACT_FRAME_BY(_n_fr) \ + "addi 1,1," #_n_fr "\n\t" + +/* These CALL_FN_ macros assume that on ppc64-aix5, sizeof(unsigned + long) == 8. */ + +#define CALL_FN_W_v(lval, orig) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+0]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_W(lval, orig, arg1) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+1]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WW(lval, orig, arg1,arg2) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+2]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+3]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+4]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+5]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+6]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+7]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+8]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+9]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + VG_EXPAND_FRAME_BY_trashes_r3(128) \ + /* arg9 */ \ + "ld 3,72(11)\n\t" \ + "std 3,112(1)\n\t" \ + /* args1-8 */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(128) \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+10]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + VG_EXPAND_FRAME_BY_trashes_r3(128) \ + /* arg10 */ \ + "ld 3,80(11)\n\t" \ + "std 3,120(1)\n\t" \ + /* arg9 */ \ + "ld 3,72(11)\n\t" \ + "std 3,112(1)\n\t" \ + /* args1-8 */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(128) \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+11]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + _argvec[2+11] = (unsigned long)arg11; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + VG_EXPAND_FRAME_BY_trashes_r3(144) \ + /* arg11 */ \ + "ld 3,88(11)\n\t" \ + "std 3,128(1)\n\t" \ + /* arg10 */ \ + "ld 3,80(11)\n\t" \ + "std 3,120(1)\n\t" \ + /* arg9 */ \ + "ld 3,72(11)\n\t" \ + "std 3,112(1)\n\t" \ + /* args1-8 */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(144) \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11,arg12) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+12]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + _argvec[2+11] = (unsigned long)arg11; \ + _argvec[2+12] = (unsigned long)arg12; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + VG_EXPAND_FRAME_BY_trashes_r3(144) \ + /* arg12 */ \ + "ld 3,96(11)\n\t" \ + "std 3,136(1)\n\t" \ + /* arg11 */ \ + "ld 3,88(11)\n\t" \ + "std 3,128(1)\n\t" \ + /* arg10 */ \ + "ld 3,80(11)\n\t" \ + "std 3,120(1)\n\t" \ + /* arg9 */ \ + "ld 3,72(11)\n\t" \ + "std 3,112(1)\n\t" \ + /* args1-8 */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(144) \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#endif /* PLAT_ppc64_aix5 */ + + +/* ------------------------------------------------------------------ */ +/* ARCHITECTURE INDEPENDENT MACROS for CLIENT REQUESTS. */ +/* */ +/* ------------------------------------------------------------------ */ + +/* Some request codes. There are many more of these, but most are not + exposed to end-user view. These are the public ones, all of the + form 0x1000 + small_number. + + Core ones are in the range 0x00000000--0x0000ffff. The non-public + ones start at 0x2000. +*/ + +/* These macros are used by tools -- they must be public, but don't + embed them into other programs. */ +#define VG_USERREQ_TOOL_BASE(a,b) \ + ((unsigned int)(((a)&0xff) << 24 | ((b)&0xff) << 16)) +#define VG_IS_TOOL_USERREQ(a, b, v) \ + (VG_USERREQ_TOOL_BASE(a,b) == ((v) & 0xffff0000)) + +/* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !! + This enum comprises an ABI exported by Valgrind to programs + which use client requests. DO NOT CHANGE THE ORDER OF THESE + ENTRIES, NOR DELETE ANY -- add new ones at the end. */ +typedef + enum { VG_USERREQ__RUNNING_ON_VALGRIND = 0x1001, + VG_USERREQ__DISCARD_TRANSLATIONS = 0x1002, + + /* These allow any function to be called from the simulated + CPU but run on the real CPU. Nb: the first arg passed to + the function is always the ThreadId of the running + thread! So CLIENT_CALL0 actually requires a 1 arg + function, etc. */ + VG_USERREQ__CLIENT_CALL0 = 0x1101, + VG_USERREQ__CLIENT_CALL1 = 0x1102, + VG_USERREQ__CLIENT_CALL2 = 0x1103, + VG_USERREQ__CLIENT_CALL3 = 0x1104, + + /* Can be useful in regression testing suites -- eg. can + send Valgrind's output to /dev/null and still count + errors. */ + VG_USERREQ__COUNT_ERRORS = 0x1201, + + /* These are useful and can be interpreted by any tool that + tracks malloc() et al, by using vg_replace_malloc.c. */ + VG_USERREQ__MALLOCLIKE_BLOCK = 0x1301, + VG_USERREQ__FREELIKE_BLOCK = 0x1302, + /* Memory pool support. */ + VG_USERREQ__CREATE_MEMPOOL = 0x1303, + VG_USERREQ__DESTROY_MEMPOOL = 0x1304, + VG_USERREQ__MEMPOOL_ALLOC = 0x1305, + VG_USERREQ__MEMPOOL_FREE = 0x1306, + VG_USERREQ__MEMPOOL_TRIM = 0x1307, + VG_USERREQ__MOVE_MEMPOOL = 0x1308, + VG_USERREQ__MEMPOOL_CHANGE = 0x1309, + VG_USERREQ__MEMPOOL_EXISTS = 0x130a, + + /* Allow printfs to valgrind log. */ + VG_USERREQ__PRINTF = 0x1401, + VG_USERREQ__PRINTF_BACKTRACE = 0x1402, + + /* Stack support. */ + VG_USERREQ__STACK_REGISTER = 0x1501, + VG_USERREQ__STACK_DEREGISTER = 0x1502, + VG_USERREQ__STACK_CHANGE = 0x1503 + } Vg_ClientRequest; + +#if !defined(__GNUC__) +# define __extension__ /* */ +#endif + +/* Returns the number of Valgrinds this code is running under. That + is, 0 if running natively, 1 if running under Valgrind, 2 if + running under Valgrind which is running under another Valgrind, + etc. */ +#define RUNNING_ON_VALGRIND __extension__ \ + ({unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* if not */, \ + VG_USERREQ__RUNNING_ON_VALGRIND, \ + 0, 0, 0, 0, 0); \ + _qzz_res; \ + }) + + +/* Discard translation of code in the range [_qzz_addr .. _qzz_addr + + _qzz_len - 1]. Useful if you are debugging a JITter or some such, + since it provides a way to make sure valgrind will retranslate the + invalidated area. Returns no value. */ +#define VALGRIND_DISCARD_TRANSLATIONS(_qzz_addr,_qzz_len) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__DISCARD_TRANSLATIONS, \ + _qzz_addr, _qzz_len, 0, 0, 0); \ + } + + +/* These requests are for getting Valgrind itself to print something. + Possibly with a backtrace. This is a really ugly hack. */ + +#if defined(NVALGRIND) + +# define VALGRIND_PRINTF(...) +# define VALGRIND_PRINTF_BACKTRACE(...) + +#else /* NVALGRIND */ + +/* Modern GCC will optimize the static routine out if unused, + and unused attribute will shut down warnings about it. */ +static int VALGRIND_PRINTF(const char *format, ...) + __attribute__((format(__printf__, 1, 2), __unused__)); +static int +VALGRIND_PRINTF(const char *format, ...) +{ + unsigned long _qzz_res; + va_list vargs; + va_start(vargs, format); + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, VG_USERREQ__PRINTF, + (unsigned long)format, (unsigned long)vargs, + 0, 0, 0); + va_end(vargs); + return (int)_qzz_res; +} + +static int VALGRIND_PRINTF_BACKTRACE(const char *format, ...) + __attribute__((format(__printf__, 1, 2), __unused__)); +static int +VALGRIND_PRINTF_BACKTRACE(const char *format, ...) +{ + unsigned long _qzz_res; + va_list vargs; + va_start(vargs, format); + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, VG_USERREQ__PRINTF_BACKTRACE, + (unsigned long)format, (unsigned long)vargs, + 0, 0, 0); + va_end(vargs); + return (int)_qzz_res; +} + +#endif /* NVALGRIND */ + + +/* These requests allow control to move from the simulated CPU to the + real CPU, calling an arbitary function. + + Note that the current ThreadId is inserted as the first argument. + So this call: + + VALGRIND_NON_SIMD_CALL2(f, arg1, arg2) + + requires f to have this signature: + + Word f(Word tid, Word arg1, Word arg2) + + where "Word" is a word-sized type. + + Note that these client requests are not entirely reliable. For example, + if you call a function with them that subsequently calls printf(), + there's a high chance Valgrind will crash. Generally, your prospects of + these working are made higher if the called function does not refer to + any global variables, and does not refer to any libc or other functions + (printf et al). Any kind of entanglement with libc or dynamic linking is + likely to have a bad outcome, for tricky reasons which we've grappled + with a lot in the past. +*/ +#define VALGRIND_NON_SIMD_CALL0(_qyy_fn) \ + __extension__ \ + ({unsigned long _qyy_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */, \ + VG_USERREQ__CLIENT_CALL0, \ + _qyy_fn, \ + 0, 0, 0, 0); \ + _qyy_res; \ + }) + +#define VALGRIND_NON_SIMD_CALL1(_qyy_fn, _qyy_arg1) \ + __extension__ \ + ({unsigned long _qyy_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */, \ + VG_USERREQ__CLIENT_CALL1, \ + _qyy_fn, \ + _qyy_arg1, 0, 0, 0); \ + _qyy_res; \ + }) + +#define VALGRIND_NON_SIMD_CALL2(_qyy_fn, _qyy_arg1, _qyy_arg2) \ + __extension__ \ + ({unsigned long _qyy_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */, \ + VG_USERREQ__CLIENT_CALL2, \ + _qyy_fn, \ + _qyy_arg1, _qyy_arg2, 0, 0); \ + _qyy_res; \ + }) + +#define VALGRIND_NON_SIMD_CALL3(_qyy_fn, _qyy_arg1, _qyy_arg2, _qyy_arg3) \ + __extension__ \ + ({unsigned long _qyy_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */, \ + VG_USERREQ__CLIENT_CALL3, \ + _qyy_fn, \ + _qyy_arg1, _qyy_arg2, \ + _qyy_arg3, 0); \ + _qyy_res; \ + }) + + +/* Counts the number of errors that have been recorded by a tool. Nb: + the tool must record the errors with VG_(maybe_record_error)() or + VG_(unique_error)() for them to be counted. */ +#define VALGRIND_COUNT_ERRORS \ + __extension__ \ + ({unsigned int _qyy_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */, \ + VG_USERREQ__COUNT_ERRORS, \ + 0, 0, 0, 0, 0); \ + _qyy_res; \ + }) + +/* Mark a block of memory as having been allocated by a malloc()-like + function. `addr' is the start of the usable block (ie. after any + redzone) `rzB' is redzone size if the allocator can apply redzones; + use '0' if not. Adding redzones makes it more likely Valgrind will spot + block overruns. `is_zeroed' indicates if the memory is zeroed, as it is + for calloc(). Put it immediately after the point where a block is + allocated. + + If you're using Memcheck: If you're allocating memory via superblocks, + and then handing out small chunks of each superblock, if you don't have + redzones on your small blocks, it's worth marking the superblock with + VALGRIND_MAKE_MEM_NOACCESS when it's created, so that block overruns are + detected. But if you can put redzones on, it's probably better to not do + this, so that messages for small overruns are described in terms of the + small block rather than the superblock (but if you have a big overrun + that skips over a redzone, you could miss an error this way). See + memcheck/tests/custom_alloc.c for an example. + + WARNING: if your allocator uses malloc() or 'new' to allocate + superblocks, rather than mmap() or brk(), this will not work properly -- + you'll likely get assertion failures during leak detection. This is + because Valgrind doesn't like seeing overlapping heap blocks. Sorry. + + Nb: block must be freed via a free()-like function specified + with VALGRIND_FREELIKE_BLOCK or mismatch errors will occur. */ +#define VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__MALLOCLIKE_BLOCK, \ + addr, sizeB, rzB, is_zeroed, 0); \ + } + +/* Mark a block of memory as having been freed by a free()-like function. + `rzB' is redzone size; it must match that given to + VALGRIND_MALLOCLIKE_BLOCK. Memory not freed will be detected by the leak + checker. Put it immediately after the point where the block is freed. */ +#define VALGRIND_FREELIKE_BLOCK(addr, rzB) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__FREELIKE_BLOCK, \ + addr, rzB, 0, 0, 0); \ + } + +/* Create a memory pool. */ +#define VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__CREATE_MEMPOOL, \ + pool, rzB, is_zeroed, 0, 0); \ + } + +/* Destroy a memory pool. */ +#define VALGRIND_DESTROY_MEMPOOL(pool) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__DESTROY_MEMPOOL, \ + pool, 0, 0, 0, 0); \ + } + +/* Associate a piece of memory with a memory pool. */ +#define VALGRIND_MEMPOOL_ALLOC(pool, addr, size) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__MEMPOOL_ALLOC, \ + pool, addr, size, 0, 0); \ + } + +/* Disassociate a piece of memory from a memory pool. */ +#define VALGRIND_MEMPOOL_FREE(pool, addr) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__MEMPOOL_FREE, \ + pool, addr, 0, 0, 0); \ + } + +/* Disassociate any pieces outside a particular range. */ +#define VALGRIND_MEMPOOL_TRIM(pool, addr, size) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__MEMPOOL_TRIM, \ + pool, addr, size, 0, 0); \ + } + +/* Resize and/or move a piece associated with a memory pool. */ +#define VALGRIND_MOVE_MEMPOOL(poolA, poolB) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__MOVE_MEMPOOL, \ + poolA, poolB, 0, 0, 0); \ + } + +/* Resize and/or move a piece associated with a memory pool. */ +#define VALGRIND_MEMPOOL_CHANGE(pool, addrA, addrB, size) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__MEMPOOL_CHANGE, \ + pool, addrA, addrB, size, 0); \ + } + +/* Return 1 if a mempool exists, else 0. */ +#define VALGRIND_MEMPOOL_EXISTS(pool) \ + ({unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__MEMPOOL_EXISTS, \ + pool, 0, 0, 0, 0); \ + _qzz_res; \ + }) + +/* Mark a piece of memory as being a stack. Returns a stack id. */ +#define VALGRIND_STACK_REGISTER(start, end) \ + ({unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__STACK_REGISTER, \ + start, end, 0, 0, 0); \ + _qzz_res; \ + }) + +/* Unmark the piece of memory associated with a stack id as being a + stack. */ +#define VALGRIND_STACK_DEREGISTER(id) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__STACK_DEREGISTER, \ + id, 0, 0, 0, 0); \ + } + +/* Change the start and end address of the stack id. */ +#define VALGRIND_STACK_CHANGE(id, start, end) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__STACK_CHANGE, \ + id, start, end, 0, 0); \ + } + + +#undef PLAT_x86_linux +#undef PLAT_amd64_linux +#undef PLAT_ppc32_linux +#undef PLAT_ppc64_linux +#undef PLAT_ppc32_aix5 +#undef PLAT_ppc64_aix5 + +#endif /* __VALGRIND_H */ diff --git a/tests/auto/exceptionsafety_objects/exceptionsafety_objects.pro b/tests/auto/exceptionsafety_objects/exceptionsafety_objects.pro index 413e1e3..d0945a4 100644 --- a/tests/auto/exceptionsafety_objects/exceptionsafety_objects.pro +++ b/tests/auto/exceptionsafety_objects/exceptionsafety_objects.pro @@ -1,3 +1,3 @@ load(qttest_p4) -HEADERS += oomsimulator.h +HEADERS += oomsimulator.h 3rdparty/valgrind.h 3rdparty/memcheck.h SOURCES += tst_exceptionsafety_objects.cpp diff --git a/tests/auto/exceptionsafety_objects/oomsimulator.h b/tests/auto/exceptionsafety_objects/oomsimulator.h index 1b092ea..3c8b389 100644 --- a/tests/auto/exceptionsafety_objects/oomsimulator.h +++ b/tests/auto/exceptionsafety_objects/oomsimulator.h @@ -40,6 +40,8 @@ ****************************************************************************/ #include +#include +#include "3rdparty/memcheck.h" /* Use glibc's memory allocation hooks */ @@ -89,18 +91,41 @@ void my_init_hook() static bool mallocFailActive = false; static int mallocFailIndex = 0; static int mallocCount = 0; -static int freeCount = 0; -struct AllocFailActivator +struct AllocFailer { - inline AllocFailActivator() { mallocFailActive = true; } - inline ~AllocFailActivator() { mallocFailActive = false; } - - inline void deactivate() { mallocFailActive = false; } + inline AllocFailer() { mallocFailActive = true; setAllocFailIndex(0); } + inline ~AllocFailer() { deactivate(); } + + inline void setAllocFailIndex(int index) + { + if (RUNNING_ON_VALGRIND) { + VALGRIND_ENABLE_OOM_AT_ALLOC_INDEX(VALGRIND_GET_ALLOC_INDEX + index + 1); + } else { + mallocFailIndex = index; + } + } + + inline void deactivate() + { + mallocFailActive = false; + VALGRIND_ENABLE_OOM_AT_ALLOC_INDEX(INT_MAX); + } + + inline int currentAllocIndex() const + { + if (RUNNING_ON_VALGRIND) { + return VALGRIND_GET_ALLOC_INDEX; + } else { + return mallocCount; + } + } }; void *my_malloc_hook(size_t size, const void *) { + ++mallocCount; + if (mallocFailActive && --mallocFailIndex < 0) return 0; // simulate OOM @@ -108,12 +133,13 @@ void *my_malloc_hook(size_t size, const void *) void *result = ::malloc (size); __malloc_hook = my_malloc_hook; - ++mallocCount; return result; } void *my_memalign_hook(size_t alignment, size_t size, const void *) { + ++mallocCount; + if (mallocFailActive && --mallocFailIndex < 0) return 0; // simulate OOM @@ -121,12 +147,13 @@ void *my_memalign_hook(size_t alignment, size_t size, const void *) void *result = ::memalign(alignment, size); __memalign_hook = my_memalign_hook; - ++mallocCount; return result; } void *my_realloc_hook(void *ptr, size_t size, const void *) { + ++mallocCount; + if (mallocFailActive && --mallocFailIndex < 0) return 0; // simulate OOM @@ -136,8 +163,6 @@ void *my_realloc_hook(void *ptr, size_t size, const void *) __malloc_hook = my_malloc_hook; __realloc_hook = my_realloc_hook; - if (!ptr) // realloc on a 0 pointer equals a new allocation - ++mallocCount; return result; } @@ -146,8 +171,6 @@ void my_free_hook(void *ptr, const void *) __free_hook = old_free_hook; ::free(ptr); __free_hook = my_free_hook; - - ++freeCount; } static void *new_helper(std::size_t size) diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index 3c85306..dd5f8da 100644 --- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -50,6 +50,7 @@ QT_USE_NAMESPACE #else #include "oomsimulator.h" +#include "3rdparty/memcheck.h" class tst_ExceptionSafetyObjects: public QObject { @@ -66,17 +67,6 @@ private slots: void widgets(); }; -void tst_ExceptionSafetyObjects::initTestCase() -{ - // sanity check whether OOM simulation works - AllocFailActivator allocFailActivator; - mallocFailIndex = 0; - - // malloc fail index is 0 -> this malloc should fail. - void *buf = malloc(42); - QVERIFY(!buf); -} - // helper structs to create an arbitrary widget struct AbstractObjectCreator { @@ -102,20 +92,107 @@ void tst_ExceptionSafetyObjects::objects_data() NEWROW(QObject); } -void tst_ExceptionSafetyObjects::objects() +// create and destructs an object, and lets each and every allocation +// during construction and destruction fail. +static void doOOMTest(AbstractObjectCreator *creator, QObject *parent) { - QFETCH(AbstractObjectCreator *, objectCreator); - - AllocFailActivator allocFailActivator; + AllocFailer allocFailer; int currentOOMIndex = 0; + bool caught = false; + + int allocStartIndex = 0; + int allocEndIndex = 0; + int lastAllocCount = 0; + do { - mallocFailIndex = ++currentOOMIndex; + allocFailer.setAllocFailIndex(++currentOOMIndex); + + caught = false; + lastAllocCount = allocEndIndex - allocStartIndex; + allocStartIndex = allocFailer.currentAllocIndex(); try { - QScopedPointer ptr(objectCreator->create(0)); + QScopedPointer ptr(creator->create(parent)); } catch (const std::bad_alloc &) { + caught = true; } - } while (mallocFailIndex <= 0); + + allocEndIndex = allocFailer.currentAllocIndex(); + + } while (caught || allocEndIndex - allocStartIndex != lastAllocCount); + + allocFailer.deactivate(); +} + +static bool alloc1Failed = false; +static bool alloc2Failed = false; +static bool alloc3Failed = false; +static bool alloc4Failed = false; +static bool malloc1Failed = false; +static bool malloc2Failed = false; + +// Tests that new, new[] and malloc() fail at least once during OOM testing. +class SelfTestObject : public QObject +{ +public: + SelfTestObject(QObject *parent = 0) + : QObject(parent) + { + try { delete new int; } catch (const std::bad_alloc &) { alloc1Failed = true; } + try { delete [] new double[5]; } catch (const std::bad_alloc &) { alloc2Failed = true; } + void *buf = malloc(42); + if (buf) + free(buf); + else + malloc1Failed = true; + } + + ~SelfTestObject() + { + try { delete new int; } catch (const std::bad_alloc &) { alloc3Failed = true; } + try { delete [] new double[5]; } catch (const std::bad_alloc &) { alloc4Failed = true; } + void *buf = malloc(42); + if (buf) + free(buf); + else + malloc2Failed = true; + } +}; + +void tst_ExceptionSafetyObjects::initTestCase() +{ + if (RUNNING_ON_VALGRIND) { + QVERIFY2(VALGRIND_GET_ALLOC_INDEX != -1u, + "You must use a valgrind with oom simulation support"); + // running in valgrind - don't use glibc hooks + disableHooks(); + } + + // sanity check whether OOM simulation works + AllocFailer allocFailer; + + // malloc fail index is 0 -> this malloc should fail. + void *buf = malloc(42); + QVERIFY(!buf); + + // malloc fail index is 1 - second malloc should fail. + allocFailer.setAllocFailIndex(1); + buf = malloc(42); + QVERIFY(buf); + free(buf); + buf = malloc(42); + QVERIFY(!buf); + + allocFailer.deactivate(); + + doOOMTest(new ObjectCreator, 0); +} + +void tst_ExceptionSafetyObjects::objects() +{ + QFETCH(AbstractObjectCreator *, objectCreator); + + doOOMTest(objectCreator, 0); } template @@ -136,56 +213,18 @@ void tst_ExceptionSafetyObjects::widgets_data() NEWROW(QWidget); NEWROW(QPushButton); NEWROW(QLabel); + NEWROW(QFrame); + NEWROW(QStackedWidget); } void tst_ExceptionSafetyObjects::widgets() { QFETCH(AbstractObjectCreator *, widgetCreator); - mallocCount = freeCount = 0; - - int currentOOMIndex = 0; - - // activate mallocFail - WE'RE HOT! - AllocFailActivator allocFailActivator; - - do { - // start after first alloc (the first alloc is creation of the widget itself) - mallocFailIndex = ++currentOOMIndex; - - // first, create without a parent - try { - QScopedPointer ptr(widgetCreator->create(0)); - // QScopedPointer deletes the widget again here. - } catch (const std::bad_alloc &) { - // ignore all std::bad_alloc - note: valgrind should show no leaks - } - - // repeat the loop until we the malloc fail index indicates that - // there was no OOM simulation happening - } while (mallocFailIndex <= 0); - - // reset counting - currentOOMIndex = 0; - - do { - mallocFailIndex = ++currentOOMIndex; - - // create the widget with a parent - try { - QWidget parent; - widgetCreator->create(&parent); - // parent goes out of scope - widget should be deleted as well - } catch (const std::bad_alloc &) { - } - } while (mallocFailIndex <= 0); - -#ifdef VERBOSE - allocFailActivator.deactivate(); + doOOMTest(widgetCreator, 0); - qDebug() << "mallocCount" << mallocCount << "freeCount" << freeCount << - "simulated alloc fails" << currentOOMIndex; -#endif + QWidget parent; + doOOMTest(widgetCreator, &parent); } QTEST_MAIN(tst_ExceptionSafetyObjects) -- cgit v0.12 From 53c3e52cbd7194ef2e2e4b4648f5fac9cd780930 Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Wed, 17 Jun 2009 09:54:10 +0200 Subject: Making the writing in the status label in sync with the current state. The writings were wrong after i.e. ftp -> connect -> disconnect. --- examples/network/ftp/ftpwindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/network/ftp/ftpwindow.cpp b/examples/network/ftp/ftpwindow.cpp index 52c31e0..abfb6cc 100644 --- a/examples/network/ftp/ftpwindow.cpp +++ b/examples/network/ftp/ftpwindow.cpp @@ -139,6 +139,7 @@ void FtpWindow::connectOrDisconnect() #ifndef QT_NO_CURSOR setCursor(Qt::ArrowCursor); #endif + statusLabel->setText(tr("Please enter the name of an FTP server.")); return; } -- cgit v0.12 From 7442925bd3a88a15ac0db0dce9bb5d7a3aa6e622 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 17 Jun 2009 12:10:06 +0300 Subject: Added proper UID for webkit examples and browser demo --- demos/browser/browser.pro | 2 ++ examples/webkit/fancybrowser/fancybrowser.pro | 2 ++ examples/webkit/formextractor/formextractor.pro | 2 ++ examples/webkit/googlechat/googlechat.pro | 2 ++ examples/webkit/previewer/previewer.pro | 2 ++ 5 files changed, 10 insertions(+) diff --git a/demos/browser/browser.pro b/demos/browser/browser.pro index c500788..7b7c448 100644 --- a/demos/browser/browser.pro +++ b/demos/browser/browser.pro @@ -91,3 +91,5 @@ sources.path = $$[QT_INSTALL_DEMOS]/browser INSTALLS += target sources include($$QT_SOURCE_TREE/demos/demobase.pri) + +symbian:TARGET.UID3 = 0xA000CF70 \ No newline at end of file diff --git a/examples/webkit/fancybrowser/fancybrowser.pro b/examples/webkit/fancybrowser/fancybrowser.pro index 3de3036..afc0cc2 100644 --- a/examples/webkit/fancybrowser/fancybrowser.pro +++ b/examples/webkit/fancybrowser/fancybrowser.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/webkit/fancybrowser sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/fancybrowser INSTALLS += target sources + +symbian:TARGET.UID3 = 0xA000CF6C \ No newline at end of file diff --git a/examples/webkit/formextractor/formextractor.pro b/examples/webkit/formextractor/formextractor.pro index ddd39b4..ecb264c 100644 --- a/examples/webkit/formextractor/formextractor.pro +++ b/examples/webkit/formextractor/formextractor.pro @@ -16,3 +16,5 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/formextractor INSTALLS += target sources include($$QT_SOURCE_TREE/examples/examplebase.pri) + +symbian:TARGET.UID3 = 0xA000CF6D \ No newline at end of file diff --git a/examples/webkit/googlechat/googlechat.pro b/examples/webkit/googlechat/googlechat.pro index 14b7085..bc2aad3 100644 --- a/examples/webkit/googlechat/googlechat.pro +++ b/examples/webkit/googlechat/googlechat.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/webkit/googlechat sources.files = $$SOURCES $$HEADERS $$FORMS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/googlechat INSTALLS += target sources + +symbian:TARGET.UID3 = 0xA000CF6E \ No newline at end of file diff --git a/examples/webkit/previewer/previewer.pro b/examples/webkit/previewer/previewer.pro index 4c8a09d..ce7906b 100644 --- a/examples/webkit/previewer/previewer.pro +++ b/examples/webkit/previewer/previewer.pro @@ -13,3 +13,5 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/previewer INSTALLS += target sources include($$QT_SOURCE_TREE/examples/examplebase.pri) + +symbian:TARGET.UID3 = 0xA000CF6F \ No newline at end of file -- cgit v0.12 From 31f97fae841b31e846e7f8754e84320f5925bff5 Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 17 Jun 2009 12:48:32 +0200 Subject: Readded code that was lost during exception integration. AutoTest: Passed RevBy: Trust me --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index 423fbaa..c0b9e02 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -231,6 +231,9 @@ void QTimerActiveObject::RunL() void QTimerActiveObject::Run() { + if (!okToRun()) + return; + if (m_timerInfo->interval > 0) { // Start a new timer immediately so that we don't lose time. iStatus = KRequestPending; -- cgit v0.12 From e601e40bcae0baee92793c0ec1222ddf9e51607b Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 17 Jun 2009 12:49:25 +0200 Subject: Fixed indentation. --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index c0b9e02..17bb9a7 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -647,9 +647,9 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla QT_TRY { Q_D(QAbstractEventDispatcher); - // It is safe if this counter overflows. The main importance is that each - // iteration count is different from the last. - m_iterationCount++; + // It is safe if this counter overflows. The main importance is that each + // iteration count is different from the last. + m_iterationCount++; RThread &thread = d->threadData->symbian_thread_handle; @@ -722,7 +722,7 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla break; } block = false; - if (timeState == TimeStarted && time.elapsed() > 100) { + if (timeState == TimeStarted && time.elapsed() > 100) { priority = m_processHandle.Priority(); m_processHandle.SetPriority(EPriorityLow); time.start(); -- cgit v0.12 From 46de9152fcd2a8ca28ffd1e37c6566aced47f35b Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 17 Jun 2009 15:23:38 +0300 Subject: Removed incorrect Carbide version from compiler patching instructions. --- doc/src/installation.qdoc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/src/installation.qdoc b/doc/src/installation.qdoc index 05188c7..c8310ff 100644 --- a/doc/src/installation.qdoc +++ b/doc/src/installation.qdoc @@ -906,8 +906,9 @@ If you are using pre-built binaries, follow the instructions \list \o \l{http://www.forum.nokia.com/main/resources/tools_and_sdks/carbide_cpp/}{Carbide.c++ v2.0.0 or higher} \list - \o \bold{Note:} It is necessary to update Carbide compiler if you are using Carbide 2.0.2 or older. - You can find a compiler patch \l{http://pepper.troll.no/s60prereleases/patches/}{here}. + \o \bold{Note:} It may be necessary to update the Carbide compiler. + See \l{http://pepper.troll.no/s60prereleases/patches/}{here} for instructions how to check your + compiler version and how to patch it, if needed. \endlist \o \l{http://www.forum.nokia.com/main/resources/tools_and_sdks/S60SDK/}{S60 Platform SDK 3rd Edition FP1 or higher} \o \l{http://www.forum.nokia.com/main/resources/technologies/openc_cpp/}{Open C/C++ v1.6.0 or higher}. -- cgit v0.12 From 2ede08bce669ddb68070ec1344a51b97ddc945d2 Mon Sep 17 00:00:00 2001 From: Janne Koskinen Date: Wed, 17 Jun 2009 15:42:12 +0200 Subject: Revert "Removed accidental allocation in QRingBuffer::clear()" This reverts commit 85e940d2fa5e8d2caf0d157f214bb826fc392e7b. --- src/corelib/tools/qringbuffer_p.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h index d4d0af7..a1bfab0 100644 --- a/src/corelib/tools/qringbuffer_p.h +++ b/src/corelib/tools/qringbuffer_p.h @@ -62,10 +62,8 @@ class Q_CORE_EXPORT QRingBuffer { public: inline QRingBuffer(int growth = 4096) : basicBlockSize(growth) { - head = tail = 0; - tailBuffer = 0; - bufferSize = 0; buffers << QByteArray(); + clear(); } inline int nextDataBlockSize() const { @@ -106,12 +104,8 @@ public: } inline char *reserve(int bytes) { - if (isEmpty()) { - buffers[tailBuffer].resize(qMax(basicBlockSize, bytes)); - bufferSize = tail = bytes; - return buffers[tailBuffer].data(); - } bufferSize += bytes; + // if there is already enough space, simply return. if (tail + bytes <= buffers.at(tailBuffer).size()) { char *writePtr = buffers[tailBuffer].data() + tail; @@ -204,7 +198,7 @@ public: } inline void clear() { - if(!isEmpty()) { + if(!buffers.isEmpty()) { QByteArray tmp = buffers[0]; buffers.clear(); buffers << tmp; -- cgit v0.12 From 75140c4776934744c37a34b10b7d4b8665aa4dc1 Mon Sep 17 00:00:00 2001 From: Janne Koskinen Date: Wed, 17 Jun 2009 15:50:16 +0200 Subject: longtap event gets properly cancelled when entering popup --- src/gui/kernel/qapplication_s60.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 4c008fb..9a2bbe6 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -343,7 +343,7 @@ void QSymbianControl::HandleLongTapEventL( const TPoint& aPenEventLocation, cons QMouseEvent mEvent(QEvent::MouseButtonPress, alienWidget->mapFrom(qwidget, widgetPos), globalPos, Qt::RightButton, QApplicationPrivate::mouse_buttons, Qt::NoModifier); sendMouseEvent(alienWidget, &mEvent); - m_previousEventLongTap = false; + m_previousEventLongTap = true; } void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent) @@ -821,18 +821,21 @@ void QApplicationPrivate::openPopup(QWidget *popup) WId id = popup->effectiveWinId(); id->SetPointerCapture(true); id->SetGloballyCapturing(true); - autoGrabWindow = id; } // popups are not focus-handled by the window system (the first // popup grabbed the keyboard), so we have to do that manually: A // new popup gets the focus - if (popup->focusWidget()) { - popup->focusWidget()->setFocus(Qt::PopupFocusReason); + if (QApplication::focusWidget()) + static_cast(QApplication::focusWidget()->effectiveWinId())->CancelLongTapTimer(); + QWidget *fw = popup->focusWidget(); + if (fw) { + fw->setFocus(Qt::PopupFocusReason); } else if (QApplicationPrivate::popupWidgets->count() == 1) { // this was the first popup - if (QWidget *fw = QApplication::focusWidget()) { - static_cast(fw->effectiveWinId())->CancelLongTapTimer(); + fw = QApplication::focusWidget(); + if (fw) { +// static_cast(fw->effectiveWinId())->CancelLongTapTimer(); QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason); q_func()->sendEvent(fw, &e); } -- cgit v0.12 From 86b28b0bf7ddd278f1b878db0b5961762e9272b2 Mon Sep 17 00:00:00 2001 From: Janne Koskinen Date: Wed, 17 Jun 2009 15:54:02 +0200 Subject: namespace fixes. s60main and corelib now compiles under a namespace --- src/corelib/global/qglobal.h | 5 +++-- src/corelib/tools/qlocale_symbian.cpp | 5 +++-- src/gui/image/qpixmap.h | 9 ++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 361c038..6e9250f 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -795,6 +795,9 @@ namespace QT_NAMESPACE {} # define Q_WS_WIN #endif +// forward declare std::exception +namespace std { class exception; } + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -2315,8 +2318,6 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf(); #if defined(Q_OS_SYMBIAN) -// forward declare std::exception -namespace std { class exception; } Q_CORE_EXPORT void qt_translateSymbianErrorToException(int error); Q_CORE_EXPORT void qt_translateExceptionToSymbianErrorL(const std::exception& ex); diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index c11a7b9..976227d 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -47,11 +47,12 @@ #include #include "private/qcore_symbian_p.h" -// Located in qlocale.cpp -extern void getLangAndCountry(const QString &name, QLocale::Language &lang, QLocale::Country &cntry); QT_BEGIN_NAMESPACE +// Located in qlocale.cpp +extern void getLangAndCountry(const QString &name, QLocale::Language &lang, QLocale::Country &cntry); + static TExtendedLocale _s60Locale; // Type definitions for runtime resolved function pointers diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 9ef5347..6c24055 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -51,6 +51,10 @@ QT_BEGIN_HEADER +#if defined(Q_OS_SYMBIAN) +class CFbsBitmap; +#endif + QT_BEGIN_NAMESPACE QT_MODULE(Gui) @@ -59,13 +63,8 @@ class QImageWriter; class QColor; class QVariant; class QX11Info; - class QPixmapData; -#if defined(Q_OS_SYMBIAN) -class CFbsBitmap; -#endif - class Q_GUI_EXPORT QPixmap : public QPaintDevice { public: -- cgit v0.12 From 87ac26f0c489911d9a43bab04aef03cadbe8bbe6 Mon Sep 17 00:00:00 2001 From: Janne Koskinen Date: Wed, 17 Jun 2009 16:03:22 +0200 Subject: removed commented code --- src/gui/kernel/qapplication_s60.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 3bd6e6b..b7561e4 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -835,7 +835,6 @@ void QApplicationPrivate::openPopup(QWidget *popup) } else if (QApplicationPrivate::popupWidgets->count() == 1) { // this was the first popup fw = QApplication::focusWidget(); if (fw) { -// static_cast(fw->effectiveWinId())->CancelLongTapTimer(); QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason); q_func()->sendEvent(fw, &e); } -- cgit v0.12 From 30525b802f17c2c815f02d81a1c771b8cee71458 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Wed, 17 Jun 2009 16:38:41 +0200 Subject: Improve softkey implementation and add a default 'Exit' button to RSK. The previous implementation had some problems where the actual position of the softkey was determined by it's position in the list. This is suboptimal since the position should be tied to the role. Actions that have "negative" conotation should be located on the right soft key (RSK) while "positive" actions go on the left soft key (LSK). This is according to the S60 User Interface Guide. It is also standard practice in S60 to have an 'Exit' button on the RSK so we add one of those if there is not already a key present there. Task-number: 256365 Reviewed-by: Markku Luukkainen --- src/gui/kernel/qaction.h | 9 +++--- src/gui/kernel/qwidget_s60.cpp | 65 +++++++++++++++++++++++++++++++----------- 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/src/gui/kernel/qaction.h b/src/gui/kernel/qaction.h index dfa4933..3449acf 100644 --- a/src/gui/kernel/qaction.h +++ b/src/gui/kernel/qaction.h @@ -91,11 +91,10 @@ class Q_GUI_EXPORT QAction : public QObject public: enum MenuRole { NoRole, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole, AboutRole, PreferencesRole, QuitRole }; - enum SoftKeyRole { OptionsSoftKey, SelectSoftKey, BackSoftKey, NextSoftKey, PreviousSoftKey, - OkSoftKey, CancelSoftKey, EditSoftKey, ViewSoftKey, BackSpaceSoftKey, - EndEditSoftKey, RevertEditSoftKey, DeselectSoftKey, FinishSoftKey, - MenuSoftKey, ContextMenuSoftKey, ExitSoftKey, Key1SoftKey, Key2SoftKey, - Key3SoftKey, Key4SoftKey, CustomSoftKey }; + enum SoftKeyRole { OptionsSoftKey, SelectSoftKey, BackSoftKey, NextSoftKey, PreviousSoftKey, + OkSoftKey, CancelSoftKey, EditSoftKey, ViewSoftKey, BackSpaceSoftKey, + EndEditSoftKey, RevertEditSoftKey, DeselectSoftKey, FinishSoftKey, + MenuSoftKey, ContextMenuSoftKey, ExitSoftKey }; explicit QAction(QObject* parent); QAction(const QString &text, QObject* parent); QAction(const QIcon &icon, const QString &text, QObject* parent); diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index bc69d6d..6109f17 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -85,29 +85,62 @@ void QWidgetPrivate::setSoftKeys_sys(const QList &softkeys) if (isEqual(old, softkeys )) return; } - CCoeAppUi* appui = CEikonEnv::Static()->AppUi(); - CAknAppUi* aknAppUi = static_cast (appui); - CEikButtonGroupContainer* nativeContainer = aknAppUi->Cba(); + CEikButtonGroupContainer* nativeContainer = S60->buttonGroupContainer(); nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); - int placeInScreen=0; + int position = -1; + int command; + bool needsExitButton = true; + for (int index = 0; index < softkeys.count(); index++) { const QAction* softKeyAction = softkeys.at(index); - if (softKeyAction->softKeyRole() != QAction::ContextMenuSoftKey) { + switch (softKeyAction->softKeyRole()) { + // Positive Actions go on LSK + case QAction::OptionsSoftKey: + case QAction::MenuSoftKey: + case QAction::ContextMenuSoftKey: + command = EAknSoftkeyOptions; //Calls DynInitMenuPane in AppUI + position = 0; + break; + case QAction::SelectSoftKey: + case QAction::PreviousSoftKey: + case QAction::OkSoftKey: + case QAction::EditSoftKey: + case QAction::ViewSoftKey: + case QAction::EndEditSoftKey: + case QAction::FinishSoftKey: + command = SOFTKEYSTART + index; + position = 0; + break; + // Negative Actions on the RSK + case QAction::BackSoftKey: + case QAction::NextSoftKey: + case QAction::CancelSoftKey: + case QAction::BackSpaceSoftKey: + case QAction::RevertEditSoftKey: + case QAction::DeselectSoftKey: + needsExitButton = false; + command = SOFTKEYSTART + index; + position = 2; + break; + case QAction::ExitSoftKey: + needsExitButton = false; + command = EAknSoftkeyExit; //Calls HandleCommand in AppUI + position = 2; + break; + default: + break; + } - HBufC* text = qt_QString2HBufC(softKeyAction->text()); - CleanupStack::PushL(text); - if (softKeyAction->softKeyRole() == QAction::MenuSoftKey) { - nativeContainer->SetCommandL(placeInScreen, EAknSoftkeyOptions, *text); - } else { - nativeContainer->SetCommandL(placeInScreen, SOFTKEYSTART + index, *text); - } - CleanupStack::PopAndDestroy(); - placeInScreen++; + if (position != -1) { + TPtrC text = qt_QString2TPtrC(softKeyAction->text()); + nativeContainer->SetCommandL(position, command, text); } - if (placeInScreen==1) - placeInScreen=2; } + + if (needsExitButton) + nativeContainer->SetCommandL(2, EAknSoftkeyExit, qt_QString2TPtrC(QObject::tr("Exit"))); + nativeContainer->DrawDeferred(); // 3.1 needs an extra invitation } -- cgit v0.12 From 4a5a9b23f41afb062fae4aaab429fcef35b3d42c Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Wed, 17 Jun 2009 16:40:46 +0200 Subject: added changes done to tower --- dist/changes-4.5.2-tower | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index 41dc8c8..9d28465 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -198,6 +198,13 @@ Optimizations * Fixed active scheduler removal when calling QThread::terminate * Fix to Open C bug: select sometimes returns -1 and errno is ECONNREFUSED +- QWidget + * Added API for setting softkeys +- QMenuBar + * Native menus are handled properly even when application has multiple QMainWindows + * Fixed a bug causing both native and qt menu to be created + * Fix for disappearing options menu after coming back from dialog + **************************************************************************** * Examples and demos * @@ -224,12 +231,15 @@ Optimizations since the issue has been fixed in qmake. * Included drilldown to demonstrate QtSql usage * Updated screenshots to S60 style + * Added softkeys example + +- Softkeys + * New example showing how to use softkeys API in QWidget **************************************************************************** * Tools * **************************************************************************** - - qmake * Support for generating Symbian "test" targets: CONFIG += symbian_test. * Support for Symbian Build System, version 2 (aka Raptor) via @@ -259,7 +269,7 @@ Optimizations * Will now patch also vendor id. **************************************************************************** -* Documnetation * +* Documentation * **************************************************************************** - qmake-manual * 250370: Added documentation for ICON keyword -- cgit v0.12 From bb0be7961f66b8d351c39d61fc0ab3f38d032223 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Wed, 17 Jun 2009 16:55:11 +0200 Subject: Renamed "menu" to "options" for S60. This follows the native style --- src/gui/widgets/qmainwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 5f8371c..394523a 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -482,7 +482,7 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar) } d->layout->setMenuBar(menuBar); if (menuBar) { - QAction* menu = new QAction(QString::fromLatin1("Menu"), this); + QAction* menu = new QAction(QString::fromLatin1("Options"), this); menu->setSoftKeyRole(QAction::MenuSoftKey); setSoftKey(menu); } @@ -1400,7 +1400,7 @@ bool QMainWindow::event(QEvent *event) case QEvent::WindowActivate: if (d->layout->menuBar()) { // ### TODO: This is evil, there is no need to create a new action every time - QAction* menu = new QAction(QString::fromLatin1("Menu"), this); + QAction* menu = new QAction(QString::fromLatin1("Options"), this); menu->setSoftKeyRole(QAction::MenuSoftKey); setSoftKey(menu); } -- cgit v0.12 From 1ec7f4029a47d22f7585c554d32ae975946ab3ce Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 17 Jun 2009 17:24:37 +0200 Subject: aportales changes for Qt for S60 "Tower" --- dist/changes-4.5.2-tower | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index 9d28465..1ed5aaa 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -61,6 +61,11 @@ Features - QSslSocket * Added support for -openssl option i.e. runtime resolving of OpenSSL symbols + +- QWidget + * Basic widgets are now navigatable and usable via keypad on SDK 3 + FP 1 and FP 2. + - todo * todo @@ -169,6 +174,8 @@ Optimizations * Fix for frame masks with color depth other than EGrey2. * Fix for squeezed QTabBars. * Fix memory leak when color skinning graphics. + * Show focus/Editfocus visualization for KeyPad navigation on + SDK 3 FP 1 and FP 2 - QDesktopServices * Switched QDesktopServices mail-to URL handling to RSendAs in Symbian, @@ -198,13 +205,21 @@ Optimizations * Fixed active scheduler removal when calling QThread::terminate * Fix to Open C bug: select sometimes returns -1 and errno is ECONNREFUSED + - QWidget * Added API for setting softkeys + - QMenuBar * Native menus are handled properly even when application has multiple QMainWindows * Fixed a bug causing both native and qt menu to be created * Fix for disappearing options menu after coming back from dialog +- QFontDataBase + * Now, also fonts from the user's /resources/fonts direactories are + available. + +- QFontMetrics + * Fixed the boundingRect calculation for text. **************************************************************************** * Examples and demos * -- cgit v0.12 From f59bc255922730bcee7b594d04fea28b278cee7c Mon Sep 17 00:00:00 2001 From: Janne Koskinen Date: Wed, 17 Jun 2009 17:36:46 +0200 Subject: make qglobal.h compile when inlcuded from c-files --- src/corelib/global/qglobal.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 6e9250f..14b6895 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -795,9 +795,6 @@ namespace QT_NAMESPACE {} # define Q_WS_WIN #endif -// forward declare std::exception -namespace std { class exception; } - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -2317,8 +2314,12 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf(); #endif #if defined(Q_OS_SYMBIAN) - - +QT_END_NAMESPACE +// forward declare std::exception +#ifdef __cplusplus +namespace std { class exception; } +#endif +QT_BEGIN_NAMESPACE Q_CORE_EXPORT void qt_translateSymbianErrorToException(int error); Q_CORE_EXPORT void qt_translateExceptionToSymbianErrorL(const std::exception& ex); Q_CORE_EXPORT int qt_translateExceptionToSymbianError(const std::exception& ex); -- cgit v0.12 From 4dcd6946fdc6940388b2ba573650143b9469d532 Mon Sep 17 00:00:00 2001 From: Janne Koskinen Date: Wed, 17 Jun 2009 17:59:11 +0200 Subject: added namespace guards --- src/gui/dialogs/qfscompleter_p.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/dialogs/qfscompleter_p.h b/src/gui/dialogs/qfscompleter_p.h index 37d9c74..c65eeea 100644 --- a/src/gui/dialogs/qfscompleter_p.h +++ b/src/gui/dialogs/qfscompleter_p.h @@ -55,8 +55,9 @@ #include "qcompleter.h" #include - +QT_BEGIN_NAMESPACE #ifndef QT_NO_COMPLETER + /*! QCompleter that can deal with QFileSystemModel */ @@ -76,6 +77,6 @@ public: QFileSystemModel *sourceModel; }; #endif // QT_NO_COMPLETER - +QT_END_NAMESPACE #endif // QCOMPLETOR_P_H -- cgit v0.12 From 2b09eb0937985015e1ecc42a8bd39f0bc4c84b17 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Thu, 18 Jun 2009 09:36:33 +0300 Subject: Fixed FTP default IAP setting. Accidentaly reverted by ce409be66. It is important to close the RConnection before calling setdefaultif. This because setdefaultif triesd to open the connection, and if it is already open it may fail. --- examples/network/ftp/main.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/network/ftp/main.cpp b/examples/network/ftp/main.cpp index 118dcfc..17423b8 100644 --- a/examples/network/ftp/main.cpp +++ b/examples/network/ftp/main.cpp @@ -112,15 +112,14 @@ static void setDefaultIapL() { User::LeaveIfError(conn.GetDesSetting(TPtrC(KIapNameSetting), iap8Name)); iap8Name.ZeroTerminate(); + conn.Stop(); + CleanupStack::PopAndDestroy(&conn); + CleanupStack::PopAndDestroy(&serv); + struct ifreq ifReq; strcpy( ifReq.ifr_name, (char*)iap8Name.Ptr()); User::LeaveIfError(setdefaultif( &ifReq )); - conn.Stop(); - conn.Close(); - serv.Close(); - CleanupStack::PopAndDestroy(&conn); - CleanupStack::PopAndDestroy(&serv); } monitor.Close(); CleanupStack::PopAndDestroy(&monitor); -- cgit v0.12 From 715db7c01d29d316700089f1abc5eea2f7c98975 Mon Sep 17 00:00:00 2001 From: mread Date: Thu, 18 Jun 2009 09:37:59 +0100 Subject: report and continue policy for exceptions in all Qt threads --- src/corelib/io/qprocess_symbian.cpp | 3 +- src/corelib/kernel/qeventdispatcher_symbian.cpp | 48 ++++++++++++++-------- src/corelib/kernel/qeventdispatcher_symbian_p.h | 10 ++++- tests/auto/exceptionsafety/tst_exceptionsafety.cpp | 23 +++++++---- 4 files changed, 58 insertions(+), 26 deletions(-) diff --git a/src/corelib/io/qprocess_symbian.cpp b/src/corelib/io/qprocess_symbian.cpp index 26e7cdc..7da6a1d 100644 --- a/src/corelib/io/qprocess_symbian.cpp +++ b/src/corelib/io/qprocess_symbian.cpp @@ -65,6 +65,7 @@ #include "qstring.h" #include "qprocess.h" #include "qprocess_p.h" +#include "qeventdispatcher_symbian_p.h" #include #include @@ -594,7 +595,7 @@ TInt processManagerThreadFunction(TAny* param) QProcessManager* manager = reinterpret_cast(param); - CActiveScheduler* scheduler = new CActiveScheduler(); + CActiveScheduler* scheduler = new CQtActiveScheduler(); QPROCESS_ASSERT(scheduler, EProcessManagerSchedulerCreationFail, diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index 423fbaa..27118be 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -246,7 +246,7 @@ void QTimerActiveObject::Run() SymbianTimerInfoPtr timerInfoPtr(m_timerInfo); m_timerInfo->dispatcher->timerFired(m_timerInfo->timerId); - + iStatus = KRequestPending; SetActive(); TRequestStatus *status = &iStatus; @@ -615,7 +615,7 @@ QEventDispatcherSymbian::~QEventDispatcherSymbian() void QEventDispatcherSymbian::startingUp() { if( !CActiveScheduler::Current() ) { - m_activeScheduler = new(ELeave)CActiveScheduler(); + m_activeScheduler = new(ELeave)CQtActiveScheduler(); CActiveScheduler::Install(m_activeScheduler); } m_wakeUpAO = new(ELeave) QWakeUpActiveObject(this); @@ -643,13 +643,13 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla QT_TRY { Q_D(QAbstractEventDispatcher); - + // It is safe if this counter overflows. The main importance is that each // iteration count is different from the last. m_iterationCount++; RThread &thread = d->threadData->symbian_thread_handle; - + bool block; if (flags & QEventLoop::WaitForMoreEvents) { block = true; @@ -657,7 +657,7 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla } else { block = false; } - + bool oldNoSocketEventsValue = m_noSocketEvents; if (flags & QEventLoop::ExcludeSocketNotifiers) { m_noSocketEvents = true; @@ -665,10 +665,10 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla m_noSocketEvents = false; handledAnyEvent = sendDeferredSocketEvents(); } - + bool handledSymbianEvent = false; m_interrupt = false; - + /* * This QTime variable is used to measure the time it takes to finish * the event loop. If we take too long in the loop, other processes @@ -684,9 +684,9 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla SubsequentRun, TimeStarted } timeState = FirstRun; - + TProcessPriority priority; - + while (1) { if (block) { // This is where Qt will spend most of its time. @@ -698,19 +698,19 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla // This one should return without delay. CActiveScheduler::Current()->WaitForAnyRequest(); } - + if (timeState == SubsequentRun) { time.start(); timeState = TimeStarted; } - + TInt error; handledSymbianEvent = CActiveScheduler::RunIfReady(error, CActive::EPriorityIdle); if (error) { qWarning("CActiveScheduler::RunIfReady() returned error: %i\n", error); CActiveScheduler::Current()->Error(error); } - + if (!handledSymbianEvent) { qFatal("QEventDispatcherSymbian::processEvents(): Caught Symbian stray signal"); } @@ -732,14 +732,14 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla if (timeState == FirstRun) timeState = SubsequentRun; }; - + emit awake(); - + m_noSocketEvents = oldNoSocketEventsValue; } QT_CATCH (const std::exception& ex) { -#ifndef QT_NO_EXCEPTIONS +#ifndef QT_NO_EXCEPTIONS CActiveScheduler::Current()->Error(qt_translateExceptionToSymbianError(ex)); -#endif +#endif } return handledAnyEvent; @@ -969,5 +969,21 @@ QList QEventDispatcherSymbian::registeredTim return list; } +/* + * This active scheduler class implements a simple report and continue policy, for Symbian OS leaves + * or exceptions from Qt that fall back to the scheduler. + * It will be used in cases where there is no existing active scheduler installed. + * Apps which link to qts60main.lib will have the UI active scheduler installed in the main thread + * instead of this one. But this would be used in other threads in the UI. + * An app could replace this behaviour by installing an alternative active scheduler. + */ +void CQtActiveScheduler::Error(TInt aError) const +{ + try { + qWarning("Error from active scheduler %d", aError); + } + catch (const std::bad_alloc&) {} // ignore alloc fails, nothing more can be done +} + QT_END_NAMESPACE diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h index 3593055..c1cf7b6 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -136,7 +136,7 @@ public: protected: void DoCancel(); void RunL(); - + private: void Run(); @@ -209,6 +209,12 @@ private: bool m_quit; }; +class Q_CORE_EXPORT CQtActiveScheduler : public CActiveScheduler + { +public: // from CActiveScheduler + virtual void Error(TInt aError) const; + }; + class Q_CORE_EXPORT QEventDispatcherSymbian : public QAbstractEventDispatcher { Q_DECLARE_PRIVATE(QAbstractEventDispatcher) @@ -253,7 +259,7 @@ private: private: QSelectThread m_selectThread; - CActiveScheduler *m_activeScheduler; + CQtActiveScheduler *m_activeScheduler; QHash m_timerList; QHash m_notifiers; diff --git a/tests/auto/exceptionsafety/tst_exceptionsafety.cpp b/tests/auto/exceptionsafety/tst_exceptionsafety.cpp index 8ed2913..4dce86d 100644 --- a/tests/auto/exceptionsafety/tst_exceptionsafety.cpp +++ b/tests/auto/exceptionsafety/tst_exceptionsafety.cpp @@ -617,6 +617,12 @@ public: {} }; +struct IntEx : public std::exception +{ + IntEx(int aEx) : ex(aEx) {} + int ex; +}; + class TestObject : public QObject { public: @@ -630,7 +636,7 @@ protected: bool event(QEvent *event) { if (int(event->type()) == ThrowEventId) { - throw ++throwEventCount; + throw IntEx(++throwEventCount); } else if (int(event->type()) == NoThrowEventId) { ++noThrowEventCount; } @@ -645,8 +651,8 @@ void tst_ExceptionSafety::exceptionEventLoop() ThrowEvent throwEvent; try { qApp->sendEvent(&obj, &throwEvent); - } catch (int code) { - QCOMPARE(code, 1); + } catch (IntEx code) { + QCOMPARE(code.ex, 1); } QCOMPARE(obj.throwEventCount, 1); @@ -655,8 +661,8 @@ void tst_ExceptionSafety::exceptionEventLoop() try { qApp->processEvents(); - } catch (int code) { - QCOMPARE(code, 2); + } catch (IntEx code) { + QCOMPARE(code.ex, 2); } QCOMPARE(obj.throwEventCount, 2); @@ -669,12 +675,15 @@ void tst_ExceptionSafety::exceptionEventLoop() try { qApp->processEvents(); - } catch (int code) { - QCOMPARE(code, 3); + } catch (IntEx code) { + QCOMPARE(code.ex, 3); } // here, we should have received on non-throwing event and one throwing one QCOMPARE(obj.throwEventCount, 3); +#ifndef __SYMBIAN32__ + // symbian event loops will have absorbed the exceptions QCOMPARE(obj.noThrowEventCount, 1); +#endif // spin the event loop again qApp->processEvents(); -- cgit v0.12 From 7f874fe9eb61eb155be02c7fc30e7a09d06d166b Mon Sep 17 00:00:00 2001 From: mread Date: Thu, 18 Jun 2009 10:20:20 +0100 Subject: review fixes --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 4 ++-- src/corelib/kernel/qeventdispatcher_symbian_p.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index 27118be..1c79aa6 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -979,10 +979,10 @@ QList QEventDispatcherSymbian::registeredTim */ void CQtActiveScheduler::Error(TInt aError) const { - try { + QT_TRY { qWarning("Error from active scheduler %d", aError); } - catch (const std::bad_alloc&) {} // ignore alloc fails, nothing more can be done + QT_CATCH (const std::bad_alloc&) {} // ignore alloc fails, nothing more can be done } QT_END_NAMESPACE diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h index c1cf7b6..b39d6df 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -210,10 +210,10 @@ private: }; class Q_CORE_EXPORT CQtActiveScheduler : public CActiveScheduler - { +{ public: // from CActiveScheduler virtual void Error(TInt aError) const; - }; +}; class Q_CORE_EXPORT QEventDispatcherSymbian : public QAbstractEventDispatcher { -- cgit v0.12 From 553a0a8fb83b8ff82574e9b0831ba56d0fd93054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Thu, 18 Jun 2009 14:34:11 +0300 Subject: S60Style: Palette has gets cleared when setting themePalette. --- src/gui/styles/qs60style.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index d2bd679..b80adc2 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -478,7 +478,9 @@ void QS60StylePrivate::setThemePalette(QApplication *app) const Q_UNUSED(app) QPalette widgetPalette = QPalette(Qt::white); setThemePalette(&widgetPalette); - QApplication::setPalette(widgetPalette); + QApplication::setPalette(widgetPalette); //calling QApplication::setPalette clears palette hash + setThemePaletteHash(&widgetPalette); + storeThemePalette(&widgetPalette); } void QS60StylePrivate::setThemePalette(QStyleOption *option) const @@ -664,7 +666,7 @@ void QS60StylePrivate::setThemePalette(QWidget *widget) const { if(!widget) return; - QPalette widgetPalette = widget->palette(); + QPalette widgetPalette = QApplication::palette(widget); //header view and its viewport need to be set 100% transparent button color, since drawing code will //draw transparent theme graphics to table column and row headers. @@ -716,9 +718,6 @@ void QS60StylePrivate::setThemePalette(QPalette *palette) const palette->setColor(QPalette::Midlight, palette->color(QPalette::Button).lighter(125)); palette->setColor(QPalette::Mid, palette->color(QPalette::Button).darker(150)); palette->setColor(QPalette::Shadow, Qt::black); - - setThemePaletteHash(palette); - storeThemePalette(palette); } void QS60StylePrivate::deleteThemePalette() @@ -791,6 +790,18 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const QApplication::setPalette(widgetPalette, "QLineEdit"); widgetPalette = *palette; + widgetPalette.setColor(QPalette::All, QPalette::Text, + s60Color(QS60StyleEnums::CL_QsnTextColors, 34, 0)); + widgetPalette.setColor(QPalette::All, QPalette::HighlightedText, + s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); + QApplication::setPalette(widgetPalette, "QTextEdit"); + widgetPalette = *palette; + + widgetPalette.setColor(QPalette::All, QPalette::HighlightedText, + s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); + QApplication::setPalette(widgetPalette, "QComboBox"); + widgetPalette = *palette; + widgetPalette.setColor(QPalette::WindowText, mainAreaTextColor); widgetPalette.setColor(QPalette::Button, QApplication::palette().color(QPalette::Button)); widgetPalette.setColor(QPalette::Dark, mainAreaTextColor.darker()); @@ -1662,7 +1673,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, case CE_MenuItem: if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(option)) { QStyleOptionMenuItem optionMenuItem = *menuItem; - + bool drawSubMenuIndicator = false; switch(menuItem->menuItemType) { case QStyleOptionMenuItem::Scroller: -- cgit v0.12 From dac3266526afd188336ca50d2fcb6c3c96c5301c Mon Sep 17 00:00:00 2001 From: Espen Riskedal Date: Thu, 18 Jun 2009 13:44:26 +0200 Subject: make sure demo builds for S60 - we don't have QtUiTools yet --- demos/browser/browser.pro | 4 ++-- demos/browser/searchlineedit.cpp | 4 ++++ demos/browser/webview.cpp | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/demos/browser/browser.pro b/demos/browser/browser.pro index 7b7c448..72c6e88 100644 --- a/demos/browser/browser.pro +++ b/demos/browser/browser.pro @@ -3,7 +3,7 @@ TARGET = browser QT += webkit network CONFIG += qt warn_on -contains(QT_BUILD_PARTS, tools): CONFIG += uitools +contains(QT_BUILD_PARTS, tools):!symbian: CONFIG += uitools else: DEFINES += QT_NO_UITOOLS FORMS += \ @@ -92,4 +92,4 @@ INSTALLS += target sources include($$QT_SOURCE_TREE/demos/demobase.pri) -symbian:TARGET.UID3 = 0xA000CF70 \ No newline at end of file +symbian:TARGET.UID3 = 0xA000CF70 diff --git a/demos/browser/searchlineedit.cpp b/demos/browser/searchlineedit.cpp index 8f668e0..aa00475 100644 --- a/demos/browser/searchlineedit.cpp +++ b/demos/browser/searchlineedit.cpp @@ -50,7 +50,9 @@ ClearButton::ClearButton(QWidget *parent) : QAbstractButton(parent) { +#ifndef QT_NO_CURSOR setCursor(Qt::ArrowCursor); +#endif // QT_NO_CURSOR setToolTip(tr("Clear")); setVisible(false); setFocusPolicy(Qt::NoFocus); @@ -103,7 +105,9 @@ SearchButton::SearchButton(QWidget *parent) m_menu(0) { setObjectName(QLatin1String("SearchButton")); +#ifndef QT_NO_CURSOR setCursor(Qt::ArrowCursor); +#endif //QT_NO_CURSOR setFocusPolicy(Qt::NoFocus); } diff --git a/demos/browser/webview.cpp b/demos/browser/webview.cpp index 6c4d857..63505f9 100644 --- a/demos/browser/webview.cpp +++ b/demos/browser/webview.cpp @@ -54,7 +54,9 @@ #include +#ifndef QT_NO_UITOOLS #include +#endif //QT_NO_UITOOLS #include #include -- cgit v0.12 From 0045fd9860b0fbc4cb5af88127c31753c5c03694 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Thu, 18 Jun 2009 13:52:53 +0200 Subject: Compilation fix. Added missing network dependency --- examples/webkit/fancybrowser/fancybrowser.pro | 4 ++-- examples/webkit/formextractor/formextractor.pro | 4 ++-- examples/webkit/googlechat/googlechat.pro | 4 ++-- examples/webkit/previewer/previewer.pro | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/webkit/fancybrowser/fancybrowser.pro b/examples/webkit/fancybrowser/fancybrowser.pro index afc0cc2..e496241 100644 --- a/examples/webkit/fancybrowser/fancybrowser.pro +++ b/examples/webkit/fancybrowser/fancybrowser.pro @@ -1,4 +1,4 @@ -QT += webkit +QT += webkit network HEADERS = mainwindow.h SOURCES = main.cpp \ mainwindow.cpp @@ -10,4 +10,4 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/fancybrowser INSTALLS += target sources -symbian:TARGET.UID3 = 0xA000CF6C \ No newline at end of file +symbian:TARGET.UID3 = 0xA000CF6C diff --git a/examples/webkit/formextractor/formextractor.pro b/examples/webkit/formextractor/formextractor.pro index ecb264c..33e2267 100644 --- a/examples/webkit/formextractor/formextractor.pro +++ b/examples/webkit/formextractor/formextractor.pro @@ -1,4 +1,4 @@ -QT += webkit +QT += webkit network TARGET = formExtractor TEMPLATE = app SOURCES += main.cpp \ @@ -17,4 +17,4 @@ INSTALLS += target sources include($$QT_SOURCE_TREE/examples/examplebase.pri) -symbian:TARGET.UID3 = 0xA000CF6D \ No newline at end of file +symbian:TARGET.UID3 = 0xA000CF6D diff --git a/examples/webkit/googlechat/googlechat.pro b/examples/webkit/googlechat/googlechat.pro index bc2aad3..8e4f9a6 100644 --- a/examples/webkit/googlechat/googlechat.pro +++ b/examples/webkit/googlechat/googlechat.pro @@ -1,4 +1,4 @@ -QT += webkit +QT += webkit network HEADERS = googlechat.h SOURCES = main.cpp \ googlechat.cpp @@ -10,4 +10,4 @@ sources.files = $$SOURCES $$HEADERS $$FORMS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/googlechat INSTALLS += target sources -symbian:TARGET.UID3 = 0xA000CF6E \ No newline at end of file +symbian:TARGET.UID3 = 0xA000CF6E diff --git a/examples/webkit/previewer/previewer.pro b/examples/webkit/previewer/previewer.pro index ce7906b..cc7fb73 100644 --- a/examples/webkit/previewer/previewer.pro +++ b/examples/webkit/previewer/previewer.pro @@ -1,4 +1,4 @@ -QT += webkit +QT += webkit network HEADERS = previewer.h \ mainwindow.h SOURCES = main.cpp \ @@ -14,4 +14,4 @@ INSTALLS += target sources include($$QT_SOURCE_TREE/examples/examplebase.pri) -symbian:TARGET.UID3 = 0xA000CF6F \ No newline at end of file +symbian:TARGET.UID3 = 0xA000CF6F -- cgit v0.12 From b2f4ac70bffc8d13177ad8aff632c6d1ebade0c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Thu, 18 Jun 2009 14:54:21 +0300 Subject: S60Style: Better theme graphic for the TextEdit background. This one does not mess the text on first row with some themes. --- src/gui/styles/qs60style_s60.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 1f02efa..6688fe7 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -318,16 +318,16 @@ const partMapEntry QS60StyleModeSpecifics::m_partMap[] = { /* SP_QsnFrButtonSideLInactive */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b7}, /* SP_QsnFrButtonSideRInactive */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b8}, /* SP_QsnFrButtonCenterInactive */ {KAknsIIDQsnFrButtonTbCenter, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b9}, - - /*SP_QsnFrNotepadCornerTl */ {KAknsIIDQsnFrNotepadCornerTl, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrNotepadCornerTr */ {KAknsIIDQsnFrNotepadCornerTr, ENoDraw, ES60_AllReleases, -1,-1}, + + /* SP_QsnFrNotepadCornerTl */ {KAknsIIDQsnFrNotepadContCornerTl, ENoDraw, ES60_AllReleases, -1,-1}, + /* SP_QsnFrNotepadCornerTr */ {KAknsIIDQsnFrNotepadContCornerTr, ENoDraw, ES60_AllReleases, -1,-1}, /* SP_QsnFrNotepadCornerBl */ {KAknsIIDQsnFrNotepadCornerBl, ENoDraw, ES60_AllReleases, -1,-1}, /* SP_QsnFrNotepadCornerBr */ {KAknsIIDQsnFrNotepadCornerBr, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrNotepadSideT */ {KAknsIIDQsnFrNotepadSideT, ENoDraw, ES60_AllReleases, -1,-1}, + /* SP_QsnFrNotepadSideT */ {KAknsIIDQsnFrNotepadContSideT, ENoDraw, ES60_AllReleases, -1,-1}, /* SP_QsnFrNotepadSideB */ {KAknsIIDQsnFrNotepadSideB, ENoDraw, ES60_AllReleases, -1,-1}, /* SP_QsnFrNotepadSideL */ {KAknsIIDQsnFrNotepadSideL, ENoDraw, ES60_AllReleases, -1,-1}, /* SP_QsnFrNotepadSideR */ {KAknsIIDQsnFrNotepadSideR, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrNotepadCenter */ {KAknsIIDQsnFrNotepadCenter, EDrawIcon, ES60_AllReleases, -1,-1} + /* SP_QsnFrNotepadCenter */ {KAknsIIDQsnFrNotepadCenter, EDrawIcon, ES60_AllReleases, -1,-1}, }; @@ -828,6 +828,10 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme centerId.Set(KAknsIIDNone); frameId.Set(KAknsIIDQsnFrSetOpt); break; + case QS60StylePrivate::SF_Editor: + centerId.Set(KAknsIIDQsnFrNotepadCenter); + frameId.Set(KAknsIIDQsnFrNotepadCont); + break; default: // center should be correct here frameId.iMinor = centerId.iMinor - 9; -- cgit v0.12 From 0cbf534a7feba5a0159877d19d15f225e1199fc8 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Thu, 18 Jun 2009 14:09:54 +0200 Subject: Compile fix --- demos/browser/browsermainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/browser/browsermainwindow.cpp b/demos/browser/browsermainwindow.cpp index f1dcaef..37b8ddc 100644 --- a/demos/browser/browsermainwindow.cpp +++ b/demos/browser/browsermainwindow.cpp @@ -575,7 +575,7 @@ QUrl BrowserMainWindow::guessUrlFromString(const QString &string) int dotIndex = urlStr.indexOf(QLatin1Char('.')); if (dotIndex != -1) { QString prefix = urlStr.left(dotIndex).toLower(); - QByteArray schema = (prefix == QLatin1String("ftp")) ? prefix.toLatin1() : "http"; + QByteArray schema = (prefix == QLatin1String("ftp")) ? prefix.toLatin1() : QByteArray("http"); QUrl url = QUrl::fromEncoded(schema + "://" + urlStr.toUtf8(), QUrl::TolerantMode); if (url.isValid()) -- cgit v0.12 From b11cac64e7a0d0ecf0295a66bf54753fc7353376 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 18 Jun 2009 15:10:31 +0300 Subject: Patching capabilities now patches also the pkg file UID. --- bin/patch_capabilities.pl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/bin/patch_capabilities.pl b/bin/patch_capabilities.pl index f18aaba..4c4e67a 100644 --- a/bin/patch_capabilities.pl +++ b/bin/patch_capabilities.pl @@ -31,13 +31,22 @@ if (@ARGV) # Start with no binaries listed. my @binaries = (); - # Open the ".pkg" file. + my $tempPkgFileName = $pkgFileName."_@@TEMP@@"; + unlink($tempPkgFileName); + open (NEW_PKG, ">>".$tempPkgFileName); open (PKG, "<".$pkgFileName); # Parse each line. while () { my $line = $_; + my $newLine = $line; + if ( $line =~ m/^\#.*\(0x[0-9|a-f|A-F]*\).*$/) + { + $newLine =~ s/\(0x./\(0xE/; + } + print NEW_PKG $newLine; + chomp ($line); # If the line specifies a file, parse the source and destination locations. @@ -54,8 +63,11 @@ if (@ARGV) } } - # Close the ".pkg" file. close (PKG); + close (NEW_PKG); + + unlink($pkgFileName); + rename($tempPkgFileName, $pkgFileName); print ("\n"); -- cgit v0.12 From 39a85ed5f0bcd590391ac7c9b005cb7612b9d765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Thu, 18 Jun 2009 16:59:55 +0300 Subject: S60Style: Remove menu scroller from UI. --- src/gui/styles/qs60style.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index b80adc2..9975b22 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1897,6 +1897,8 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, if (option->state & State_HasFocus) drawPrimitive(PE_FrameFocusRect, option, painter, widget); break; + case CE_MenuScroller: + break; default: QCommonStyle::drawControl(element, option, painter, widget); } -- cgit v0.12 From 829307fa214586d40ff13d9e9eb4ece4d1bd4ff1 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Thu, 18 Jun 2009 17:24:03 +0200 Subject: Updated example to make more sense --- examples/widgets/softkeys/softkeys.cpp | 46 ++++++++++++++++++---------------- examples/widgets/softkeys/softkeys.h | 3 ++- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/examples/widgets/softkeys/softkeys.cpp b/examples/widgets/softkeys/softkeys.cpp index e717510..110f2e6 100644 --- a/examples/widgets/softkeys/softkeys.cpp +++ b/examples/widgets/softkeys/softkeys.cpp @@ -49,20 +49,24 @@ MainWindow::MainWindow(QWidget *parent) setCentralWidget(central); // Create text editor and set softkeys to it - textEditor= new QTextEdit(tr("Choose items from menu or navigate around with tab+selection to see what softkeys can do"), this); - QAction* fill = new QAction(tr("Fill"), this); - fill->setSoftKeyRole(QAction::OkSoftKey); + textEditor= new QTextEdit(tr("Navigate in UI to see context sensitive softkeys in action"), this); + QAction* menu = new QAction(tr("Menu"), this); + menu->setSoftKeyRole(QAction::MenuSoftKey); QAction* clear = new QAction(tr("Clear"), this); clear->setSoftKeyRole(QAction::CancelSoftKey); QList textEditorSoftKeys; - textEditorSoftKeys.append(fill); + textEditorSoftKeys.append(menu); textEditorSoftKeys.append(clear); textEditor->setSoftKeys(textEditorSoftKeys); infoLabel = new QLabel(tr(""), this); infoLabel->setContextMenuPolicy(Qt::NoContextMenu); + toggleButton = new QPushButton(tr("Custom softkeys"), this); + toggleButton->setContextMenuPolicy(Qt::NoContextMenu); + toggleButton->setCheckable(true); + pushButton = new QPushButton(tr("Open File Dialog"), this); pushButton->setContextMenuPolicy(Qt::NoContextMenu); @@ -77,21 +81,19 @@ MainWindow::MainWindow(QWidget *parent) layout = new QVBoxLayout; layout->addWidget(textEditor); layout->addWidget(infoLabel); + layout->addWidget(toggleButton); layout->addWidget(pushButton); layout->addWidget(comboBox); central->setLayout(layout); fileMenu = menuBar()->addMenu(tr("&File")); - addSoftKeysAct = new QAction(tr("&Add Softkeys"), this); - fileMenu->addAction(addSoftKeysAct); exit = new QAction(tr("&Exit"), this); fileMenu->addAction(exit); - connect(fill, SIGNAL(triggered()), this, SLOT(fillTextEditor())); connect(clear, SIGNAL(triggered()), this, SLOT(clearTextEditor())); connect(pushButton, SIGNAL(clicked()), this, SLOT(openDialog())); - connect(addSoftKeysAct, SIGNAL(triggered()), this, SLOT(addSoftKeys())); connect(exit, SIGNAL(triggered()), this, SLOT(exitApplication())); + connect(toggleButton, SIGNAL(clicked()), this, SLOT(setCustomSoftKeys())); pushButton->setFocus(); } @@ -99,11 +101,6 @@ MainWindow::~MainWindow() { } -void MainWindow::fillTextEditor() -{ - textEditor->setText(tr("The fill softkey was pressed and here is some text to fill the editor")); -} - void MainWindow::clearTextEditor() { textEditor->setText(tr("")); @@ -121,7 +118,7 @@ void MainWindow::addSoftKeys() connect(ok, SIGNAL(triggered()), this, SLOT(okPressed())); cancel = new QAction(tr("Cancel"), this); - cancel->setSoftKeyRole(QAction::OkSoftKey); + cancel->setSoftKeyRole(QAction::CancelSoftKey); connect(cancel, SIGNAL(triggered()), this, SLOT(cancelPressed())); QList softkeys; @@ -132,6 +129,20 @@ void MainWindow::addSoftKeys() focusWidget->setSoftKeys(softkeys); } +void MainWindow::setCustomSoftKeys() +{ + if (toggleButton->isChecked()) { + infoLabel->setText(tr("Custom softkeys set")); + addSoftKeys(); + } + else { + infoLabel->setText(tr("Custom softkeys removed")); + QWidget* focusWidget = QApplication::focusWidget(); + if (focusWidget) + focusWidget->setSoftKey(0); + } +} + void MainWindow::exitApplication() { qApp->exit(); @@ -140,18 +151,11 @@ void MainWindow::exitApplication() void MainWindow::okPressed() { infoLabel->setText(tr("OK pressed")); - QWidget* focusWidget = QApplication::focusWidget(); - if (focusWidget) - focusWidget->setSoftKey(0); } void MainWindow::cancelPressed() { infoLabel->setText(tr("Cancel pressed")); - QWidget* focusWidget = QApplication::focusWidget(); - if (focusWidget) - focusWidget->setSoftKey(0); } - diff --git a/examples/widgets/softkeys/softkeys.h b/examples/widgets/softkeys/softkeys.h index bd75473..da56eae 100644 --- a/examples/widgets/softkeys/softkeys.h +++ b/examples/widgets/softkeys/softkeys.h @@ -50,13 +50,13 @@ class MainWindow : public QMainWindow public: private slots: - void fillTextEditor(); void clearTextEditor(); void openDialog(); void addSoftKeys(); void exitApplication(); void okPressed(); void cancelPressed(); + void setCustomSoftKeys(); public: MainWindow(QWidget *parent = 0); ~MainWindow(); @@ -65,6 +65,7 @@ private: QWidget *central; QTextEdit* textEditor; QLabel *infoLabel; + QPushButton* toggleButton; QPushButton* pushButton; QMenu* fileMenu; QAction* addSoftKeysAct; -- cgit v0.12 From be589f500689395f8579100a121bfdef7c3ed169 Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Thu, 18 Jun 2009 22:58:48 +0200 Subject: The native Symbian code that helps to select and set default IAP has been moved to separate header. This should make the code shareable among other examples. The location of the header is not perfect. Unfortunately, there is no shared include area for Qt examples. The proper way woud be to have proper API that manages IAP. --- examples/network/ftp/ftp.pro | 1 + examples/network/ftp/main.cpp | 90 +------------------------ examples/network/ftp/sym_iap_util.h | 131 ++++++++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+), 87 deletions(-) create mode 100644 examples/network/ftp/sym_iap_util.h diff --git a/examples/network/ftp/ftp.pro b/examples/network/ftp/ftp.pro index 634c43c..c70b812 100644 --- a/examples/network/ftp/ftp.pro +++ b/examples/network/ftp/ftp.pro @@ -13,6 +13,7 @@ INSTALLS += target sources include($$QT_SOURCE_TREE/examples/examplebase.pri) symbian { + HEADERS += sym_iap_util.h INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE TARGET.CAPABILITY="NetworkServices" TARGET.UID3 = 0xA000A648 diff --git a/examples/network/ftp/main.cpp b/examples/network/ftp/main.cpp index 17423b8..ecabb31 100644 --- a/examples/network/ftp/main.cpp +++ b/examples/network/ftp/main.cpp @@ -44,99 +44,15 @@ #ifdef Q_OS_SYMBIAN #include -#include - -#include -#include -#include -#include - -QString qt_TDesC2QStringL(const TDesC& aDescriptor) { -#ifdef QT_NO_UNICODE - return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length()); -#else - return QString::fromUtf16(aDescriptor.Ptr(), aDescriptor.Length()); -#endif -} - -static void setDefaultIapL() { - RConnectionMonitor monitor; - CleanupClosePushL(monitor); - monitor.ConnectL(); - TUint count; - TRequestStatus status; - TUint ids[ 15 ]; - - monitor.GetConnectionCount( count, status ); - User::WaitForRequest( status ); - if(status.Int() != KErrNone) { - User::Leave(status.Int()); - } - - TUint numSubConnections; - - if(count > 0) { - for ( TInt i = 1; i <= count; i++ ) { - User::LeaveIfError(monitor.GetConnectionInfo( i, ids[ i-1 ], numSubConnections )); - } - /* - * get IAP value for first active connection - */ - TBuf< 50 > iapName; - monitor.GetStringAttribute( ids[ 0 ], 0, KIAPName, iapName, status ); - User::WaitForRequest( status ); - if ( status.Int() != KErrNone ) { - User::Leave(status.Int()); - } else { - QString strIapName = qt_TDesC2QStringL(iapName); - struct ifreq ifReq; - strcpy( ifReq.ifr_name, strIapName.toLatin1().data()); - User::LeaveIfError(setdefaultif( &ifReq )); - } - } else { - /* - * no active connections yet - * use IAP dialog to select one - */ - RSocketServ serv; - CleanupClosePushL(serv); - User::LeaveIfError(serv.Connect()); - - RConnection conn; - CleanupClosePushL(conn); - User::LeaveIfError(conn.Open(serv)); - User::LeaveIfError(conn.Start()); - - _LIT(KIapNameSetting, "IAP\\Name"); - TBuf8<50> iap8Name; - User::LeaveIfError(conn.GetDesSetting(TPtrC(KIapNameSetting), iap8Name)); - iap8Name.ZeroTerminate(); - - conn.Stop(); - CleanupStack::PopAndDestroy(&conn); - CleanupStack::PopAndDestroy(&serv); - - struct ifreq ifReq; - strcpy( ifReq.ifr_name, (char*)iap8Name.Ptr()); - User::LeaveIfError(setdefaultif( &ifReq )); - - } - monitor.Close(); - CleanupStack::PopAndDestroy(&monitor); -} - -static int setDefaultIap() -{ - TRAPD(err, setDefaultIapL()); - return err; -} +#include +#include "sym_iap_util.h" #endif int main(int argc, char *argv[]) { Q_INIT_RESOURCE(ftp); #ifdef Q_OS_SYMBIAN - setDefaultIap(); + qt_SetDefaultIap(); // Change current directory from default private to c:\data // in order that user can access the downloaded content QDir::setCurrent( "c:\\data" ); diff --git a/examples/network/ftp/sym_iap_util.h b/examples/network/ftp/sym_iap_util.h new file mode 100644 index 0000000..14df5af --- /dev/null +++ b/examples/network/ftp/sym_iap_util.h @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QSYM_IAP_UTIL_H +#define QSYM_IAP_UTIL_H + +#include +#include +#include +#include + +QString qt_TDesC2QStringL(const TDesC& aDescriptor) +{ +#ifdef QT_NO_UNICODE + return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length()); +#else + return QString::fromUtf16(aDescriptor.Ptr(), aDescriptor.Length()); +#endif +} + +static void qt_SetDefaultIapL() +{ + TUint count; + TRequestStatus status; + TUint ids[15]; + + RSocketServ serv; + CleanupClosePushL(serv); + + RConnection conn; + CleanupClosePushL(conn); + + RConnectionMonitor monitor; + CleanupClosePushL(monitor); + + monitor.ConnectL(); + monitor.GetConnectionCount(count, status); + User::WaitForRequest(status); + if(status.Int() != KErrNone) { + User::Leave(status.Int()); + } + + TUint numSubConnections; + + if(count > 0) { + for (TInt i = 1; i <= count; i++) { + User::LeaveIfError(monitor.GetConnectionInfo(i, ids[i-1], numSubConnections)); + } + /* + * get IAP value for first active connection + */ + TBuf< 50 > iapName; + monitor.GetStringAttribute(ids[0], 0, KIAPName, iapName, status); + User::WaitForRequest(status); + if (status.Int() != KErrNone) { + User::Leave(status.Int()); + } else { + QString strIapName = qt_TDesC2QStringL(iapName); + struct ifreq ifReq; + strcpy(ifReq.ifr_name, strIapName.toLatin1().data()); + User::LeaveIfError(setdefaultif(&ifReq)); + } + } else { + /* + * no active connections yet + * use IAP dialog to select one + */ + User::LeaveIfError(serv.Connect()); + User::LeaveIfError(conn.Open(serv)); + User::LeaveIfError(conn.Start()); + + _LIT(KIapNameSetting, "IAP\\Name"); + TBuf8<50> iap8Name; + User::LeaveIfError(conn.GetDesSetting(TPtrC(KIapNameSetting), iap8Name)); + iap8Name.ZeroTerminate(); + + conn.Stop(); + + struct ifreq ifReq; + strcpy(ifReq.ifr_name, (char*)iap8Name.Ptr()); + User::LeaveIfError(setdefaultif(&ifReq)); + } + CleanupStack::PopAndDestroy(&monitor); + CleanupStack::PopAndDestroy(&conn); + CleanupStack::PopAndDestroy(&serv); +} + +static int qt_SetDefaultIap() +{ + TRAPD(err, qt_SetDefaultIapL()); + return err; +} + +#endif // QSYM_IAP_UTIL_H -- cgit v0.12 From 8acac3aba4a04f1f8f502190a445093af15cd563 Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Thu, 18 Jun 2009 23:28:57 +0200 Subject: This changes will make firts FTP UI to be visible and then, if needed activate IAP dialog. --- examples/network/ftp/ftpwindow.cpp | 14 ++++++++++++++ examples/network/ftp/ftpwindow.h | 4 ++++ examples/network/ftp/main.cpp | 2 -- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/examples/network/ftp/ftpwindow.cpp b/examples/network/ftp/ftpwindow.cpp index abfb6cc..a48252a 100644 --- a/examples/network/ftp/ftpwindow.cpp +++ b/examples/network/ftp/ftpwindow.cpp @@ -44,6 +44,10 @@ #include "ftpwindow.h" +#ifdef Q_OS_SYMBIAN +#include "sym_iap_util.h" +#endif + FtpWindow::FtpWindow(QWidget *parent) : QDialog(parent), ftp(0) { @@ -115,6 +119,10 @@ FtpWindow::FtpWindow(QWidget *parent) mainLayout->addWidget(buttonBox); setLayout(mainLayout); +#ifdef Q_OS_SYMBIAN + bDefaultIapSet = false; +#endif + setWindowTitle(tr("FTP")); } @@ -126,6 +134,12 @@ QSize FtpWindow::sizeHint() const //![0] void FtpWindow::connectOrDisconnect() { +#ifdef Q_OS_SYMBIAN + if(!bDefaultIapSet) { + qt_SetDefaultIap(); + bDefaultIapSet = true; + } +#endif if (ftp) { ftp->abort(); ftp->deleteLater(); diff --git a/examples/network/ftp/ftpwindow.h b/examples/network/ftp/ftpwindow.h index a3045fa..70c1210 100644 --- a/examples/network/ftp/ftpwindow.h +++ b/examples/network/ftp/ftpwindow.h @@ -98,6 +98,10 @@ private: QString currentPath; QFtp *ftp; QFile *file; + +#ifdef Q_OS_SYMBIAN + bool bDefaultIapSet; +#endif //![1] }; diff --git a/examples/network/ftp/main.cpp b/examples/network/ftp/main.cpp index ecabb31..5c24788 100644 --- a/examples/network/ftp/main.cpp +++ b/examples/network/ftp/main.cpp @@ -45,14 +45,12 @@ #ifdef Q_OS_SYMBIAN #include #include -#include "sym_iap_util.h" #endif int main(int argc, char *argv[]) { Q_INIT_RESOURCE(ftp); #ifdef Q_OS_SYMBIAN - qt_SetDefaultIap(); // Change current directory from default private to c:\data // in order that user can access the downloaded content QDir::setCurrent( "c:\\data" ); -- cgit v0.12 From 3cb2e9936a2b7c534ed41bee151e20b8fc58aa3a Mon Sep 17 00:00:00 2001 From: Iain Date: Mon, 22 Jun 2009 09:04:29 +0200 Subject: Add dependancy on Symbian OS std C++ support now the exceptions branch has been merged --- src/s60installs/qt.iby | 1 + 1 file changed, 1 insertion(+) diff --git a/src/s60installs/qt.iby b/src/s60installs/qt.iby index dc702f9..79edc56 100644 --- a/src/s60installs/qt.iby +++ b/src/s60installs/qt.iby @@ -7,6 +7,7 @@ #include #include // QtCore, QtGui, QtNetwork, QtOpenGL, QSvgIconEngine, #include // QtGui, QtOpenGL +#include // for std C++ support // QtGui dependancies #include -- cgit v0.12 From 342171da548c80f59aa459aad68700890c6e0283 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 22 Jun 2009 11:46:05 +0300 Subject: Fixed a typo in a desktopservices demo messagebox. --- demos/embedded/desktopservices/linktab.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/demos/embedded/desktopservices/linktab.cpp b/demos/embedded/desktopservices/linktab.cpp index 58d1cc6..32411fe 100644 --- a/demos/embedded/desktopservices/linktab.cpp +++ b/demos/embedded/desktopservices/linktab.cpp @@ -49,19 +49,19 @@ // CLASS HEADER #include "linktab.h" -LinkTab::LinkTab(QWidget *parent) : +LinkTab::LinkTab(QWidget *parent) : ContentTab(parent) -{ +{ } - -LinkTab::~LinkTab() + +LinkTab::~LinkTab() { } void LinkTab::populateListWidget() { m_WebItem = new QListWidgetItem(QIcon(":/resources/browser.png"), tr("Launch Browser"), this); - m_MailToItem = new QListWidgetItem(QIcon(":/resources/message.png"), tr("New e-mail"), this); + m_MailToItem = new QListWidgetItem(QIcon(":/resources/message.png"), tr("New e-mail"), this); } QUrl LinkTab::itemUrl(QListWidgetItem *item) @@ -78,8 +78,8 @@ QUrl LinkTab::itemUrl(QListWidgetItem *item) } void LinkTab::handleErrorInOpen(QListWidgetItem *item) { - if(m_MailToItem == item) { - QMessageBox::warning( this, tr("Operation Failed"), tr("Please check that you have\ne-mail accunt defined"), QMessageBox::Close); + if(m_MailToItem == item) { + QMessageBox::warning( this, tr("Operation Failed"), tr("Please check that you have\ne-mail account defined."), QMessageBox::Close); } else { ContentTab::handleErrorInOpen(item); } -- cgit v0.12 From 8e0652a494580ba3b806a1b10905b5420f7c94e6 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Mon, 22 Jun 2009 10:47:33 +0200 Subject: added ariyas embbeded browser Anamoly --- demos/embedded/anamoly/README.TXT | 0 demos/embedded/anamoly/anomaly.pro | 29 ++ demos/embedded/anamoly/src/AddressBar.cpp | 91 +++++++ demos/embedded/anamoly/src/AddressBar.h | 55 ++++ demos/embedded/anamoly/src/BookmarksView.cpp | 52 ++++ demos/embedded/anamoly/src/BookmarksView.h | 46 ++++ demos/embedded/anamoly/src/BrowserView.cpp | 153 +++++++++++ demos/embedded/anamoly/src/BrowserView.h | 71 +++++ demos/embedded/anamoly/src/BrowserWindow.cpp | 169 ++++++++++++ demos/embedded/anamoly/src/BrowserWindow.h | 62 +++++ demos/embedded/anamoly/src/ControlStrip.cpp | 83 ++++++ demos/embedded/anamoly/src/ControlStrip.h | 54 ++++ demos/embedded/anamoly/src/HomeView.cpp | 58 ++++ demos/embedded/anamoly/src/HomeView.h | 56 ++++ demos/embedded/anamoly/src/Main.cpp | 59 +++++ demos/embedded/anamoly/src/TitleBar.cpp | 106 ++++++++ demos/embedded/anamoly/src/TitleBar.h | 52 ++++ demos/embedded/anamoly/src/ZoomStrip.cpp | 64 +++++ demos/embedded/anamoly/src/ZoomStrip.h | 52 ++++ demos/embedded/anamoly/src/anomaly.qrc | 9 + demos/embedded/anamoly/src/flickcharm.cpp | 309 ++++++++++++++++++++++ demos/embedded/anamoly/src/flickcharm.h | 49 ++++ demos/embedded/anamoly/src/images/edit-find.png | Bin 0 -> 1636 bytes demos/embedded/anamoly/src/images/go-next.png | Bin 0 -> 1219 bytes demos/embedded/anamoly/src/images/go-previous.png | Bin 0 -> 1200 bytes demos/embedded/anamoly/src/images/list-add.png | Bin 0 -> 601 bytes demos/embedded/anamoly/src/images/list-remove.png | Bin 0 -> 317 bytes 27 files changed, 1679 insertions(+) create mode 100644 demos/embedded/anamoly/README.TXT create mode 100644 demos/embedded/anamoly/anomaly.pro create mode 100644 demos/embedded/anamoly/src/AddressBar.cpp create mode 100644 demos/embedded/anamoly/src/AddressBar.h create mode 100644 demos/embedded/anamoly/src/BookmarksView.cpp create mode 100644 demos/embedded/anamoly/src/BookmarksView.h create mode 100644 demos/embedded/anamoly/src/BrowserView.cpp create mode 100644 demos/embedded/anamoly/src/BrowserView.h create mode 100644 demos/embedded/anamoly/src/BrowserWindow.cpp create mode 100644 demos/embedded/anamoly/src/BrowserWindow.h create mode 100644 demos/embedded/anamoly/src/ControlStrip.cpp create mode 100644 demos/embedded/anamoly/src/ControlStrip.h create mode 100644 demos/embedded/anamoly/src/HomeView.cpp create mode 100644 demos/embedded/anamoly/src/HomeView.h create mode 100644 demos/embedded/anamoly/src/Main.cpp create mode 100644 demos/embedded/anamoly/src/TitleBar.cpp create mode 100644 demos/embedded/anamoly/src/TitleBar.h create mode 100644 demos/embedded/anamoly/src/ZoomStrip.cpp create mode 100644 demos/embedded/anamoly/src/ZoomStrip.h create mode 100644 demos/embedded/anamoly/src/anomaly.qrc create mode 100644 demos/embedded/anamoly/src/flickcharm.cpp create mode 100644 demos/embedded/anamoly/src/flickcharm.h create mode 100644 demos/embedded/anamoly/src/images/edit-find.png create mode 100644 demos/embedded/anamoly/src/images/go-next.png create mode 100644 demos/embedded/anamoly/src/images/go-previous.png create mode 100644 demos/embedded/anamoly/src/images/list-add.png create mode 100644 demos/embedded/anamoly/src/images/list-remove.png diff --git a/demos/embedded/anamoly/README.TXT b/demos/embedded/anamoly/README.TXT new file mode 100644 index 0000000..e69de29 diff --git a/demos/embedded/anamoly/anomaly.pro b/demos/embedded/anamoly/anomaly.pro new file mode 100644 index 0000000..5fe5625 --- /dev/null +++ b/demos/embedded/anamoly/anomaly.pro @@ -0,0 +1,29 @@ +QT += network \ + webkit +HEADERS += src/BrowserWindow.h \ + src/BrowserView.h \ + src/TitleBar.h \ + src/HomeView.h \ + src/AddressBar.h \ + src/BookmarksView.h \ + src/flickcharm.h \ + src/ZoomStrip.h \ + src/ControlStrip.h +SOURCES += src/Main.cpp \ + src/BrowserWindow.cpp \ + src/BrowserView.cpp \ + src/TitleBar.cpp \ + src/HomeView.cpp \ + src/AddressBar.cpp \ + src/BookmarksView.cpp \ + src/flickcharm.cpp \ + src/ZoomStrip.cpp \ + src/ControlStrip.cpp +RESOURCES += src/anomaly.qrc + +symbian { + HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h + LIBS += -lesock -lconnmon + TARGET.CAPABILITY = NetworkServices + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 +} diff --git a/demos/embedded/anamoly/src/AddressBar.cpp b/demos/embedded/anamoly/src/AddressBar.cpp new file mode 100644 index 0000000..64734c8 --- /dev/null +++ b/demos/embedded/anamoly/src/AddressBar.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "AddressBar.h" + +#include +#include + +class LineEdit: public QLineEdit +{ +public: + LineEdit(QWidget *parent = 0): QLineEdit(parent) {} + + void paintEvent(QPaintEvent *event) { + QLineEdit::paintEvent(event); + if (text().isEmpty()) { + QPainter p(this); + int flags = Qt::AlignLeft | Qt::AlignVCenter; + p.setPen(palette().color(QPalette::Disabled, QPalette::Text)); + p.drawText(rect().adjusted(10, 0, 0, 0), flags, "Enter address or search terms"); + p.end(); + } + } +}; + +AddressBar::AddressBar(QWidget *parent) + : QWidget(parent) +{ + m_lineEdit = new LineEdit(parent); + connect(m_lineEdit, SIGNAL(returnPressed()), SLOT(processAddress())); + m_toolButton = new QToolButton(parent); + m_toolButton->setText("Go"); + connect(m_toolButton, SIGNAL(clicked()), SLOT(processAddress())); +} + +QSize AddressBar::sizeHint() const +{ + return m_lineEdit->sizeHint(); +} + +void AddressBar::processAddress() +{ + if (!m_lineEdit->text().isEmpty()) + emit addressEntered(m_lineEdit->text()); +} + +void AddressBar::resizeEvent(QResizeEvent *event) +{ + int x, y, w, h; + + m_toolButton->adjustSize(); + x = width() - m_toolButton->width(); + y = 0; + w = m_toolButton->width(); + h = height() - 1; + m_toolButton->setGeometry(x, y, w, h); + m_toolButton->show(); + + x = 0; + y = 0; + w = width() - m_toolButton->width(); + h = height() - 1; + m_lineEdit->setGeometry(x, y, w, h); + m_lineEdit->show(); +} + +void AddressBar::focusInEvent(QFocusEvent *event) +{ + m_lineEdit->setFocus(); + QWidget::focusInEvent(event); +} diff --git a/demos/embedded/anamoly/src/AddressBar.h b/demos/embedded/anamoly/src/AddressBar.h new file mode 100644 index 0000000..632ae1f --- /dev/null +++ b/demos/embedded/anamoly/src/AddressBar.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef ADDRESSBAR_H +#define ADDRESSBAR_H + +#include + +class QLineEdit; +class QToolButton; + +class AddressBar : public QWidget +{ + Q_OBJECT + +public: + AddressBar(QWidget *parent = 0); + QSize sizeHint() const; + +protected: + void resizeEvent(QResizeEvent *event); + void focusInEvent(QFocusEvent *event); + +signals: + void addressEntered(const QString &address); + +private slots: + void processAddress(); + +private: + QLineEdit *m_lineEdit; + QToolButton *m_toolButton; +}; + +#endif // ADDRESSBAR_H diff --git a/demos/embedded/anamoly/src/BookmarksView.cpp b/demos/embedded/anamoly/src/BookmarksView.cpp new file mode 100644 index 0000000..f705383 --- /dev/null +++ b/demos/embedded/anamoly/src/BookmarksView.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "BookmarksView.h" + +#include + +BookmarksView::BookmarksView(QWidget *parent) + : QWidget(parent) +{ + QListWidget *m_iconView = new QListWidget(this); + connect(m_iconView, SIGNAL(itemActivated(QListWidgetItem*)), SLOT(activate(QListWidgetItem*))); + + QVBoxLayout *layout = new QVBoxLayout(this); + setLayout(layout); + layout->addWidget(m_iconView); + + m_iconView->addItem("www.google.com"); + m_iconView->addItem("doc.trolltech.com/4.5"); + m_iconView->addItem("news.bbc.co.uk/text_only.stm"); + m_iconView->addItem("mobile.wikipedia.org"); + m_iconView->addItem("www.qtsoftware.com"); + m_iconView->addItem("en.wikipedia.org"); + + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); +} + +void BookmarksView::activate(QListWidgetItem *item) +{ + QUrl url = item->text().prepend("http://"); + emit urlSelected(url); +} diff --git a/demos/embedded/anamoly/src/BookmarksView.h b/demos/embedded/anamoly/src/BookmarksView.h new file mode 100644 index 0000000..95abdd7 --- /dev/null +++ b/demos/embedded/anamoly/src/BookmarksView.h @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef BOOKMARKSVIEW_H +#define BOOKMARKSVIEW_H + +#include + +class QListWidgetItem; +class QUrl; + +class BookmarksView : public QWidget +{ + Q_OBJECT + +public: + BookmarksView(QWidget *parent = 0); + +signals: + void urlSelected(const QUrl &url); + +private slots: + void activate(QListWidgetItem *item); +}; + +#endif // BOOKMARKSVIEW_H diff --git a/demos/embedded/anamoly/src/BrowserView.cpp b/demos/embedded/anamoly/src/BrowserView.cpp new file mode 100644 index 0000000..e81d834 --- /dev/null +++ b/demos/embedded/anamoly/src/BrowserView.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "BrowserView.h" + +#include +#include +#include + +#include "ControlStrip.h" +#include "TitleBar.h" +#include "flickcharm.h" +#include "ZoomStrip.h" + +BrowserView::BrowserView(QWidget *parent) + : QWidget(parent) + , m_titleBar(0) + , m_webView(0) + , m_progress(0) + , m_currentZoom(100) +{ + m_titleBar = new TitleBar(this); + m_webView = new QWebView(this); + m_zoomStrip = new ZoomStrip(this); + m_controlStrip = new ControlStrip(this); + + m_zoomLevels << 30 << 50 << 67 << 80 << 90; + m_zoomLevels << 100; + m_zoomLevels << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300; + + QTimer::singleShot(0, this, SLOT(initialize())); +} + +void BrowserView::initialize() +{ + connect(m_zoomStrip, SIGNAL(zoomInClicked()), SLOT(zoomIn())); + connect(m_zoomStrip, SIGNAL(zoomOutClicked()), SLOT(zoomOut())); + + connect(m_controlStrip, SIGNAL(menuClicked()), SIGNAL(menuButtonClicked())); + connect(m_controlStrip, SIGNAL(backClicked()), m_webView, SLOT(back())); + connect(m_controlStrip, SIGNAL(forwardClicked()), m_webView, SLOT(forward())); + + QPalette pal = m_webView->palette(); + pal.setBrush(QPalette::Base, Qt::white); + m_webView->setPalette(pal); + + FlickCharm *flickCharm = new FlickCharm(this); + flickCharm->activateOn(m_webView); + + m_webView->setZoomFactor(static_cast(m_currentZoom)/100.0); + connect(m_webView, SIGNAL(loadStarted()), SLOT(start())); + connect(m_webView, SIGNAL(loadProgress(int)), SLOT(setProgress(int))); + connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(finish(bool))); + connect(m_webView, SIGNAL(urlChanged(QUrl)), SLOT(updateTitleBar())); + + m_webView->load(QUrl("http://news.bbc.co.uk/text_only.stm")); + m_webView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_webView->setFocus(); +} + +void BrowserView::start() +{ + m_progress = 0; + updateTitleBar(); + //m_titleBar->setText(m_webView->url().toString()); +} + +void BrowserView::setProgress(int percent) +{ + m_progress = percent; + updateTitleBar(); + //m_titleBar->setText(QString("Loading %1%").arg(percent)); +} + +void BrowserView::updateTitleBar() +{ + QUrl url = m_webView->url(); + m_titleBar->setHost(url.host()); + m_titleBar->setTitle(m_webView->title()); + m_titleBar->setProgress(m_progress); +} + +void BrowserView::finish(bool ok) +{ + m_progress = 0; + updateTitleBar(); + + // TODO: handle error + if (!ok) { + //m_titleBar->setText("Loading failed."); + } +} + +void BrowserView::zoomIn() +{ + int i = m_zoomLevels.indexOf(m_currentZoom); + Q_ASSERT(i >= 0); + if (i < m_zoomLevels.count() - 1) + m_currentZoom = m_zoomLevels[i + 1]; + + m_webView->setZoomFactor(static_cast(m_currentZoom)/100.0); +} + +void BrowserView::zoomOut() +{ + int i = m_zoomLevels.indexOf(m_currentZoom); + Q_ASSERT(i >= 0); + if (i > 0) + m_currentZoom = m_zoomLevels[i - 1]; + + m_webView->setZoomFactor(static_cast(m_currentZoom)/100.0); +} + +void BrowserView::resizeEvent(QResizeEvent *event) +{ + QWidget::resizeEvent(event); + + int h1 = m_titleBar->sizeHint().height(); + int h2 = m_controlStrip->sizeHint().height(); + + m_titleBar->setGeometry(0, 0, width(), h1); + m_controlStrip->setGeometry(0, height() - h2, width(), h2); + m_webView->setGeometry(0, h1, width(), height() - h1); + + int zw = m_zoomStrip->sizeHint().width(); + int zh = m_zoomStrip->sizeHint().height(); + m_zoomStrip->move(width() - zw, (height() - zh) / 2); +} + +void BrowserView::navigate(const QUrl &url) +{ + m_webView->load(url); +} diff --git a/demos/embedded/anamoly/src/BrowserView.h b/demos/embedded/anamoly/src/BrowserView.h new file mode 100644 index 0000000..36d3291 --- /dev/null +++ b/demos/embedded/anamoly/src/BrowserView.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef BROWSERVIEW_H +#define BROWSERVIEW_H + +#include +#include + +class QUrl; +class QWebView; +class TitleBar; +class ControlStrip; +class ZoomStrip; + +class BrowserView : public QWidget +{ + Q_OBJECT + +public: + BrowserView(QWidget *parent = 0); + +public slots: + void navigate(const QUrl &url); + void zoomIn(); + void zoomOut(); + +private slots: + void initialize(); + void start(); + void setProgress(int percent); + void finish(bool); + void updateTitleBar(); + +signals: + void menuButtonClicked(); + +protected: + void resizeEvent(QResizeEvent *event); + +private: + TitleBar *m_titleBar; + QWebView *m_webView; + ZoomStrip *m_zoomStrip; + ControlStrip *m_controlStrip; + int m_progress; + int m_currentZoom; + QVector m_zoomLevels; +}; + +#endif // BROWSERVIEW_H diff --git a/demos/embedded/anamoly/src/BrowserWindow.cpp b/demos/embedded/anamoly/src/BrowserWindow.cpp new file mode 100644 index 0000000..fd2f833 --- /dev/null +++ b/demos/embedded/anamoly/src/BrowserWindow.cpp @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "BrowserWindow.h" + +#include +#include + +#include "BrowserView.h" +#include "HomeView.h" + +BrowserWindow::BrowserWindow() + : QWidget() + , m_homeView(0) + , m_browserView(0) +{ + m_timeLine = new QTimeLine(300, this); + m_timeLine->setCurveShape(QTimeLine::EaseInOutCurve); + QTimer::singleShot(0, this, SLOT(initialize())); +} + +void BrowserWindow::initialize() +{ + m_homeView = new HomeView(this); + m_browserView = new BrowserView(this); + + m_homeView->hide(); + m_homeView->resize(size()); + m_homeView->move(0, 0); + + m_browserView->hide(); + m_browserView->resize(size()); + m_browserView->move(0, 0); + + connect(m_homeView, SIGNAL(addressEntered(QString)), SLOT(gotoAddress(QString))); + connect(m_homeView, SIGNAL(urlActivated(QUrl)), SLOT(navigate(QUrl))); + + connect(m_browserView, SIGNAL(menuButtonClicked()), SLOT(showHomeView())); + + m_homeView->setVisible(false); + m_browserView->setVisible(false); + slide(0); + + connect(m_timeLine, SIGNAL(frameChanged(int)), SLOT(slide(int))); +} + + +// from Demo Browser +QUrl guessUrlFromString(const QString &string) +{ + QString urlStr = string.trimmed(); + QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*")); + + // Check if it looks like a qualified URL. Try parsing it and see. + bool hasSchema = test.exactMatch(urlStr); + if (hasSchema) { + QUrl url = QUrl::fromEncoded(urlStr.toUtf8(), QUrl::TolerantMode); + if (url.isValid()) + return url; + } + + // Might be a file. + if (QFile::exists(urlStr)) { + QFileInfo info(urlStr); + return QUrl::fromLocalFile(info.absoluteFilePath()); + } + + // Might be a shorturl - try to detect the schema. + if (!hasSchema) { + int dotIndex = urlStr.indexOf(QLatin1Char('.')); + if (dotIndex != -1) { + QString prefix = urlStr.left(dotIndex).toLower(); + QString schema = (prefix == QString("ftp")) ? prefix.toLatin1() : QString("http"); + QString location = schema + "://" + urlStr; + QUrl url = QUrl::fromEncoded(location.toUtf8(), QUrl::TolerantMode); + if (url.isValid()) + return url; + } + } + + // Fall back to QUrl's own tolerant parser. + QUrl url = QUrl::fromEncoded(string.toUtf8(), QUrl::TolerantMode); + + // finally for cases where the user just types in a hostname add http + if (url.scheme().isEmpty()) + url = QUrl::fromEncoded("http://" + string.toUtf8(), QUrl::TolerantMode); + return url; +} + +void BrowserWindow::gotoAddress(const QString &address) +{ + m_browserView->navigate(guessUrlFromString(address)); + showBrowserView(); +} + +void BrowserWindow::navigate(const QUrl &url) +{ + m_browserView->navigate(url); + showBrowserView(); +} + +void BrowserWindow::slide(int pos) +{ + m_browserView->move(pos, 0); + m_homeView->move(pos - width(), 0); + m_browserView->show(); + m_homeView->show(); +} + +void BrowserWindow::showHomeView() +{ + if (m_timeLine->state() != QTimeLine::NotRunning) + return; + + m_timeLine->setFrameRange(0, width()); + m_timeLine->start(); + m_homeView->setFocus(); +} + +void BrowserWindow::showBrowserView() +{ + if (m_timeLine->state() != QTimeLine::NotRunning) + return; + + m_timeLine->setFrameRange(width(), 0); + m_timeLine->start(); + m_browserView->setFocus(); +} + +void BrowserWindow::keyReleaseEvent(QKeyEvent *event) +{ + QWidget::keyReleaseEvent(event); + + if (event->key() == Qt::Key_F3) { + if (m_homeView->isVisible()) + showBrowserView(); + else + showHomeView(); + } +} + +void BrowserWindow::resizeEvent(QResizeEvent *event) +{ + if (m_homeView) + m_homeView->resize(size()); + + if (m_browserView) + m_browserView->resize(size()); +} diff --git a/demos/embedded/anamoly/src/BrowserWindow.h b/demos/embedded/anamoly/src/BrowserWindow.h new file mode 100644 index 0000000..50a6508 --- /dev/null +++ b/demos/embedded/anamoly/src/BrowserWindow.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + + +#ifndef BROWSERWINDOW_H +#define BROWSERWINDOW_H + +#include +class QTimeLine; +class QUrl; + +class BrowserView; +class HomeView; + +class BrowserWindow : public QWidget +{ + Q_OBJECT + +public: + BrowserWindow(); + +private slots: + void initialize(); + void navigate(const QUrl &url); + void gotoAddress(const QString &address); + +public slots: + void showBrowserView(); + void showHomeView(); + void slide(int); + +protected: + void keyReleaseEvent(QKeyEvent *event); + void resizeEvent(QResizeEvent *event); + +private: + HomeView *m_homeView; + BrowserView *m_browserView; + QTimeLine *m_timeLine; +}; + +#endif // BROWSERWINDOW_H diff --git a/demos/embedded/anamoly/src/ControlStrip.cpp b/demos/embedded/anamoly/src/ControlStrip.cpp new file mode 100644 index 0000000..72bc485 --- /dev/null +++ b/demos/embedded/anamoly/src/ControlStrip.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "ControlStrip.h" + +#include +#include + +ControlStrip::ControlStrip(QWidget *parent) + : QWidget(parent) +{ + menuPixmap.load(":/images/edit-find.png"); + backPixmap.load(":/images/go-previous.png"); + forwardPixmap.load(":/images/go-next.png"); +} + +QSize ControlStrip::sizeHint() const +{ + return minimumSizeHint(); +} + +QSize ControlStrip::minimumSizeHint() const +{ + return QSize(320, 48); +} + +void ControlStrip::mousePressEvent(QMouseEvent *event) +{ + int h = height(); + int x = event->pos().x(); + + if (x < h) { + emit menuClicked(); + event->accept(); + return; + } + + if (x > width() - h) { + emit forwardClicked(); + event->accept(); + return; + } + + if ((x < width() - 2 * h) && (x > width() - 3 * h)) { + emit backClicked(); + event->accept(); + return; + } +} + +void ControlStrip::paintEvent(QPaintEvent *event) +{ + int h = height(); + int s = (h - menuPixmap.height()) / 2; + + QPainter p(this); + p.fillRect(event->rect(), QColor(32, 32, 32, 192)); + p.setCompositionMode(QPainter::CompositionMode_SourceOver); + p.drawPixmap(s, s, menuPixmap); + p.drawPixmap(width() - 3 * h + s, s, backPixmap); + p.drawPixmap(width() - h + s, s, forwardPixmap); + p.end(); +} diff --git a/demos/embedded/anamoly/src/ControlStrip.h b/demos/embedded/anamoly/src/ControlStrip.h new file mode 100644 index 0000000..99fc58d --- /dev/null +++ b/demos/embedded/anamoly/src/ControlStrip.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef CONTROLSTRIP_H +#define CONTROLSTRIP_H + +#include + +class ControlStrip : public QWidget +{ + Q_OBJECT + +public: + ControlStrip(QWidget *parent = 0); + + QSize sizeHint() const; + QSize minimumSizeHint() const; + +signals: + void menuClicked(); + void backClicked(); + void forwardClicked(); + +protected: + void paintEvent(QPaintEvent *event); + void mousePressEvent(QMouseEvent *event); + +private: + QPixmap menuPixmap; + QPixmap backPixmap; + QPixmap forwardPixmap; +}; + +#endif // CONTROLSTRIP_H diff --git a/demos/embedded/anamoly/src/HomeView.cpp b/demos/embedded/anamoly/src/HomeView.cpp new file mode 100644 index 0000000..0f59d54 --- /dev/null +++ b/demos/embedded/anamoly/src/HomeView.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "HomeView.h" + +#include +#include + +#include "AddressBar.h" +#include "BookmarksView.h" + +HomeView::HomeView(QWidget *parent) + : QWidget(parent) + , m_addressBar(0) +{ + m_addressBar = new AddressBar(parent); + connect(m_addressBar, SIGNAL(addressEntered(QString)), SLOT(gotoAddress(QString))); + + m_bookmarks = new BookmarksView(parent); + connect(m_bookmarks, SIGNAL(urlSelected(QUrl)), SIGNAL(urlActivated(QUrl))); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(4); + layout->setSpacing(4); + layout->addWidget(m_addressBar); + layout->addWidget(m_bookmarks); +} + +void HomeView::gotoAddress(const QString &address) +{ + emit addressEntered(address); +} + +void HomeView::focusInEvent(QFocusEvent *event) +{ + m_addressBar->setFocus(); + QWidget::focusInEvent(event); +} diff --git a/demos/embedded/anamoly/src/HomeView.h b/demos/embedded/anamoly/src/HomeView.h new file mode 100644 index 0000000..b54f07e --- /dev/null +++ b/demos/embedded/anamoly/src/HomeView.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef HOMEVIEW_H +#define HOMEVIEW_H + +#include + +class QUrl; + +class AddressBar; +class BookmarksView; + +class HomeView : public QWidget +{ + Q_OBJECT + +public: + HomeView(QWidget *parent); + +signals: + void urlActivated(const QUrl &url); + void addressEntered(const QString &address); + +private slots: + void gotoAddress(const QString &address); + +protected: + void focusInEvent(QFocusEvent *event); + +private: + AddressBar *m_addressBar; + BookmarksView *m_bookmarks; +}; + +#endif // HOMEVIEW_H diff --git a/demos/embedded/anamoly/src/Main.cpp b/demos/embedded/anamoly/src/Main.cpp new file mode 100644 index 0000000..2be6143 --- /dev/null +++ b/demos/embedded/anamoly/src/Main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include +#include +#include + +#include "BrowserWindow.h" + +#if defined (Q_OS_SYMBIAN) +#include "sym_iap_util.h" +#endif + +int main(int argc, char *argv[]) +{ +#if !defined(Q_WS_S60) + QApplication::setGraphicsSystem("raster"); +#endif + + QApplication app(argc, argv); + + app.setApplicationName("Anomaly"); + app.setApplicationVersion("0.0.0"); + + BrowserWindow window; +#ifdef Q_OS_SYMBIAN + window.showFullScreen(); + QWebSettings::globalSettings()->setObjectCacheCapacities(128*1024, 1024*1024, 1024*1024); + QWebSettings::globalSettings()->setMaximumPagesInCache(3); + qt_SetDefaultIap(); +#else + window.resize(360, 640); + window.show(); + app.setStyle("windows"); +#endif + + return app.exec(); +} + diff --git a/demos/embedded/anamoly/src/TitleBar.cpp b/demos/embedded/anamoly/src/TitleBar.cpp new file mode 100644 index 0000000..ff7837c --- /dev/null +++ b/demos/embedded/anamoly/src/TitleBar.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "TitleBar.h" + +#include +#include + +TitleBar::TitleBar(QWidget *parent) + : QWidget(parent) + , m_progress(0) +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); +} + +void TitleBar::setHost(const QString &host) +{ + m_host = host; + update(); +} + +void TitleBar::setTitle(const QString &title) +{ + m_title = title; + update(); +} + +void TitleBar::setProgress(int percent) +{ + m_progress = percent; + update(); +} + +QSize TitleBar::sizeHint() const +{ + return minimumSizeHint(); +} + +QSize TitleBar::minimumSizeHint() const +{ + QFontMetrics fm = fontMetrics(); + return QSize(100, fm.height()); +} + +void TitleBar::paintEvent(QPaintEvent *event) +{ + QString title = m_host; + if (!m_title.isEmpty()) + title.append(": ").append(m_title); + + QPalette pal = palette(); + QPainter p(this); + p.fillRect(event->rect(), pal.color(QPalette::Highlight)); + + if (m_progress > 0) { + + QRect box = rect(); + box.setLeft(16); + box.setWidth(width() - box.left() - 110); + + p.setPen(pal.color(QPalette::HighlightedText)); + p.setOpacity(0.8); + p.drawText(box, Qt::AlignLeft + Qt::AlignVCenter, title); + + int x = width() - 100 - 5; + int y = 1; + int h = height() - 4; + + p.setOpacity(1.0); + p.setBrush(Qt::NoBrush); + p.setPen(pal.color(QPalette::HighlightedText)); + p.drawRect(x, y, 100, h); + p.setPen(Qt::NoPen); + p.setBrush(pal.color(QPalette::HighlightedText)); + p.drawRect(x, y, m_progress, h); + } else { + + QRect box = rect(); + box.setLeft(16); + box.setWidth(width() - box.left() - 5); + p.setPen(pal.color(QPalette::HighlightedText)); + p.drawText(box, Qt::AlignLeft + Qt::AlignVCenter, title); + } + + p.end(); +} diff --git a/demos/embedded/anamoly/src/TitleBar.h b/demos/embedded/anamoly/src/TitleBar.h new file mode 100644 index 0000000..10ef2a8 --- /dev/null +++ b/demos/embedded/anamoly/src/TitleBar.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef TITLEBAR_H +#define TITLEBAR_H + +#include + +class TitleBar : public QWidget +{ + Q_OBJECT + +public: + TitleBar(QWidget *parent = 0); + + void setHost(const QString &host); + void setTitle(const QString &title); + void setProgress(int percent); + + QSize sizeHint() const; + QSize minimumSizeHint() const; + +protected: + void paintEvent(QPaintEvent *event); + +private: + QString m_host; + QString m_title; + int m_progress; +}; + +#endif // TITLEBAR_H diff --git a/demos/embedded/anamoly/src/ZoomStrip.cpp b/demos/embedded/anamoly/src/ZoomStrip.cpp new file mode 100644 index 0000000..80bfdea --- /dev/null +++ b/demos/embedded/anamoly/src/ZoomStrip.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "ZoomStrip.h" + +#include +#include + +ZoomStrip::ZoomStrip(QWidget *parent) + : QWidget(parent) +{ + zoomInPixmap.load(":/images/list-add.png"); + zoomOutPixmap.load(":/images/list-remove.png"); +} + +QSize ZoomStrip::sizeHint() const +{ + return minimumSizeHint(); +} + +QSize ZoomStrip::minimumSizeHint() const +{ + return QSize(48, 96); +} + +void ZoomStrip::mousePressEvent(QMouseEvent *event) +{ + if (event->pos().y() < height() / 2) + emit zoomInClicked(); + else + emit zoomOutClicked(); +} + +void ZoomStrip::paintEvent(QPaintEvent *event) +{ + int w = width(); + int s = (w - zoomInPixmap.width()) / 2; + + QPainter p(this); + p.fillRect(event->rect(), QColor(128, 128, 128, 128)); + p.drawPixmap(s, s, zoomInPixmap); + p.drawPixmap(s, s + w, zoomOutPixmap); + p.end(); +} diff --git a/demos/embedded/anamoly/src/ZoomStrip.h b/demos/embedded/anamoly/src/ZoomStrip.h new file mode 100644 index 0000000..fdf0328 --- /dev/null +++ b/demos/embedded/anamoly/src/ZoomStrip.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef ZOOMSTRIP_H +#define ZOOMSTRIP_H + +#include + +class ZoomStrip : public QWidget +{ + Q_OBJECT + +public: + ZoomStrip(QWidget *parent = 0); + + QSize sizeHint() const; + QSize minimumSizeHint() const; + +signals: + void zoomInClicked(); + void zoomOutClicked(); + +protected: + void paintEvent(QPaintEvent *event); + void mousePressEvent(QMouseEvent *event); + +private: + QPixmap zoomInPixmap; + QPixmap zoomOutPixmap; +}; + +#endif // ZOOMSTRIP_H diff --git a/demos/embedded/anamoly/src/anomaly.qrc b/demos/embedded/anamoly/src/anomaly.qrc new file mode 100644 index 0000000..601a34e --- /dev/null +++ b/demos/embedded/anamoly/src/anomaly.qrc @@ -0,0 +1,9 @@ + + + images/go-next.png + images/go-previous.png + images/edit-find.png + images/list-add.png + images/list-remove.png + + diff --git a/demos/embedded/anamoly/src/flickcharm.cpp b/demos/embedded/anamoly/src/flickcharm.cpp new file mode 100644 index 0000000..620ef88 --- /dev/null +++ b/demos/embedded/anamoly/src/flickcharm.cpp @@ -0,0 +1,309 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Graphics Dojo project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "flickcharm.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +struct FlickData { + typedef enum { Steady, Pressed, ManualScroll, AutoScroll, Stop } State; + State state; + QWidget *widget; + QPoint pressPos; + QPoint offset; + QPoint dragPos; + QPoint speed; + QList ignored; +}; + +class FlickCharmPrivate +{ +public: + QHash flickData; + QBasicTimer ticker; +}; + +FlickCharm::FlickCharm(QObject *parent): QObject(parent) +{ + d = new FlickCharmPrivate; +} + +FlickCharm::~FlickCharm() +{ + delete d; +} + +void FlickCharm::activateOn(QWidget *widget) +{ + QAbstractScrollArea *scrollArea = dynamic_cast(widget); + if (scrollArea) { + scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + QWidget *viewport = scrollArea->viewport(); + + viewport->installEventFilter(this); + scrollArea->installEventFilter(this); + + d->flickData.remove(viewport); + d->flickData[viewport] = new FlickData; + d->flickData[viewport]->widget = widget; + d->flickData[viewport]->state = FlickData::Steady; + + return; + } + + QWebView *webView = dynamic_cast(widget); + if (webView) { + QWebFrame *frame = webView->page()->mainFrame(); + frame->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); + frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); + + webView->installEventFilter(this); + + d->flickData.remove(webView); + d->flickData[webView] = new FlickData; + d->flickData[webView]->widget = webView; + d->flickData[webView]->state = FlickData::Steady; + + return; + } + + qWarning() << "FlickCharm only works on QAbstractScrollArea (and derived classes)"; + qWarning() << "or QWebView (and derived classes)"; +} + +void FlickCharm::deactivateFrom(QWidget *widget) +{ + QAbstractScrollArea *scrollArea = dynamic_cast(widget); + if (scrollArea) { + QWidget *viewport = scrollArea->viewport(); + + viewport->removeEventFilter(this); + scrollArea->removeEventFilter(this); + + delete d->flickData[viewport]; + d->flickData.remove(viewport); + + return; + } + + QWebView *webView = dynamic_cast(widget); + if (webView) { + webView->removeEventFilter(this); + + delete d->flickData[webView]; + d->flickData.remove(webView); + + return; + } +} + +static QPoint scrollOffset(QWidget *widget) +{ + int x = 0, y = 0; + + QAbstractScrollArea *scrollArea = dynamic_cast(widget); + if (scrollArea) { + x = scrollArea->horizontalScrollBar()->value(); + y = scrollArea->verticalScrollBar()->value(); + } + + QWebView *webView = dynamic_cast(widget); + if (webView) { + QWebFrame *frame = webView->page()->mainFrame(); + x = frame->evaluateJavaScript("window.scrollX").toInt(); + y = frame->evaluateJavaScript("window.scrollY").toInt(); + } + + return QPoint(x, y); +} + +static void setScrollOffset(QWidget *widget, const QPoint &p) +{ + QAbstractScrollArea *scrollArea = dynamic_cast(widget); + if (scrollArea) { + scrollArea->horizontalScrollBar()->setValue(p.x()); + scrollArea->verticalScrollBar()->setValue(p.y()); + } + + QWebView *webView = dynamic_cast(widget); + QWebFrame *frame = webView ? webView->page()->mainFrame() : 0; + if (frame) + frame->evaluateJavaScript(QString("window.scrollTo(%1,%2);").arg(p.x()).arg(p.y())); +} + +static QPoint deaccelerate(const QPoint &speed, int a = 1, int max = 64) +{ + int x = qBound(-max, speed.x(), max); + int y = qBound(-max, speed.y(), max); + x = (x == 0) ? x : (x > 0) ? qMax(0, x - a) : qMin(0, x + a); + y = (y == 0) ? y : (y > 0) ? qMax(0, y - a) : qMin(0, y + a); + return QPoint(x, y); +} + +bool FlickCharm::eventFilter(QObject *object, QEvent *event) +{ + if (!object->isWidgetType()) + return false; + + QEvent::Type type = event->type(); + if (type != QEvent::MouseButtonPress && + type != QEvent::MouseButtonRelease && + type != QEvent::MouseMove) + return false; + + QMouseEvent *mouseEvent = dynamic_cast(event); + if (!mouseEvent || mouseEvent->modifiers() != Qt::NoModifier) + return false; + + QWidget *viewport = dynamic_cast(object); + FlickData *data = d->flickData.value(viewport); + if (!viewport || !data || data->ignored.removeAll(event)) + return false; + + bool consumed = false; + switch (data->state) { + + case FlickData::Steady: + if (mouseEvent->type() == QEvent::MouseButtonPress) + if (mouseEvent->buttons() == Qt::LeftButton) { + consumed = true; + data->state = FlickData::Pressed; + data->pressPos = mouseEvent->pos(); + data->offset = scrollOffset(data->widget); + } + break; + + case FlickData::Pressed: + if (mouseEvent->type() == QEvent::MouseButtonRelease) { + consumed = true; + data->state = FlickData::Steady; + + QMouseEvent *event1 = new QMouseEvent(QEvent::MouseButtonPress, + data->pressPos, Qt::LeftButton, + Qt::LeftButton, Qt::NoModifier); + QMouseEvent *event2 = new QMouseEvent(*mouseEvent); + + data->ignored << event1; + data->ignored << event2; + QApplication::postEvent(object, event1); + QApplication::postEvent(object, event2); + } + if (mouseEvent->type() == QEvent::MouseMove) { + consumed = true; + data->state = FlickData::ManualScroll; + data->dragPos = QCursor::pos(); + if (!d->ticker.isActive()) + d->ticker.start(20, this); + } + break; + + case FlickData::ManualScroll: + if (mouseEvent->type() == QEvent::MouseMove) { + consumed = true; + QPoint delta = mouseEvent->pos() - data->pressPos; + setScrollOffset(data->widget, data->offset - delta); + } + if (mouseEvent->type() == QEvent::MouseButtonRelease) { + consumed = true; + data->state = FlickData::AutoScroll; + } + break; + + case FlickData::AutoScroll: + if (mouseEvent->type() == QEvent::MouseButtonPress) { + consumed = true; + data->state = FlickData::Stop; + data->speed = QPoint(0, 0); + data->pressPos = mouseEvent->pos(); + data->offset = scrollOffset(data->widget); + } + if (mouseEvent->type() == QEvent::MouseButtonRelease) { + consumed = true; + data->state = FlickData::Steady; + data->speed = QPoint(0, 0); + } + break; + + case FlickData::Stop: + if (mouseEvent->type() == QEvent::MouseButtonRelease) { + consumed = true; + data->state = FlickData::Steady; + } + if (mouseEvent->type() == QEvent::MouseMove) { + consumed = true; + data->state = FlickData::ManualScroll; + data->dragPos = QCursor::pos(); + if (!d->ticker.isActive()) + d->ticker.start(20, this); + } + break; + + default: + break; + } + + return consumed; +} + +void FlickCharm::timerEvent(QTimerEvent *event) +{ + int count = 0; + QHashIterator item(d->flickData); + while (item.hasNext()) { + item.next(); + FlickData *data = item.value(); + + if (data->state == FlickData::ManualScroll) { + count++; + data->speed = QCursor::pos() - data->dragPos; + data->dragPos = QCursor::pos(); + } + + if (data->state == FlickData::AutoScroll) { + count++; + data->speed = deaccelerate(data->speed); + QPoint p = scrollOffset(data->widget); + setScrollOffset(data->widget, p - data->speed); + if (data->speed == QPoint(0, 0)) + data->state = FlickData::Steady; + } + } + + if (!count) + d->ticker.stop(); + + QObject::timerEvent(event); +} diff --git a/demos/embedded/anamoly/src/flickcharm.h b/demos/embedded/anamoly/src/flickcharm.h new file mode 100644 index 0000000..3b3831f --- /dev/null +++ b/demos/embedded/anamoly/src/flickcharm.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Graphics Dojo project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef FLICKCHARM_H +#define FLICKCHARM_H + +#include + +class FlickCharmPrivate; +class QWidget; + +class FlickCharm: public QObject +{ + Q_OBJECT +public: + FlickCharm(QObject *parent = 0); + ~FlickCharm(); + void activateOn(QWidget *widget); + void deactivateFrom(QWidget *widget); + bool eventFilter(QObject *object, QEvent *event); + +protected: + void timerEvent(QTimerEvent *event); + +private: + FlickCharmPrivate *d; +}; + +#endif // FLICKCHARM_H diff --git a/demos/embedded/anamoly/src/images/edit-find.png b/demos/embedded/anamoly/src/images/edit-find.png new file mode 100644 index 0000000..5594785 Binary files /dev/null and b/demos/embedded/anamoly/src/images/edit-find.png differ diff --git a/demos/embedded/anamoly/src/images/go-next.png b/demos/embedded/anamoly/src/images/go-next.png new file mode 100644 index 0000000..a68e2db Binary files /dev/null and b/demos/embedded/anamoly/src/images/go-next.png differ diff --git a/demos/embedded/anamoly/src/images/go-previous.png b/demos/embedded/anamoly/src/images/go-previous.png new file mode 100644 index 0000000..c37bc04 Binary files /dev/null and b/demos/embedded/anamoly/src/images/go-previous.png differ diff --git a/demos/embedded/anamoly/src/images/list-add.png b/demos/embedded/anamoly/src/images/list-add.png new file mode 100644 index 0000000..2acdd8f Binary files /dev/null and b/demos/embedded/anamoly/src/images/list-add.png differ diff --git a/demos/embedded/anamoly/src/images/list-remove.png b/demos/embedded/anamoly/src/images/list-remove.png new file mode 100644 index 0000000..c5524f7 Binary files /dev/null and b/demos/embedded/anamoly/src/images/list-remove.png differ -- cgit v0.12 From 2d4d17eda8a172ab3839997b44d9fc952292eb94 Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 22 Jun 2009 10:48:29 +0200 Subject: Small doc update. --- doc/src/installation.qdoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/src/installation.qdoc b/doc/src/installation.qdoc index c8310ff..6fb367f 100644 --- a/doc/src/installation.qdoc +++ b/doc/src/installation.qdoc @@ -523,8 +523,10 @@ in the \l{Qt for S60 Requirements} document. to try out. An excellent starting point is the "fluidlauncher" demo. To run the demo on a real device, you first have to install \c{qt_libs.sis} and \c{fluidlauncher.sis} found in the Qt installation - directory. In Windows Explorer right click on the \c{.sis} files and select - "Install with Nokia Application Installer" and follow the instructions. + directory. Begin by connecting your phone using the USB cable and + selecting "PC Suite mode". In Windows Explorer right click on the + \c{.sis} files and select "Install with Nokia Application Installer" + and follow the instructions. To run the demos and examples on the emulator, you need to build them first. Open the "Qt for S60 Command Prompt" from the Start menu and type: -- cgit v0.12 From be49dfa4f3ed9111731d9503061882ac70b89e71 Mon Sep 17 00:00:00 2001 From: Espen Riskedal Date: Mon, 22 Jun 2009 11:20:47 +0200 Subject: fix spelling and add to embedded.pro --- demos/embedded/anamoly/README.TXT | 0 demos/embedded/anamoly/anomaly.pro | 29 -- demos/embedded/anamoly/src/AddressBar.cpp | 91 ------- demos/embedded/anamoly/src/AddressBar.h | 55 ---- demos/embedded/anamoly/src/BookmarksView.cpp | 52 ---- demos/embedded/anamoly/src/BookmarksView.h | 46 ---- demos/embedded/anamoly/src/BrowserView.cpp | 153 ----------- demos/embedded/anamoly/src/BrowserView.h | 71 ----- demos/embedded/anamoly/src/BrowserWindow.cpp | 169 ------------ demos/embedded/anamoly/src/BrowserWindow.h | 62 ----- demos/embedded/anamoly/src/ControlStrip.cpp | 83 ------ demos/embedded/anamoly/src/ControlStrip.h | 54 ---- demos/embedded/anamoly/src/HomeView.cpp | 58 ---- demos/embedded/anamoly/src/HomeView.h | 56 ---- demos/embedded/anamoly/src/Main.cpp | 59 ----- demos/embedded/anamoly/src/TitleBar.cpp | 106 -------- demos/embedded/anamoly/src/TitleBar.h | 52 ---- demos/embedded/anamoly/src/ZoomStrip.cpp | 64 ----- demos/embedded/anamoly/src/ZoomStrip.h | 52 ---- demos/embedded/anamoly/src/anomaly.qrc | 9 - demos/embedded/anamoly/src/flickcharm.cpp | 309 ---------------------- demos/embedded/anamoly/src/flickcharm.h | 49 ---- demos/embedded/anamoly/src/images/edit-find.png | Bin 1636 -> 0 bytes demos/embedded/anamoly/src/images/go-next.png | Bin 1219 -> 0 bytes demos/embedded/anamoly/src/images/go-previous.png | Bin 1200 -> 0 bytes demos/embedded/anamoly/src/images/list-add.png | Bin 601 -> 0 bytes demos/embedded/anamoly/src/images/list-remove.png | Bin 317 -> 0 bytes demos/embedded/anomaly/README.TXT | 0 demos/embedded/anomaly/anomaly.pro | 29 ++ demos/embedded/anomaly/src/AddressBar.cpp | 91 +++++++ demos/embedded/anomaly/src/AddressBar.h | 55 ++++ demos/embedded/anomaly/src/BookmarksView.cpp | 52 ++++ demos/embedded/anomaly/src/BookmarksView.h | 46 ++++ demos/embedded/anomaly/src/BrowserView.cpp | 153 +++++++++++ demos/embedded/anomaly/src/BrowserView.h | 71 +++++ demos/embedded/anomaly/src/BrowserWindow.cpp | 169 ++++++++++++ demos/embedded/anomaly/src/BrowserWindow.h | 62 +++++ demos/embedded/anomaly/src/ControlStrip.cpp | 83 ++++++ demos/embedded/anomaly/src/ControlStrip.h | 54 ++++ demos/embedded/anomaly/src/HomeView.cpp | 58 ++++ demos/embedded/anomaly/src/HomeView.h | 56 ++++ demos/embedded/anomaly/src/Main.cpp | 59 +++++ demos/embedded/anomaly/src/TitleBar.cpp | 106 ++++++++ demos/embedded/anomaly/src/TitleBar.h | 52 ++++ demos/embedded/anomaly/src/ZoomStrip.cpp | 64 +++++ demos/embedded/anomaly/src/ZoomStrip.h | 52 ++++ demos/embedded/anomaly/src/anomaly.qrc | 9 + demos/embedded/anomaly/src/flickcharm.cpp | 309 ++++++++++++++++++++++ demos/embedded/anomaly/src/flickcharm.h | 49 ++++ demos/embedded/anomaly/src/images/edit-find.png | Bin 0 -> 1636 bytes demos/embedded/anomaly/src/images/go-next.png | Bin 0 -> 1219 bytes demos/embedded/anomaly/src/images/go-previous.png | Bin 0 -> 1200 bytes demos/embedded/anomaly/src/images/list-add.png | Bin 0 -> 601 bytes demos/embedded/anomaly/src/images/list-remove.png | Bin 0 -> 317 bytes demos/embedded/embedded.pro | 2 + 55 files changed, 1681 insertions(+), 1679 deletions(-) delete mode 100644 demos/embedded/anamoly/README.TXT delete mode 100644 demos/embedded/anamoly/anomaly.pro delete mode 100644 demos/embedded/anamoly/src/AddressBar.cpp delete mode 100644 demos/embedded/anamoly/src/AddressBar.h delete mode 100644 demos/embedded/anamoly/src/BookmarksView.cpp delete mode 100644 demos/embedded/anamoly/src/BookmarksView.h delete mode 100644 demos/embedded/anamoly/src/BrowserView.cpp delete mode 100644 demos/embedded/anamoly/src/BrowserView.h delete mode 100644 demos/embedded/anamoly/src/BrowserWindow.cpp delete mode 100644 demos/embedded/anamoly/src/BrowserWindow.h delete mode 100644 demos/embedded/anamoly/src/ControlStrip.cpp delete mode 100644 demos/embedded/anamoly/src/ControlStrip.h delete mode 100644 demos/embedded/anamoly/src/HomeView.cpp delete mode 100644 demos/embedded/anamoly/src/HomeView.h delete mode 100644 demos/embedded/anamoly/src/Main.cpp delete mode 100644 demos/embedded/anamoly/src/TitleBar.cpp delete mode 100644 demos/embedded/anamoly/src/TitleBar.h delete mode 100644 demos/embedded/anamoly/src/ZoomStrip.cpp delete mode 100644 demos/embedded/anamoly/src/ZoomStrip.h delete mode 100644 demos/embedded/anamoly/src/anomaly.qrc delete mode 100644 demos/embedded/anamoly/src/flickcharm.cpp delete mode 100644 demos/embedded/anamoly/src/flickcharm.h delete mode 100644 demos/embedded/anamoly/src/images/edit-find.png delete mode 100644 demos/embedded/anamoly/src/images/go-next.png delete mode 100644 demos/embedded/anamoly/src/images/go-previous.png delete mode 100644 demos/embedded/anamoly/src/images/list-add.png delete mode 100644 demos/embedded/anamoly/src/images/list-remove.png create mode 100644 demos/embedded/anomaly/README.TXT create mode 100644 demos/embedded/anomaly/anomaly.pro create mode 100644 demos/embedded/anomaly/src/AddressBar.cpp create mode 100644 demos/embedded/anomaly/src/AddressBar.h create mode 100644 demos/embedded/anomaly/src/BookmarksView.cpp create mode 100644 demos/embedded/anomaly/src/BookmarksView.h create mode 100644 demos/embedded/anomaly/src/BrowserView.cpp create mode 100644 demos/embedded/anomaly/src/BrowserView.h create mode 100644 demos/embedded/anomaly/src/BrowserWindow.cpp create mode 100644 demos/embedded/anomaly/src/BrowserWindow.h create mode 100644 demos/embedded/anomaly/src/ControlStrip.cpp create mode 100644 demos/embedded/anomaly/src/ControlStrip.h create mode 100644 demos/embedded/anomaly/src/HomeView.cpp create mode 100644 demos/embedded/anomaly/src/HomeView.h create mode 100644 demos/embedded/anomaly/src/Main.cpp create mode 100644 demos/embedded/anomaly/src/TitleBar.cpp create mode 100644 demos/embedded/anomaly/src/TitleBar.h create mode 100644 demos/embedded/anomaly/src/ZoomStrip.cpp create mode 100644 demos/embedded/anomaly/src/ZoomStrip.h create mode 100644 demos/embedded/anomaly/src/anomaly.qrc create mode 100644 demos/embedded/anomaly/src/flickcharm.cpp create mode 100644 demos/embedded/anomaly/src/flickcharm.h create mode 100644 demos/embedded/anomaly/src/images/edit-find.png create mode 100644 demos/embedded/anomaly/src/images/go-next.png create mode 100644 demos/embedded/anomaly/src/images/go-previous.png create mode 100644 demos/embedded/anomaly/src/images/list-add.png create mode 100644 demos/embedded/anomaly/src/images/list-remove.png diff --git a/demos/embedded/anamoly/README.TXT b/demos/embedded/anamoly/README.TXT deleted file mode 100644 index e69de29..0000000 diff --git a/demos/embedded/anamoly/anomaly.pro b/demos/embedded/anamoly/anomaly.pro deleted file mode 100644 index 5fe5625..0000000 --- a/demos/embedded/anamoly/anomaly.pro +++ /dev/null @@ -1,29 +0,0 @@ -QT += network \ - webkit -HEADERS += src/BrowserWindow.h \ - src/BrowserView.h \ - src/TitleBar.h \ - src/HomeView.h \ - src/AddressBar.h \ - src/BookmarksView.h \ - src/flickcharm.h \ - src/ZoomStrip.h \ - src/ControlStrip.h -SOURCES += src/Main.cpp \ - src/BrowserWindow.cpp \ - src/BrowserView.cpp \ - src/TitleBar.cpp \ - src/HomeView.cpp \ - src/AddressBar.cpp \ - src/BookmarksView.cpp \ - src/flickcharm.cpp \ - src/ZoomStrip.cpp \ - src/ControlStrip.cpp -RESOURCES += src/anomaly.qrc - -symbian { - HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h - LIBS += -lesock -lconnmon - TARGET.CAPABILITY = NetworkServices - TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 -} diff --git a/demos/embedded/anamoly/src/AddressBar.cpp b/demos/embedded/anamoly/src/AddressBar.cpp deleted file mode 100644 index 64734c8..0000000 --- a/demos/embedded/anamoly/src/AddressBar.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#include "AddressBar.h" - -#include -#include - -class LineEdit: public QLineEdit -{ -public: - LineEdit(QWidget *parent = 0): QLineEdit(parent) {} - - void paintEvent(QPaintEvent *event) { - QLineEdit::paintEvent(event); - if (text().isEmpty()) { - QPainter p(this); - int flags = Qt::AlignLeft | Qt::AlignVCenter; - p.setPen(palette().color(QPalette::Disabled, QPalette::Text)); - p.drawText(rect().adjusted(10, 0, 0, 0), flags, "Enter address or search terms"); - p.end(); - } - } -}; - -AddressBar::AddressBar(QWidget *parent) - : QWidget(parent) -{ - m_lineEdit = new LineEdit(parent); - connect(m_lineEdit, SIGNAL(returnPressed()), SLOT(processAddress())); - m_toolButton = new QToolButton(parent); - m_toolButton->setText("Go"); - connect(m_toolButton, SIGNAL(clicked()), SLOT(processAddress())); -} - -QSize AddressBar::sizeHint() const -{ - return m_lineEdit->sizeHint(); -} - -void AddressBar::processAddress() -{ - if (!m_lineEdit->text().isEmpty()) - emit addressEntered(m_lineEdit->text()); -} - -void AddressBar::resizeEvent(QResizeEvent *event) -{ - int x, y, w, h; - - m_toolButton->adjustSize(); - x = width() - m_toolButton->width(); - y = 0; - w = m_toolButton->width(); - h = height() - 1; - m_toolButton->setGeometry(x, y, w, h); - m_toolButton->show(); - - x = 0; - y = 0; - w = width() - m_toolButton->width(); - h = height() - 1; - m_lineEdit->setGeometry(x, y, w, h); - m_lineEdit->show(); -} - -void AddressBar::focusInEvent(QFocusEvent *event) -{ - m_lineEdit->setFocus(); - QWidget::focusInEvent(event); -} diff --git a/demos/embedded/anamoly/src/AddressBar.h b/demos/embedded/anamoly/src/AddressBar.h deleted file mode 100644 index 632ae1f..0000000 --- a/demos/embedded/anamoly/src/AddressBar.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#ifndef ADDRESSBAR_H -#define ADDRESSBAR_H - -#include - -class QLineEdit; -class QToolButton; - -class AddressBar : public QWidget -{ - Q_OBJECT - -public: - AddressBar(QWidget *parent = 0); - QSize sizeHint() const; - -protected: - void resizeEvent(QResizeEvent *event); - void focusInEvent(QFocusEvent *event); - -signals: - void addressEntered(const QString &address); - -private slots: - void processAddress(); - -private: - QLineEdit *m_lineEdit; - QToolButton *m_toolButton; -}; - -#endif // ADDRESSBAR_H diff --git a/demos/embedded/anamoly/src/BookmarksView.cpp b/demos/embedded/anamoly/src/BookmarksView.cpp deleted file mode 100644 index f705383..0000000 --- a/demos/embedded/anamoly/src/BookmarksView.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#include "BookmarksView.h" - -#include - -BookmarksView::BookmarksView(QWidget *parent) - : QWidget(parent) -{ - QListWidget *m_iconView = new QListWidget(this); - connect(m_iconView, SIGNAL(itemActivated(QListWidgetItem*)), SLOT(activate(QListWidgetItem*))); - - QVBoxLayout *layout = new QVBoxLayout(this); - setLayout(layout); - layout->addWidget(m_iconView); - - m_iconView->addItem("www.google.com"); - m_iconView->addItem("doc.trolltech.com/4.5"); - m_iconView->addItem("news.bbc.co.uk/text_only.stm"); - m_iconView->addItem("mobile.wikipedia.org"); - m_iconView->addItem("www.qtsoftware.com"); - m_iconView->addItem("en.wikipedia.org"); - - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); -} - -void BookmarksView::activate(QListWidgetItem *item) -{ - QUrl url = item->text().prepend("http://"); - emit urlSelected(url); -} diff --git a/demos/embedded/anamoly/src/BookmarksView.h b/demos/embedded/anamoly/src/BookmarksView.h deleted file mode 100644 index 95abdd7..0000000 --- a/demos/embedded/anamoly/src/BookmarksView.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#ifndef BOOKMARKSVIEW_H -#define BOOKMARKSVIEW_H - -#include - -class QListWidgetItem; -class QUrl; - -class BookmarksView : public QWidget -{ - Q_OBJECT - -public: - BookmarksView(QWidget *parent = 0); - -signals: - void urlSelected(const QUrl &url); - -private slots: - void activate(QListWidgetItem *item); -}; - -#endif // BOOKMARKSVIEW_H diff --git a/demos/embedded/anamoly/src/BrowserView.cpp b/demos/embedded/anamoly/src/BrowserView.cpp deleted file mode 100644 index e81d834..0000000 --- a/demos/embedded/anamoly/src/BrowserView.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#include "BrowserView.h" - -#include -#include -#include - -#include "ControlStrip.h" -#include "TitleBar.h" -#include "flickcharm.h" -#include "ZoomStrip.h" - -BrowserView::BrowserView(QWidget *parent) - : QWidget(parent) - , m_titleBar(0) - , m_webView(0) - , m_progress(0) - , m_currentZoom(100) -{ - m_titleBar = new TitleBar(this); - m_webView = new QWebView(this); - m_zoomStrip = new ZoomStrip(this); - m_controlStrip = new ControlStrip(this); - - m_zoomLevels << 30 << 50 << 67 << 80 << 90; - m_zoomLevels << 100; - m_zoomLevels << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300; - - QTimer::singleShot(0, this, SLOT(initialize())); -} - -void BrowserView::initialize() -{ - connect(m_zoomStrip, SIGNAL(zoomInClicked()), SLOT(zoomIn())); - connect(m_zoomStrip, SIGNAL(zoomOutClicked()), SLOT(zoomOut())); - - connect(m_controlStrip, SIGNAL(menuClicked()), SIGNAL(menuButtonClicked())); - connect(m_controlStrip, SIGNAL(backClicked()), m_webView, SLOT(back())); - connect(m_controlStrip, SIGNAL(forwardClicked()), m_webView, SLOT(forward())); - - QPalette pal = m_webView->palette(); - pal.setBrush(QPalette::Base, Qt::white); - m_webView->setPalette(pal); - - FlickCharm *flickCharm = new FlickCharm(this); - flickCharm->activateOn(m_webView); - - m_webView->setZoomFactor(static_cast(m_currentZoom)/100.0); - connect(m_webView, SIGNAL(loadStarted()), SLOT(start())); - connect(m_webView, SIGNAL(loadProgress(int)), SLOT(setProgress(int))); - connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(finish(bool))); - connect(m_webView, SIGNAL(urlChanged(QUrl)), SLOT(updateTitleBar())); - - m_webView->load(QUrl("http://news.bbc.co.uk/text_only.stm")); - m_webView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - m_webView->setFocus(); -} - -void BrowserView::start() -{ - m_progress = 0; - updateTitleBar(); - //m_titleBar->setText(m_webView->url().toString()); -} - -void BrowserView::setProgress(int percent) -{ - m_progress = percent; - updateTitleBar(); - //m_titleBar->setText(QString("Loading %1%").arg(percent)); -} - -void BrowserView::updateTitleBar() -{ - QUrl url = m_webView->url(); - m_titleBar->setHost(url.host()); - m_titleBar->setTitle(m_webView->title()); - m_titleBar->setProgress(m_progress); -} - -void BrowserView::finish(bool ok) -{ - m_progress = 0; - updateTitleBar(); - - // TODO: handle error - if (!ok) { - //m_titleBar->setText("Loading failed."); - } -} - -void BrowserView::zoomIn() -{ - int i = m_zoomLevels.indexOf(m_currentZoom); - Q_ASSERT(i >= 0); - if (i < m_zoomLevels.count() - 1) - m_currentZoom = m_zoomLevels[i + 1]; - - m_webView->setZoomFactor(static_cast(m_currentZoom)/100.0); -} - -void BrowserView::zoomOut() -{ - int i = m_zoomLevels.indexOf(m_currentZoom); - Q_ASSERT(i >= 0); - if (i > 0) - m_currentZoom = m_zoomLevels[i - 1]; - - m_webView->setZoomFactor(static_cast(m_currentZoom)/100.0); -} - -void BrowserView::resizeEvent(QResizeEvent *event) -{ - QWidget::resizeEvent(event); - - int h1 = m_titleBar->sizeHint().height(); - int h2 = m_controlStrip->sizeHint().height(); - - m_titleBar->setGeometry(0, 0, width(), h1); - m_controlStrip->setGeometry(0, height() - h2, width(), h2); - m_webView->setGeometry(0, h1, width(), height() - h1); - - int zw = m_zoomStrip->sizeHint().width(); - int zh = m_zoomStrip->sizeHint().height(); - m_zoomStrip->move(width() - zw, (height() - zh) / 2); -} - -void BrowserView::navigate(const QUrl &url) -{ - m_webView->load(url); -} diff --git a/demos/embedded/anamoly/src/BrowserView.h b/demos/embedded/anamoly/src/BrowserView.h deleted file mode 100644 index 36d3291..0000000 --- a/demos/embedded/anamoly/src/BrowserView.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#ifndef BROWSERVIEW_H -#define BROWSERVIEW_H - -#include -#include - -class QUrl; -class QWebView; -class TitleBar; -class ControlStrip; -class ZoomStrip; - -class BrowserView : public QWidget -{ - Q_OBJECT - -public: - BrowserView(QWidget *parent = 0); - -public slots: - void navigate(const QUrl &url); - void zoomIn(); - void zoomOut(); - -private slots: - void initialize(); - void start(); - void setProgress(int percent); - void finish(bool); - void updateTitleBar(); - -signals: - void menuButtonClicked(); - -protected: - void resizeEvent(QResizeEvent *event); - -private: - TitleBar *m_titleBar; - QWebView *m_webView; - ZoomStrip *m_zoomStrip; - ControlStrip *m_controlStrip; - int m_progress; - int m_currentZoom; - QVector m_zoomLevels; -}; - -#endif // BROWSERVIEW_H diff --git a/demos/embedded/anamoly/src/BrowserWindow.cpp b/demos/embedded/anamoly/src/BrowserWindow.cpp deleted file mode 100644 index fd2f833..0000000 --- a/demos/embedded/anamoly/src/BrowserWindow.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#include "BrowserWindow.h" - -#include -#include - -#include "BrowserView.h" -#include "HomeView.h" - -BrowserWindow::BrowserWindow() - : QWidget() - , m_homeView(0) - , m_browserView(0) -{ - m_timeLine = new QTimeLine(300, this); - m_timeLine->setCurveShape(QTimeLine::EaseInOutCurve); - QTimer::singleShot(0, this, SLOT(initialize())); -} - -void BrowserWindow::initialize() -{ - m_homeView = new HomeView(this); - m_browserView = new BrowserView(this); - - m_homeView->hide(); - m_homeView->resize(size()); - m_homeView->move(0, 0); - - m_browserView->hide(); - m_browserView->resize(size()); - m_browserView->move(0, 0); - - connect(m_homeView, SIGNAL(addressEntered(QString)), SLOT(gotoAddress(QString))); - connect(m_homeView, SIGNAL(urlActivated(QUrl)), SLOT(navigate(QUrl))); - - connect(m_browserView, SIGNAL(menuButtonClicked()), SLOT(showHomeView())); - - m_homeView->setVisible(false); - m_browserView->setVisible(false); - slide(0); - - connect(m_timeLine, SIGNAL(frameChanged(int)), SLOT(slide(int))); -} - - -// from Demo Browser -QUrl guessUrlFromString(const QString &string) -{ - QString urlStr = string.trimmed(); - QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*")); - - // Check if it looks like a qualified URL. Try parsing it and see. - bool hasSchema = test.exactMatch(urlStr); - if (hasSchema) { - QUrl url = QUrl::fromEncoded(urlStr.toUtf8(), QUrl::TolerantMode); - if (url.isValid()) - return url; - } - - // Might be a file. - if (QFile::exists(urlStr)) { - QFileInfo info(urlStr); - return QUrl::fromLocalFile(info.absoluteFilePath()); - } - - // Might be a shorturl - try to detect the schema. - if (!hasSchema) { - int dotIndex = urlStr.indexOf(QLatin1Char('.')); - if (dotIndex != -1) { - QString prefix = urlStr.left(dotIndex).toLower(); - QString schema = (prefix == QString("ftp")) ? prefix.toLatin1() : QString("http"); - QString location = schema + "://" + urlStr; - QUrl url = QUrl::fromEncoded(location.toUtf8(), QUrl::TolerantMode); - if (url.isValid()) - return url; - } - } - - // Fall back to QUrl's own tolerant parser. - QUrl url = QUrl::fromEncoded(string.toUtf8(), QUrl::TolerantMode); - - // finally for cases where the user just types in a hostname add http - if (url.scheme().isEmpty()) - url = QUrl::fromEncoded("http://" + string.toUtf8(), QUrl::TolerantMode); - return url; -} - -void BrowserWindow::gotoAddress(const QString &address) -{ - m_browserView->navigate(guessUrlFromString(address)); - showBrowserView(); -} - -void BrowserWindow::navigate(const QUrl &url) -{ - m_browserView->navigate(url); - showBrowserView(); -} - -void BrowserWindow::slide(int pos) -{ - m_browserView->move(pos, 0); - m_homeView->move(pos - width(), 0); - m_browserView->show(); - m_homeView->show(); -} - -void BrowserWindow::showHomeView() -{ - if (m_timeLine->state() != QTimeLine::NotRunning) - return; - - m_timeLine->setFrameRange(0, width()); - m_timeLine->start(); - m_homeView->setFocus(); -} - -void BrowserWindow::showBrowserView() -{ - if (m_timeLine->state() != QTimeLine::NotRunning) - return; - - m_timeLine->setFrameRange(width(), 0); - m_timeLine->start(); - m_browserView->setFocus(); -} - -void BrowserWindow::keyReleaseEvent(QKeyEvent *event) -{ - QWidget::keyReleaseEvent(event); - - if (event->key() == Qt::Key_F3) { - if (m_homeView->isVisible()) - showBrowserView(); - else - showHomeView(); - } -} - -void BrowserWindow::resizeEvent(QResizeEvent *event) -{ - if (m_homeView) - m_homeView->resize(size()); - - if (m_browserView) - m_browserView->resize(size()); -} diff --git a/demos/embedded/anamoly/src/BrowserWindow.h b/demos/embedded/anamoly/src/BrowserWindow.h deleted file mode 100644 index 50a6508..0000000 --- a/demos/embedded/anamoly/src/BrowserWindow.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - - -#ifndef BROWSERWINDOW_H -#define BROWSERWINDOW_H - -#include -class QTimeLine; -class QUrl; - -class BrowserView; -class HomeView; - -class BrowserWindow : public QWidget -{ - Q_OBJECT - -public: - BrowserWindow(); - -private slots: - void initialize(); - void navigate(const QUrl &url); - void gotoAddress(const QString &address); - -public slots: - void showBrowserView(); - void showHomeView(); - void slide(int); - -protected: - void keyReleaseEvent(QKeyEvent *event); - void resizeEvent(QResizeEvent *event); - -private: - HomeView *m_homeView; - BrowserView *m_browserView; - QTimeLine *m_timeLine; -}; - -#endif // BROWSERWINDOW_H diff --git a/demos/embedded/anamoly/src/ControlStrip.cpp b/demos/embedded/anamoly/src/ControlStrip.cpp deleted file mode 100644 index 72bc485..0000000 --- a/demos/embedded/anamoly/src/ControlStrip.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#include "ControlStrip.h" - -#include -#include - -ControlStrip::ControlStrip(QWidget *parent) - : QWidget(parent) -{ - menuPixmap.load(":/images/edit-find.png"); - backPixmap.load(":/images/go-previous.png"); - forwardPixmap.load(":/images/go-next.png"); -} - -QSize ControlStrip::sizeHint() const -{ - return minimumSizeHint(); -} - -QSize ControlStrip::minimumSizeHint() const -{ - return QSize(320, 48); -} - -void ControlStrip::mousePressEvent(QMouseEvent *event) -{ - int h = height(); - int x = event->pos().x(); - - if (x < h) { - emit menuClicked(); - event->accept(); - return; - } - - if (x > width() - h) { - emit forwardClicked(); - event->accept(); - return; - } - - if ((x < width() - 2 * h) && (x > width() - 3 * h)) { - emit backClicked(); - event->accept(); - return; - } -} - -void ControlStrip::paintEvent(QPaintEvent *event) -{ - int h = height(); - int s = (h - menuPixmap.height()) / 2; - - QPainter p(this); - p.fillRect(event->rect(), QColor(32, 32, 32, 192)); - p.setCompositionMode(QPainter::CompositionMode_SourceOver); - p.drawPixmap(s, s, menuPixmap); - p.drawPixmap(width() - 3 * h + s, s, backPixmap); - p.drawPixmap(width() - h + s, s, forwardPixmap); - p.end(); -} diff --git a/demos/embedded/anamoly/src/ControlStrip.h b/demos/embedded/anamoly/src/ControlStrip.h deleted file mode 100644 index 99fc58d..0000000 --- a/demos/embedded/anamoly/src/ControlStrip.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#ifndef CONTROLSTRIP_H -#define CONTROLSTRIP_H - -#include - -class ControlStrip : public QWidget -{ - Q_OBJECT - -public: - ControlStrip(QWidget *parent = 0); - - QSize sizeHint() const; - QSize minimumSizeHint() const; - -signals: - void menuClicked(); - void backClicked(); - void forwardClicked(); - -protected: - void paintEvent(QPaintEvent *event); - void mousePressEvent(QMouseEvent *event); - -private: - QPixmap menuPixmap; - QPixmap backPixmap; - QPixmap forwardPixmap; -}; - -#endif // CONTROLSTRIP_H diff --git a/demos/embedded/anamoly/src/HomeView.cpp b/demos/embedded/anamoly/src/HomeView.cpp deleted file mode 100644 index 0f59d54..0000000 --- a/demos/embedded/anamoly/src/HomeView.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#include "HomeView.h" - -#include -#include - -#include "AddressBar.h" -#include "BookmarksView.h" - -HomeView::HomeView(QWidget *parent) - : QWidget(parent) - , m_addressBar(0) -{ - m_addressBar = new AddressBar(parent); - connect(m_addressBar, SIGNAL(addressEntered(QString)), SLOT(gotoAddress(QString))); - - m_bookmarks = new BookmarksView(parent); - connect(m_bookmarks, SIGNAL(urlSelected(QUrl)), SIGNAL(urlActivated(QUrl))); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(4); - layout->setSpacing(4); - layout->addWidget(m_addressBar); - layout->addWidget(m_bookmarks); -} - -void HomeView::gotoAddress(const QString &address) -{ - emit addressEntered(address); -} - -void HomeView::focusInEvent(QFocusEvent *event) -{ - m_addressBar->setFocus(); - QWidget::focusInEvent(event); -} diff --git a/demos/embedded/anamoly/src/HomeView.h b/demos/embedded/anamoly/src/HomeView.h deleted file mode 100644 index b54f07e..0000000 --- a/demos/embedded/anamoly/src/HomeView.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#ifndef HOMEVIEW_H -#define HOMEVIEW_H - -#include - -class QUrl; - -class AddressBar; -class BookmarksView; - -class HomeView : public QWidget -{ - Q_OBJECT - -public: - HomeView(QWidget *parent); - -signals: - void urlActivated(const QUrl &url); - void addressEntered(const QString &address); - -private slots: - void gotoAddress(const QString &address); - -protected: - void focusInEvent(QFocusEvent *event); - -private: - AddressBar *m_addressBar; - BookmarksView *m_bookmarks; -}; - -#endif // HOMEVIEW_H diff --git a/demos/embedded/anamoly/src/Main.cpp b/demos/embedded/anamoly/src/Main.cpp deleted file mode 100644 index 2be6143..0000000 --- a/demos/embedded/anamoly/src/Main.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#include -#include -#include - -#include "BrowserWindow.h" - -#if defined (Q_OS_SYMBIAN) -#include "sym_iap_util.h" -#endif - -int main(int argc, char *argv[]) -{ -#if !defined(Q_WS_S60) - QApplication::setGraphicsSystem("raster"); -#endif - - QApplication app(argc, argv); - - app.setApplicationName("Anomaly"); - app.setApplicationVersion("0.0.0"); - - BrowserWindow window; -#ifdef Q_OS_SYMBIAN - window.showFullScreen(); - QWebSettings::globalSettings()->setObjectCacheCapacities(128*1024, 1024*1024, 1024*1024); - QWebSettings::globalSettings()->setMaximumPagesInCache(3); - qt_SetDefaultIap(); -#else - window.resize(360, 640); - window.show(); - app.setStyle("windows"); -#endif - - return app.exec(); -} - diff --git a/demos/embedded/anamoly/src/TitleBar.cpp b/demos/embedded/anamoly/src/TitleBar.cpp deleted file mode 100644 index ff7837c..0000000 --- a/demos/embedded/anamoly/src/TitleBar.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#include "TitleBar.h" - -#include -#include - -TitleBar::TitleBar(QWidget *parent) - : QWidget(parent) - , m_progress(0) -{ - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); -} - -void TitleBar::setHost(const QString &host) -{ - m_host = host; - update(); -} - -void TitleBar::setTitle(const QString &title) -{ - m_title = title; - update(); -} - -void TitleBar::setProgress(int percent) -{ - m_progress = percent; - update(); -} - -QSize TitleBar::sizeHint() const -{ - return minimumSizeHint(); -} - -QSize TitleBar::minimumSizeHint() const -{ - QFontMetrics fm = fontMetrics(); - return QSize(100, fm.height()); -} - -void TitleBar::paintEvent(QPaintEvent *event) -{ - QString title = m_host; - if (!m_title.isEmpty()) - title.append(": ").append(m_title); - - QPalette pal = palette(); - QPainter p(this); - p.fillRect(event->rect(), pal.color(QPalette::Highlight)); - - if (m_progress > 0) { - - QRect box = rect(); - box.setLeft(16); - box.setWidth(width() - box.left() - 110); - - p.setPen(pal.color(QPalette::HighlightedText)); - p.setOpacity(0.8); - p.drawText(box, Qt::AlignLeft + Qt::AlignVCenter, title); - - int x = width() - 100 - 5; - int y = 1; - int h = height() - 4; - - p.setOpacity(1.0); - p.setBrush(Qt::NoBrush); - p.setPen(pal.color(QPalette::HighlightedText)); - p.drawRect(x, y, 100, h); - p.setPen(Qt::NoPen); - p.setBrush(pal.color(QPalette::HighlightedText)); - p.drawRect(x, y, m_progress, h); - } else { - - QRect box = rect(); - box.setLeft(16); - box.setWidth(width() - box.left() - 5); - p.setPen(pal.color(QPalette::HighlightedText)); - p.drawText(box, Qt::AlignLeft + Qt::AlignVCenter, title); - } - - p.end(); -} diff --git a/demos/embedded/anamoly/src/TitleBar.h b/demos/embedded/anamoly/src/TitleBar.h deleted file mode 100644 index 10ef2a8..0000000 --- a/demos/embedded/anamoly/src/TitleBar.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#ifndef TITLEBAR_H -#define TITLEBAR_H - -#include - -class TitleBar : public QWidget -{ - Q_OBJECT - -public: - TitleBar(QWidget *parent = 0); - - void setHost(const QString &host); - void setTitle(const QString &title); - void setProgress(int percent); - - QSize sizeHint() const; - QSize minimumSizeHint() const; - -protected: - void paintEvent(QPaintEvent *event); - -private: - QString m_host; - QString m_title; - int m_progress; -}; - -#endif // TITLEBAR_H diff --git a/demos/embedded/anamoly/src/ZoomStrip.cpp b/demos/embedded/anamoly/src/ZoomStrip.cpp deleted file mode 100644 index 80bfdea..0000000 --- a/demos/embedded/anamoly/src/ZoomStrip.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#include "ZoomStrip.h" - -#include -#include - -ZoomStrip::ZoomStrip(QWidget *parent) - : QWidget(parent) -{ - zoomInPixmap.load(":/images/list-add.png"); - zoomOutPixmap.load(":/images/list-remove.png"); -} - -QSize ZoomStrip::sizeHint() const -{ - return minimumSizeHint(); -} - -QSize ZoomStrip::minimumSizeHint() const -{ - return QSize(48, 96); -} - -void ZoomStrip::mousePressEvent(QMouseEvent *event) -{ - if (event->pos().y() < height() / 2) - emit zoomInClicked(); - else - emit zoomOutClicked(); -} - -void ZoomStrip::paintEvent(QPaintEvent *event) -{ - int w = width(); - int s = (w - zoomInPixmap.width()) / 2; - - QPainter p(this); - p.fillRect(event->rect(), QColor(128, 128, 128, 128)); - p.drawPixmap(s, s, zoomInPixmap); - p.drawPixmap(s, s + w, zoomOutPixmap); - p.end(); -} diff --git a/demos/embedded/anamoly/src/ZoomStrip.h b/demos/embedded/anamoly/src/ZoomStrip.h deleted file mode 100644 index fdf0328..0000000 --- a/demos/embedded/anamoly/src/ZoomStrip.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Anomaly project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#ifndef ZOOMSTRIP_H -#define ZOOMSTRIP_H - -#include - -class ZoomStrip : public QWidget -{ - Q_OBJECT - -public: - ZoomStrip(QWidget *parent = 0); - - QSize sizeHint() const; - QSize minimumSizeHint() const; - -signals: - void zoomInClicked(); - void zoomOutClicked(); - -protected: - void paintEvent(QPaintEvent *event); - void mousePressEvent(QMouseEvent *event); - -private: - QPixmap zoomInPixmap; - QPixmap zoomOutPixmap; -}; - -#endif // ZOOMSTRIP_H diff --git a/demos/embedded/anamoly/src/anomaly.qrc b/demos/embedded/anamoly/src/anomaly.qrc deleted file mode 100644 index 601a34e..0000000 --- a/demos/embedded/anamoly/src/anomaly.qrc +++ /dev/null @@ -1,9 +0,0 @@ - - - images/go-next.png - images/go-previous.png - images/edit-find.png - images/list-add.png - images/list-remove.png - - diff --git a/demos/embedded/anamoly/src/flickcharm.cpp b/demos/embedded/anamoly/src/flickcharm.cpp deleted file mode 100644 index 620ef88..0000000 --- a/demos/embedded/anamoly/src/flickcharm.cpp +++ /dev/null @@ -1,309 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Graphics Dojo project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#include "flickcharm.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -struct FlickData { - typedef enum { Steady, Pressed, ManualScroll, AutoScroll, Stop } State; - State state; - QWidget *widget; - QPoint pressPos; - QPoint offset; - QPoint dragPos; - QPoint speed; - QList ignored; -}; - -class FlickCharmPrivate -{ -public: - QHash flickData; - QBasicTimer ticker; -}; - -FlickCharm::FlickCharm(QObject *parent): QObject(parent) -{ - d = new FlickCharmPrivate; -} - -FlickCharm::~FlickCharm() -{ - delete d; -} - -void FlickCharm::activateOn(QWidget *widget) -{ - QAbstractScrollArea *scrollArea = dynamic_cast(widget); - if (scrollArea) { - scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - QWidget *viewport = scrollArea->viewport(); - - viewport->installEventFilter(this); - scrollArea->installEventFilter(this); - - d->flickData.remove(viewport); - d->flickData[viewport] = new FlickData; - d->flickData[viewport]->widget = widget; - d->flickData[viewport]->state = FlickData::Steady; - - return; - } - - QWebView *webView = dynamic_cast(widget); - if (webView) { - QWebFrame *frame = webView->page()->mainFrame(); - frame->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); - frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); - - webView->installEventFilter(this); - - d->flickData.remove(webView); - d->flickData[webView] = new FlickData; - d->flickData[webView]->widget = webView; - d->flickData[webView]->state = FlickData::Steady; - - return; - } - - qWarning() << "FlickCharm only works on QAbstractScrollArea (and derived classes)"; - qWarning() << "or QWebView (and derived classes)"; -} - -void FlickCharm::deactivateFrom(QWidget *widget) -{ - QAbstractScrollArea *scrollArea = dynamic_cast(widget); - if (scrollArea) { - QWidget *viewport = scrollArea->viewport(); - - viewport->removeEventFilter(this); - scrollArea->removeEventFilter(this); - - delete d->flickData[viewport]; - d->flickData.remove(viewport); - - return; - } - - QWebView *webView = dynamic_cast(widget); - if (webView) { - webView->removeEventFilter(this); - - delete d->flickData[webView]; - d->flickData.remove(webView); - - return; - } -} - -static QPoint scrollOffset(QWidget *widget) -{ - int x = 0, y = 0; - - QAbstractScrollArea *scrollArea = dynamic_cast(widget); - if (scrollArea) { - x = scrollArea->horizontalScrollBar()->value(); - y = scrollArea->verticalScrollBar()->value(); - } - - QWebView *webView = dynamic_cast(widget); - if (webView) { - QWebFrame *frame = webView->page()->mainFrame(); - x = frame->evaluateJavaScript("window.scrollX").toInt(); - y = frame->evaluateJavaScript("window.scrollY").toInt(); - } - - return QPoint(x, y); -} - -static void setScrollOffset(QWidget *widget, const QPoint &p) -{ - QAbstractScrollArea *scrollArea = dynamic_cast(widget); - if (scrollArea) { - scrollArea->horizontalScrollBar()->setValue(p.x()); - scrollArea->verticalScrollBar()->setValue(p.y()); - } - - QWebView *webView = dynamic_cast(widget); - QWebFrame *frame = webView ? webView->page()->mainFrame() : 0; - if (frame) - frame->evaluateJavaScript(QString("window.scrollTo(%1,%2);").arg(p.x()).arg(p.y())); -} - -static QPoint deaccelerate(const QPoint &speed, int a = 1, int max = 64) -{ - int x = qBound(-max, speed.x(), max); - int y = qBound(-max, speed.y(), max); - x = (x == 0) ? x : (x > 0) ? qMax(0, x - a) : qMin(0, x + a); - y = (y == 0) ? y : (y > 0) ? qMax(0, y - a) : qMin(0, y + a); - return QPoint(x, y); -} - -bool FlickCharm::eventFilter(QObject *object, QEvent *event) -{ - if (!object->isWidgetType()) - return false; - - QEvent::Type type = event->type(); - if (type != QEvent::MouseButtonPress && - type != QEvent::MouseButtonRelease && - type != QEvent::MouseMove) - return false; - - QMouseEvent *mouseEvent = dynamic_cast(event); - if (!mouseEvent || mouseEvent->modifiers() != Qt::NoModifier) - return false; - - QWidget *viewport = dynamic_cast(object); - FlickData *data = d->flickData.value(viewport); - if (!viewport || !data || data->ignored.removeAll(event)) - return false; - - bool consumed = false; - switch (data->state) { - - case FlickData::Steady: - if (mouseEvent->type() == QEvent::MouseButtonPress) - if (mouseEvent->buttons() == Qt::LeftButton) { - consumed = true; - data->state = FlickData::Pressed; - data->pressPos = mouseEvent->pos(); - data->offset = scrollOffset(data->widget); - } - break; - - case FlickData::Pressed: - if (mouseEvent->type() == QEvent::MouseButtonRelease) { - consumed = true; - data->state = FlickData::Steady; - - QMouseEvent *event1 = new QMouseEvent(QEvent::MouseButtonPress, - data->pressPos, Qt::LeftButton, - Qt::LeftButton, Qt::NoModifier); - QMouseEvent *event2 = new QMouseEvent(*mouseEvent); - - data->ignored << event1; - data->ignored << event2; - QApplication::postEvent(object, event1); - QApplication::postEvent(object, event2); - } - if (mouseEvent->type() == QEvent::MouseMove) { - consumed = true; - data->state = FlickData::ManualScroll; - data->dragPos = QCursor::pos(); - if (!d->ticker.isActive()) - d->ticker.start(20, this); - } - break; - - case FlickData::ManualScroll: - if (mouseEvent->type() == QEvent::MouseMove) { - consumed = true; - QPoint delta = mouseEvent->pos() - data->pressPos; - setScrollOffset(data->widget, data->offset - delta); - } - if (mouseEvent->type() == QEvent::MouseButtonRelease) { - consumed = true; - data->state = FlickData::AutoScroll; - } - break; - - case FlickData::AutoScroll: - if (mouseEvent->type() == QEvent::MouseButtonPress) { - consumed = true; - data->state = FlickData::Stop; - data->speed = QPoint(0, 0); - data->pressPos = mouseEvent->pos(); - data->offset = scrollOffset(data->widget); - } - if (mouseEvent->type() == QEvent::MouseButtonRelease) { - consumed = true; - data->state = FlickData::Steady; - data->speed = QPoint(0, 0); - } - break; - - case FlickData::Stop: - if (mouseEvent->type() == QEvent::MouseButtonRelease) { - consumed = true; - data->state = FlickData::Steady; - } - if (mouseEvent->type() == QEvent::MouseMove) { - consumed = true; - data->state = FlickData::ManualScroll; - data->dragPos = QCursor::pos(); - if (!d->ticker.isActive()) - d->ticker.start(20, this); - } - break; - - default: - break; - } - - return consumed; -} - -void FlickCharm::timerEvent(QTimerEvent *event) -{ - int count = 0; - QHashIterator item(d->flickData); - while (item.hasNext()) { - item.next(); - FlickData *data = item.value(); - - if (data->state == FlickData::ManualScroll) { - count++; - data->speed = QCursor::pos() - data->dragPos; - data->dragPos = QCursor::pos(); - } - - if (data->state == FlickData::AutoScroll) { - count++; - data->speed = deaccelerate(data->speed); - QPoint p = scrollOffset(data->widget); - setScrollOffset(data->widget, p - data->speed); - if (data->speed == QPoint(0, 0)) - data->state = FlickData::Steady; - } - } - - if (!count) - d->ticker.stop(); - - QObject::timerEvent(event); -} diff --git a/demos/embedded/anamoly/src/flickcharm.h b/demos/embedded/anamoly/src/flickcharm.h deleted file mode 100644 index 3b3831f..0000000 --- a/demos/embedded/anamoly/src/flickcharm.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Graphics Dojo project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#ifndef FLICKCHARM_H -#define FLICKCHARM_H - -#include - -class FlickCharmPrivate; -class QWidget; - -class FlickCharm: public QObject -{ - Q_OBJECT -public: - FlickCharm(QObject *parent = 0); - ~FlickCharm(); - void activateOn(QWidget *widget); - void deactivateFrom(QWidget *widget); - bool eventFilter(QObject *object, QEvent *event); - -protected: - void timerEvent(QTimerEvent *event); - -private: - FlickCharmPrivate *d; -}; - -#endif // FLICKCHARM_H diff --git a/demos/embedded/anamoly/src/images/edit-find.png b/demos/embedded/anamoly/src/images/edit-find.png deleted file mode 100644 index 5594785..0000000 Binary files a/demos/embedded/anamoly/src/images/edit-find.png and /dev/null differ diff --git a/demos/embedded/anamoly/src/images/go-next.png b/demos/embedded/anamoly/src/images/go-next.png deleted file mode 100644 index a68e2db..0000000 Binary files a/demos/embedded/anamoly/src/images/go-next.png and /dev/null differ diff --git a/demos/embedded/anamoly/src/images/go-previous.png b/demos/embedded/anamoly/src/images/go-previous.png deleted file mode 100644 index c37bc04..0000000 Binary files a/demos/embedded/anamoly/src/images/go-previous.png and /dev/null differ diff --git a/demos/embedded/anamoly/src/images/list-add.png b/demos/embedded/anamoly/src/images/list-add.png deleted file mode 100644 index 2acdd8f..0000000 Binary files a/demos/embedded/anamoly/src/images/list-add.png and /dev/null differ diff --git a/demos/embedded/anamoly/src/images/list-remove.png b/demos/embedded/anamoly/src/images/list-remove.png deleted file mode 100644 index c5524f7..0000000 Binary files a/demos/embedded/anamoly/src/images/list-remove.png and /dev/null differ diff --git a/demos/embedded/anomaly/README.TXT b/demos/embedded/anomaly/README.TXT new file mode 100644 index 0000000..e69de29 diff --git a/demos/embedded/anomaly/anomaly.pro b/demos/embedded/anomaly/anomaly.pro new file mode 100644 index 0000000..5fe5625 --- /dev/null +++ b/demos/embedded/anomaly/anomaly.pro @@ -0,0 +1,29 @@ +QT += network \ + webkit +HEADERS += src/BrowserWindow.h \ + src/BrowserView.h \ + src/TitleBar.h \ + src/HomeView.h \ + src/AddressBar.h \ + src/BookmarksView.h \ + src/flickcharm.h \ + src/ZoomStrip.h \ + src/ControlStrip.h +SOURCES += src/Main.cpp \ + src/BrowserWindow.cpp \ + src/BrowserView.cpp \ + src/TitleBar.cpp \ + src/HomeView.cpp \ + src/AddressBar.cpp \ + src/BookmarksView.cpp \ + src/flickcharm.cpp \ + src/ZoomStrip.cpp \ + src/ControlStrip.cpp +RESOURCES += src/anomaly.qrc + +symbian { + HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h + LIBS += -lesock -lconnmon + TARGET.CAPABILITY = NetworkServices + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 +} diff --git a/demos/embedded/anomaly/src/AddressBar.cpp b/demos/embedded/anomaly/src/AddressBar.cpp new file mode 100644 index 0000000..64734c8 --- /dev/null +++ b/demos/embedded/anomaly/src/AddressBar.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "AddressBar.h" + +#include +#include + +class LineEdit: public QLineEdit +{ +public: + LineEdit(QWidget *parent = 0): QLineEdit(parent) {} + + void paintEvent(QPaintEvent *event) { + QLineEdit::paintEvent(event); + if (text().isEmpty()) { + QPainter p(this); + int flags = Qt::AlignLeft | Qt::AlignVCenter; + p.setPen(palette().color(QPalette::Disabled, QPalette::Text)); + p.drawText(rect().adjusted(10, 0, 0, 0), flags, "Enter address or search terms"); + p.end(); + } + } +}; + +AddressBar::AddressBar(QWidget *parent) + : QWidget(parent) +{ + m_lineEdit = new LineEdit(parent); + connect(m_lineEdit, SIGNAL(returnPressed()), SLOT(processAddress())); + m_toolButton = new QToolButton(parent); + m_toolButton->setText("Go"); + connect(m_toolButton, SIGNAL(clicked()), SLOT(processAddress())); +} + +QSize AddressBar::sizeHint() const +{ + return m_lineEdit->sizeHint(); +} + +void AddressBar::processAddress() +{ + if (!m_lineEdit->text().isEmpty()) + emit addressEntered(m_lineEdit->text()); +} + +void AddressBar::resizeEvent(QResizeEvent *event) +{ + int x, y, w, h; + + m_toolButton->adjustSize(); + x = width() - m_toolButton->width(); + y = 0; + w = m_toolButton->width(); + h = height() - 1; + m_toolButton->setGeometry(x, y, w, h); + m_toolButton->show(); + + x = 0; + y = 0; + w = width() - m_toolButton->width(); + h = height() - 1; + m_lineEdit->setGeometry(x, y, w, h); + m_lineEdit->show(); +} + +void AddressBar::focusInEvent(QFocusEvent *event) +{ + m_lineEdit->setFocus(); + QWidget::focusInEvent(event); +} diff --git a/demos/embedded/anomaly/src/AddressBar.h b/demos/embedded/anomaly/src/AddressBar.h new file mode 100644 index 0000000..632ae1f --- /dev/null +++ b/demos/embedded/anomaly/src/AddressBar.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef ADDRESSBAR_H +#define ADDRESSBAR_H + +#include + +class QLineEdit; +class QToolButton; + +class AddressBar : public QWidget +{ + Q_OBJECT + +public: + AddressBar(QWidget *parent = 0); + QSize sizeHint() const; + +protected: + void resizeEvent(QResizeEvent *event); + void focusInEvent(QFocusEvent *event); + +signals: + void addressEntered(const QString &address); + +private slots: + void processAddress(); + +private: + QLineEdit *m_lineEdit; + QToolButton *m_toolButton; +}; + +#endif // ADDRESSBAR_H diff --git a/demos/embedded/anomaly/src/BookmarksView.cpp b/demos/embedded/anomaly/src/BookmarksView.cpp new file mode 100644 index 0000000..f705383 --- /dev/null +++ b/demos/embedded/anomaly/src/BookmarksView.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "BookmarksView.h" + +#include + +BookmarksView::BookmarksView(QWidget *parent) + : QWidget(parent) +{ + QListWidget *m_iconView = new QListWidget(this); + connect(m_iconView, SIGNAL(itemActivated(QListWidgetItem*)), SLOT(activate(QListWidgetItem*))); + + QVBoxLayout *layout = new QVBoxLayout(this); + setLayout(layout); + layout->addWidget(m_iconView); + + m_iconView->addItem("www.google.com"); + m_iconView->addItem("doc.trolltech.com/4.5"); + m_iconView->addItem("news.bbc.co.uk/text_only.stm"); + m_iconView->addItem("mobile.wikipedia.org"); + m_iconView->addItem("www.qtsoftware.com"); + m_iconView->addItem("en.wikipedia.org"); + + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); +} + +void BookmarksView::activate(QListWidgetItem *item) +{ + QUrl url = item->text().prepend("http://"); + emit urlSelected(url); +} diff --git a/demos/embedded/anomaly/src/BookmarksView.h b/demos/embedded/anomaly/src/BookmarksView.h new file mode 100644 index 0000000..95abdd7 --- /dev/null +++ b/demos/embedded/anomaly/src/BookmarksView.h @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef BOOKMARKSVIEW_H +#define BOOKMARKSVIEW_H + +#include + +class QListWidgetItem; +class QUrl; + +class BookmarksView : public QWidget +{ + Q_OBJECT + +public: + BookmarksView(QWidget *parent = 0); + +signals: + void urlSelected(const QUrl &url); + +private slots: + void activate(QListWidgetItem *item); +}; + +#endif // BOOKMARKSVIEW_H diff --git a/demos/embedded/anomaly/src/BrowserView.cpp b/demos/embedded/anomaly/src/BrowserView.cpp new file mode 100644 index 0000000..e81d834 --- /dev/null +++ b/demos/embedded/anomaly/src/BrowserView.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "BrowserView.h" + +#include +#include +#include + +#include "ControlStrip.h" +#include "TitleBar.h" +#include "flickcharm.h" +#include "ZoomStrip.h" + +BrowserView::BrowserView(QWidget *parent) + : QWidget(parent) + , m_titleBar(0) + , m_webView(0) + , m_progress(0) + , m_currentZoom(100) +{ + m_titleBar = new TitleBar(this); + m_webView = new QWebView(this); + m_zoomStrip = new ZoomStrip(this); + m_controlStrip = new ControlStrip(this); + + m_zoomLevels << 30 << 50 << 67 << 80 << 90; + m_zoomLevels << 100; + m_zoomLevels << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300; + + QTimer::singleShot(0, this, SLOT(initialize())); +} + +void BrowserView::initialize() +{ + connect(m_zoomStrip, SIGNAL(zoomInClicked()), SLOT(zoomIn())); + connect(m_zoomStrip, SIGNAL(zoomOutClicked()), SLOT(zoomOut())); + + connect(m_controlStrip, SIGNAL(menuClicked()), SIGNAL(menuButtonClicked())); + connect(m_controlStrip, SIGNAL(backClicked()), m_webView, SLOT(back())); + connect(m_controlStrip, SIGNAL(forwardClicked()), m_webView, SLOT(forward())); + + QPalette pal = m_webView->palette(); + pal.setBrush(QPalette::Base, Qt::white); + m_webView->setPalette(pal); + + FlickCharm *flickCharm = new FlickCharm(this); + flickCharm->activateOn(m_webView); + + m_webView->setZoomFactor(static_cast(m_currentZoom)/100.0); + connect(m_webView, SIGNAL(loadStarted()), SLOT(start())); + connect(m_webView, SIGNAL(loadProgress(int)), SLOT(setProgress(int))); + connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(finish(bool))); + connect(m_webView, SIGNAL(urlChanged(QUrl)), SLOT(updateTitleBar())); + + m_webView->load(QUrl("http://news.bbc.co.uk/text_only.stm")); + m_webView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_webView->setFocus(); +} + +void BrowserView::start() +{ + m_progress = 0; + updateTitleBar(); + //m_titleBar->setText(m_webView->url().toString()); +} + +void BrowserView::setProgress(int percent) +{ + m_progress = percent; + updateTitleBar(); + //m_titleBar->setText(QString("Loading %1%").arg(percent)); +} + +void BrowserView::updateTitleBar() +{ + QUrl url = m_webView->url(); + m_titleBar->setHost(url.host()); + m_titleBar->setTitle(m_webView->title()); + m_titleBar->setProgress(m_progress); +} + +void BrowserView::finish(bool ok) +{ + m_progress = 0; + updateTitleBar(); + + // TODO: handle error + if (!ok) { + //m_titleBar->setText("Loading failed."); + } +} + +void BrowserView::zoomIn() +{ + int i = m_zoomLevels.indexOf(m_currentZoom); + Q_ASSERT(i >= 0); + if (i < m_zoomLevels.count() - 1) + m_currentZoom = m_zoomLevels[i + 1]; + + m_webView->setZoomFactor(static_cast(m_currentZoom)/100.0); +} + +void BrowserView::zoomOut() +{ + int i = m_zoomLevels.indexOf(m_currentZoom); + Q_ASSERT(i >= 0); + if (i > 0) + m_currentZoom = m_zoomLevels[i - 1]; + + m_webView->setZoomFactor(static_cast(m_currentZoom)/100.0); +} + +void BrowserView::resizeEvent(QResizeEvent *event) +{ + QWidget::resizeEvent(event); + + int h1 = m_titleBar->sizeHint().height(); + int h2 = m_controlStrip->sizeHint().height(); + + m_titleBar->setGeometry(0, 0, width(), h1); + m_controlStrip->setGeometry(0, height() - h2, width(), h2); + m_webView->setGeometry(0, h1, width(), height() - h1); + + int zw = m_zoomStrip->sizeHint().width(); + int zh = m_zoomStrip->sizeHint().height(); + m_zoomStrip->move(width() - zw, (height() - zh) / 2); +} + +void BrowserView::navigate(const QUrl &url) +{ + m_webView->load(url); +} diff --git a/demos/embedded/anomaly/src/BrowserView.h b/demos/embedded/anomaly/src/BrowserView.h new file mode 100644 index 0000000..36d3291 --- /dev/null +++ b/demos/embedded/anomaly/src/BrowserView.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef BROWSERVIEW_H +#define BROWSERVIEW_H + +#include +#include + +class QUrl; +class QWebView; +class TitleBar; +class ControlStrip; +class ZoomStrip; + +class BrowserView : public QWidget +{ + Q_OBJECT + +public: + BrowserView(QWidget *parent = 0); + +public slots: + void navigate(const QUrl &url); + void zoomIn(); + void zoomOut(); + +private slots: + void initialize(); + void start(); + void setProgress(int percent); + void finish(bool); + void updateTitleBar(); + +signals: + void menuButtonClicked(); + +protected: + void resizeEvent(QResizeEvent *event); + +private: + TitleBar *m_titleBar; + QWebView *m_webView; + ZoomStrip *m_zoomStrip; + ControlStrip *m_controlStrip; + int m_progress; + int m_currentZoom; + QVector m_zoomLevels; +}; + +#endif // BROWSERVIEW_H diff --git a/demos/embedded/anomaly/src/BrowserWindow.cpp b/demos/embedded/anomaly/src/BrowserWindow.cpp new file mode 100644 index 0000000..fd2f833 --- /dev/null +++ b/demos/embedded/anomaly/src/BrowserWindow.cpp @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "BrowserWindow.h" + +#include +#include + +#include "BrowserView.h" +#include "HomeView.h" + +BrowserWindow::BrowserWindow() + : QWidget() + , m_homeView(0) + , m_browserView(0) +{ + m_timeLine = new QTimeLine(300, this); + m_timeLine->setCurveShape(QTimeLine::EaseInOutCurve); + QTimer::singleShot(0, this, SLOT(initialize())); +} + +void BrowserWindow::initialize() +{ + m_homeView = new HomeView(this); + m_browserView = new BrowserView(this); + + m_homeView->hide(); + m_homeView->resize(size()); + m_homeView->move(0, 0); + + m_browserView->hide(); + m_browserView->resize(size()); + m_browserView->move(0, 0); + + connect(m_homeView, SIGNAL(addressEntered(QString)), SLOT(gotoAddress(QString))); + connect(m_homeView, SIGNAL(urlActivated(QUrl)), SLOT(navigate(QUrl))); + + connect(m_browserView, SIGNAL(menuButtonClicked()), SLOT(showHomeView())); + + m_homeView->setVisible(false); + m_browserView->setVisible(false); + slide(0); + + connect(m_timeLine, SIGNAL(frameChanged(int)), SLOT(slide(int))); +} + + +// from Demo Browser +QUrl guessUrlFromString(const QString &string) +{ + QString urlStr = string.trimmed(); + QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*")); + + // Check if it looks like a qualified URL. Try parsing it and see. + bool hasSchema = test.exactMatch(urlStr); + if (hasSchema) { + QUrl url = QUrl::fromEncoded(urlStr.toUtf8(), QUrl::TolerantMode); + if (url.isValid()) + return url; + } + + // Might be a file. + if (QFile::exists(urlStr)) { + QFileInfo info(urlStr); + return QUrl::fromLocalFile(info.absoluteFilePath()); + } + + // Might be a shorturl - try to detect the schema. + if (!hasSchema) { + int dotIndex = urlStr.indexOf(QLatin1Char('.')); + if (dotIndex != -1) { + QString prefix = urlStr.left(dotIndex).toLower(); + QString schema = (prefix == QString("ftp")) ? prefix.toLatin1() : QString("http"); + QString location = schema + "://" + urlStr; + QUrl url = QUrl::fromEncoded(location.toUtf8(), QUrl::TolerantMode); + if (url.isValid()) + return url; + } + } + + // Fall back to QUrl's own tolerant parser. + QUrl url = QUrl::fromEncoded(string.toUtf8(), QUrl::TolerantMode); + + // finally for cases where the user just types in a hostname add http + if (url.scheme().isEmpty()) + url = QUrl::fromEncoded("http://" + string.toUtf8(), QUrl::TolerantMode); + return url; +} + +void BrowserWindow::gotoAddress(const QString &address) +{ + m_browserView->navigate(guessUrlFromString(address)); + showBrowserView(); +} + +void BrowserWindow::navigate(const QUrl &url) +{ + m_browserView->navigate(url); + showBrowserView(); +} + +void BrowserWindow::slide(int pos) +{ + m_browserView->move(pos, 0); + m_homeView->move(pos - width(), 0); + m_browserView->show(); + m_homeView->show(); +} + +void BrowserWindow::showHomeView() +{ + if (m_timeLine->state() != QTimeLine::NotRunning) + return; + + m_timeLine->setFrameRange(0, width()); + m_timeLine->start(); + m_homeView->setFocus(); +} + +void BrowserWindow::showBrowserView() +{ + if (m_timeLine->state() != QTimeLine::NotRunning) + return; + + m_timeLine->setFrameRange(width(), 0); + m_timeLine->start(); + m_browserView->setFocus(); +} + +void BrowserWindow::keyReleaseEvent(QKeyEvent *event) +{ + QWidget::keyReleaseEvent(event); + + if (event->key() == Qt::Key_F3) { + if (m_homeView->isVisible()) + showBrowserView(); + else + showHomeView(); + } +} + +void BrowserWindow::resizeEvent(QResizeEvent *event) +{ + if (m_homeView) + m_homeView->resize(size()); + + if (m_browserView) + m_browserView->resize(size()); +} diff --git a/demos/embedded/anomaly/src/BrowserWindow.h b/demos/embedded/anomaly/src/BrowserWindow.h new file mode 100644 index 0000000..50a6508 --- /dev/null +++ b/demos/embedded/anomaly/src/BrowserWindow.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + + +#ifndef BROWSERWINDOW_H +#define BROWSERWINDOW_H + +#include +class QTimeLine; +class QUrl; + +class BrowserView; +class HomeView; + +class BrowserWindow : public QWidget +{ + Q_OBJECT + +public: + BrowserWindow(); + +private slots: + void initialize(); + void navigate(const QUrl &url); + void gotoAddress(const QString &address); + +public slots: + void showBrowserView(); + void showHomeView(); + void slide(int); + +protected: + void keyReleaseEvent(QKeyEvent *event); + void resizeEvent(QResizeEvent *event); + +private: + HomeView *m_homeView; + BrowserView *m_browserView; + QTimeLine *m_timeLine; +}; + +#endif // BROWSERWINDOW_H diff --git a/demos/embedded/anomaly/src/ControlStrip.cpp b/demos/embedded/anomaly/src/ControlStrip.cpp new file mode 100644 index 0000000..72bc485 --- /dev/null +++ b/demos/embedded/anomaly/src/ControlStrip.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "ControlStrip.h" + +#include +#include + +ControlStrip::ControlStrip(QWidget *parent) + : QWidget(parent) +{ + menuPixmap.load(":/images/edit-find.png"); + backPixmap.load(":/images/go-previous.png"); + forwardPixmap.load(":/images/go-next.png"); +} + +QSize ControlStrip::sizeHint() const +{ + return minimumSizeHint(); +} + +QSize ControlStrip::minimumSizeHint() const +{ + return QSize(320, 48); +} + +void ControlStrip::mousePressEvent(QMouseEvent *event) +{ + int h = height(); + int x = event->pos().x(); + + if (x < h) { + emit menuClicked(); + event->accept(); + return; + } + + if (x > width() - h) { + emit forwardClicked(); + event->accept(); + return; + } + + if ((x < width() - 2 * h) && (x > width() - 3 * h)) { + emit backClicked(); + event->accept(); + return; + } +} + +void ControlStrip::paintEvent(QPaintEvent *event) +{ + int h = height(); + int s = (h - menuPixmap.height()) / 2; + + QPainter p(this); + p.fillRect(event->rect(), QColor(32, 32, 32, 192)); + p.setCompositionMode(QPainter::CompositionMode_SourceOver); + p.drawPixmap(s, s, menuPixmap); + p.drawPixmap(width() - 3 * h + s, s, backPixmap); + p.drawPixmap(width() - h + s, s, forwardPixmap); + p.end(); +} diff --git a/demos/embedded/anomaly/src/ControlStrip.h b/demos/embedded/anomaly/src/ControlStrip.h new file mode 100644 index 0000000..99fc58d --- /dev/null +++ b/demos/embedded/anomaly/src/ControlStrip.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef CONTROLSTRIP_H +#define CONTROLSTRIP_H + +#include + +class ControlStrip : public QWidget +{ + Q_OBJECT + +public: + ControlStrip(QWidget *parent = 0); + + QSize sizeHint() const; + QSize minimumSizeHint() const; + +signals: + void menuClicked(); + void backClicked(); + void forwardClicked(); + +protected: + void paintEvent(QPaintEvent *event); + void mousePressEvent(QMouseEvent *event); + +private: + QPixmap menuPixmap; + QPixmap backPixmap; + QPixmap forwardPixmap; +}; + +#endif // CONTROLSTRIP_H diff --git a/demos/embedded/anomaly/src/HomeView.cpp b/demos/embedded/anomaly/src/HomeView.cpp new file mode 100644 index 0000000..0f59d54 --- /dev/null +++ b/demos/embedded/anomaly/src/HomeView.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "HomeView.h" + +#include +#include + +#include "AddressBar.h" +#include "BookmarksView.h" + +HomeView::HomeView(QWidget *parent) + : QWidget(parent) + , m_addressBar(0) +{ + m_addressBar = new AddressBar(parent); + connect(m_addressBar, SIGNAL(addressEntered(QString)), SLOT(gotoAddress(QString))); + + m_bookmarks = new BookmarksView(parent); + connect(m_bookmarks, SIGNAL(urlSelected(QUrl)), SIGNAL(urlActivated(QUrl))); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(4); + layout->setSpacing(4); + layout->addWidget(m_addressBar); + layout->addWidget(m_bookmarks); +} + +void HomeView::gotoAddress(const QString &address) +{ + emit addressEntered(address); +} + +void HomeView::focusInEvent(QFocusEvent *event) +{ + m_addressBar->setFocus(); + QWidget::focusInEvent(event); +} diff --git a/demos/embedded/anomaly/src/HomeView.h b/demos/embedded/anomaly/src/HomeView.h new file mode 100644 index 0000000..b54f07e --- /dev/null +++ b/demos/embedded/anomaly/src/HomeView.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef HOMEVIEW_H +#define HOMEVIEW_H + +#include + +class QUrl; + +class AddressBar; +class BookmarksView; + +class HomeView : public QWidget +{ + Q_OBJECT + +public: + HomeView(QWidget *parent); + +signals: + void urlActivated(const QUrl &url); + void addressEntered(const QString &address); + +private slots: + void gotoAddress(const QString &address); + +protected: + void focusInEvent(QFocusEvent *event); + +private: + AddressBar *m_addressBar; + BookmarksView *m_bookmarks; +}; + +#endif // HOMEVIEW_H diff --git a/demos/embedded/anomaly/src/Main.cpp b/demos/embedded/anomaly/src/Main.cpp new file mode 100644 index 0000000..2be6143 --- /dev/null +++ b/demos/embedded/anomaly/src/Main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include +#include +#include + +#include "BrowserWindow.h" + +#if defined (Q_OS_SYMBIAN) +#include "sym_iap_util.h" +#endif + +int main(int argc, char *argv[]) +{ +#if !defined(Q_WS_S60) + QApplication::setGraphicsSystem("raster"); +#endif + + QApplication app(argc, argv); + + app.setApplicationName("Anomaly"); + app.setApplicationVersion("0.0.0"); + + BrowserWindow window; +#ifdef Q_OS_SYMBIAN + window.showFullScreen(); + QWebSettings::globalSettings()->setObjectCacheCapacities(128*1024, 1024*1024, 1024*1024); + QWebSettings::globalSettings()->setMaximumPagesInCache(3); + qt_SetDefaultIap(); +#else + window.resize(360, 640); + window.show(); + app.setStyle("windows"); +#endif + + return app.exec(); +} + diff --git a/demos/embedded/anomaly/src/TitleBar.cpp b/demos/embedded/anomaly/src/TitleBar.cpp new file mode 100644 index 0000000..ff7837c --- /dev/null +++ b/demos/embedded/anomaly/src/TitleBar.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "TitleBar.h" + +#include +#include + +TitleBar::TitleBar(QWidget *parent) + : QWidget(parent) + , m_progress(0) +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); +} + +void TitleBar::setHost(const QString &host) +{ + m_host = host; + update(); +} + +void TitleBar::setTitle(const QString &title) +{ + m_title = title; + update(); +} + +void TitleBar::setProgress(int percent) +{ + m_progress = percent; + update(); +} + +QSize TitleBar::sizeHint() const +{ + return minimumSizeHint(); +} + +QSize TitleBar::minimumSizeHint() const +{ + QFontMetrics fm = fontMetrics(); + return QSize(100, fm.height()); +} + +void TitleBar::paintEvent(QPaintEvent *event) +{ + QString title = m_host; + if (!m_title.isEmpty()) + title.append(": ").append(m_title); + + QPalette pal = palette(); + QPainter p(this); + p.fillRect(event->rect(), pal.color(QPalette::Highlight)); + + if (m_progress > 0) { + + QRect box = rect(); + box.setLeft(16); + box.setWidth(width() - box.left() - 110); + + p.setPen(pal.color(QPalette::HighlightedText)); + p.setOpacity(0.8); + p.drawText(box, Qt::AlignLeft + Qt::AlignVCenter, title); + + int x = width() - 100 - 5; + int y = 1; + int h = height() - 4; + + p.setOpacity(1.0); + p.setBrush(Qt::NoBrush); + p.setPen(pal.color(QPalette::HighlightedText)); + p.drawRect(x, y, 100, h); + p.setPen(Qt::NoPen); + p.setBrush(pal.color(QPalette::HighlightedText)); + p.drawRect(x, y, m_progress, h); + } else { + + QRect box = rect(); + box.setLeft(16); + box.setWidth(width() - box.left() - 5); + p.setPen(pal.color(QPalette::HighlightedText)); + p.drawText(box, Qt::AlignLeft + Qt::AlignVCenter, title); + } + + p.end(); +} diff --git a/demos/embedded/anomaly/src/TitleBar.h b/demos/embedded/anomaly/src/TitleBar.h new file mode 100644 index 0000000..10ef2a8 --- /dev/null +++ b/demos/embedded/anomaly/src/TitleBar.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef TITLEBAR_H +#define TITLEBAR_H + +#include + +class TitleBar : public QWidget +{ + Q_OBJECT + +public: + TitleBar(QWidget *parent = 0); + + void setHost(const QString &host); + void setTitle(const QString &title); + void setProgress(int percent); + + QSize sizeHint() const; + QSize minimumSizeHint() const; + +protected: + void paintEvent(QPaintEvent *event); + +private: + QString m_host; + QString m_title; + int m_progress; +}; + +#endif // TITLEBAR_H diff --git a/demos/embedded/anomaly/src/ZoomStrip.cpp b/demos/embedded/anomaly/src/ZoomStrip.cpp new file mode 100644 index 0000000..80bfdea --- /dev/null +++ b/demos/embedded/anomaly/src/ZoomStrip.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "ZoomStrip.h" + +#include +#include + +ZoomStrip::ZoomStrip(QWidget *parent) + : QWidget(parent) +{ + zoomInPixmap.load(":/images/list-add.png"); + zoomOutPixmap.load(":/images/list-remove.png"); +} + +QSize ZoomStrip::sizeHint() const +{ + return minimumSizeHint(); +} + +QSize ZoomStrip::minimumSizeHint() const +{ + return QSize(48, 96); +} + +void ZoomStrip::mousePressEvent(QMouseEvent *event) +{ + if (event->pos().y() < height() / 2) + emit zoomInClicked(); + else + emit zoomOutClicked(); +} + +void ZoomStrip::paintEvent(QPaintEvent *event) +{ + int w = width(); + int s = (w - zoomInPixmap.width()) / 2; + + QPainter p(this); + p.fillRect(event->rect(), QColor(128, 128, 128, 128)); + p.drawPixmap(s, s, zoomInPixmap); + p.drawPixmap(s, s + w, zoomOutPixmap); + p.end(); +} diff --git a/demos/embedded/anomaly/src/ZoomStrip.h b/demos/embedded/anomaly/src/ZoomStrip.h new file mode 100644 index 0000000..fdf0328 --- /dev/null +++ b/demos/embedded/anomaly/src/ZoomStrip.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Anomaly project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef ZOOMSTRIP_H +#define ZOOMSTRIP_H + +#include + +class ZoomStrip : public QWidget +{ + Q_OBJECT + +public: + ZoomStrip(QWidget *parent = 0); + + QSize sizeHint() const; + QSize minimumSizeHint() const; + +signals: + void zoomInClicked(); + void zoomOutClicked(); + +protected: + void paintEvent(QPaintEvent *event); + void mousePressEvent(QMouseEvent *event); + +private: + QPixmap zoomInPixmap; + QPixmap zoomOutPixmap; +}; + +#endif // ZOOMSTRIP_H diff --git a/demos/embedded/anomaly/src/anomaly.qrc b/demos/embedded/anomaly/src/anomaly.qrc new file mode 100644 index 0000000..601a34e --- /dev/null +++ b/demos/embedded/anomaly/src/anomaly.qrc @@ -0,0 +1,9 @@ + + + images/go-next.png + images/go-previous.png + images/edit-find.png + images/list-add.png + images/list-remove.png + + diff --git a/demos/embedded/anomaly/src/flickcharm.cpp b/demos/embedded/anomaly/src/flickcharm.cpp new file mode 100644 index 0000000..620ef88 --- /dev/null +++ b/demos/embedded/anomaly/src/flickcharm.cpp @@ -0,0 +1,309 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Graphics Dojo project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "flickcharm.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +struct FlickData { + typedef enum { Steady, Pressed, ManualScroll, AutoScroll, Stop } State; + State state; + QWidget *widget; + QPoint pressPos; + QPoint offset; + QPoint dragPos; + QPoint speed; + QList ignored; +}; + +class FlickCharmPrivate +{ +public: + QHash flickData; + QBasicTimer ticker; +}; + +FlickCharm::FlickCharm(QObject *parent): QObject(parent) +{ + d = new FlickCharmPrivate; +} + +FlickCharm::~FlickCharm() +{ + delete d; +} + +void FlickCharm::activateOn(QWidget *widget) +{ + QAbstractScrollArea *scrollArea = dynamic_cast(widget); + if (scrollArea) { + scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + QWidget *viewport = scrollArea->viewport(); + + viewport->installEventFilter(this); + scrollArea->installEventFilter(this); + + d->flickData.remove(viewport); + d->flickData[viewport] = new FlickData; + d->flickData[viewport]->widget = widget; + d->flickData[viewport]->state = FlickData::Steady; + + return; + } + + QWebView *webView = dynamic_cast(widget); + if (webView) { + QWebFrame *frame = webView->page()->mainFrame(); + frame->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); + frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); + + webView->installEventFilter(this); + + d->flickData.remove(webView); + d->flickData[webView] = new FlickData; + d->flickData[webView]->widget = webView; + d->flickData[webView]->state = FlickData::Steady; + + return; + } + + qWarning() << "FlickCharm only works on QAbstractScrollArea (and derived classes)"; + qWarning() << "or QWebView (and derived classes)"; +} + +void FlickCharm::deactivateFrom(QWidget *widget) +{ + QAbstractScrollArea *scrollArea = dynamic_cast(widget); + if (scrollArea) { + QWidget *viewport = scrollArea->viewport(); + + viewport->removeEventFilter(this); + scrollArea->removeEventFilter(this); + + delete d->flickData[viewport]; + d->flickData.remove(viewport); + + return; + } + + QWebView *webView = dynamic_cast(widget); + if (webView) { + webView->removeEventFilter(this); + + delete d->flickData[webView]; + d->flickData.remove(webView); + + return; + } +} + +static QPoint scrollOffset(QWidget *widget) +{ + int x = 0, y = 0; + + QAbstractScrollArea *scrollArea = dynamic_cast(widget); + if (scrollArea) { + x = scrollArea->horizontalScrollBar()->value(); + y = scrollArea->verticalScrollBar()->value(); + } + + QWebView *webView = dynamic_cast(widget); + if (webView) { + QWebFrame *frame = webView->page()->mainFrame(); + x = frame->evaluateJavaScript("window.scrollX").toInt(); + y = frame->evaluateJavaScript("window.scrollY").toInt(); + } + + return QPoint(x, y); +} + +static void setScrollOffset(QWidget *widget, const QPoint &p) +{ + QAbstractScrollArea *scrollArea = dynamic_cast(widget); + if (scrollArea) { + scrollArea->horizontalScrollBar()->setValue(p.x()); + scrollArea->verticalScrollBar()->setValue(p.y()); + } + + QWebView *webView = dynamic_cast(widget); + QWebFrame *frame = webView ? webView->page()->mainFrame() : 0; + if (frame) + frame->evaluateJavaScript(QString("window.scrollTo(%1,%2);").arg(p.x()).arg(p.y())); +} + +static QPoint deaccelerate(const QPoint &speed, int a = 1, int max = 64) +{ + int x = qBound(-max, speed.x(), max); + int y = qBound(-max, speed.y(), max); + x = (x == 0) ? x : (x > 0) ? qMax(0, x - a) : qMin(0, x + a); + y = (y == 0) ? y : (y > 0) ? qMax(0, y - a) : qMin(0, y + a); + return QPoint(x, y); +} + +bool FlickCharm::eventFilter(QObject *object, QEvent *event) +{ + if (!object->isWidgetType()) + return false; + + QEvent::Type type = event->type(); + if (type != QEvent::MouseButtonPress && + type != QEvent::MouseButtonRelease && + type != QEvent::MouseMove) + return false; + + QMouseEvent *mouseEvent = dynamic_cast(event); + if (!mouseEvent || mouseEvent->modifiers() != Qt::NoModifier) + return false; + + QWidget *viewport = dynamic_cast(object); + FlickData *data = d->flickData.value(viewport); + if (!viewport || !data || data->ignored.removeAll(event)) + return false; + + bool consumed = false; + switch (data->state) { + + case FlickData::Steady: + if (mouseEvent->type() == QEvent::MouseButtonPress) + if (mouseEvent->buttons() == Qt::LeftButton) { + consumed = true; + data->state = FlickData::Pressed; + data->pressPos = mouseEvent->pos(); + data->offset = scrollOffset(data->widget); + } + break; + + case FlickData::Pressed: + if (mouseEvent->type() == QEvent::MouseButtonRelease) { + consumed = true; + data->state = FlickData::Steady; + + QMouseEvent *event1 = new QMouseEvent(QEvent::MouseButtonPress, + data->pressPos, Qt::LeftButton, + Qt::LeftButton, Qt::NoModifier); + QMouseEvent *event2 = new QMouseEvent(*mouseEvent); + + data->ignored << event1; + data->ignored << event2; + QApplication::postEvent(object, event1); + QApplication::postEvent(object, event2); + } + if (mouseEvent->type() == QEvent::MouseMove) { + consumed = true; + data->state = FlickData::ManualScroll; + data->dragPos = QCursor::pos(); + if (!d->ticker.isActive()) + d->ticker.start(20, this); + } + break; + + case FlickData::ManualScroll: + if (mouseEvent->type() == QEvent::MouseMove) { + consumed = true; + QPoint delta = mouseEvent->pos() - data->pressPos; + setScrollOffset(data->widget, data->offset - delta); + } + if (mouseEvent->type() == QEvent::MouseButtonRelease) { + consumed = true; + data->state = FlickData::AutoScroll; + } + break; + + case FlickData::AutoScroll: + if (mouseEvent->type() == QEvent::MouseButtonPress) { + consumed = true; + data->state = FlickData::Stop; + data->speed = QPoint(0, 0); + data->pressPos = mouseEvent->pos(); + data->offset = scrollOffset(data->widget); + } + if (mouseEvent->type() == QEvent::MouseButtonRelease) { + consumed = true; + data->state = FlickData::Steady; + data->speed = QPoint(0, 0); + } + break; + + case FlickData::Stop: + if (mouseEvent->type() == QEvent::MouseButtonRelease) { + consumed = true; + data->state = FlickData::Steady; + } + if (mouseEvent->type() == QEvent::MouseMove) { + consumed = true; + data->state = FlickData::ManualScroll; + data->dragPos = QCursor::pos(); + if (!d->ticker.isActive()) + d->ticker.start(20, this); + } + break; + + default: + break; + } + + return consumed; +} + +void FlickCharm::timerEvent(QTimerEvent *event) +{ + int count = 0; + QHashIterator item(d->flickData); + while (item.hasNext()) { + item.next(); + FlickData *data = item.value(); + + if (data->state == FlickData::ManualScroll) { + count++; + data->speed = QCursor::pos() - data->dragPos; + data->dragPos = QCursor::pos(); + } + + if (data->state == FlickData::AutoScroll) { + count++; + data->speed = deaccelerate(data->speed); + QPoint p = scrollOffset(data->widget); + setScrollOffset(data->widget, p - data->speed); + if (data->speed == QPoint(0, 0)) + data->state = FlickData::Steady; + } + } + + if (!count) + d->ticker.stop(); + + QObject::timerEvent(event); +} diff --git a/demos/embedded/anomaly/src/flickcharm.h b/demos/embedded/anomaly/src/flickcharm.h new file mode 100644 index 0000000..3b3831f --- /dev/null +++ b/demos/embedded/anomaly/src/flickcharm.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Graphics Dojo project on Qt Labs. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 or 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of +** this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef FLICKCHARM_H +#define FLICKCHARM_H + +#include + +class FlickCharmPrivate; +class QWidget; + +class FlickCharm: public QObject +{ + Q_OBJECT +public: + FlickCharm(QObject *parent = 0); + ~FlickCharm(); + void activateOn(QWidget *widget); + void deactivateFrom(QWidget *widget); + bool eventFilter(QObject *object, QEvent *event); + +protected: + void timerEvent(QTimerEvent *event); + +private: + FlickCharmPrivate *d; +}; + +#endif // FLICKCHARM_H diff --git a/demos/embedded/anomaly/src/images/edit-find.png b/demos/embedded/anomaly/src/images/edit-find.png new file mode 100644 index 0000000..5594785 Binary files /dev/null and b/demos/embedded/anomaly/src/images/edit-find.png differ diff --git a/demos/embedded/anomaly/src/images/go-next.png b/demos/embedded/anomaly/src/images/go-next.png new file mode 100644 index 0000000..a68e2db Binary files /dev/null and b/demos/embedded/anomaly/src/images/go-next.png differ diff --git a/demos/embedded/anomaly/src/images/go-previous.png b/demos/embedded/anomaly/src/images/go-previous.png new file mode 100644 index 0000000..c37bc04 Binary files /dev/null and b/demos/embedded/anomaly/src/images/go-previous.png differ diff --git a/demos/embedded/anomaly/src/images/list-add.png b/demos/embedded/anomaly/src/images/list-add.png new file mode 100644 index 0000000..2acdd8f Binary files /dev/null and b/demos/embedded/anomaly/src/images/list-add.png differ diff --git a/demos/embedded/anomaly/src/images/list-remove.png b/demos/embedded/anomaly/src/images/list-remove.png new file mode 100644 index 0000000..c5524f7 Binary files /dev/null and b/demos/embedded/anomaly/src/images/list-remove.png differ diff --git a/demos/embedded/embedded.pro b/demos/embedded/embedded.pro index 8214dd3..8a79298 100644 --- a/demos/embedded/embedded.pro +++ b/demos/embedded/embedded.pro @@ -7,6 +7,8 @@ contains(QT_CONFIG, svg) { desktopservices } +SUBDIRS += anomaly + # install sources.files = README *.pro sources.path = $$[QT_INSTALL_DEMOS]/embedded -- cgit v0.12 From 628d29fc17b47160778a2a81fcaf9a0feedc34d0 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 22 Jun 2009 12:26:19 +0300 Subject: Cleaning up changes doc. --- dist/changes-4.5.2-tower | 122 +++++++++++++++++++++++++---------------------- 1 file changed, 66 insertions(+), 56 deletions(-) diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index 1ed5aaa..1e2fb71 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -4,8 +4,6 @@ Qt 4.5.2-tower The Qt for S60 "Tower" release is the fifth pre-release from the Qt for S60 porting project. "Tower" is based on the Qt 4.5 codebase. -Up to and including SHA: not yet started :D - Lists just S60 fixes, for general 4.5.0 changes go to: http://www.qtsoftware.com/developer/changes/changes-4.5.0 @@ -30,8 +28,11 @@ New modules - QtSql * Implemented QtSql module with sqlite3 backend. For now backend is provided only in binary format. + - QtWebkit - * Experimental webkit build for s60. Can be enabled by passing -webkit to configure. + * Experimental webkit build for s60. Can be enabled by passing -webkit + to configure. + - Phonon * The Phonon library is now part of Qt, but it comes without a backend. This means that applications can build and run against the Phonon @@ -50,17 +51,18 @@ Ported classes - QSound * Implemented CMdaAudioPlayerUtility based Symbian backend for QSound. + - QLocalSocket and QLocalServer - * Added support for QLocalSocket and QLocalServer on Symbian + * Added support for QLocalSocket and QLocalServer on Symbian. Features -------- - QApplication - * Implemented QApplication::beep() for Symbian + * Implemented QApplication::beep() for Symbian. - QSslSocket * Added support for -openssl option i.e. runtime resolving of OpenSSL - symbols + symbols. - QWidget * Basic widgets are now navigatable and usable via keypad on SDK 3 @@ -76,32 +78,34 @@ Optimizations * Optimized drawing operations for RVCT builds, particulary for ARMV6. - qwidget_s60.cpp - * Avoid unnecessary calls to FocusChanged in Symbian + * Avoid unnecessary calls to FocusChanged in Symbian. **************************************************************************** * Code clean-up * **************************************************************************** - Cleanup qeventdispatcher_unix.cpp - * 247268: All qeventdispatcher_unix.cpp changes were reverted since, + * 247268: All qeventdispatcher_unix.cpp changes were reverted since this file is not anymore used in Symbian OS branch. + - Cleanup QtNetwork workarounds implemented earlier due to Open C bugs. - * 247287: Removed getaddrinfo workaround - * 247288: Removed waitForConnected workaround - * 247289: Removed qt_socket_accept workaround - * 247290: Removed qt_socket_connect workaround - * 247290: Removed E32IONREAD workaround - * 247293: Removed nativeHasPendingDatagrams workaround + * 247287: Removed getaddrinfo workaround. + * 247288: Removed waitForConnected workaround. + * 247289: Removed qt_socket_accept workaround. + * 247290: Removed qt_socket_connect workaround. + * 247290: Removed E32IONREAD workaround. + * 247293: Removed nativeHasPendingDatagrams workaround. * 247295: Removed QNativeSocketEnginePrivate::nativeRead EPIPE - workaround + workaround. + - Other code clean-ups * 247278: Removed unnecessary includes from qbackingstore.cpp. - * Fixed Q_OS_SYMBIAN ifdef usage in qfiledialog_p.h + * Fixed Q_OS_SYMBIAN ifdef usage in qfiledialog_p.h. * 247272: Removed qtestnetworkservers.h dependency, used - network-settings.h + network-settings.h. * Revert "Work around compiler bug on Nokia Metrowerks compiler." - * Remove UI highlights being inverted colors based on highlight text colors. - + * Remove UI highlights being inverted colors based on highlight text + colors. **************************************************************************** * Build issues * @@ -109,33 +113,31 @@ Optimizations - QTest * Fixed testlib export macros for RVCT builds. -- namespaces - * Now builds when -qtnamespace option is defined + +- Namespaces + * Now builds when -qtnamespace option is defined. **************************************************************************** * Changes to existing classes * **************************************************************************** - QDesktopServices - * Fixed forwardslash/backslash usage as an path separator + * Fixed forwardslash/backslash usage as an path separator. - QPluginLoader * QPluginLoader will look for plugin stubs from the same folder on other drives if it can't find them from the indicated drive. -- QEventDispatcher - * Lowered the timeout for reprioritizing the process to 100ms - - QNetworkInterface - * Fixed R-handle leak in Symbian version of qnetworkinterface_unix.cpp + * Fixed R-handle leak in Symbian version of qnetworkinterface_unix.cpp. * Introduced a new qnetworkinterface_symbian.cpp, because there wasn't - really anything common to UNIX equivalent + really anything common to UNIX equivalent. - QHostInfo * Added support for host lookups with multiple ipv4 addresses. - QUdpSocket - * Updated BindFlag documentation to reflect behaviour on Symbian OS + * Updated BindFlag documentation to reflect behaviour on Symbian OS. - QLocale * Removed workaround for missing tzname symbol, fixes QLocal timeZone @@ -145,7 +147,7 @@ Optimizations * Fixed temporary file rename in Symbian OS. - QThread - * Fix for thread termination in Symbian OS. + * Fixed thread termination in Symbian OS. - QIoDevice * Fixed compilation error when QIODEVICE_DEBUG is defined. @@ -153,13 +155,16 @@ Optimizations - QS60Style * Added subElementRect implementation for SE_ItemViewItemCheckIndicator. * Added support for E90 layouts. - * Added support for QScrollArea, QTextEditor, QGroupBox, QTreeView, QToolBar and QDial styling. + * Added support for QScrollArea, QTextEditor, QGroupBox, QTreeView, + QToolBar and QDial styling. * Better support for theme and layout changes. * Better support for themed palettes and themed text colors. * Better support for multiselection in item views. * Better theming for QTable and QPanel. - * Better support of highlight graphics and texts for QLists, QTreeViews, QCalendarWidgets and QComboBoxes. - * Support polishing fonts. Fonts are no longer changed within the drawing code. + * Better support of highlight graphics and texts for QLists, QTreeViews, + QCalendarWidgets and QComboBoxes. + * Support polishing fonts. Fonts are no longer changed within the drawing + code. * Draw spinbox arrowbuttons side-by-side, instead one on top of the other. * Harmonize widget drawing so that widgets are of similar height. * Support check states for QLists and QPushButtons. @@ -170,12 +175,13 @@ Optimizations * Separate theme background for QDialogs. * Clarify QToolButton pressed state. * Removed linedrawing of panels and groupboxes. - * Fix palette-polution for a style that is activated from an application after S60Style has been in use. + * Fix palette-polution for a style that is activated from an application + after S60Style has been in use. * Fix for frame masks with color depth other than EGrey2. * Fix for squeezed QTabBars. * Fix memory leak when color skinning graphics. * Show focus/Editfocus visualization for KeyPad navigation on - SDK 3 FP 1 and FP 2 + SDK 3 FP 1 and FP 2. - QDesktopServices * Switched QDesktopServices mail-to URL handling to RSendAs in Symbian, @@ -189,33 +195,34 @@ Optimizations - QApplication * 252798: Fixed layout when orientation changed via AknAppUi::SetOrientationL. - * Generating MouseEvents has gone through several changes + * Generating MouseEvents has gone through several changes. - QUdpSocket * Wrote hack for QUdpSocket::writeDatagram return value in Symbian OS. - QNativeSocketEnginePrivate (non-public) - * Changed select to listen also expectfds in Symbain OS for given - sockets (Workaround to Open C bug). - * Fix to Open C bug: Socket connect failure is indicated exception set. + * Socket connect and listen failure is indicated in exception set. + (Workaround to Open C bug) - QEventDispatcherSymbian (non-public) - * Fixed ASSERT panic in Symbian event dispatcher - * 246600: Fix problem in eventdispatcher destructor / AO canceling - * Fixed active scheduler removal when calling QThread::terminate + * Lowered the timeout for reprioritizing the process to 100ms. + * Fixed ASSERT panic in Symbian event dispatcher. + * 246600: Fix problem in eventdispatcher destructor / AO canceling. + * Fixed active scheduler removal when calling QThread::terminate. * Fix to Open C bug: select sometimes returns -1 and errno is - ECONNREFUSED + ECONNREFUSED. - QWidget - * Added API for setting softkeys + * Added API for setting softkeys. - QMenuBar - * Native menus are handled properly even when application has multiple QMainWindows - * Fixed a bug causing both native and qt menu to be created - * Fix for disappearing options menu after coming back from dialog + * Native menus are handled properly even when application has multiple + QMainWindows. + * Fixed a bug causing both native and qt menu to be created. + * Fix for disappearing options menu after coming back from dialog. - QFontDataBase - * Now, also fonts from the user's /resources/fonts direactories are + * Now, also fonts from the user's /resources/fonts directories are available. - QFontMetrics @@ -224,15 +231,16 @@ Optimizations **************************************************************************** * Examples and demos * **************************************************************************** + - Drilldown - * Added to demonstrate QtSql usage in Symbian OS + * Added to demonstrate QtSql usage in Symbian OS. - Deform, Pathstroke, and Wiggly * Removed Symbian specific animation timer fixes since more generic fix was made to event dispatcher. - Ftp - * Enabled default iap setting for FTP example + * Enabled default IAP setting for FTP example. - DesktopServices * Implemented content filters for desktopservices example. @@ -244,17 +252,17 @@ Optimizations - Fluidlauncher * Removed ugly workaround to make emulator deployment work correctly, since the issue has been fixed in qmake. - * Included drilldown to demonstrate QtSql usage - * Updated screenshots to S60 style - * Added softkeys example + * Included drilldown to demonstrate QtSql usage. + * Updated screenshots to S60 style. + * Added softkeys example. - Softkeys - * New example showing how to use softkeys API in QWidget - + * New example showing how to use softkeys API in QWidget. **************************************************************************** * Tools * **************************************************************************** + - qmake * Support for generating Symbian "test" targets: CONFIG += symbian_test. * Support for Symbian Build System, version 2 (aka Raptor) via @@ -281,13 +289,15 @@ Optimizations * Now creates packages with .sis suffix. - Patch_capabilities script - * Will now patch also vendor id. + * Will now patch also vendor id in binaries and the UID in the pkg file. + **************************************************************************** * Documentation * **************************************************************************** + - qmake-manual - * 250370: Added documentation for ICON keyword + * 250370: Added documentation for ICON keyword. **************************************************************************** * Plugins * -- cgit v0.12 From afceb76c880cf346f92e1c0e95d7fed07fbbe8a0 Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 22 Jun 2009 11:51:01 +0200 Subject: Added my changes to changes-4.5.2-tower. --- dist/changes-4.5.2-tower | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index 1ed5aaa..c3d5673 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -38,6 +38,17 @@ New modules library, but there is currently no S60 backend plugin providing actual multimedia playback. Possible alternatives such as Helix and MMF are being investigated. +- Input methods + * Added events to support opening and closing the virtual keyboard, called + software input panel in Qt. + * Added an option to QApplication to choose between single or double click + input panel activation. + * Added input method hints API to Qt. These can be used to instruct input methods + to only allow certain characters or tailor their appearance. + * Added Qt::ImAnchorPosition to support querying for selections through input + methods. + * Added QInputMethodEvent::Selection to support setting the selection through + input methods. New classes ------------ @@ -107,6 +118,8 @@ Optimizations * Build issues * **************************************************************************** +- Macros + * QT_NO_DEBUG now properly defined in release mode. - QTest * Fixed testlib export macros for RVCT builds. - namespaces @@ -183,8 +196,17 @@ Optimizations correctly. Currently e-mail sending with qdesktopservices::openUrl works in Symbian only if e-mail account already exists. +- QInputContext + * Added QInputContext::s60FilterEvent(). + - QCoeFepInputContext (non-public) * Fixes FEP crash when changing the focused Qt widget to NULL. + * Fixed a bug where the virtual keyboard could not be opened if there + was only one input widget. + * Fixed a crash in FEP when exiting application. + +- QKeyMapper (non-public) + * Fixed a broken keymapping where Enter key would be mapped to Tab. - QApplication * 252798: Fixed layout when orientation changed via @@ -205,6 +227,9 @@ Optimizations * Fixed active scheduler removal when calling QThread::terminate * Fix to Open C bug: select sometimes returns -1 and errno is ECONNREFUSED + * Fix a crash when using QEventLoop::ExcludeSocketNotifiers flag. + * Changed to round robin scheduling for Qt's active objects. Other + active objects will still be scheduled like before. - QWidget * Added API for setting softkeys -- cgit v0.12 From e5482db4317ea0679c9fb5c4d05b0159142ba8a2 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 22 Jun 2009 13:07:03 +0300 Subject: Included demobase.pri to anomaly demo --- demos/embedded/anomaly/anomaly.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/demos/embedded/anomaly/anomaly.pro b/demos/embedded/anomaly/anomaly.pro index 5fe5625..4a0f407 100644 --- a/demos/embedded/anomaly/anomaly.pro +++ b/demos/embedded/anomaly/anomaly.pro @@ -21,6 +21,8 @@ SOURCES += src/Main.cpp \ src/ControlStrip.cpp RESOURCES += src/anomaly.qrc +include($$QT_SOURCE_TREE/demos/demobase.pri) + symbian { HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h LIBS += -lesock -lconnmon -- cgit v0.12 From 4eafa677877e17f67e31d8c40d3480ba0d5830b8 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 22 Jun 2009 12:35:05 +0300 Subject: Added proper UID for demos/embedded/anomaly --- demos/embedded/anomaly/anomaly.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/embedded/anomaly/anomaly.pro b/demos/embedded/anomaly/anomaly.pro index 4a0f407..cf9277e 100644 --- a/demos/embedded/anomaly/anomaly.pro +++ b/demos/embedded/anomaly/anomaly.pro @@ -28,4 +28,5 @@ symbian { LIBS += -lesock -lconnmon TARGET.CAPABILITY = NetworkServices TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 + TARGET.UID3 = 0xA000CF71 } -- cgit v0.12 From 6892bf465ad8768e57c38a7b9efda3615125b83f Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 22 Jun 2009 13:08:14 +0300 Subject: Added anomaly browser to fluidlauncher --- demos/embedded/fluidlauncher/config_s60/config.xml | 1 + demos/embedded/fluidlauncher/fluidlauncher.pro | 9 ++++++--- .../embedded/fluidlauncher/screenshots/anomaly_s60.png | Bin 0 -> 47478 bytes 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 demos/embedded/fluidlauncher/screenshots/anomaly_s60.png diff --git a/demos/embedded/fluidlauncher/config_s60/config.xml b/demos/embedded/fluidlauncher/config_s60/config.xml index 92d9123..f6bac67 100644 --- a/demos/embedded/fluidlauncher/config_s60/config.xml +++ b/demos/embedded/fluidlauncher/config_s60/config.xml @@ -13,6 +13,7 @@ + diff --git a/demos/embedded/fluidlauncher/fluidlauncher.pro b/demos/embedded/fluidlauncher/fluidlauncher.pro index 341b321..11d8a8c 100644 --- a/demos/embedded/fluidlauncher/fluidlauncher.pro +++ b/demos/embedded/fluidlauncher/fluidlauncher.pro @@ -72,7 +72,8 @@ symbian { desktopservices.exe \ fridgemagnets.exe \ drilldown.exe \ - softkeys.exe + softkeys.exe \ + anomaly.exe executables.path = /sys/bin @@ -88,7 +89,8 @@ symbian { $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/desktopservices_reg.rsc \ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/fridgemagnets_reg.rsc \ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/drilldown_reg.rsc \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/softkeys_reg.rsc + $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/softkeys_reg.rsc \ + $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/anomaly_reg.rsc reg_resource.path = $$REG_RESOURCE_IMPORT_DIR @@ -105,7 +107,8 @@ symbian { $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/desktopservices.rsc \ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/fridgemagnets.rsc \ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/drilldown.rsc \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/softkeys.rsc + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/softkeys.rsc \ + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/anomaly.rsc resource.path = $$APP_RESOURCE_DIR diff --git a/demos/embedded/fluidlauncher/screenshots/anomaly_s60.png b/demos/embedded/fluidlauncher/screenshots/anomaly_s60.png new file mode 100644 index 0000000..b9a73fd Binary files /dev/null and b/demos/embedded/fluidlauncher/screenshots/anomaly_s60.png differ -- cgit v0.12 From d59e724d21938fe6886a25b0ba6f4d8d851da7b9 Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Mon, 22 Jun 2009 12:33:45 +0200 Subject: Adding chagest for Tower, --- dist/changes-4.5.2-tower | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index edc029b..4e3a456 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -218,6 +218,8 @@ Optimizations * 252798: Fixed layout when orientation changed via AknAppUi::SetOrientationL. * Generating MouseEvents has gone through several changes. + * qt_init() has been changed: auto flush is always enabled for + window server sessions on 3.1 SDK for both UDEB and UREL. - QUdpSocket * Wrote hack for QUdpSocket::writeDatagram return value in Symbian OS. @@ -253,6 +255,27 @@ Optimizations - QFontMetrics * Fixed the boundingRect calculation for text. +- QPlainTextEdit + * Added support for input methods. + +- QTextEdit + * Added support for input methods. + +- QGraphicsTextItem + * Added support for input methods. + +- QGraphicsView + * Added support for input methods to the the viewport. + +- QLocalSocket + * Connecting to QLocalServer is always done in blocking mode. + +- QSelectThread + * We force monitoring sockets exception status as well, and not + just read/write. + * Notification related to the particular socket signaled via exception + fd_set will be mapped to the appropriate read/write notification. + **************************************************************************** * Examples and demos * **************************************************************************** @@ -266,6 +289,8 @@ Optimizations - Ftp * Enabled default IAP setting for FTP example. + * IAP dialog will show after FTP UI is on screen. + * If active IAP exist that one will be used. - DesktopServices * Implemented content filters for desktopservices example. @@ -345,6 +370,8 @@ Optimizations of Qt libs is desired. * QtCore and QtSql made UNPAGED as workaround for an obscure crash when they are paged. + * qt_libs.pro updated to reflect Open C dependencies, as Qt requires + 1.5.0 and newer release. - todo * todo -- cgit v0.12 From 8084b20b71de5a804dc68a03bca70b733a46ec8c Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Mon, 22 Jun 2009 13:11:14 +0200 Subject: Added jbarron's changes to the changelog. --- dist/changes-4.5.2-tower | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index 4e3a456..78763ae 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -66,6 +66,9 @@ Ported classes - QLocalSocket and QLocalServer * Added support for QLocalSocket and QLocalServer on Symbian. +- QColormap + * Added basic implementation of QColormap for Symbian. + Features -------- - QApplication @@ -78,6 +81,11 @@ Features - QWidget * Basic widgets are now navigatable and usable via keypad on SDK 3 FP 1 and FP 2. + * Widgets can now be made semi-transparent on systems that support it + using Qt::WA_TranslucentBackground. + +- QPixmap + * Added supported for converting to/from CFbsBitmap - todo * todo @@ -91,6 +99,12 @@ Optimizations - qwidget_s60.cpp * Avoid unnecessary calls to FocusChanged in Symbian. +- qwindowsurface_s60.cpp + * Avoid updating raster buffer pointer on window hide + +- QFont + * Use cached DPI for metrics. + **************************************************************************** * Code clean-up * **************************************************************************** @@ -195,6 +209,7 @@ Optimizations * Fix memory leak when color skinning graphics. * Show focus/Editfocus visualization for KeyPad navigation on SDK 3 FP 1 and FP 2. + * Fix for overwriting user specified palettes. - QDesktopServices * Switched QDesktopServices mail-to URL handling to RSendAs in Symbian, @@ -220,6 +235,7 @@ Optimizations * Generating MouseEvents has gone through several changes. * qt_init() has been changed: auto flush is always enabled for window server sessions on 3.1 SDK for both UDEB and UREL. + * Added support for '-graphics-system' command line option - QUdpSocket * Wrote hack for QUdpSocket::writeDatagram return value in Symbian OS. @@ -238,9 +254,13 @@ Optimizations * Fix a crash when using QEventLoop::ExcludeSocketNotifiers flag. * Changed to round robin scheduling for Qt's active objects. Other active objects will still be scheduled like before. + * Fixed crash if events are posted before QApplication construction - QWidget * Added API for setting softkeys. + * Fixed background painting. Background can now be overwritten from + setting the respective palette role. + * Add support for Qt::WA_TranslucentBackground. - QMenuBar * Native menus are handled properly even when application has multiple @@ -255,6 +275,9 @@ Optimizations - QFontMetrics * Fixed the boundingRect calculation for text. +- QFontEngine + * Fix the vertical advance of glyph metrics. + - QPlainTextEdit * Added support for input methods. @@ -276,6 +299,19 @@ Optimizations * Notification related to the particular socket signaled via exception fd_set will be mapped to the appropriate read/write notification. +- QDebug + * Fixed debug printing (incl. qWarning, qFatal) for strings longer + than 256 characters. + +- QDesktopWidget + * 253930: Implement proper resize behavior and emit necessary signals. + +- QTest + * Disable keypad navigation for autotests by default + +- QPixmap + * Added fromSymbianCFbsBitmap() and toSymbianCFbsBitmap(). + **************************************************************************** * Examples and demos * **************************************************************************** -- cgit v0.12 From e4b18d3bff10e89e801939cfed51f720be2828d9 Mon Sep 17 00:00:00 2001 From: Espen Riskedal Date: Mon, 22 Jun 2009 13:52:56 +0200 Subject: some small cosmetic changes --- dist/changes-4.5.2-tower | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index 1ed5aaa..4c2c270 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -2,13 +2,14 @@ Qt 4.5.2-tower --------------- The Qt for S60 "Tower" release is the fifth pre-release from the Qt for -S60 porting project. "Tower" is based on the Qt 4.5 codebase. +S60 porting project. "Tower" is based on the Qt 4.5 codebase (mostly Qt 4.5.2). -Up to and including SHA: not yet started :D - -Lists just S60 fixes, for general 4.5.0 changes go to: +This list of changes lists S60 spesific fixes, +for general 4.5.x changes go to: http://www.qtsoftware.com/developer/changes/changes-4.5.0 + http://www.qtsoftware.com/developer/changes/changes-4.5.1 + http://www.qtsoftware.com/developer/changes/changes-4.5.2 (partially in Tower) Some of the changes listed in this file include issue tracking numbers corresponding to tasks in the Task Tracker: @@ -30,8 +31,10 @@ New modules - QtSql * Implemented QtSql module with sqlite3 backend. For now backend is provided only in binary format. + - QtWebkit - * Experimental webkit build for s60. Can be enabled by passing -webkit to configure. + * Experimental webkit build for S60. Can be enabled by passing -webkit to configure. + - Phonon * The Phonon library is now part of Qt, but it comes without a backend. This means that applications can build and run against the Phonon @@ -39,22 +42,18 @@ New modules multimedia playback. Possible alternatives such as Helix and MMF are being investigated. -New classes ------------- - -- todo - * todo - Ported classes -------------- - QSound * Implemented CMdaAudioPlayerUtility based Symbian backend for QSound. + - QLocalSocket and QLocalServer * Added support for QLocalSocket and QLocalServer on Symbian Features -------- + - QApplication * Implemented QApplication::beep() for Symbian @@ -66,9 +65,6 @@ Features * Basic widgets are now navigatable and usable via keypad on SDK 3 FP 1 and FP 2. -- todo - * todo - Optimizations ------------- @@ -85,6 +81,7 @@ Optimizations - Cleanup qeventdispatcher_unix.cpp * 247268: All qeventdispatcher_unix.cpp changes were reverted since, this file is not anymore used in Symbian OS branch. + - Cleanup QtNetwork workarounds implemented earlier due to Open C bugs. * 247287: Removed getaddrinfo workaround * 247288: Removed waitForConnected workaround @@ -94,6 +91,7 @@ Optimizations * 247293: Removed nativeHasPendingDatagrams workaround * 247295: Removed QNativeSocketEnginePrivate::nativeRead EPIPE workaround + - Other code clean-ups * 247278: Removed unnecessary includes from qbackingstore.cpp. * Fixed Q_OS_SYMBIAN ifdef usage in qfiledialog_p.h @@ -109,6 +107,7 @@ Optimizations - QTest * Fixed testlib export macros for RVCT builds. + - namespaces * Now builds when -qtnamespace option is defined @@ -224,6 +223,7 @@ Optimizations **************************************************************************** * Examples and demos * **************************************************************************** + - Drilldown * Added to demonstrate QtSql usage in Symbian OS @@ -299,7 +299,6 @@ Optimizations run on any supported device, even if with reduced functionality on some. - **************************************************************************** * Important Behavior Changes * **************************************************************************** @@ -310,6 +309,3 @@ Optimizations of Qt libs is desired. * QtCore and QtSql made UNPAGED as workaround for an obscure crash when they are paged. - -- todo - * todo -- cgit v0.12 From 41ea40a0bfd1a288c4b433d215aa475ac0f494ab Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 22 Jun 2009 14:08:55 +0200 Subject: Sorted changes entries by class names. --- dist/changes-4.5.2-tower | 282 +++++++++++++++++++++++------------------------ 1 file changed, 140 insertions(+), 142 deletions(-) diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index 78763ae..94800d3 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -25,20 +25,6 @@ S60 at the moment. New modules ----------- -- QtSql - * Implemented QtSql module with sqlite3 backend. For now backend is - provided only in binary format. - -- QtWebkit - * Experimental webkit build for s60. Can be enabled by passing -webkit - to configure. - -- Phonon - * The Phonon library is now part of Qt, but it comes without a backend. - This means that applications can build and run against the Phonon - library, but there is currently no S60 backend plugin providing actual - multimedia playback. Possible alternatives such as Helix and MMF are - being investigated. - Input methods * Added events to support opening and closing the virtual keyboard, called software input panel in Qt. @@ -51,6 +37,21 @@ New modules * Added QInputMethodEvent::Selection to support setting the selection through input methods. +- Phonon + * The Phonon library is now part of Qt, but it comes without a backend. + This means that applications can build and run against the Phonon + library, but there is currently no S60 backend plugin providing actual + multimedia playback. Possible alternatives such as Helix and MMF are + being investigated. + +- QtSql + * Implemented QtSql module with sqlite3 backend. For now backend is + provided only in binary format. + +- QtWebkit + * Experimental webkit build for s60. Can be enabled by passing -webkit + to configure. + New classes ------------ @@ -60,20 +61,23 @@ New classes Ported classes -------------- -- QSound - * Implemented CMdaAudioPlayerUtility based Symbian backend for QSound. +- QColormap + * Added basic implementation of QColormap for Symbian. - QLocalSocket and QLocalServer * Added support for QLocalSocket and QLocalServer on Symbian. -- QColormap - * Added basic implementation of QColormap for Symbian. +- QSound + * Implemented CMdaAudioPlayerUtility based Symbian backend for QSound. Features -------- - QApplication * Implemented QApplication::beep() for Symbian. +- QPixmap + * Added supported for converting to/from CFbsBitmap + - QSslSocket * Added support for -openssl option i.e. runtime resolving of OpenSSL symbols. @@ -84,9 +88,6 @@ Features * Widgets can now be made semi-transparent on systems that support it using Qt::WA_TranslucentBackground. -- QPixmap - * Added supported for converting to/from CFbsBitmap - - todo * todo @@ -96,15 +97,15 @@ Optimizations - qdrawhelper * Optimized drawing operations for RVCT builds, particulary for ARMV6. +- QFont + * Use cached DPI for metrics. + - qwidget_s60.cpp * Avoid unnecessary calls to FocusChanged in Symbian. - qwindowsurface_s60.cpp * Avoid updating raster buffer pointer on window hide -- QFont - * Use cached DPI for metrics. - **************************************************************************** * Code clean-up * **************************************************************************** @@ -138,6 +139,7 @@ Optimizations - Macros * QT_NO_DEBUG now properly defined in release mode. + - QTest * Fixed testlib export macros for RVCT builds. @@ -148,36 +150,105 @@ Optimizations * Changes to existing classes * **************************************************************************** +- QApplication + * 252798: Fixed layout when orientation changed via + AknAppUi::SetOrientationL. + * Generating MouseEvents has gone through several changes. + * qt_init() has been changed: auto flush is always enabled for + window server sessions on 3.1 SDK for both UDEB and UREL. + * Added support for '-graphics-system' command line option + +- QCoeFepInputContext (non-public) + * Fixes FEP crash when changing the focused Qt widget to NULL. + * Fixed a bug where the virtual keyboard could not be opened if there + was only one input widget. + * Fixed a crash in FEP when exiting application. + +- QDebug + * Fixed debug printing (incl. qWarning, qFatal) for strings longer + than 256 characters. + - QDesktopServices * Fixed forwardslash/backslash usage as an path separator. + * Switched QDesktopServices mail-to URL handling to RSendAs in Symbian, + due to the fact that CSendUi requires extensive capabilities to work + correctly. Currently e-mail sending with qdesktopservices::openUrl + works in Symbian only if e-mail account already exists. -- QPluginLoader - * QPluginLoader will look for plugin stubs from the same folder on other - drives if it can't find them from the indicated drive. +- QDesktopWidget + * 253930: Implement proper resize behavior and emit necessary signals. -- QNetworkInterface - * Fixed R-handle leak in Symbian version of qnetworkinterface_unix.cpp. - * Introduced a new qnetworkinterface_symbian.cpp, because there wasn't - really anything common to UNIX equivalent. +- QEventDispatcherSymbian (non-public) + * Lowered the timeout for reprioritizing the process to 100ms. + * Fixed ASSERT panic in Symbian event dispatcher. + * 246600: Fix problem in eventdispatcher destructor / AO canceling. + * Fixed active scheduler removal when calling QThread::terminate. + * Fix to Open C bug: select sometimes returns -1 and errno is + ECONNREFUSED. + * Fix a crash when using QEventLoop::ExcludeSocketNotifiers flag. + * Changed to round robin scheduling for Qt's active objects. Other + active objects will still be scheduled like before. + * Fixed crash if events are posted before QApplication construction + +- QFontDataBase + * Now, also fonts from the user's /resources/fonts directories are + available. + +- QFontEngine + * Fix the vertical advance of glyph metrics. + +- QFontMetrics + * Fixed the boundingRect calculation for text. + +- QGraphicsView + * Added support for input methods to the the viewport. + +- QGraphicsTextItem + * Added support for input methods. - QHostInfo * Added support for host lookups with multiple ipv4 addresses. -- QUdpSocket - * Updated BindFlag documentation to reflect behaviour on Symbian OS. +- QInputContext + * Added QInputContext::s60FilterEvent(). + +- QIoDevice + * Fixed compilation error when QIODEVICE_DEBUG is defined. + +- QKeyMapper (non-public) + * Fixed a broken keymapping where Enter key would be mapped to Tab. - QLocale * Removed workaround for missing tzname symbol, fixes QLocal timeZone implementation for Symbian. -- QTemporaryFile - * Fixed temporary file rename in Symbian OS. +- QLocalSocket + * Connecting to QLocalServer is always done in blocking mode. -- QThread - * Fixed thread termination in Symbian OS. +- QMenuBar + * Native menus are handled properly even when application has multiple + QMainWindows. + * Fixed a bug causing both native and qt menu to be created. + * Fix for disappearing options menu after coming back from dialog. -- QIoDevice - * Fixed compilation error when QIODEVICE_DEBUG is defined. +- QNativeSocketEnginePrivate (non-public) + * Socket connect and listen failure is indicated in exception set. + (Workaround to Open C bug) + +- QNetworkInterface + * Fixed R-handle leak in Symbian version of qnetworkinterface_unix.cpp. + * Introduced a new qnetworkinterface_symbian.cpp, because there wasn't + really anything common to UNIX equivalent. + +- QPixmap + * Added fromSymbianCFbsBitmap() and toSymbianCFbsBitmap(). + +- QPlainTextEdit + * Added support for input methods. + +- QPluginLoader + * QPluginLoader will look for plugin stubs from the same folder on other + drives if it can't find them from the indicated drive. - QS60Style * Added subElementRect implementation for SE_ItemViewItemCheckIndicator. @@ -211,129 +282,48 @@ Optimizations SDK 3 FP 1 and FP 2. * Fix for overwriting user specified palettes. -- QDesktopServices - * Switched QDesktopServices mail-to URL handling to RSendAs in Symbian, - due to the fact that CSendUi requires extensive capabilities to work - correctly. Currently e-mail sending with qdesktopservices::openUrl - works in Symbian only if e-mail account already exists. +- QSelectThread (non-public) + * We force monitoring sockets exception status as well, and not + just read/write. + * Notification related to the particular socket signaled via exception + fd_set will be mapped to the appropriate read/write notification. -- QInputContext - * Added QInputContext::s60FilterEvent(). +- QTemporaryFile + * Fixed temporary file rename in Symbian OS. -- QCoeFepInputContext (non-public) - * Fixes FEP crash when changing the focused Qt widget to NULL. - * Fixed a bug where the virtual keyboard could not be opened if there - was only one input widget. - * Fixed a crash in FEP when exiting application. +- QTest + * Disable keypad navigation for autotests by default -- QKeyMapper (non-public) - * Fixed a broken keymapping where Enter key would be mapped to Tab. +- QTextEdit + * Added support for input methods. -- QApplication - * 252798: Fixed layout when orientation changed via - AknAppUi::SetOrientationL. - * Generating MouseEvents has gone through several changes. - * qt_init() has been changed: auto flush is always enabled for - window server sessions on 3.1 SDK for both UDEB and UREL. - * Added support for '-graphics-system' command line option +- QThread + * Fixed thread termination in Symbian OS. - QUdpSocket + * Updated BindFlag documentation to reflect behaviour on Symbian OS. * Wrote hack for QUdpSocket::writeDatagram return value in Symbian OS. -- QNativeSocketEnginePrivate (non-public) - * Socket connect and listen failure is indicated in exception set. - (Workaround to Open C bug) - -- QEventDispatcherSymbian (non-public) - * Lowered the timeout for reprioritizing the process to 100ms. - * Fixed ASSERT panic in Symbian event dispatcher. - * 246600: Fix problem in eventdispatcher destructor / AO canceling. - * Fixed active scheduler removal when calling QThread::terminate. - * Fix to Open C bug: select sometimes returns -1 and errno is - ECONNREFUSED. - * Fix a crash when using QEventLoop::ExcludeSocketNotifiers flag. - * Changed to round robin scheduling for Qt's active objects. Other - active objects will still be scheduled like before. - * Fixed crash if events are posted before QApplication construction - - QWidget * Added API for setting softkeys. * Fixed background painting. Background can now be overwritten from setting the respective palette role. * Add support for Qt::WA_TranslucentBackground. -- QMenuBar - * Native menus are handled properly even when application has multiple - QMainWindows. - * Fixed a bug causing both native and qt menu to be created. - * Fix for disappearing options menu after coming back from dialog. - -- QFontDataBase - * Now, also fonts from the user's /resources/fonts directories are - available. - -- QFontMetrics - * Fixed the boundingRect calculation for text. - -- QFontEngine - * Fix the vertical advance of glyph metrics. - -- QPlainTextEdit - * Added support for input methods. - -- QTextEdit - * Added support for input methods. - -- QGraphicsTextItem - * Added support for input methods. - -- QGraphicsView - * Added support for input methods to the the viewport. - -- QLocalSocket - * Connecting to QLocalServer is always done in blocking mode. - -- QSelectThread - * We force monitoring sockets exception status as well, and not - just read/write. - * Notification related to the particular socket signaled via exception - fd_set will be mapped to the appropriate read/write notification. - -- QDebug - * Fixed debug printing (incl. qWarning, qFatal) for strings longer - than 256 characters. - -- QDesktopWidget - * 253930: Implement proper resize behavior and emit necessary signals. - -- QTest - * Disable keypad navigation for autotests by default - -- QPixmap - * Added fromSymbianCFbsBitmap() and toSymbianCFbsBitmap(). - **************************************************************************** * Examples and demos * **************************************************************************** -- Drilldown - * Added to demonstrate QtSql usage in Symbian OS. - - Deform, Pathstroke, and Wiggly * Removed Symbian specific animation timer fixes since more generic fix was made to event dispatcher. -- Ftp - * Enabled default IAP setting for FTP example. - * IAP dialog will show after FTP UI is on screen. - * If active IAP exist that one will be used. - - DesktopServices * Implemented content filters for desktopservices example. * Added error handling to qdesktopservices example when openUrl fails. -- SecureSocketClient - * Fixed build issue caused by lack of cursor. +- Drilldown + * Added to demonstrate QtSql usage in Symbian OS. - Fluidlauncher * Removed ugly workaround to make emulator deployment work correctly, @@ -342,6 +332,14 @@ Optimizations * Updated screenshots to S60 style. * Added softkeys example. +- Ftp + * Enabled default IAP setting for FTP example. + * IAP dialog will show after FTP UI is on screen. + * If active IAP exist that one will be used. + +- SecureSocketClient + * Fixed build issue caused by lack of cursor. + - Softkeys * New example showing how to use softkeys API in QWidget. @@ -349,6 +347,12 @@ Optimizations * Tools * **************************************************************************** +- configure + * -cetest is no longer a supported switch for configure. + * -stl option is enabled by default for Symbian OS + * -openssl option is enabled by default for Symbian OS. + * -fpu option enables vfpu type selection for ARM targets. + - qmake * Support for generating Symbian "test" targets: CONFIG += symbian_test. * Support for Symbian Build System, version 2 (aka Raptor) via @@ -362,12 +366,6 @@ Optimizations * Qt's VERSION variable will now generate VERSION keyword in mmp files. * Made Open C include paths handling bit more robust. -- configure - * -cetest is no longer a supported switch for configure. - * -stl option is enabled by default for Symbian OS - * -openssl option is enabled by default for Symbian OS. - * -fpu option enables vfpu type selection for ARM targets. - - Release package creation * Removed the obsolete script to create release package. -- cgit v0.12 From 51f22da2d2332c1a5c039a079bdc357e0f09176b Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 22 Jun 2009 14:25:02 +0200 Subject: Changed to a more accurate change description. The elements always had input method support. It was the virtual keyboard that was missing. --- dist/changes-4.5.2-tower | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index 6683775..5d5deed 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -197,10 +197,10 @@ Optimizations * Fixed the boundingRect calculation for text. - QGraphicsView - * Added support for input methods to the the viewport. + * Added support for virtual keyboard to the the viewport. - QGraphicsTextItem - * Added support for input methods. + * Added support for virtual keyboard. - QHostInfo * Added support for host lookups with multiple ipv4 addresses. @@ -240,7 +240,7 @@ Optimizations * Added fromSymbianCFbsBitmap() and toSymbianCFbsBitmap(). - QPlainTextEdit - * Added support for input methods. + * Added support for virtual keyboard. - QPluginLoader * QPluginLoader will look for plugin stubs from the same folder on other @@ -291,7 +291,7 @@ Optimizations * Disable keypad navigation for autotests by default - QTextEdit - * Added support for input methods. + * Added support for virtual keyboard. - QThread * Fixed thread termination in Symbian OS. -- cgit v0.12 From 54d8f6f7f43a15c9e1ab4708bc5be62a37f82de6 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 22 Jun 2009 15:37:46 +0300 Subject: Added changes releated to anomaly browser --- dist/changes-4.5.2-tower | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index 5d5deed..b3f2913 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -310,6 +310,9 @@ Optimizations * Examples and demos * **************************************************************************** +- Anomaly browser + * Added to demonstrate QtWebkit usage. + - Deform, Pathstroke, and Wiggly * Removed Symbian specific animation timer fixes since more generic fix was made to event dispatcher. @@ -327,6 +330,7 @@ Optimizations * Included drilldown to demonstrate QtSql usage. * Updated screenshots to S60 style. * Added softkeys example. + * Added Anomaly browser to fluidlauncher. - Ftp * Enabled default IAP setting for FTP example. -- cgit v0.12 From 0a945c6211421162e9af04bfb291da2a0a02d075 Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 22 Jun 2009 14:45:37 +0200 Subject: Corrected typo. --- dist/changes-4.5.2-tower | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index b3f2913..e5f2914 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -4,7 +4,7 @@ Qt 4.5.2-tower The Qt for S60 "Tower" release is the fifth pre-release from the Qt for S60 porting project. "Tower" is based on the Qt 4.5 codebase (mostly Qt 4.5.2). -This list of changes lists S60 spesific fixes only, +This list of changes lists S60 specific fixes only, for general 4.5.x changes go to: http://www.qtsoftware.com/developer/changes/changes-4.5.0 -- cgit v0.12 From 0e4ecf60cca560c3f0cadb1a3616b7ac8793bc00 Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 22 Jun 2009 14:47:52 +0200 Subject: Brought the file in sync with the Tower release file. --- dist/changes-4.5.2-tower | 1 - 1 file changed, 1 deletion(-) diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index e5f2914..a793eee 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -138,7 +138,6 @@ Optimizations - QTest * Fixed testlib export macros for RVCT builds. - - Namespaces * Now builds when -qtnamespace option is defined. -- cgit v0.12 From 6b32ad93bea82601dcf7c1c5984aa4fceb83dceb Mon Sep 17 00:00:00 2001 From: Iain Date: Mon, 22 Jun 2009 16:05:56 +0200 Subject: Tower changes --- dist/changes-4.5.2-tower | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index a793eee..3ca32ed 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -162,6 +162,8 @@ Optimizations - QDebug * Fixed debug printing (incl. qWarning, qFatal) for strings longer than 256 characters. + * introduce a breakpoint to get the emulator to stop in the debugger + when qFatal is called - QDesktopServices * Fixed forwardslash/backslash usage as an path separator. @@ -364,6 +366,8 @@ Optimizations by qmake for symbian-* mkspecs. * Qt's VERSION variable will now generate VERSION keyword in mmp files. * Made Open C include paths handling bit more robust. + * Support both Symbian Foundation header structure in /epoc32/include, + as well as old Symbian/S60 structure - Release package creation * Removed the obsolete script to create release package. @@ -400,7 +404,7 @@ Optimizations * Qt libs are now built with "All -Tcb" capabilities always. It is now always necessary to run patch_capabilities.pl script if self-signing of Qt libs is desired. - * QtCore and QtSql made UNPAGED as workaround for an obscure crash - when they are paged. + * QtCore and QtSql made UNPAGED when installed via SIS file as a + workaround for an obscure crash when they are paged. * qt_libs.pro updated to reflect Open C dependencies, as Qt requires 1.5.0 and newer release. -- cgit v0.12 From 3903747324b87cf8c3a0d831478c0854557caf79 Mon Sep 17 00:00:00 2001 From: mread Date: Mon, 22 Jun 2009 17:00:29 +0100 Subject: exceptions added to changes doc --- dist/changes-4.5.2-tower | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index 3ca32ed..eaf493d 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -55,6 +55,12 @@ New modules * Experimental webkit build for S60. Can be enabled by passing -webkit to configure. +New classes +------------ + +- QScopedPointer + * Smart pointer, which deletes pointer when destroyed. + Ported classes -------------- @@ -86,6 +92,11 @@ Features * Widgets can now be made semi-transparent on systems that support it using Qt::WA_TranslucentBackground. +- Exception safety + * Improving the exception safety of Qt, not yet complete. + * Added support for translating between Symbian leaves and standard C++ + exceptions. + Optimizations ------------- @@ -100,6 +111,15 @@ Optimizations - qwindowsurface_s60.cpp * Avoid updating raster buffer pointer on window hide + +Documentation +------------- + +- exceptionsafety.qdoc + * A guide to exception safety in Qt. + +- symbian-exceptionsafety.qdoc + * A guide to integrating exception safety in Qt with Symbian. **************************************************************************** * Code clean-up * @@ -307,6 +327,9 @@ Optimizations setting the respective palette role. * Add support for Qt::WA_TranslucentBackground. +- Many classes + * Improved exception safety. + **************************************************************************** * Examples and demos * **************************************************************************** @@ -408,3 +431,6 @@ Optimizations workaround for an obscure crash when they are paged. * qt_libs.pro updated to reflect Open C dependencies, as Qt requires 1.5.0 and newer release. + * Qt libs are now build with the "STDCPP" mmp flag. On platforms from + TB9.2, Qt code will throw std::bad_alloc exceptions on allocation + failure. -- cgit v0.12 From 87d6f3e2af17adf244c4280bbadf67340412e0a5 Mon Sep 17 00:00:00 2001 From: Iain Date: Mon, 22 Jun 2009 18:56:18 +0200 Subject: Wrap anomaly demo in a QT_CONFIG statement to indicate dependancy on webkit --- demos/embedded/embedded.pro | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/demos/embedded/embedded.pro b/demos/embedded/embedded.pro index 8a79298..25904ef 100644 --- a/demos/embedded/embedded.pro +++ b/demos/embedded/embedded.pro @@ -7,7 +7,9 @@ contains(QT_CONFIG, svg) { desktopservices } -SUBDIRS += anomaly +contains(QT_CONFIG, webkit) { + SUBDIRS += anomaly +} # install sources.files = README *.pro -- cgit v0.12 From 1d67e109bcb75271bfbe6ffaefac87cec19f1e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Tue, 23 Jun 2009 16:17:14 +0300 Subject: Draw white rect into canvas to distinguish the script graphic from theme background. --- examples/script/context2d/qcontext2dcanvas.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/script/context2d/qcontext2dcanvas.cpp b/examples/script/context2d/qcontext2dcanvas.cpp index 30bb3eb..c6772ce 100644 --- a/examples/script/context2d/qcontext2dcanvas.cpp +++ b/examples/script/context2d/qcontext2dcanvas.cpp @@ -85,6 +85,11 @@ void QContext2DCanvas::contentsChanged(const QImage &image) void QContext2DCanvas::paintEvent(QPaintEvent *e) { QPainter p(this); +#ifdef Q_WS_S60 +// Draw white rect first since in with some themes the js-file content will produce black-on-black. + QBrush whiteBgBrush(Qt::white); + p.fillRect(e->rect(), whiteBgBrush); +#endif p.setClipRect(e->rect()); p.drawImage(0, 0, m_image); } -- cgit v0.12 From 8aafaa65a1d16f8b982279f5aceedf1e281ddb5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Tue, 23 Jun 2009 18:22:01 +0300 Subject: S60Style: QTable theme background moved from cell area to be 'behind' the whole widget. Also item view highlight slightly tuned to be closer to what it is like on native UI. --- src/gui/styles/qs60style.cpp | 42 ++++++++++++++-------------------------- src/gui/styles/qs60style_s60.cpp | 4 ++++ 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 9975b22..794e19f 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1394,8 +1394,10 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, option, painter, widget);} // draw the focus rect - if (isSelected) - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); + if (isSelected) { + const QRect highlightRect = option->rect.adjusted(1,1,-1,-1); + QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, highlightRect, flags); + } // draw the icon const QIcon::Mode mode = (voptAdj.state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled; @@ -1796,39 +1798,24 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, painter->restore(); } break; - case CE_HeaderEmptyArea: - { - QS60StylePrivate::SkinElementFlags adjFlags = flags; - QRect emptyAreaRect = option->rect; - const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); - if (option->state & QStyle::State_Horizontal) { - emptyAreaRect.adjust(-frameWidth,-frameWidth,frameWidth,-frameWidth); - } else { - if ( option->direction == Qt::LeftToRight ) { - emptyAreaRect.adjust(-frameWidth,-frameWidth,0,frameWidth); - adjFlags |= QS60StylePrivate::SF_PointWest; - } else { - emptyAreaRect.adjust(frameWidth,frameWidth,0,-frameWidth); - adjFlags |= QS60StylePrivate::SF_PointEast; - } - } - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, emptyAreaRect, adjFlags); - } + case CE_HeaderEmptyArea: // no need to draw this break; case CE_Header: if ( const QStyleOptionHeader *header = qstyleoption_cast(option)) { QS60StylePrivate::SkinElementFlags adjFlags = flags; QRect mtyRect = header->rect; - QRect parentRect = widget->parentWidget()->rect(); const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); if (header->orientation == Qt::Horizontal) { - mtyRect.adjust(-frameWidth,-frameWidth,frameWidth,-frameWidth); + if (header->position == QStyleOptionHeader::OnlyOneSection) + mtyRect.adjust(frameWidth,1,frameWidth,-frameWidth); + else + mtyRect.adjust(-frameWidth,1,frameWidth,-frameWidth); } else { if ( header->direction == Qt::LeftToRight ) { - mtyRect.adjust(-frameWidth,-frameWidth,0,frameWidth); + mtyRect.adjust(1,-frameWidth,0,frameWidth); adjFlags |= QS60StylePrivate::SF_PointWest; } else { - mtyRect.adjust(frameWidth,frameWidth,0,-frameWidth); + mtyRect.adjust(-1,frameWidth,0,-frameWidth); adjFlags |= QS60StylePrivate::SF_PointEast; } } @@ -1892,8 +1879,11 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, break; #endif //QT_NO_TOOLBAR case CE_ShapedFrame: - if (qobject_cast(widget)) + if (qobject_cast(widget)) { QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags); + } else if (qobject_cast(widget) && qobject_cast(widget)) { + QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableItem, painter, option->rect, flags); + } if (option->state & State_HasFocus) drawPrimitive(PE_FrameFocusRect, option, painter, widget); break; @@ -2136,8 +2126,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti #ifndef QT_NO_ITEMVIEWS case PE_PanelItemViewItem: case PE_PanelItemViewRow: // ### Qt 5: remove - if (qobject_cast(widget) && qstyleoption_cast(option)) - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableItem, painter, option->rect, flags); break; #endif //QT_NO_ITEMVIEWS diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 6688fe7..63346da 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -853,6 +853,10 @@ TRect QS60StyleModeSpecifics::innerRectFromElement(QS60StylePrivate::SkinFrameEl widthShrink = widthShrink>>1; heightShrink = heightShrink>>1; break; + case QS60StylePrivate::SF_ListHighlight: + widthShrink = widthShrink-2; + heightShrink = heightShrink-2; + break; default: break; } -- cgit v0.12