summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-02-10 01:34:42 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-02-10 01:34:42 (GMT)
commitf57a2756ebfb48c2fad94c0c319fa181d2af4dfd (patch)
tree6cff930efe7d988001d514802a35e79a943064df
parentbd145e708d97ffb5a68bf53bbdf04b8df8ea4a9b (diff)
parentb0c972dfd208411086b53ee2c2b0594ade3e2d10 (diff)
downloadQt-f57a2756ebfb48c2fad94c0c319fa181d2af4dfd.zip
Qt-f57a2756ebfb48c2fad94c0c319fa181d2af4dfd.tar.gz
Qt-f57a2756ebfb48c2fad94c0c319fa181d2af4dfd.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt-s60-public into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/qt-s60-public: Add the download URI for smart installer package to documentation Catch up symbianutils to creator 3efdb87682a5785bac7b90f9f9a8bb819a1cb053 rename trk -> symbianutils Catch up TRK library to creator f2b3e9f2dfbc580389b9b683a3e46e5a8422f55b Fixed defect in handling of expose events for Symbian Added qwidget test case which displays a native child widget Fix tst_QAbstractItemView::task250754_fontChange and tst_QAbstractItemView::QTBUG6407_extendedSelection for Symbian & 5800
-rw-r--r--doc/src/deployment/deployment.qdoc7
-rw-r--r--doc/src/platforms/symbian-introduction.qdoc11
-rw-r--r--src/gui/kernel/qapplication_s60.cpp11
-rw-r--r--src/gui/kernel/qwidget_p.h3
-rw-r--r--src/gui/kernel/qwidget_s60.cpp2
-rw-r--r--src/gui/painting/qwindowsurface_s60.cpp11
-rw-r--r--tests/auto/qabstractitemview/tst_qabstractitemview.cpp11
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp11
-rw-r--r--tools/runonphone/main.cpp4
-rw-r--r--tools/runonphone/runonphone.pro4
-rw-r--r--tools/runonphone/symbianutils/bluetoothlistener.cpp (renamed from tools/runonphone/trk/bluetoothlistener.cpp)2
-rw-r--r--tools/runonphone/symbianutils/bluetoothlistener.h (renamed from tools/runonphone/trk/bluetoothlistener.h)4
-rw-r--r--tools/runonphone/symbianutils/bluetoothlistener_gui.cpp (renamed from tools/runonphone/trk/bluetoothlistener_gui.cpp)6
-rw-r--r--tools/runonphone/symbianutils/bluetoothlistener_gui.h (renamed from tools/runonphone/trk/bluetoothlistener_gui.h)8
-rw-r--r--tools/runonphone/symbianutils/callback.h (renamed from tools/runonphone/trk/callback.h)2
-rw-r--r--tools/runonphone/symbianutils/communicationstarter.cpp (renamed from tools/runonphone/trk/communicationstarter.cpp)21
-rw-r--r--tools/runonphone/symbianutils/communicationstarter.h (renamed from tools/runonphone/trk/communicationstarter.h)10
-rw-r--r--tools/runonphone/symbianutils/launcher.cpp (renamed from tools/runonphone/trk/launcher.cpp)34
-rw-r--r--tools/runonphone/symbianutils/launcher.h (renamed from tools/runonphone/trk/launcher.h)2
-rw-r--r--tools/runonphone/symbianutils/symbiandevicemanager.cpp331
-rw-r--r--tools/runonphone/symbianutils/symbiandevicemanager.h145
-rw-r--r--tools/runonphone/symbianutils/symbianutils.pri (renamed from tools/runonphone/trk/trk.pri)10
-rw-r--r--tools/runonphone/symbianutils/symbianutils_global.h55
-rw-r--r--tools/runonphone/symbianutils/trkdevice.cpp (renamed from tools/runonphone/trk/trkdevice.cpp)47
-rw-r--r--tools/runonphone/symbianutils/trkdevice.h (renamed from tools/runonphone/trk/trkdevice.h)9
-rw-r--r--tools/runonphone/symbianutils/trkutils.cpp (renamed from tools/runonphone/trk/trkutils.cpp)106
-rw-r--r--tools/runonphone/symbianutils/trkutils.h (renamed from tools/runonphone/trk/trkutils.h)45
-rw-r--r--tools/runonphone/symbianutils/trkutils_p.h62
28 files changed, 806 insertions, 168 deletions
diff --git a/doc/src/deployment/deployment.qdoc b/doc/src/deployment/deployment.qdoc
index ecd6b11..bf0bc74 100644
--- a/doc/src/deployment/deployment.qdoc
+++ b/doc/src/deployment/deployment.qdoc
@@ -1557,7 +1557,12 @@
\snippet doc/src/snippets/code/doc_src_deployment.qdoc 58
If everything compiled and linked without any errors, we are now ready to create
- an application installation package (\c wiggly_installer.sis):
+ an application installation package (\c wiggly_installer.sis).
+
+ If you haven't done so already, download the latest release of the Smart Installer
+ from \l{http://get.qt.nokia.com/nokiasmartinstaller/}, and install it on top of the Qt package
+
+ Then use this command to create the installer sis package:
\snippet doc/src/snippets/code/doc_src_deployment.qdoc 59
diff --git a/doc/src/platforms/symbian-introduction.qdoc b/doc/src/platforms/symbian-introduction.qdoc
index 94075f5..5cebee3 100644
--- a/doc/src/platforms/symbian-introduction.qdoc
+++ b/doc/src/platforms/symbian-introduction.qdoc
@@ -127,7 +127,8 @@
\row \o \c run \o Run the application on the emulator.
\row \o \c runonphone \o Run the application on a device.
\row \o \c sis \o Create signed \c .sis file for project.
- \row \o \c installer_sis \o Create signed smart installer \c .sis file for project.
+ \row \o \c installer_sis \o Create signed \l{Smart Installer}{smart installer}
+ \c .sis file for project.
Smart installer will attempt to download
missing dependencies in addition to
just installing the application.
@@ -141,6 +142,14 @@
To work on your project in Carbide, simply import the \c .pro file
by right clicking on the project explorer and executing "Import...".
+ \section2 Smart Installer
+
+ The Smart Installer makes sure that deployed applications have all the Qt dependencies
+ they need to run on a device.
+
+ Download the latest release of the Smart Installer from \l{http://get.qt.nokia.com/nokiasmartinstaller/},
+ and install it on top of the Qt package.
+
\section1 Installing your own applications
To install your own applications on hardware, you need a signed \c .sis file.
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index 4a137ee..bf3ad71 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -809,12 +809,15 @@ TCoeInputCapabilities QSymbianControl::InputCapabilities() const
void QSymbianControl::Draw(const TRect& controlRect) const
{
// Set flag to avoid calling DrawNow in window surface
- QWExtra *extra = qwidget->d_func()->extraData();
- if (extra && !extra->inExpose) {
- extra->inExpose = true;
+ QWidget *window = qwidget->window();
+ Q_ASSERT(window);
+ QTLWExtra *topExtra = window->d_func()->maybeTopData();
+ Q_ASSERT(topExtra);
+ if (!topExtra->inExpose) {
+ topExtra->inExpose = true;
QRect exposeRect = qt_TRect2QRect(controlRect);
qwidget->d_func()->syncBackingStore(exposeRect);
- extra->inExpose = false;
+ topExtra->inExpose = false;
}
QWindowSurface *surface = qwidget->windowSurface();
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index b1eb3c3..4b62074 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -173,6 +173,8 @@ struct QTLWExtra {
#ifndef QT_NO_QWS_MANAGER
QWSManager *qwsManager;
#endif
+#elif defined(Q_OS_SYMBIAN)
+ uint inExpose : 1; // Prevents drawing recursion
#endif
};
@@ -229,7 +231,6 @@ struct QWExtra {
#endif
#elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian
uint activated : 1; // RWindowBase::Activated has been called
- uint inExpose : 1; // Prevents drawing recursion
/**
* Defines the behaviour of QSymbianControl::Draw.
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index a844430..ebd289c 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -878,6 +878,7 @@ void QWidgetPrivate::registerDropSite(bool /* on */)
void QWidgetPrivate::createTLSysExtra()
{
extra->topextra->backingStore = 0;
+ extra->topextra->inExpose = 0;
}
void QWidgetPrivate::deleteTLSysExtra()
@@ -891,7 +892,6 @@ void QWidgetPrivate::createSysExtra()
extra->activated = 0;
extra->nativePaintMode = QWExtra::Default;
extra->receiveNativePaintEvents = 0;
- extra->inExpose = 0;
}
void QWidgetPrivate::deleteSysExtra()
diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp
index b41dc2c..6cbf3d9 100644
--- a/src/gui/painting/qwindowsurface_s60.cpp
+++ b/src/gui/painting/qwindowsurface_s60.cpp
@@ -145,12 +145,15 @@ QImage* QS60WindowSurface::buffer(const QWidget *widget)
void QS60WindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &)
{
- QWExtra *extra = widget->d_func()->extraData();
- if (extra && !extra->inExpose) {
- extra->inExpose = true; // Prevent DrawNow() from calling syncBackingStore() again
+ QWidget *window = widget->window();
+ Q_ASSERT(window);
+ QTLWExtra *topExtra = window->d_func()->maybeTopData();
+ Q_ASSERT(topExtra);
+ if (!topExtra->inExpose) {
+ topExtra->inExpose = true; // Prevent DrawNow() from calling syncBackingStore() again
TRect tr = qt_QRect2TRect(region.boundingRect());
widget->winId()->DrawNow(tr);
- extra->inExpose = false;
+ topExtra->inExpose = false;
}
}
diff --git a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
index 504ceac..ea86c16 100644
--- a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
@@ -1213,14 +1213,14 @@ void tst_QAbstractItemView::task250754_fontChange()
tree.setModel(m);
w.show();
- w.resize(150,150);
+ w.resize(150,240);
QTest::qWait(30);
QFont font = tree.font();
- font.setPointSize(5);
+ font.setPixelSize(10);
tree.setFont(font);
QTRY_VERIFY(!tree.verticalScrollBar()->isVisible());
- font.setPointSize(45);
+ font.setPixelSize(60);
tree.setFont(font);
//now with the huge items, the scrollbar must be visible
QTRY_VERIFY(tree.verticalScrollBar()->isVisible());
@@ -1444,7 +1444,10 @@ void tst_QAbstractItemView::QTBUG6407_extendedSelection()
for(int i = 0; i < 50; ++i)
view.addItem(QString::number(i));
- view.resize(200,200);
+ QFont font = view.font();
+ font.setPixelSize(10);
+ view.setFont(font);
+ view.resize(200,240);
view.show();
QApplication::setActiveWindow(&view);
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 03eddee..b59017b 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -250,6 +250,7 @@ private slots:
#else
void persistentWinId();
#endif
+ void showNativeChild();
void qobject_castInDestroyedSlot();
void showHideEvent_data();
@@ -4586,6 +4587,16 @@ void tst_QWidget::persistentWinId()
}
#endif // Q_OS_SYMBIAN
+void tst_QWidget::showNativeChild()
+{
+ QWidget topLevel;
+ topLevel.setGeometry(0, 0, 100, 100);
+ QWidget child(&topLevel);
+ child.winId();
+ topLevel.show();
+ QTest::qWaitForWindowShown(&topLevel);
+}
+
class ShowHideEventWidget : public QWidget
{
public:
diff --git a/tools/runonphone/main.cpp b/tools/runonphone/main.cpp
index a77e713..1a5cdee 100644
--- a/tools/runonphone/main.cpp
+++ b/tools/runonphone/main.cpp
@@ -174,11 +174,7 @@ int main(int argc, char *argv[])
}
if(loglevel > 0)
outstream << "Connecting to target via " << serialPortName << endl;
-#ifdef Q_OS_WIN
- launcher->setTrkServerName(QString("\\\\.\\") + serialPortName);
-#else
launcher->setTrkServerName(serialPortName);
-#endif
launcher->setFileName(QString("c:\\sys\\bin\\") + exeFile);
launcher->setCommandLineArgs(cmdLine);
diff --git a/tools/runonphone/runonphone.pro b/tools/runonphone/runonphone.pro
index 2c1be98..7bed3e5 100644
--- a/tools/runonphone/runonphone.pro
+++ b/tools/runonphone/runonphone.pro
@@ -4,7 +4,7 @@ QT -= gui
CONFIG += console
CONFIG -= app_bundle
-include(trk/trk.pri)
+include(symbianutils/symbianutils.pri)
SOURCES += main.cpp \
trksignalhandler.cpp
@@ -12,6 +12,8 @@ SOURCES += main.cpp \
HEADERS += trksignalhandler.h \
serenum.h
+DEFINES += SYMBIANUTILS_INCLUDE_PRI
+
windows {
SOURCES += serenum_win.cpp
LIBS += -lsetupapi \
diff --git a/tools/runonphone/trk/bluetoothlistener.cpp b/tools/runonphone/symbianutils/bluetoothlistener.cpp
index 8d45fb5..df04288 100644
--- a/tools/runonphone/trk/bluetoothlistener.cpp
+++ b/tools/runonphone/symbianutils/bluetoothlistener.cpp
@@ -184,7 +184,7 @@ bool BluetoothListener::start(const QString &device, QString *errorMessage)
return true;
}
-void BluetoothListener::slotStdOutput()
+void BluetoothListener::slotStdOutput()
{
emitMessage(QString::fromLocal8Bit(d->process.readAllStandardOutput()));
}
diff --git a/tools/runonphone/trk/bluetoothlistener.h b/tools/runonphone/symbianutils/bluetoothlistener.h
index 027f286..36894e7 100644
--- a/tools/runonphone/trk/bluetoothlistener.h
+++ b/tools/runonphone/symbianutils/bluetoothlistener.h
@@ -42,6 +42,8 @@
#ifndef BLUETOOTHLISTENER_H
#define BLUETOOTHLISTENER_H
+#include "symbianutils_global.h"
+
#include <QtCore/QObject>
#include <QtCore/QProcess>
@@ -53,7 +55,7 @@ struct BluetoothListenerPrivate;
* The rfcomm command is used. It process can be started in the background
* while connection attempts (TrkDevice::open()) are made in the foreground. */
-class BluetoothListener : public QObject
+class SYMBIANUTILS_EXPORT BluetoothListener : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(BluetoothListener)
diff --git a/tools/runonphone/trk/bluetoothlistener_gui.cpp b/tools/runonphone/symbianutils/bluetoothlistener_gui.cpp
index 6ffdaef..5994eb5 100644
--- a/tools/runonphone/trk/bluetoothlistener_gui.cpp
+++ b/tools/runonphone/symbianutils/bluetoothlistener_gui.cpp
@@ -50,7 +50,7 @@
namespace trk {
-PromptStartCommunicationResult
+SYMBIANUTILS_EXPORT PromptStartCommunicationResult
promptStartCommunication(BaseCommunicationStarter &starter,
const QString &msgBoxTitle,
const QString &msgBoxText,
@@ -88,7 +88,7 @@ PromptStartCommunicationResult
return PromptStartCommunicationConnected;
}
-PromptStartCommunicationResult
+SYMBIANUTILS_EXPORT PromptStartCommunicationResult
promptStartSerial(BaseCommunicationStarter &starter,
QWidget *msgBoxParent,
QString *errorMessage)
@@ -98,7 +98,7 @@ PromptStartCommunicationResult
return promptStartCommunication(starter, title, message, msgBoxParent, errorMessage);
}
-PromptStartCommunicationResult
+SYMBIANUTILS_EXPORT PromptStartCommunicationResult
promptStartBluetooth(BaseCommunicationStarter &starter,
QWidget *msgBoxParent,
QString *errorMessage)
diff --git a/tools/runonphone/trk/bluetoothlistener_gui.h b/tools/runonphone/symbianutils/bluetoothlistener_gui.h
index d673ffe..10e7145 100644
--- a/tools/runonphone/trk/bluetoothlistener_gui.h
+++ b/tools/runonphone/symbianutils/bluetoothlistener_gui.h
@@ -42,6 +42,8 @@
#ifndef BLUETOOTHLISTENER_GUI_H
#define BLUETOOTHLISTENER_GUI_H
+#include "symbianutils_global.h"
+
#include <QtCore/QtGlobal>
QT_BEGIN_NAMESPACE
@@ -62,7 +64,7 @@ enum PromptStartCommunicationResult {
PromptStartCommunicationError
};
-PromptStartCommunicationResult
+SYMBIANUTILS_EXPORT PromptStartCommunicationResult
promptStartCommunication(BaseCommunicationStarter &starter,
const QString &msgBoxTitle,
const QString &msgBoxText,
@@ -71,14 +73,14 @@ PromptStartCommunicationResult
// Convenience to start a serial connection (messages prompting
// to launch Trk).
-PromptStartCommunicationResult
+SYMBIANUTILS_EXPORT PromptStartCommunicationResult
promptStartSerial(BaseCommunicationStarter &starter,
QWidget *msgBoxParent,
QString *errorMessage);
// Convenience to start blue tooth connection (messages
// prompting to connect).
-PromptStartCommunicationResult
+SYMBIANUTILS_EXPORT PromptStartCommunicationResult
promptStartBluetooth(BaseCommunicationStarter &starter,
QWidget *msgBoxParent,
QString *errorMessage);
diff --git a/tools/runonphone/trk/callback.h b/tools/runonphone/symbianutils/callback.h
index edc2c74..3996d73 100644
--- a/tools/runonphone/trk/callback.h
+++ b/tools/runonphone/symbianutils/callback.h
@@ -42,7 +42,7 @@
#ifndef DEBUGGER_CALLBACK_H
#define DEBUGGER_CALLBACK_H
-#include <QtCore/QtGlobal>
+#include "symbianutils_global.h"
namespace trk {
namespace Internal {
diff --git a/tools/runonphone/trk/communicationstarter.cpp b/tools/runonphone/symbianutils/communicationstarter.cpp
index e5e556e..cdee49f 100644
--- a/tools/runonphone/trk/communicationstarter.cpp
+++ b/tools/runonphone/symbianutils/communicationstarter.cpp
@@ -58,7 +58,6 @@ struct BaseCommunicationStarterPrivate {
int intervalMS;
int attempts;
int n;
- QString device;
QString errorString;
BaseCommunicationStarter::State state;
};
@@ -70,7 +69,6 @@ BaseCommunicationStarterPrivate::BaseCommunicationStarterPrivate(const BaseCommu
intervalMS(1000),
attempts(-1),
n(0),
- device(QLatin1String("/dev/rfcomm0")),
state(BaseCommunicationStarter::TimedOut)
{
}
@@ -108,7 +106,7 @@ BaseCommunicationStarter::StartResult BaseCommunicationStarter::start()
// Before we instantiate timers, and such, try to open the device,
// which should succeed if another listener is already running in
// 'Watch' mode
- if (d->trkDevice->open(d->device , &(d->errorString)))
+ if (d->trkDevice->open(&(d->errorString)))
return ConnectionSucceeded;
// Pull up resources for next attempt
d->n = 0;
@@ -155,12 +153,7 @@ void BaseCommunicationStarter::setAttempts(int a)
QString BaseCommunicationStarter::device() const
{
- return d->device;
-}
-
-void BaseCommunicationStarter::setDevice(const QString &dv)
-{
- d->device = dv;
+ return d->trkDevice->port();
}
QString BaseCommunicationStarter::errorString() const
@@ -175,20 +168,20 @@ void BaseCommunicationStarter::slotTimer()
if (d->attempts >= 0 && d->n >= d->attempts) {
stopTimer();
d->errorString = tr("%1: timed out after %n attempts using an interval of %2ms.", 0, d->n)
- .arg(d->device).arg(d->intervalMS);
+ .arg(d->trkDevice->port()).arg(d->intervalMS);
d->state = TimedOut;
emit timeout();
} else {
// Attempt n to connect?
- if (d->trkDevice->open(d->device , &(d->errorString))) {
+ if (d->trkDevice->open(&(d->errorString))) {
stopTimer();
- const QString msg = tr("%1: Connection attempt %2 succeeded.").arg(d->device).arg(d->n);
+ const QString msg = tr("%1: Connection attempt %2 succeeded.").arg(d->trkDevice->port()).arg(d->n);
emit message(msg);
d->state = Connected;
emit connected();
} else {
const QString msg = tr("%1: Connection attempt %2 failed: %3 (retrying)...")
- .arg(d->device).arg(d->n).arg(d->errorString);
+ .arg(d->trkDevice->port()).arg(d->n).arg(d->errorString);
emit message(msg);
}
}
@@ -228,13 +221,11 @@ BluetoothListener *ConsoleBluetoothStarter::createListener()
bool ConsoleBluetoothStarter::startBluetooth(const TrkDevicePtr &trkDevice,
QObject *listenerParent,
- const QString &device,
int attempts,
QString *errorMessage)
{
// Set up a console starter to print to stdout.
ConsoleBluetoothStarter starter(trkDevice, listenerParent);
- starter.setDevice(device);
starter.setAttempts(attempts);
switch (starter.start()) {
case Started:
diff --git a/tools/runonphone/trk/communicationstarter.h b/tools/runonphone/symbianutils/communicationstarter.h
index 34cf398..0a060ee 100644
--- a/tools/runonphone/trk/communicationstarter.h
+++ b/tools/runonphone/symbianutils/communicationstarter.h
@@ -42,6 +42,8 @@
#ifndef COMMUNICATIONSTARTER_H
#define COMMUNICATIONSTARTER_H
+#include "symbianutils_global.h"
+
#include <QtCore/QSharedPointer>
#include <QtCore/QObject>
@@ -60,7 +62,7 @@ struct BaseCommunicationStarterPrivate;
* The base class can be used as is to prompt the user to launch App TRK for a
* serial communication as this requires no further resource setup. */
-class BaseCommunicationStarter : public QObject {
+class SYMBIANUTILS_EXPORT BaseCommunicationStarter : public QObject {
Q_OBJECT
Q_DISABLE_COPY(BaseCommunicationStarter)
public:
@@ -78,7 +80,6 @@ public:
void setAttempts(int a);
QString device() const;
- void setDevice(const QString &);
State state() const;
QString errorString() const;
@@ -117,7 +118,7 @@ private:
* implement as a factory function that creates and sets up the
* listener (mode, message connection, etc). */
-class AbstractBluetoothStarter : public BaseCommunicationStarter {
+class SYMBIANUTILS_EXPORT AbstractBluetoothStarter : public BaseCommunicationStarter {
Q_OBJECT
Q_DISABLE_COPY(AbstractBluetoothStarter)
public:
@@ -134,13 +135,12 @@ protected:
/* ConsoleBluetoothStarter: Convenience class for console processes. Creates a
* listener in "Listen" mode with the messages redirected to standard output. */
-class ConsoleBluetoothStarter : public AbstractBluetoothStarter {
+class SYMBIANUTILS_EXPORT ConsoleBluetoothStarter : public AbstractBluetoothStarter {
Q_OBJECT
Q_DISABLE_COPY(ConsoleBluetoothStarter)
public:
static bool startBluetooth(const TrkDevicePtr& trkDevice,
QObject *listenerParent,
- const QString &device,
int attempts,
QString *errorMessage);
diff --git a/tools/runonphone/trk/launcher.cpp b/tools/runonphone/symbianutils/launcher.cpp
index 1796fc5..408829b 100644
--- a/tools/runonphone/trk/launcher.cpp
+++ b/tools/runonphone/symbianutils/launcher.cpp
@@ -41,6 +41,7 @@
#include "launcher.h"
#include "trkutils.h"
+#include "trkutils_p.h"
#include "trkdevice.h"
#include "bluetoothlistener.h"
@@ -66,7 +67,6 @@ struct LauncherPrivate {
explicit LauncherPrivate(const TrkDevicePtr &d);
TrkDevicePtr m_device;
- QString m_trkServerName;
QByteArray m_trkReadBuffer;
Launcher::State m_state;
@@ -130,12 +130,12 @@ void Launcher::addStartupActions(trk::Launcher::Actions startupActions)
void Launcher::setTrkServerName(const QString &name)
{
- d->m_trkServerName = name;
+ d->m_device->setPort(name);
}
QString Launcher::trkServerName() const
{
- return d->m_trkServerName;
+ return d->m_device->port();
}
TrkDevicePtr Launcher::trkDevice() const
@@ -190,7 +190,7 @@ bool Launcher::startServer(QString *errorMessage)
errorMessage->clear();
if (d->m_verbose) {
const QString msg = QString::fromLatin1("Port=%1 Executable=%2 Arguments=%3 Package=%4 Remote Package=%5 Install file=%6")
- .arg(d->m_trkServerName, d->m_fileName,
+ .arg(trkServerName(), d->m_fileName,
d->m_commandLineArgs.join(QString(QLatin1Char(' '))),
d->m_copyState.sourceFileName, d->m_copyState.destinationFileName, d->m_installFileName);
logMessage(msg);
@@ -212,7 +212,7 @@ bool Launcher::startServer(QString *errorMessage)
qWarning("No remote executable given for running.");
return false;
}
- if (!d->m_device->isOpen() && !d->m_device->open(d->m_trkServerName, errorMessage))
+ if (!d->m_device->isOpen() && !d->m_device->open(errorMessage))
return false;
if (d->m_closeDevice) {
connect(this, SIGNAL(finished()), d->m_device.data(), SLOT(close()));
@@ -595,17 +595,19 @@ void Launcher::handleSupportMask(const TrkResult &result)
return;
const char *data = result.data.data() + 1;
- QByteArray str;
+ QString str = QLatin1String("SUPPORTED: ");
for (int i = 0; i < 32; ++i) {
//str.append(" [" + formatByte(data[i]) + "]: ");
- for (int j = 0; j < 8; ++j)
- if (data[i] & (1 << j))
- str.append(QByteArray::number(i * 8 + j, 16) + " ");
+ for (int j = 0; j < 8; ++j) {
+ if (data[i] & (1 << j)) {
+ str.append(QString::number(i * 8 + j, 16));
+ str.append(QLatin1Char(' '));
+ }
+ }
}
- logMessage("SUPPORTED: " + str);
+ logMessage(str);
}
-
void Launcher::cleanUp()
{
//
@@ -614,9 +616,7 @@ void Launcher::cleanUp()
// Sub Cmd: Delete Process
//ProcessID: 0x0000071F (1823)
// [41 24 00 00 00 00 07 1F]
- QByteArray ba;
- appendByte(&ba, 0x00);
- appendByte(&ba, 0x00);
+ QByteArray ba(2, char(0));
appendInt(&ba, d->m_session.pid);
d->m_device->sendTrkMessage(TrkDeleteItem, TrkCallback(), ba, "Delete process");
@@ -669,7 +669,7 @@ void Launcher::copyFileToRemote()
{
emit copyingStarted();
QByteArray ba;
- appendByte(&ba, 0x10);
+ ba.append(char(10));
appendString(&ba, d->m_copyState.destinationFileName.toLocal8Bit(), TargetByteOrder, false);
d->m_device->sendTrkMessage(TrkOpenFile, TrkCallback(this, &Launcher::handleFileCreation), ba);
}
@@ -678,7 +678,7 @@ void Launcher::installRemotePackageSilently()
{
emit installingStarted();
QByteArray ba;
- appendByte(&ba, 'C');
+ ba.append('C');
appendString(&ba, d->m_installFileName.toLocal8Bit(), TargetByteOrder, false);
d->m_device->sendTrkMessage(TrkInstallFile, TrkCallback(this, &Launcher::handleInstallPackageFinished), ba);
}
@@ -705,7 +705,7 @@ QByteArray Launcher::startProcessMessage(const QString &executable,
// It's not started yet
QByteArray ba;
appendShort(&ba, 0, TargetByteOrder); // create new process
- appendByte(&ba, 0); // options - currently unused
+ ba.append(char(0)); // options - currently unused
if(arguments.isEmpty()) {
appendString(&ba, executable.toLocal8Bit(), TargetByteOrder);
return ba;
diff --git a/tools/runonphone/trk/launcher.h b/tools/runonphone/symbianutils/launcher.h
index 8dc6ebe..2b23fd8 100644
--- a/tools/runonphone/trk/launcher.h
+++ b/tools/runonphone/symbianutils/launcher.h
@@ -56,7 +56,7 @@ struct LauncherPrivate;
typedef QSharedPointer<TrkDevice> TrkDevicePtr;
-class Launcher : public QObject
+class SYMBIANUTILS_EXPORT Launcher : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(Launcher)
diff --git a/tools/runonphone/symbianutils/symbiandevicemanager.cpp b/tools/runonphone/symbianutils/symbiandevicemanager.cpp
new file mode 100644
index 0000000..f663816
--- /dev/null
+++ b/tools/runonphone/symbianutils/symbiandevicemanager.cpp
@@ -0,0 +1,331 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "symbiandevicemanager.h"
+
+#include <QtCore/QSettings>
+#include <QtCore/QStringList>
+#include <QtCore/QFileInfo>
+#include <QtCore/QtDebug>
+#include <QtCore/QTextStream>
+#include <QtCore/QSharedData>
+#include <QtCore/QScopedPointer>
+
+namespace SymbianUtils {
+
+enum { debug = 0 };
+
+static const char REGKEY_CURRENT_CONTROL_SET[] = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet";
+static const char USBSER[] = "Services/usbser/Enum";
+
+const char *SymbianDeviceManager::linuxBlueToothDeviceRootC = "/dev/rfcomm";
+
+// ------------- SymbianDevice
+class SymbianDeviceData : public QSharedData {
+public:
+ SymbianDeviceData() : type(SerialPortCommunication) {}
+
+ QString portName;
+ QString friendlyName;
+ QString deviceDesc;
+ QString manufacturer;
+ DeviceCommunicationType type;
+};
+
+SymbianDevice::SymbianDevice(SymbianDeviceData *data) :
+ m_data(data)
+{
+
+}
+
+SymbianDevice::SymbianDevice() :
+ m_data(new SymbianDeviceData)
+{
+}
+SymbianDevice::SymbianDevice(const SymbianDevice &rhs) :
+ m_data(rhs.m_data)
+{
+}
+
+SymbianDevice &SymbianDevice::operator=(const SymbianDevice &rhs)
+{
+ if (this != &rhs)
+ m_data = rhs.m_data;
+ return *this;
+}
+
+SymbianDevice::~SymbianDevice()
+{
+}
+
+QString SymbianDevice::portName() const
+{
+ return m_data->portName;
+}
+
+QString SymbianDevice::friendlyName() const
+{
+ return m_data->friendlyName;
+}
+
+QString SymbianDevice::deviceDesc() const
+{
+ return m_data->deviceDesc;
+}
+
+QString SymbianDevice::manufacturer() const
+{
+ return m_data->manufacturer;
+}
+
+DeviceCommunicationType SymbianDevice::type() const
+{
+ return m_data->type;
+}
+
+bool SymbianDevice::isNull() const
+{
+ return !m_data->portName.isEmpty();
+}
+
+QString SymbianDevice::toString() const
+{
+ QString rc;
+ QTextStream str(&rc);
+ format(str);
+ return rc;
+}
+
+void SymbianDevice::format(QTextStream &str) const
+{
+ str << (m_data->type == BlueToothCommunication ? "Bluetooth: " : "Serial: ")
+ << m_data->portName;
+ if (!m_data->friendlyName.isEmpty()) {
+ str << " (" << m_data->friendlyName;
+ if (!m_data->deviceDesc.isEmpty())
+ str << " / " << m_data->deviceDesc;
+ str << ')';
+ }
+ if (!m_data->manufacturer.isEmpty())
+ str << " [" << m_data->manufacturer << ']';
+}
+
+// Compare by port and friendly name
+int SymbianDevice::compare(const SymbianDevice &rhs) const
+{
+ if (const int prc = m_data->portName.compare(rhs.m_data->portName))
+ return prc;
+ if (const int frc = m_data->friendlyName.compare(rhs.m_data->friendlyName))
+ return frc;
+ return 0;
+}
+
+QDebug operator<<(QDebug d, const SymbianDevice &cd)
+{
+ d.nospace() << cd.toString();
+ return d;
+}
+
+// ------------- SymbianDeviceManagerPrivate
+struct SymbianDeviceManagerPrivate {
+ SymbianDeviceManagerPrivate() : m_initialized(false) {}
+
+ bool m_initialized;
+ SymbianDeviceManager::SymbianDeviceList m_devices;
+};
+
+SymbianDeviceManager::SymbianDeviceManager(QObject *parent) :
+ QObject(parent),
+ d(new SymbianDeviceManagerPrivate)
+{
+}
+
+SymbianDeviceManager::~SymbianDeviceManager()
+{
+ delete d;
+}
+
+SymbianDeviceManager::SymbianDeviceList SymbianDeviceManager::devices() const
+{
+ if (!d->m_initialized)
+ const_cast<SymbianDeviceManager*>(this)->update(false);
+ return d->m_devices;
+}
+
+QString SymbianDeviceManager::toString() const
+{
+ QString rc;
+ QTextStream str(&rc);
+ const int count = d->m_devices.size();
+ for (int i = 0; i < count; i++) {
+ str << '#' << i << ' ';
+ d->m_devices.at(i).format(str);
+ str << '\n';
+ }
+ return rc;
+}
+
+QString SymbianDeviceManager::friendlyNameForPort(const QString &port) const
+{
+ foreach (const SymbianDevice &device, d->m_devices) {
+ if (device.portName() == port)
+ return device.friendlyName();
+ }
+ return QString();
+}
+
+void SymbianDeviceManager::update()
+{
+ update(true);
+}
+
+void SymbianDeviceManager::update(bool emitSignals)
+{
+ typedef SymbianDeviceList::iterator SymbianDeviceListIterator;
+
+ if (debug)
+ qDebug(">SerialDeviceLister::update(%d)\n%s", int(emitSignals),
+ qPrintable(toString()));
+
+ d->m_initialized = true;
+ // Get ordered new list
+ SymbianDeviceList newDevices = serialPorts() + blueToothDevices();
+ if (newDevices.size() > 1)
+ qStableSort(newDevices.begin(), newDevices.end());
+ if (d->m_devices == newDevices) // Happy, nothing changed.
+ return;
+ // Merge the lists and emit the respective added/removed signals, assuming
+ // no one can plug a different device on the same port at the speed of lightning
+ if (!d->m_devices.isEmpty()) {
+ // Find deleted devices
+ for (SymbianDeviceListIterator oldIt = d->m_devices.begin(); oldIt != d->m_devices.end(); ) {
+ if (newDevices.contains(*oldIt)) {
+ ++oldIt;
+ } else {
+ const SymbianDevice toBeDeleted = *oldIt;
+ oldIt = d->m_devices.erase(oldIt);
+ if (emitSignals)
+ emit deviceRemoved(toBeDeleted);
+ }
+ }
+ }
+ if (!newDevices.isEmpty()) {
+ // Find new devices and insert in order
+ foreach(const SymbianDevice &newDevice, newDevices) {
+ if (!d->m_devices.contains(newDevice)) {
+ d->m_devices.append(newDevice);
+ if (emitSignals)
+ emit deviceAdded(newDevice);
+ }
+ }
+ if (d->m_devices.size() > 1)
+ qStableSort(d->m_devices.begin(), d->m_devices.end());
+ }
+ if (emitSignals)
+ emit updated();
+
+ if (debug)
+ qDebug("<SerialDeviceLister::update\n%s\n", qPrintable(toString()));
+}
+
+SymbianDeviceManager::SymbianDeviceList SymbianDeviceManager::serialPorts() const
+{
+ SymbianDeviceList rc;
+#ifdef Q_OS_WIN
+ const QSettings registry(REGKEY_CURRENT_CONTROL_SET, QSettings::NativeFormat);
+ const QString usbSerialRootKey = QLatin1String(USBSER) + QLatin1Char('/');
+ const int count = registry.value(usbSerialRootKey + QLatin1String("Count")).toInt();
+ for (int i = 0; i < count; ++i) {
+ QString driver = registry.value(usbSerialRootKey + QString::number(i)).toString();
+ if (driver.contains(QLatin1String("JAVACOMM"))) {
+ driver.replace(QLatin1Char('\\'), QLatin1Char('/'));
+ const QString driverRootKey = QLatin1String("Enum/") + driver + QLatin1Char('/');
+ if (debug > 1)
+ qDebug() << "SerialDeviceLister::serialPorts(): Checking " << i << count
+ << REGKEY_CURRENT_CONTROL_SET << usbSerialRootKey << driverRootKey;
+ QScopedPointer<SymbianDeviceData> device(new SymbianDeviceData);
+ device->type = SerialPortCommunication;
+ device->friendlyName = registry.value(driverRootKey + QLatin1String("FriendlyName")).toString();
+ device->portName = registry.value(driverRootKey + QLatin1String("Device Parameters/PortName")).toString();
+ device->deviceDesc = registry.value(driverRootKey + QLatin1String("DeviceDesc")).toString();
+ device->manufacturer = registry.value(driverRootKey + QLatin1String("Mfg")).toString();
+ rc.append(SymbianDevice(device.take()));
+ }
+ }
+#endif
+ return rc;
+}
+
+SymbianDeviceManager::SymbianDeviceList SymbianDeviceManager::blueToothDevices() const
+{
+ SymbianDeviceList rc;
+#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
+ // Bluetooth devices are created on connection. List the existing ones
+ // or at least the first one.
+ const QString prefix = QLatin1String(linuxBlueToothDeviceRootC);
+ const QString friendlyFormat = QLatin1String("Bluetooth device (%1)");
+ for (int d = 0; d < 4; d++) {
+ QScopedPointer<SymbianDeviceData> device(new SymbianDeviceData);
+ device->type = BlueToothCommunication;
+ device->portName = prefix + QString::number(d);
+ if (d == 0 || QFileInfo(device->portName).exists()) {
+ device->friendlyName = friendlyFormat.arg(device->portName);
+ rc.push_back(SymbianDevice(device.take()));
+ }
+ }
+#endif
+ return rc;
+}
+
+Q_GLOBAL_STATIC(SymbianDeviceManager, symbianDeviceManager)
+
+SymbianDeviceManager *SymbianDeviceManager::instance()
+{
+ return symbianDeviceManager();
+}
+
+QDebug operator<<(QDebug d, const SymbianDeviceManager &sdm)
+{
+ d.nospace() << sdm.toString();
+ return d;
+}
+
+} // namespace SymbianUtilsInternal
diff --git a/tools/runonphone/symbianutils/symbiandevicemanager.h b/tools/runonphone/symbianutils/symbiandevicemanager.h
new file mode 100644
index 0000000..dcf131a
--- /dev/null
+++ b/tools/runonphone/symbianutils/symbiandevicemanager.h
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SYMBIANDEVICEMANAGER_H
+#define SYMBIANDEVICEMANAGER_H
+
+#include "symbianutils_global.h"
+
+#include <QtCore/QObject>
+#include <QtCore/QExplicitlySharedDataPointer>
+
+QT_BEGIN_NAMESPACE
+class QDebug;
+class QTextStream;
+QT_END_NAMESPACE
+
+namespace SymbianUtils {
+
+struct SymbianDeviceManagerPrivate;
+class SymbianDeviceData;
+
+enum DeviceCommunicationType {
+ SerialPortCommunication = 0,
+ BlueToothCommunication = 1
+};
+
+// SymbianDevice, explicitly shared.
+class SYMBIANUTILS_EXPORT SymbianDevice {
+ explicit SymbianDevice(SymbianDeviceData *data);
+ friend class SymbianDeviceManager;
+public:
+ SymbianDevice();
+ SymbianDevice(const SymbianDevice &rhs);
+ SymbianDevice &operator=(const SymbianDevice &rhs);
+ ~SymbianDevice();
+ int compare(const SymbianDevice &rhs) const;
+
+ DeviceCommunicationType type() const;
+ bool isNull() const;
+ QString portName() const;
+ QString friendlyName() const;
+
+ // Windows only.
+ QString deviceDesc() const;
+ QString manufacturer() const;
+
+ void format(QTextStream &str) const;
+ QString toString() const;
+
+private:
+ QExplicitlySharedDataPointer<SymbianDeviceData> m_data;
+};
+
+QDebug operator<<(QDebug d, const SymbianDevice &);
+
+inline bool operator==(const SymbianDevice &d1, const SymbianDevice &d2)
+ { return d1.compare(d2) == 0; }
+inline bool operator!=(const SymbianDevice &d1, const SymbianDevice &d2)
+ { return d1.compare(d2) != 0; }
+inline bool operator<(const SymbianDevice &d1, const SymbianDevice &d2)
+ { return d1.compare(d2) < 0; }
+
+/* SymbianDeviceManager: Singleton that maintains a list of Symbian devices.
+ * and emits change signals.
+ * On Windows, the update slot must be connected to a signal
+ * emitted from an event handler listening for WM_DEVICECHANGE. */
+class SYMBIANUTILS_EXPORT SymbianDeviceManager : public QObject
+{
+ Q_OBJECT
+public:
+ typedef QList<SymbianDevice> SymbianDeviceList;
+
+ static const char *linuxBlueToothDeviceRootC;
+
+ // Do not use this constructor, it is just public for Q_GLOBAL_STATIC
+ explicit SymbianDeviceManager(QObject *parent = 0);
+ virtual ~SymbianDeviceManager();
+
+ // Singleton access.
+ static SymbianDeviceManager *instance();
+
+ SymbianDeviceList devices() const;
+ QString toString() const;
+
+ QString friendlyNameForPort(const QString &port) const;
+
+public slots:
+ void update();
+
+signals:
+ void deviceRemoved(const SymbianDevice &d);
+ void deviceAdded(const SymbianDevice &d);
+ void updated();
+
+private:
+ void update(bool emitSignals);
+ SymbianDeviceList serialPorts() const;
+ SymbianDeviceList blueToothDevices() const;
+
+ SymbianDeviceManagerPrivate *d;
+};
+
+QDebug operator<<(QDebug d, const SymbianDeviceManager &);
+
+} // namespace SymbianUtils
+
+#endif // SYMBIANDEVICEMANAGER_H
diff --git a/tools/runonphone/trk/trk.pri b/tools/runonphone/symbianutils/symbianutils.pri
index 2ce17c0..6309517 100644
--- a/tools/runonphone/trk/trk.pri
+++ b/tools/runonphone/symbianutils/symbianutils.pri
@@ -1,18 +1,22 @@
INCLUDEPATH *= $$PWD
# Input
-HEADERS += $$PWD/callback.h \
+HEADERS += $$PWD/symbianutils_global.h \
+ $$PWD/callback.h \
$$PWD/trkutils.h \
+ $$PWD/trkutils_p.h \
$$PWD/trkdevice.h \
$$PWD/launcher.h \
$$PWD/bluetoothlistener.h \
- $$PWD/communicationstarter.h
+ $$PWD/communicationstarter.h \
+ $$PWD/symbiandevicemanager.h
SOURCES += $$PWD/trkutils.cpp \
$$PWD/trkdevice.cpp \
$$PWD/launcher.cpp \
$$PWD/bluetoothlistener.cpp \
- $$PWD/communicationstarter.cpp
+ $$PWD/communicationstarter.cpp \
+ $$PWD/symbiandevicemanager.cpp
# Tests/trklauncher is a console application
contains(QT, gui) {
diff --git a/tools/runonphone/symbianutils/symbianutils_global.h b/tools/runonphone/symbianutils/symbianutils_global.h
new file mode 100644
index 0000000..a6ffbe7
--- /dev/null
+++ b/tools/runonphone/symbianutils/symbianutils_global.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SYMBIANUTILS_GLOBAL_H
+#define SYMBIANUTILS_GLOBAL_H
+
+#include <QtCore/qglobal.h>
+
+#if defined(SYMBIANUTILS_BUILD_LIB)
+# define SYMBIANUTILS_EXPORT Q_DECL_EXPORT
+#elif defined(SYMBIANUTILS_BUILD_STATIC_LIB) || defined(SYMBIANUTILS_INCLUDE_PRI)
+# define SYMBIANUTILS_EXPORT
+#else
+# define SYMBIANUTILS_EXPORT Q_DECL_IMPORT
+#endif
+
+#endif // SYMBIANUTILS_GLOBAL_H
diff --git a/tools/runonphone/trk/trkdevice.cpp b/tools/runonphone/symbianutils/trkdevice.cpp
index fe3261b..b327ab3 100644
--- a/tools/runonphone/trk/trkdevice.cpp
+++ b/tools/runonphone/symbianutils/trkdevice.cpp
@@ -41,6 +41,7 @@
#include "trkdevice.h"
#include "trkutils.h"
+#include "trkutils_p.h"
#include <QtCore/QString>
#include <QtCore/QDebug>
@@ -516,7 +517,7 @@ static inline bool overlappedSyncWrite(HANDLE file,
bool WriterThread::write(const QByteArray &data, QString *errorMessage)
{
if (verboseTrk)
- qDebug() << "Write raw data: " << data.toHex();
+ qDebug() << "Write raw data: " << stringFromArray(data).toLatin1();
QMutexLocker locker(&m_context->mutex);
#ifdef Q_OS_WIN
DWORD charsWritten;
@@ -856,8 +857,8 @@ void UnixReaderThread::terminate()
{
// Trigger select() by writing to the pipe
char c = 0;
- int written = write(m_terminatePipeFileDescriptors[1], &c, 1);
- // FIXME: Use result.
+ const int written = write(m_terminatePipeFileDescriptors[1], &c, 1);
+ Q_UNUSED(written)
wait();
}
@@ -882,6 +883,7 @@ struct TrkDevicePrivate
QByteArray trkReadBuffer;
int verbose;
QString errorString;
+ QString port;
};
///////////////////////////////////////////////////////////////////////
@@ -913,13 +915,19 @@ TrkDevice::~TrkDevice()
delete d;
}
-bool TrkDevice::open(const QString &port, QString *errorMessage)
+bool TrkDevice::open(QString *errorMessage)
{
if (d->verbose)
- qDebug() << "Opening" << port << "is open: " << isOpen() << " serialFrame=" << serialFrame();
+ qDebug() << "Opening" << port() << "is open: " << isOpen() << " serialFrame=" << serialFrame();
+ if (d->port.isEmpty()) {
+ *errorMessage = QLatin1String("Internal error: No port set on TrkDevice");
+ return false;
+ }
+
close();
#ifdef Q_OS_WIN
- d->deviceContext->device = CreateFile(port.toStdWString().c_str(),
+ const QString fullPort = QLatin1String("\\\\.\\") + d->port;
+ d->deviceContext->device = CreateFile(reinterpret_cast<const WCHAR*>(fullPort.utf16()),
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
@@ -928,7 +936,7 @@ bool TrkDevice::open(const QString &port, QString *errorMessage)
NULL);
if (INVALID_HANDLE_VALUE == d->deviceContext->device) {
- *errorMessage = QString::fromLatin1("Could not open device '%1': %2").arg(port, winErrorMessage(GetLastError()));
+ *errorMessage = QString::fromLatin1("Could not open device '%1': %2").arg(port(), winErrorMessage(GetLastError()));
return false;
}
memset(&d->deviceContext->readOverlapped, 0, sizeof(OVERLAPPED));
@@ -940,9 +948,9 @@ bool TrkDevice::open(const QString &port, QString *errorMessage)
return false;
}
#else
- d->deviceContext->file.setFileName(port);
+ d->deviceContext->file.setFileName(d->port);
if (!d->deviceContext->file.open(QIODevice::ReadWrite|QIODevice::Unbuffered)) {
- *errorMessage = QString::fromLatin1("Cannot open %1: %2").arg(port, d->deviceContext->file.errorString());
+ *errorMessage = QString::fromLatin1("Cannot open %1: %2").arg(d->port, d->deviceContext->file.errorString());
return false;
}
@@ -981,7 +989,7 @@ bool TrkDevice::open(const QString &port, QString *errorMessage)
d->writerThread->start();
if (d->verbose)
- qDebug() << "Opened" << port;
+ qDebug() << "Opened" << d->port;
return true;
}
@@ -1015,6 +1023,16 @@ bool TrkDevice::isOpen() const
#endif
}
+QString TrkDevice::port() const
+{
+ return d->port;
+}
+
+void TrkDevice::setPort(const QString &p)
+{
+ d->port = p;
+}
+
QString TrkDevice::errorString() const
{
return d->errorString;
@@ -1061,8 +1079,13 @@ void TrkDevice::sendTrkMessage(byte code, TrkCallback callback,
const QByteArray &data, const QVariant &cookie)
{
if (!d->writerThread.isNull()) {
- if (d->verbose > 1)
- qDebug() << "Sending " << code << data.toHex();
+ if (d->verbose > 1) {
+ QByteArray msg = "Sending: ";
+ msg += QByteArray::number(code, 16);
+ msg += ": ";
+ msg += stringFromArray(data).toLatin1();
+ qDebug("%s", msg.data());
+ }
d->writerThread->queueTrkMessage(code, callback, data, cookie);
}
}
diff --git a/tools/runonphone/trk/trkdevice.h b/tools/runonphone/symbianutils/trkdevice.h
index e04f791..78012fd 100644
--- a/tools/runonphone/trk/trkdevice.h
+++ b/tools/runonphone/symbianutils/trkdevice.h
@@ -42,6 +42,7 @@
#ifndef TRKDEVICE_H
#define TRKDEVICE_H
+#include "symbianutils_global.h"
#include "callback.h"
#include <QtCore/QObject>
@@ -74,18 +75,22 @@ enum { TRK_WRITE_QUEUE_NOOP_CODE = 0x7f };
typedef trk::Callback<const TrkResult &> TrkCallback;
-class TrkDevice : public QObject
+class SYMBIANUTILS_EXPORT TrkDevice : public QObject
{
Q_OBJECT
Q_PROPERTY(bool serialFrame READ serialFrame WRITE setSerialFrame)
Q_PROPERTY(bool verbose READ verbose WRITE setVerbose)
+ Q_PROPERTY(QString port READ port WRITE setPort)
public:
explicit TrkDevice(QObject *parent = 0);
virtual ~TrkDevice();
- bool open(const QString &port, QString *errorMessage);
+ bool open(QString *errorMessage);
bool isOpen() const;
+ QString port() const;
+ void setPort(const QString &p);
+
QString errorString() const;
bool serialFrame() const;
diff --git a/tools/runonphone/trk/trkutils.cpp b/tools/runonphone/symbianutils/trkutils.cpp
index 3a96053..9b43c96 100644
--- a/tools/runonphone/trk/trkutils.cpp
+++ b/tools/runonphone/symbianutils/trkutils.cpp
@@ -86,7 +86,7 @@ void Session::reset()
trkAppVersion.reset();
}
-QString formatCpu(int major, int minor)
+static QString formatCpu(int major, int minor)
{
//: CPU description of an S60 device
//: %1 major verison, %2 minor version
@@ -143,14 +143,46 @@ QString Session::deviceDescription(unsigned verbose) const
return msg.arg(formatTrkVersion(trkAppVersion));
}
+// --------------
+
+QByteArray decode7d(const QByteArray &ba)
+{
+ QByteArray res;
+ res.reserve(ba.size());
+ for (int i = 0; i < ba.size(); ++i) {
+ byte c = byte(ba.at(i));
+ if (c == 0x7d) {
+ ++i;
+ c = 0x20 ^ byte(ba.at(i));
+ }
+ res.append(c);
+ }
+ return res;
+}
+
+QByteArray encode7d(const QByteArray &ba)
+{
+ QByteArray res;
+ res.reserve(ba.size() + 2);
+ for (int i = 0; i < ba.size(); ++i) {
+ byte c = byte(ba.at(i));
+ if (c == 0x7e || c == 0x7d) {
+ res.append(0x7d);
+ res.append(0x20 ^ c);
+ } else {
+ res.append(c);
+ }
+ }
+ return res;
+}
// FIXME: Use the QByteArray based version below?
-QString stringFromByte(byte c)
+static inline QString stringFromByte(byte c)
{
- return QString("%1 ").arg(c, 2, 16, QChar('0'));
+ return QString::fromLatin1("%1").arg(c, 2, 16, QChar('0'));
}
-QString stringFromArray(const QByteArray &ba, int maxLen)
+SYMBIANUTILS_EXPORT QString stringFromArray(const QByteArray &ba, int maxLen)
{
QString str;
QString ascii;
@@ -170,7 +202,7 @@ QString stringFromArray(const QByteArray &ba, int maxLen)
return str + " " + ascii;
}
-QByteArray hexNumber(uint n, int digits)
+SYMBIANUTILS_EXPORT QByteArray hexNumber(uint n, int digits)
{
QByteArray ba = QByteArray::number(n, 16);
if (digits == 0 || ba.size() == digits)
@@ -178,7 +210,7 @@ QByteArray hexNumber(uint n, int digits)
return QByteArray(digits - ba.size(), '0') + ba;
}
-QByteArray hexxNumber(uint n, int digits)
+SYMBIANUTILS_EXPORT QByteArray hexxNumber(uint n, int digits)
{
return "0x" + hexNumber(n, digits);
}
@@ -200,9 +232,13 @@ void TrkResult::clear()
QString TrkResult::toString() const
{
- QString res = stringFromByte(code) + "[" + stringFromByte(token);
- res.chop(1);
- return res + "] " + stringFromArray(data);
+ QString res = stringFromByte(code);
+ res += QLatin1String(" [");
+ res += stringFromByte(token);
+ res += QLatin1Char(']');
+ res += QLatin1Char(' ');
+ res += stringFromArray(data);
+ return res;
}
QByteArray frameMessage(byte command, byte token, const QByteArray &data, bool serialFrame)
@@ -303,12 +339,12 @@ bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *result, QByt
return true;
}
-ushort extractShort(const char *data)
+SYMBIANUTILS_EXPORT ushort extractShort(const char *data)
{
return byte(data[0]) * 256 + byte(data[1]);
}
-uint extractInt(const char *data)
+SYMBIANUTILS_EXPORT uint extractInt(const char *data)
{
uint res = byte(data[0]);
res *= 256; res += byte(data[1]);
@@ -317,7 +353,7 @@ uint extractInt(const char *data)
return res;
}
-QString quoteUnprintableLatin1(const QByteArray &ba)
+SYMBIANUTILS_EXPORT QString quoteUnprintableLatin1(const QByteArray &ba)
{
QString res;
char buf[10];
@@ -333,49 +369,7 @@ QString quoteUnprintableLatin1(const QByteArray &ba)
return res;
}
-QByteArray decode7d(const QByteArray &ba)
-{
- QByteArray res;
- res.reserve(ba.size());
- for (int i = 0; i < ba.size(); ++i) {
- byte c = byte(ba.at(i));
- if (c == 0x7d) {
- ++i;
- c = 0x20 ^ byte(ba.at(i));
- }
- res.append(c);
- }
- //if (res != ba)
- // logMessage("DECODED: " << stringFromArray(ba)
- // << " -> " << stringFromArray(res));
- return res;
-}
-
-QByteArray encode7d(const QByteArray &ba)
-{
- QByteArray res;
- res.reserve(ba.size() + 2);
- for (int i = 0; i < ba.size(); ++i) {
- byte c = byte(ba.at(i));
- if (c == 0x7e || c == 0x7d) {
- res.append(0x7d);
- res.append(0x20 ^ c);
- } else {
- res.append(c);
- }
- }
- //if (res != ba)
- // logMessage("ENCODED: " << stringFromArray(ba)
- // << " -> " << stringFromArray(res));
- return res;
-}
-
-void appendByte(QByteArray *ba, byte b)
-{
- ba->append(b);
-}
-
-void appendShort(QByteArray *ba, ushort s, Endianness endian)
+SYMBIANUTILS_EXPORT void appendShort(QByteArray *ba, ushort s, Endianness endian)
{
if (endian == BigEndian) {
ba->append(s / 256);
@@ -386,7 +380,7 @@ void appendShort(QByteArray *ba, ushort s, Endianness endian)
}
}
-void appendInt(QByteArray *ba, uint i, Endianness endian)
+SYMBIANUTILS_EXPORT void appendInt(QByteArray *ba, uint i, Endianness endian)
{
const uchar b3 = i % 256; i /= 256;
const uchar b2 = i % 256; i /= 256;
diff --git a/tools/runonphone/trk/trkutils.h b/tools/runonphone/symbianutils/trkutils.h
index 328dd2b..3a485c7 100644
--- a/tools/runonphone/trk/trkutils.h
+++ b/tools/runonphone/symbianutils/trkutils.h
@@ -42,19 +42,20 @@
#ifndef DEBUGGER_TRK_UTILS
#define DEBUGGER_TRK_UTILS
+#include "symbianutils_global.h"
#include <QtCore/QByteArray>
#include <QtCore/QHash>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
-typedef unsigned char byte;
-
QT_BEGIN_NAMESPACE
class QDateTime;
QT_END_NAMESPACE
namespace trk {
+typedef unsigned char byte;
+
enum Command {
TrkPing = 0x00,
TrkConnect = 0x01,
@@ -85,17 +86,14 @@ enum Command {
TrkNotifyProcessorReset = 0xa7
};
-QByteArray decode7d(const QByteArray &ba);
-QByteArray encode7d(const QByteArray &ba);
-
inline byte extractByte(const char *data) { return *data; }
-ushort extractShort(const char *data);
-uint extractInt(const char *data);
+SYMBIANUTILS_EXPORT ushort extractShort(const char *data);
+SYMBIANUTILS_EXPORT uint extractInt(const char *data);
-QString quoteUnprintableLatin1(const QByteArray &ba);
+SYMBIANUTILS_EXPORT QString quoteUnprintableLatin1(const QByteArray &ba);
// produces "xx xx xx "
-QString stringFromArray(const QByteArray &ba, int maxLen = - 1);
+SYMBIANUTILS_EXPORT QString stringFromArray(const QByteArray &ba, int maxLen = - 1);
enum Endianness
{
@@ -104,13 +102,11 @@ enum Endianness
TargetByteOrder = BigEndian,
};
-void appendByte(QByteArray *ba, byte b);
-void appendShort(QByteArray *ba, ushort s, Endianness = TargetByteOrder);
-void appendInt(QByteArray *ba, uint i, Endianness = TargetByteOrder);
-void appendString(QByteArray *ba, const QByteArray &str, Endianness = TargetByteOrder, bool appendNullTerminator = true);
-void appendDateTime(QByteArray *ba, QDateTime dateTime, Endianness = TargetByteOrder);
+SYMBIANUTILS_EXPORT void appendShort(QByteArray *ba, ushort s, Endianness = TargetByteOrder);
+SYMBIANUTILS_EXPORT void appendInt(QByteArray *ba, uint i, Endianness = TargetByteOrder);
+SYMBIANUTILS_EXPORT void appendString(QByteArray *ba, const QByteArray &str, Endianness = TargetByteOrder, bool appendNullTerminator = true);
-struct Library
+struct SYMBIANUTILS_EXPORT Library
{
Library() {}
@@ -119,7 +115,7 @@ struct Library
uint dataseg;
};
-struct TrkAppVersion
+struct SYMBIANUTILS_EXPORT TrkAppVersion
{
TrkAppVersion();
void reset();
@@ -130,7 +126,7 @@ struct TrkAppVersion
int protocolMinor;
};
-struct Session
+struct SYMBIANUTILS_EXPORT Session
{
Session();
void reset();
@@ -163,7 +159,7 @@ struct Session
QStringList modules;
};
-struct TrkResult
+struct SYMBIANUTILS_EXPORT TrkResult
{
TrkResult();
void clear();
@@ -179,15 +175,10 @@ struct TrkResult
bool isDebugOutput;
};
-// returns a QByteArray containing optionally
-// the serial frame [0x01 0x90 <len>] and 0x7e encoded7d(ba) 0x7e
-QByteArray frameMessage(byte command, byte token, const QByteArray &data, bool serialFrame);
-ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame);
-bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *r, QByteArray *rawData = 0);
-QByteArray errorMessage(byte code);
-QByteArray hexNumber(uint n, int digits = 0);
-QByteArray hexxNumber(uint n, int digits = 0); // prepends '0x', too
-uint swapEndian(uint in);
+SYMBIANUTILS_EXPORT QByteArray errorMessage(byte code);
+SYMBIANUTILS_EXPORT QByteArray hexNumber(uint n, int digits = 0);
+SYMBIANUTILS_EXPORT QByteArray hexxNumber(uint n, int digits = 0); // prepends '0x', too
+SYMBIANUTILS_EXPORT uint swapEndian(uint in);
} // namespace trk
diff --git a/tools/runonphone/symbianutils/trkutils_p.h b/tools/runonphone/symbianutils/trkutils_p.h
new file mode 100644
index 0000000..12b0109
--- /dev/null
+++ b/tools/runonphone/symbianutils/trkutils_p.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DEBUGGER_TRK_PRIVATE_UTILS
+#define DEBUGGER_TRK_PRIVATE_UTILS
+
+#include "trkutils.h"
+#include "symbianutils_global.h"
+
+QT_BEGIN_NAMESPACE
+class QDateTime;
+QT_END_NAMESPACE
+
+namespace trk {
+
+void appendDateTime(QByteArray *ba, QDateTime dateTime, Endianness = TargetByteOrder);
+// returns a QByteArray containing optionally
+// the serial frame [0x01 0x90 <len>] and 0x7e encoded7d(ba) 0x7e
+QByteArray frameMessage(byte command, byte token, const QByteArray &data, bool serialFrame);
+bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *r, QByteArray *rawData = 0);
+
+} // namespace trk
+
+#endif // DEBUGGER_TRK_PRIVATE_UTILS