From e41daa4edb0799866fc910de692fcecf8f75c7eb Mon Sep 17 00:00:00 2001
From: Iain <qt-info@nokia.com>
Date: Thu, 5 Nov 2009 13:31:38 +0100
Subject: gcc for Symbian doesn't support gcc extensions like atomicity.h -
 disable

---
 src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h | 4 ++--
 src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h
index 1599562..5fb7fe3 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h
@@ -75,7 +75,7 @@
 #include <libkern/OSAtomic.h>
 #elif OS(ANDROID)
 #include <cutils/atomic.h>
-#elif COMPILER(GCC)
+#elif COMPILER(GCC) && !PLATFORM(SYMBIAN)
 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2))
 #include <ext/atomicity.h>
 #else
@@ -239,7 +239,7 @@ inline int atomicDecrement(int volatile* addend) { return OSAtomicDecrement32Bar
 inline int atomicIncrement(int volatile* addend) { return android_atomic_inc(addend); }
 inline int atomicDecrement(int volatile* addend) { return android_atomic_dec(addend); }
 
-#elif COMPILER(GCC) && !CPU(SPARC64) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc
+#elif COMPILER(GCC) && !PLATFORM(SPARC64) && !PLATFORM(SYMBIAN) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc
 #define WTF_USE_LOCKFREE_THREADSAFESHARED 1
 
 inline int atomicIncrement(int volatile* addend) { return __gnu_cxx::__exchange_and_add(addend, 1) + 1; }
diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h
index 71c9402..52a24f6 100644
--- a/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h
+++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h
@@ -73,7 +73,7 @@
 #include <windows.h>
 #elif PLATFORM(DARWIN)
 #include <libkern/OSAtomic.h>
-#elif COMPILER(GCC)
+#elif COMPILER(GCC) && !PLATFORM(SYMBIAN)
 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2))
 #include <ext/atomicity.h>
 #else
@@ -232,7 +232,7 @@ inline int atomicDecrement(int volatile* addend) { return InterlockedDecrement(r
 inline int atomicIncrement(int volatile* addend) { return OSAtomicIncrement32Barrier(const_cast<int*>(addend)); }
 inline int atomicDecrement(int volatile* addend) { return OSAtomicDecrement32Barrier(const_cast<int*>(addend)); }
 
-#elif COMPILER(GCC) && !PLATFORM(SPARC64) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc
+#elif COMPILER(GCC) && !PLATFORM(SPARC64) && !PLATFORM(SYMBIAN) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc
 #define WTF_USE_LOCKFREE_THREADSAFESHARED 1
 
 inline int atomicIncrement(int volatile* addend) { return __gnu_cxx::__exchange_and_add(addend, 1) + 1; }
-- 
cgit v0.12


From a38bf46289d6dd5da6d252d23d4c99711243eeb0 Mon Sep 17 00:00:00 2001
From: Thomas Zander <t.zander@nokia.com>
Date: Tue, 16 Mar 2010 14:28:26 +0100
Subject: Make multimedia only depend on opengl when the latter is build

Reviewed-By: axis
---
 src/src.pro | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/src.pro b/src/src.pro
index 0033942..c2ed59d 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -109,7 +109,8 @@ src_declarative.target = sub-declarative
    src_tools_idc.depends = src_corelib             # target defined in tools.pro
    src_tools_uic3.depends = src_qt3support src_xml # target defined in tools.pro
    src_phonon.depends = src_gui
-   src_multimedia.depends = src_gui src_opengl
+   src_multimedia.depends = src_gui
+   contains(QT_CONFIG, opengl):src_multimedia.depends += src_opengl
    src_tools_activeqt.depends = src_tools_idc src_gui
    src_declarative.depends = src_xml src_gui src_script src_network src_svg
    src_plugins.depends = src_gui src_sql src_svg src_multimedia
-- 
cgit v0.12


From d758a688f037d8d369e4150dda322736ce6b5346 Mon Sep 17 00:00:00 2001
From: Thomas Zander <t.zander@nokia.com>
Date: Tue, 16 Mar 2010 16:42:59 +0100
Subject: Whitespace

---
 tools/runonphone/main.cpp             | 42 +++++++++++++++++------------------
 tools/runonphone/serenum_stub.cpp     |  2 +-
 tools/runonphone/serenum_unix.cpp     |  2 +-
 tools/runonphone/trksignalhandler.cpp | 30 ++++++++++++-------------
 4 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/tools/runonphone/main.cpp b/tools/runonphone/main.cpp
index 1a5cdee..65085e0 100644
--- a/tools/runonphone/main.cpp
+++ b/tools/runonphone/main.cpp
@@ -44,9 +44,9 @@
 #include <QStringList>
 #include <QScopedPointer>
 #include <QTimer>
-#include "trkutils.h"
-#include "trkdevice.h"
-#include "launcher.h"
+#include "symbianutils/trkutils.h"
+#include "symbianutils/trkdevice.h"
+#include "symbianutils/launcher.h"
 
 #include "trksignalhandler.h"
 #include "serenum.h"
@@ -133,28 +133,28 @@ int main(int argc, char *argv[])
         return 1;
     }
 
-    if(serialPortName.isEmpty()) {
-        if(loglevel > 0)
+    if (serialPortName.isEmpty()) {
+        if (loglevel > 0)
             outstream << "Detecting serial ports" << endl;
         QList <SerialPortId> ports = enumerateSerialPorts();
         foreach(SerialPortId id, ports) {
-            if(loglevel > 0)
+            if (loglevel > 0)
                 outstream << "Port Name: " << id.portName << ", "
                      << "Friendly Name:" << id.friendlyName << endl;
-            if(serialPortName.isEmpty()) {
-                if(!id.friendlyName.isEmpty() &&
-                   serialPortFriendlyName.isEmpty() &&
-                    (id.friendlyName.contains("symbian", Qt::CaseInsensitive) ||
-                       id.friendlyName.contains("s60", Qt::CaseInsensitive) ||
-                       id.friendlyName.contains("nokia", Qt::CaseInsensitive)))
-                        serialPortName = id.portName;
-                else if (!id.friendlyName.isEmpty() &&
-                         !serialPortFriendlyName.isEmpty() &&
-                         id.friendlyName.contains(serialPortFriendlyName))
+            if (serialPortName.isEmpty()) {
+                if (!id.friendlyName.isEmpty()
+                        && serialPortFriendlyName.isEmpty()
+                        && (id.friendlyName.contains("symbian", Qt::CaseInsensitive)
+                            || id.friendlyName.contains("s60", Qt::CaseInsensitive)
+                            || id.friendlyName.contains("nokia", Qt::CaseInsensitive)))
                         serialPortName = id.portName;
+                else if (!id.friendlyName.isEmpty()
+                        && !serialPortFriendlyName.isEmpty()
+                        && id.friendlyName.contains(serialPortFriendlyName))
+                    serialPortName = id.portName;
             }
         }
-        if(serialPortName.isEmpty()) {
+        if (serialPortName.isEmpty()) {
             errstream << "No phone found, ensure USB cable is connected or specify manually with -p" << endl;
             return 1;
         }
@@ -162,7 +162,7 @@ int main(int argc, char *argv[])
 
     QScopedPointer<trk::Launcher> launcher;
 
-    if(sisFile.isEmpty()) {
+    if (sisFile.isEmpty()) {
         launcher.reset(new trk::Launcher(trk::Launcher::ActionCopyRun));
         launcher->setCopyFileName(exeFile, QString("c:\\sys\\bin\\") + exeFile);
         errstream << "System TRK required to copy EXE, use --sis if using Application TRK" << endl;
@@ -172,14 +172,14 @@ int main(int argc, char *argv[])
         launcher->setCopyFileName(sisFile, "c:\\data\\testtemp.sis");
         launcher->setInstallFileName("c:\\data\\testtemp.sis");
     }
-    if(loglevel > 0)
+    if (loglevel > 0)
         outstream << "Connecting to target via " << serialPortName << endl;
     launcher->setTrkServerName(serialPortName);
 
     launcher->setFileName(QString("c:\\sys\\bin\\") + exeFile);
     launcher->setCommandLineArgs(cmdLine);
 
-    if(loglevel > 1)
+    if (loglevel > 1)
         launcher->setVerbose(1);
 
     TrkSignalHandler handler;
@@ -212,7 +212,7 @@ int main(int argc, char *argv[])
     }
 
     QString errorMessage;
-    if(!launcher->startServer(&errorMessage)) {
+    if (!launcher->startServer(&errorMessage)) {
         errstream << errorMessage << endl;
         return 1;
     }
diff --git a/tools/runonphone/serenum_stub.cpp b/tools/runonphone/serenum_stub.cpp
index f39765e..6f0e1ef 100644
--- a/tools/runonphone/serenum_stub.cpp
+++ b/tools/runonphone/serenum_stub.cpp
@@ -47,7 +47,7 @@
 QList<SerialPortId> enumerateSerialPorts()
 {
     QList<SerialPortId> list;
-    qWarning() << "enumerateSerialPorts not implemented" << endl;
+    qWarning() << "enumerateSerialPorts not implemented";
     return list;
 }
 
diff --git a/tools/runonphone/serenum_unix.cpp b/tools/runonphone/serenum_unix.cpp
index ca6c437..c8ec021 100644
--- a/tools/runonphone/serenum_unix.cpp
+++ b/tools/runonphone/serenum_unix.cpp
@@ -51,7 +51,7 @@ QList<SerialPortId> enumerateSerialPorts()
     QList<SerialPortId> list;
     QDir dir("/dev/serial/by-id/");
     QFileInfoList ports(dir.entryInfoList());
-    foreach(QFileInfo info, ports) {
+    foreach (const QFileInfo &info, ports) {
         if (!info.isDir()) {
             SerialPortId id;
             id.friendlyName = info.fileName();
diff --git a/tools/runonphone/trksignalhandler.cpp b/tools/runonphone/trksignalhandler.cpp
index 4fa79f1..9fe2035 100644
--- a/tools/runonphone/trksignalhandler.cpp
+++ b/tools/runonphone/trksignalhandler.cpp
@@ -58,13 +58,13 @@ private:
 
 void TrkSignalHandler::copyingStarted()
 {
-    if(d->loglevel > 0)
+    if (d->loglevel > 0)
         d->out << "Copying..." << endl;
 }
 
 void TrkSignalHandler::canNotConnect(const QString &errorMessage)
 {
-    d->err << "Cannot Connect - " << errorMessage << endl;
+    d->err << "Cannot connect - " << errorMessage << endl;
 }
 
 void TrkSignalHandler::canNotCreateFile(const QString &filename, const QString &errorMessage)
@@ -84,7 +84,7 @@ void TrkSignalHandler::canNotCloseFile(const QString &filename, const QString &e
 
 void TrkSignalHandler::installingStarted()
 {
-    if(d->loglevel > 0)
+    if (d->loglevel > 0)
         d->out << "Installing..." << endl;
 }
 
@@ -95,19 +95,19 @@ void TrkSignalHandler::canNotInstall(const QString &packageFilename, const QStri
 
 void TrkSignalHandler::installingFinished()
 {
-    if(d->loglevel > 0)
+    if (d->loglevel > 0)
         d->out << "Installing finished" << endl;
 }
 
 void TrkSignalHandler::startingApplication()
 {
-    if(d->loglevel > 0)
+    if (d->loglevel > 0)
         d->out << "Starting app..." << endl;
 }
 
 void TrkSignalHandler::applicationRunning(uint pid)
 {
-    if(d->loglevel > 0)
+    if (d->loglevel > 0)
         d->out << "Running..." << endl;
 }
 
@@ -118,7 +118,7 @@ void TrkSignalHandler::canNotRun(const QString &errorMessage)
 
 void TrkSignalHandler::finished()
 {
-    if(d->loglevel > 0)
+    if (d->loglevel > 0)
         d->out << "Done." << endl;
     QCoreApplication::quit();
 }
@@ -130,17 +130,17 @@ void TrkSignalHandler::applicationOutputReceived(const QString &output)
 
 void TrkSignalHandler::copyProgress(int percent)
 {
-    if(d->loglevel > 0) {
+    if (d->loglevel > 0) {
         d->out << percent << "% ";
         d->out.flush();
-        if(percent==100)
+        if (percent==100)
             d->out << endl;
     }
 }
 
 void TrkSignalHandler::stateChanged(int state)
 {
-    if(d->loglevel > 1)
+    if (d->loglevel > 1)
         d->out << "State" << state << endl;
 }
 
@@ -164,10 +164,10 @@ void TrkSignalHandler::timeout()
     emit terminate();
 }
 
-TrkSignalHandlerPrivate::TrkSignalHandlerPrivate() :
-        out(stdout),
-        err(stderr),
-        loglevel(0)
+TrkSignalHandlerPrivate::TrkSignalHandlerPrivate()
+    : out(stdout),
+    err(stderr),
+    loglevel(0)
 {
 
 }
@@ -179,8 +179,8 @@ TrkSignalHandlerPrivate::~TrkSignalHandlerPrivate()
 }
 
 TrkSignalHandler::TrkSignalHandler()
+    : d(new TrkSignalHandlerPrivate())
 {
-    d = new TrkSignalHandlerPrivate();
 }
 
 TrkSignalHandler::~TrkSignalHandler()
-- 
cgit v0.12


From a34c82bb5a0a0e6c2bdccfef5fb31e7a0667c906 Mon Sep 17 00:00:00 2001
From: Thomas Zander <t.zander@nokia.com>
Date: Thu, 18 Mar 2010 16:40:30 +0100
Subject: Use libusb to auto-detect the port to use to communicate with the
 phone

---
 tools/runonphone/main.cpp         | 26 +++++++-------
 tools/runonphone/runonphone.pro   |  3 ++
 tools/runonphone/serenum_unix.cpp | 71 +++++++++++++++++++++++++++++++++++++--
 3 files changed, 85 insertions(+), 15 deletions(-)

diff --git a/tools/runonphone/main.cpp b/tools/runonphone/main.cpp
index 65085e0..af08777 100644
--- a/tools/runonphone/main.cpp
+++ b/tools/runonphone/main.cpp
@@ -136,22 +136,22 @@ int main(int argc, char *argv[])
     if (serialPortName.isEmpty()) {
         if (loglevel > 0)
             outstream << "Detecting serial ports" << endl;
-        QList <SerialPortId> ports = enumerateSerialPorts();
-        foreach(SerialPortId id, ports) {
+        foreach (const SerialPortId &id, enumerateSerialPorts()) {
             if (loglevel > 0)
                 outstream << "Port Name: " << id.portName << ", "
                      << "Friendly Name:" << id.friendlyName << endl;
-            if (serialPortName.isEmpty()) {
-                if (!id.friendlyName.isEmpty()
-                        && serialPortFriendlyName.isEmpty()
-                        && (id.friendlyName.contains("symbian", Qt::CaseInsensitive)
-                            || id.friendlyName.contains("s60", Qt::CaseInsensitive)
-                            || id.friendlyName.contains("nokia", Qt::CaseInsensitive)))
-                        serialPortName = id.portName;
-                else if (!id.friendlyName.isEmpty()
-                        && !serialPortFriendlyName.isEmpty()
-                        && id.friendlyName.contains(serialPortFriendlyName))
-                    serialPortName = id.portName;
+            if (!id.friendlyName.isEmpty()
+                    && serialPortFriendlyName.isEmpty()
+                    && (id.friendlyName.contains("symbian", Qt::CaseInsensitive)
+                        || id.friendlyName.contains("s60", Qt::CaseInsensitive)
+                        || id.friendlyName.contains("nokia", Qt::CaseInsensitive))) {
+                serialPortName = id.portName;
+                break;
+            } else if (!id.friendlyName.isEmpty()
+                    && !serialPortFriendlyName.isEmpty()
+                    && id.friendlyName.contains(serialPortFriendlyName)) {
+                serialPortName = id.portName;
+                break;
             }
         }
         if (serialPortName.isEmpty()) {
diff --git a/tools/runonphone/runonphone.pro b/tools/runonphone/runonphone.pro
index 7bed3e5..0c63723 100644
--- a/tools/runonphone/runonphone.pro
+++ b/tools/runonphone/runonphone.pro
@@ -22,7 +22,10 @@ windows {
 }
 else:unix:!symbian {
     SOURCES += serenum_unix.cpp
+    LIBS += -lusb
 }
 else {
     SOURCES += serenum_stub.cpp
 }
+
+
diff --git a/tools/runonphone/serenum_unix.cpp b/tools/runonphone/serenum_unix.cpp
index c8ec021..b6f0293 100644
--- a/tools/runonphone/serenum_unix.cpp
+++ b/tools/runonphone/serenum_unix.cpp
@@ -46,13 +46,80 @@
 #include <QFileInfo>
 #include <QDir>
 
+#include <usb.h>
+
 QList<SerialPortId> enumerateSerialPorts()
 {
+    QList<QString> eligableInterfaces;
     QList<SerialPortId> list;
+
+    usb_init();
+    usb_find_busses();
+    usb_find_devices();
+
+    for (struct usb_bus *bus = usb_get_busses(); bus; bus = bus->next) {
+        for (struct usb_device *device = bus->devices; device; device = device->next) {
+            for (int n = 0; n < device->descriptor.bNumConfigurations; ++n) {
+                struct usb_config_descriptor &usbConfig =device->config[n];
+                QList<int> usableInterfaces;
+                for (int m = 0; m < usbConfig.bNumInterfaces; ++m) {
+                    for (int o = 0; o < usbConfig.interface[m].num_altsetting; ++o) {
+                        struct usb_interface_descriptor &descriptor = usbConfig.interface[m].altsetting[o];
+                        if (descriptor.bInterfaceClass != 2 // "Communication"
+                                || descriptor.bInterfaceSubClass != 2 // Abstract (modem)
+                                || descriptor.bInterfaceProtocol != 255) // Vendor Specific
+                            continue;
+
+                        unsigned char *buf = descriptor.extra;
+                        unsigned int size = descriptor.extralen;
+                        while (size >= 2 * sizeof(u_int8_t)) {
+                            // for Communication devices there is a slave interface for the actual
+                            // data transmission.
+                            // the extra info stores that as a index for the interface
+                            if (buf[0] >= 5 && buf[1] == 36 && buf[2] == 6) { // CDC Union
+                                for (int i = 4; i < buf[0]; i++)
+                                    usableInterfaces.append((int) buf[i]);
+                            }
+                            size -= buf[0];
+                            buf += buf[0];
+                        }
+                    }
+                }
+
+                // second loop to find the actual data interface.
+                foreach (int i, usableInterfaces) {
+                    for (int m = 0; m < usbConfig.bNumInterfaces; ++m) {
+                        for (int o = 0; o < usbConfig.interface[m].num_altsetting; ++o) {
+                            struct usb_interface_descriptor &descriptor = usbConfig.interface[m].altsetting[o];
+                            if (descriptor.bInterfaceNumber != i)
+                                continue;
+                            if (descriptor.bInterfaceClass == 10) { // "CDC Data"
+                                // qDebug() << "      found the data port"
+                                //     << "bus:" << bus->dirname
+                                //     << "device" << device->filename
+                                //     << "interface" << descriptor.bInterfaceNumber;
+                                eligableInterfaces << QString("if%1").arg(QString::number(i), 2, QChar('0')); // fix!
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
     QDir dir("/dev/serial/by-id/");
-    QFileInfoList ports(dir.entryInfoList());
-    foreach (const QFileInfo &info, ports) {
+    foreach (const QFileInfo &info, dir.entryInfoList()) {
         if (!info.isDir()) {
+            bool usable = eligableInterfaces.isEmpty();
+            foreach (const QString &iface, eligableInterfaces) {
+                if (info.fileName().contains(iface)) {
+                    usable = true;
+                    break;
+                }
+            }
+            if (!usable)
+                continue;
+
             SerialPortId id;
             id.friendlyName = info.fileName();
             id.portName = info.canonicalFilePath();
-- 
cgit v0.12


From aea135e1b1dad919229c9bfde248f8bb615c3c5d Mon Sep 17 00:00:00 2001
From: Miikka Heikkinen <miikka.heikkinen@digia.com>
Date: Fri, 19 Mar 2010 15:06:10 +0200
Subject: Moved QMAKE_MOC etc. variable declarations after symbian.conf
 inclusion

$${DIR_SEPARATOR} wasn't yet declared in the previous place.
This was only a problem for projects built outside Qt tree, as
.qmake.cache also redefined these variables.

Reviewed-by: axis
---
 mkspecs/common/symbian/symbian-mmp.conf | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/mkspecs/common/symbian/symbian-mmp.conf b/mkspecs/common/symbian/symbian-mmp.conf
index e54e878..507b60c 100644
--- a/mkspecs/common/symbian/symbian-mmp.conf
+++ b/mkspecs/common/symbian/symbian-mmp.conf
@@ -2,17 +2,18 @@
 # qmake configuration for symbian-*
 #
 
+include(symbian.conf)
+
 contains(QMAKE_HOST.os, "Windows") {
-    QMAKE_MOC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc.exe
-    QMAKE_UIC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe
-    QMAKE_IDC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe
+    QMAKE_MOC       = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc.exe
+    QMAKE_UIC       = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe
+    QMAKE_IDC       = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe
 } else {
-    QMAKE_MOC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc
-    QMAKE_UIC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic
-    QMAKE_IDC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc
+    QMAKE_MOC       = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc
+    QMAKE_UIC       = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic
+    QMAKE_IDC       = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc
 }
 
-include(symbian.conf)
 load(symbian/add_mmp_rules)
 
 symbian-abld {
-- 
cgit v0.12