aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmltooling
diff options
context:
space:
mode:
authorQt by Nokia <qt-info@nokia.com>2011-04-27 12:05:43 +0200
committeraxis <qt-info@nokia.com>2011-04-27 12:05:43 +0200
commit885735d011472bcfbb96e688d9e64553d7fe9d4b (patch)
tree734963625eba643bf11bc4870a4c407809a6400a /src/plugins/qmltooling
Initial import from the monolithic Qt.
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12
Diffstat (limited to 'src/plugins/qmltooling')
-rw-r--r--src/plugins/qmltooling/qmldbg_ost/qmldbg_ost.pro21
-rw-r--r--src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp143
-rw-r--r--src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h81
-rw-r--r--src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp180
-rw-r--r--src/plugins/qmltooling/qmldbg_ost/qostdevice.h75
-rw-r--r--src/plugins/qmltooling/qmldbg_ost/usbostcomm.h191
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro18
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp178
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h84
-rw-r--r--src/plugins/qmltooling/qmltooling.pro4
10 files changed, 975 insertions, 0 deletions
diff --git a/src/plugins/qmltooling/qmldbg_ost/qmldbg_ost.pro b/src/plugins/qmltooling/qmldbg_ost/qmldbg_ost.pro
new file mode 100644
index 0000000000..274888940a
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_ost/qmldbg_ost.pro
@@ -0,0 +1,21 @@
+TARGET = qmldbg_ost
+QT += declarative network
+
+include(../../qpluginbase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/qmltooling
+QTDIR_build:REQUIRES += "contains(QT_CONFIG, declarative)"
+
+SOURCES += \
+ qmlostplugin.cpp \
+ qostdevice.cpp
+
+HEADERS += \
+ qmlostplugin.h \
+ qostdevice.h \
+ usbostcomm.h
+
+target.path += $$[QT_INSTALL_PLUGINS]/qmltooling
+INSTALLS += target
+
+symbian:TARGET.UID3=0x20031E92
diff --git a/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp b/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp
new file mode 100644
index 0000000000..1c91c3455a
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmlostplugin.h"
+#include "qostdevice.h"
+
+#include <private/qdeclarativedebugserver_p.h>
+#include <private/qpacketprotocol_p.h>
+
+QT_BEGIN_NAMESPACE
+
+static const TInt KQmlOstProtocolId = 0x94;
+
+class QmlOstPluginPrivate {
+public:
+ QmlOstPluginPrivate();
+
+ QOstDevice *ost;
+ QPacketProtocol *protocol;
+ QDeclarativeDebugServer *debugServer;
+};
+
+QmlOstPluginPrivate::QmlOstPluginPrivate() :
+ ost(0),
+ protocol(0),
+ debugServer(0)
+{
+}
+
+QmlOstPlugin::QmlOstPlugin() :
+ d_ptr(new QmlOstPluginPrivate)
+{
+}
+
+QmlOstPlugin::~QmlOstPlugin()
+{
+ delete d_ptr;
+}
+
+void QmlOstPlugin::setServer(QDeclarativeDebugServer *server)
+{
+ Q_D(QmlOstPlugin);
+ d->debugServer = server;
+}
+
+bool QmlOstPlugin::isConnected() const
+{
+ Q_D(const QmlOstPlugin);
+ return d->ost && d->ost->isOpen();
+}
+
+void QmlOstPlugin::send(const QByteArray &message)
+{
+ Q_D(QmlOstPlugin);
+
+ if (!isConnected())
+ return;
+
+ QPacket pack;
+ pack.writeRawData(message.data(), message.length());
+
+ d->protocol->send(pack);
+ //d->socket->flush();
+}
+
+void QmlOstPlugin::disconnect()
+{
+ Q_D(QmlOstPlugin);
+
+ delete d->protocol;
+ d->protocol = 0;
+}
+
+void QmlOstPlugin::setPort(int port, bool block)
+{
+ Q_UNUSED(port);
+ Q_UNUSED(block);
+
+ Q_D(QmlOstPlugin);
+
+ d->ost = new QOstDevice(this);
+ bool ok = d->ost->open(KQmlOstProtocolId);
+ if (!ok) {
+ if (d->ost->errorString().length())
+ qDebug("Error from QOstDevice: %s", qPrintable(d->ost->errorString()));
+ qWarning("QDeclarativeDebugServer: Unable to listen on OST"); // This message is part of the signalling - do not change the format!
+ return;
+ }
+ d->protocol = new QPacketProtocol(d->ost, this);
+ QObject::connect(d->protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
+ qWarning("QDeclarativeDebugServer: Waiting for connection via OST"); // This message is part of the signalling - do not change the format!
+}
+
+void QmlOstPlugin::readyRead()
+{
+ Q_D(QmlOstPlugin);
+ QPacket packet = d->protocol->read();
+
+ QByteArray content = packet.data();
+ d->debugServer->receiveMessage(content);
+}
+
+Q_EXPORT_PLUGIN2(qmlostplugin, QmlOstPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h b/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h
new file mode 100644
index 0000000000..eee6ee179b
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLOSTPLUGIN_H
+#define QMLOSTPLUGIN_H
+
+#include <QtGui/QStylePlugin>
+#include <QtDeclarative/private/qdeclarativedebugserverconnection_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeDebugServer;
+class QmlOstPluginPrivate;
+
+class QmlOstPlugin : public QObject, public QDeclarativeDebugServerConnection
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QmlOstPlugin)
+ Q_DISABLE_COPY(QmlOstPlugin)
+ Q_INTERFACES(QDeclarativeDebugServerConnection)
+
+
+public:
+ QmlOstPlugin();
+ ~QmlOstPlugin();
+
+ void setServer(QDeclarativeDebugServer *server);
+ void setPort(int port, bool bock);
+
+ bool isConnected() const;
+ void send(const QByteArray &message);
+ void disconnect();
+
+private Q_SLOTS:
+ void readyRead();
+
+private:
+ QmlOstPluginPrivate *d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMLOSTPLUGIN_H
diff --git a/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp b/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp
new file mode 100644
index 0000000000..21b0169c81
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp
@@ -0,0 +1,180 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qostdevice.h"
+#include <e32base.h>
+
+#include "usbostcomm.h"
+
+class QOstDevicePrivate : public CActive
+{
+ QOstDevice* q_ptr;
+ Q_DECLARE_PUBLIC(QOstDevice)
+
+public:
+ QOstDevicePrivate() : CActive(CActive::EPriorityStandard) {
+ CActiveScheduler::Add(this);
+ }
+ ~QOstDevicePrivate() {
+ Cancel();
+ }
+
+private:
+ void RunL();
+ void DoCancel();
+
+private:
+ RUsbOstComm ost;
+ TBuf8<4096> readBuf;
+ QByteArray dataBuf;
+};
+
+QOstDevice::QOstDevice(QObject *parent) :
+ QIODevice(parent), d_ptr(new QOstDevicePrivate)
+{
+ d_ptr->q_ptr = this;
+}
+
+QOstDevice::~QOstDevice()
+{
+ close();
+ delete d_ptr;
+}
+
+bool QOstDevice::open(int ostProtocolId)
+{
+ if (isOpen())
+ return false;
+
+ Q_D(QOstDevice);
+ TInt err = d->ost.Connect();
+ if (!err) err = d->ost.Open();
+ const TVersion KRequiredVersion(1,1,0);
+ TVersion version = d->ost.Version();
+ if (version.iMajor < KRequiredVersion.iMajor ||
+ (version.iMajor == KRequiredVersion.iMajor && version.iMinor < KRequiredVersion.iMinor)) {
+ setErrorString("CODA version too old. At least version 4.0.18 (without TRK) is required.");
+ return false;
+ }
+
+ if (!err) err = d->ost.RegisterProtocolID((TOstProtIds)ostProtocolId, EFalse);
+ if (!err) {
+ d->ost.ReadMessage(d->iStatus, d->readBuf);
+ d->SetActive();
+ return QIODevice::open(ReadWrite | Unbuffered);
+ }
+ return false;
+}
+
+void QOstDevicePrivate::RunL()
+{
+ Q_Q(QOstDevice);
+ //qDebug("QOstDevice received %d bytes q=%x", readBuf.Size(), q);
+ if (iStatus == KErrNone) {
+ QByteArray data = QByteArray::fromRawData((const char*)readBuf.Ptr(), readBuf.Size());
+ dataBuf.append(data);
+
+ readBuf.Zero();
+ ost.ReadMessage(iStatus, readBuf);
+ SetActive();
+
+ emit q->readyRead();
+ } else {
+ q->setErrorString(QString("Error %1 from RUsbOstComm::ReadMessage()").arg(iStatus.Int()));
+ }
+ //qDebug("-QOstDevicePrivate RunL");
+}
+
+void QOstDevicePrivate::DoCancel()
+{
+ ost.ReadCancel();
+}
+
+void QOstDevice::close()
+{
+ Q_D(QOstDevice);
+ QIODevice::close();
+ d->Cancel();
+ // RDbgTrcComm::Close isn't safe to call when not open, sigh
+ if (d->ost.Handle()) {
+ d->ost.Close();
+ }
+}
+
+qint64 QOstDevice::readData(char *data, qint64 maxSize)
+{
+ Q_D(QOstDevice);
+ if (d->dataBuf.length() == 0 && !d->IsActive())
+ return -1;
+ qint64 available = qMin(maxSize, (qint64)d->dataBuf.length());
+ memcpy(data, d->dataBuf.constData(), available);
+ d->dataBuf.remove(0, available);
+ return available;
+}
+
+static const TInt KMaxOstPacketLen = 4096;
+
+qint64 QOstDevice::writeData(const char *data, qint64 maxSize)
+{
+ Q_D(QOstDevice);
+ TPtrC8 ptr((const TUint8*)data, (TInt)maxSize);
+ while (ptr.Length()) {
+ TPtrC8 fragment = ptr.Left(qMin(ptr.Length(), KMaxOstPacketLen));
+ //qDebug("QOstDevice writing %d bytes", fragment.Length());
+ TRequestStatus stat;
+ d->ost.WriteMessage(stat, fragment);
+ User::WaitForRequest(stat);
+ if (stat.Int() != KErrNone) {
+ setErrorString(QString("Error %1 from RUsbOstComm::WriteMessage()").arg(stat.Int()));
+ return -1;
+ }
+ ptr.Set(ptr.Mid(fragment.Length()));
+ }
+ emit bytesWritten(maxSize); //TODO does it matter this is emitted synchronously?
+ //qDebug("QOstDevice wrote %d bytes", ptr.Size());
+ return maxSize;
+}
+
+qint64 QOstDevice::bytesAvailable() const
+{
+ Q_D(const QOstDevice);
+ return d->dataBuf.length();
+}
diff --git a/src/plugins/qmltooling/qmldbg_ost/qostdevice.h b/src/plugins/qmltooling/qmldbg_ost/qostdevice.h
new file mode 100644
index 0000000000..2c26ff707d
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_ost/qostdevice.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QOSTDEVICE_H
+#define QOSTDEVICE_H
+
+#include <QtCore/QIODevice>
+
+QT_BEGIN_NAMESPACE
+
+class QOstDevicePrivate;
+
+class QOstDevice : public QIODevice
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QOstDevice)
+ Q_DISABLE_COPY(QOstDevice)
+
+public:
+ explicit QOstDevice(QObject *parent=0);
+ ~QOstDevice();
+
+ bool open(int ostProtocolId);
+ void close();
+
+protected:
+ qint64 readData(char *data, qint64 maxSize);
+ qint64 writeData(const char *data, qint64 maxSize);
+ qint64 bytesAvailable() const;
+
+private:
+ QOstDevicePrivate* d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QOSTDEVICE_H
diff --git a/src/plugins/qmltooling/qmldbg_ost/usbostcomm.h b/src/plugins/qmltooling/qmldbg_ost/usbostcomm.h
new file mode 100644
index 0000000000..48ff7bf554
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_ost/usbostcomm.h
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef USBHOSTCOMM_H
+#define USBHOSTCOMM_H
+
+// Based on the official usbostrouter header, modified to remove dependancy on
+// the client DLL
+
+#include <e32base.h>
+
+typedef int TOstProtIds;
+
+class RUsbOstComm : public RSessionBase
+{
+public:
+ RUsbOstComm();
+ TInt Connect();
+ TInt Disconnect();
+ TInt Open();
+ TInt Close();
+ TInt RegisterProtocolID(TOstProtIds aId, TBool aNeedHeader);
+ void ReadMessage(TRequestStatus& aStatus, TDes8& aDes);
+ TInt ReadCancel();
+ void WriteMessage(TRequestStatus& aStatus, const TDesC8& aDes, TBool aHasHeader=EFalse);
+ TVersion Version() const;
+
+private:
+ enum TUsbOstCmdCode
+ {
+ EUsbOstCmdCodeFirst,
+ EUsbOstCmdConnect,
+ EUsbOstCmdDisconnect,
+ EUsbOstCmdCodeGetAcmConfig,
+ EUsbOstCmdCodeSetAcmConfig,
+ EUsbOstCmdCodeOpen,
+ EUsbOstCmdCodeClose,
+ EUsbOstCmdCodeRegisterId,
+ EUsbOstCmdCodeRegisterIds,
+ EUsbOstCmdCodeUnRegisterId,
+ EUsbOstCmdCodeUnRegisterIds,
+ EUsbOstCmdCodeReadMsg,
+ EUsbOstCmdCodeReadCancel,
+ EUsbOstCmdCodeWriteMsg,
+ EUsbOstCmdCodeWriteCancel,
+ EUsbOstCmdCodeLast
+ };
+};
+
+RUsbOstComm::RUsbOstComm()
+{
+}
+
+TInt RUsbOstComm::Connect()
+{
+ _LIT(KUsbOstServerName, "!UsbOstRouter");
+ _LIT(KUsbOstServerImageName, "usbostrouter");
+ const TUid KUsbOstServerUid = { 0x200170BE };
+ TInt startupAttempts = 2;
+ for(;;) {
+ TInt ret = CreateSession(KUsbOstServerName, TVersion(1,0,0));
+ if (ret != KErrNotFound && ret != KErrServerTerminated) {
+ return ret;
+ }
+
+ if (startupAttempts-- == 0) {
+ return ret;
+ }
+
+ RProcess server;
+ ret = server.Create(KUsbOstServerImageName, KNullDesC, KUsbOstServerUid);
+ if (ret != KErrNone)
+ return ret;
+
+ TRequestStatus serverDiedRequestStatus;
+ server.Rendezvous(serverDiedRequestStatus);
+
+ if (serverDiedRequestStatus != KRequestPending) {
+ // Abort startup
+ server.Kill(KErrNone);
+ } else {
+ // Logon OK - start the server
+ server.Resume();
+ }
+ User::WaitForRequest(serverDiedRequestStatus);
+ ret = (server.ExitType() == EExitPanic) ? KErrGeneral : serverDiedRequestStatus.Int();
+ server.Close();
+
+ if (ret != KErrNone && ret != KErrAlreadyExists) {
+ return ret;
+ }
+ }
+}
+
+TInt RUsbOstComm::Disconnect()
+{
+ return SendReceive(EUsbOstCmdDisconnect);
+}
+
+TInt RUsbOstComm::Open()
+{
+ return SendReceive(EUsbOstCmdCodeOpen);
+}
+
+TInt RUsbOstComm::Close()
+{
+ TInt err = SendReceive(EUsbOstCmdCodeClose);
+ RHandleBase::Close();
+ return err;
+}
+
+TInt RUsbOstComm::RegisterProtocolID(const TOstProtIds aId, TBool aNeedHeader)
+{
+ TIpcArgs args(aId, aNeedHeader);
+ return SendReceive(EUsbOstCmdCodeRegisterId, args);
+}
+
+void RUsbOstComm::ReadMessage(TRequestStatus& aStatus, TDes8& aDes)
+{
+ TIpcArgs args(aDes.MaxLength(), &aDes);
+ SendReceive(EUsbOstCmdCodeReadMsg, args, aStatus);
+}
+
+TInt RUsbOstComm::ReadCancel()
+{
+ return SendReceive(EUsbOstCmdCodeReadCancel);
+}
+
+void RUsbOstComm::WriteMessage(TRequestStatus& aStatus, const TDesC8& aDes, TBool aHasHeader)
+{
+ TIpcArgs args(aHasHeader, aDes.Length(), &aDes);
+ SendReceive(EUsbOstCmdCodeWriteMsg, args, aStatus);
+}
+
+typedef TVersion (*TVersionFunction)(const RUsbOstComm*);
+const TInt KVersionOrdinal = 17;
+
+TVersion RUsbOstComm::Version() const
+{
+ // This function has to go to the DLL, unfortunately
+ TVersion result; // Return 0.0.0 on any error
+ RLibrary lib;
+ TInt err = lib.Load(_L("usbostcomm"));
+ if (err) return result;
+
+ TLibraryFunction fn = lib.Lookup(KVersionOrdinal);
+ if (fn)
+ result = ((TVersionFunction)fn)(this);
+ lib.Close();
+ return result;
+}
+
+#endif //USBHOSTCOMM_H
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro b/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro
new file mode 100644
index 0000000000..e8ab962da8
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro
@@ -0,0 +1,18 @@
+TARGET = qmldbg_tcp
+QT += declarative network
+
+include(../../qpluginbase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/qmltooling
+QTDIR_build:REQUIRES += "contains(QT_CONFIG, declarative)"
+
+SOURCES += \
+ qtcpserverconnection.cpp
+
+HEADERS += \
+ qtcpserverconnection.h
+
+target.path += $$[QT_INSTALL_PLUGINS]/qmltooling
+INSTALLS += target
+
+symbian:TARGET.UID3=0x20031E90
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
new file mode 100644
index 0000000000..85c43e3760
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
@@ -0,0 +1,178 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtcpserverconnection.h"
+
+#include <QtNetwork/qtcpserver.h>
+#include <QtNetwork/qtcpsocket.h>
+
+#include <private/qdeclarativedebugserver_p.h>
+#include <private/qpacketprotocol_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QTcpServerConnectionPrivate {
+public:
+ QTcpServerConnectionPrivate();
+
+ int port;
+ QTcpSocket *socket;
+ QPacketProtocol *protocol;
+ QTcpServer *tcpServer;
+
+ QDeclarativeDebugServer *debugServer;
+};
+
+QTcpServerConnectionPrivate::QTcpServerConnectionPrivate() :
+ port(0),
+ socket(0),
+ protocol(0),
+ tcpServer(0),
+ debugServer(0)
+{
+}
+
+QTcpServerConnection::QTcpServerConnection() :
+ d_ptr(new QTcpServerConnectionPrivate)
+{
+
+}
+
+QTcpServerConnection::~QTcpServerConnection()
+{
+ delete d_ptr;
+}
+
+void QTcpServerConnection::setServer(QDeclarativeDebugServer *server)
+{
+ Q_D(QTcpServerConnection);
+ d->debugServer = server;
+}
+
+bool QTcpServerConnection::isConnected() const
+{
+ Q_D(const QTcpServerConnection);
+ return d->socket && d->socket->state() == QTcpSocket::ConnectedState;
+}
+
+void QTcpServerConnection::send(const QByteArray &message)
+{
+ Q_D(QTcpServerConnection);
+
+ if (!isConnected()
+ || !d->protocol || !d->socket)
+ return;
+
+ QPacket pack;
+ pack.writeRawData(message.data(), message.length());
+
+ d->protocol->send(pack);
+ d->socket->flush();
+}
+
+void QTcpServerConnection::disconnect()
+{
+ Q_D(QTcpServerConnection);
+
+ // protocol might still be processing packages at this point
+ d->protocol->deleteLater();
+ d->protocol = 0;
+ d->socket->deleteLater();
+ d->socket = 0;
+}
+
+void QTcpServerConnection::setPort(int port, bool block)
+{
+ Q_D(QTcpServerConnection);
+ d->port = port;
+
+ listen();
+ if (block)
+ d->tcpServer->waitForNewConnection(-1);
+}
+
+void QTcpServerConnection::listen()
+{
+ Q_D(QTcpServerConnection);
+
+ d->tcpServer = new QTcpServer(this);
+ QObject::connect(d->tcpServer, SIGNAL(newConnection()), this, SLOT(newConnection()));
+ if (d->tcpServer->listen(QHostAddress::Any, d->port))
+ qWarning("QDeclarativeDebugServer: Waiting for connection on port %d...", d->port);
+ else
+ qWarning("QDeclarativeDebugServer: Unable to listen on port %d", d->port);
+}
+
+
+void QTcpServerConnection::readyRead()
+{
+ Q_D(QTcpServerConnection);
+ if (!d->protocol)
+ return;
+
+ QPacket packet = d->protocol->read();
+
+ QByteArray content = packet.data();
+ d->debugServer->receiveMessage(content);
+}
+
+void QTcpServerConnection::newConnection()
+{
+ Q_D(QTcpServerConnection);
+
+ if (d->socket) {
+ qWarning("QDeclarativeDebugServer: Another client is already connected");
+ QTcpSocket *faultyConnection = d->tcpServer->nextPendingConnection();
+ delete faultyConnection;
+ return;
+ }
+
+ d->socket = d->tcpServer->nextPendingConnection();
+ d->socket->setParent(this);
+ d->protocol = new QPacketProtocol(d->socket, this);
+ QObject::connect(d->protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
+}
+
+
+Q_EXPORT_PLUGIN2(tcpserver, QTcpServerConnection)
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
new file mode 100644
index 0000000000..66a10e18db
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTCPSERVERCONNECTION_H
+#define QTCPSERVERCONNECTION_H
+
+#include <QtGui/QStylePlugin>
+#include <QtDeclarative/private/qdeclarativedebugserverconnection_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeDebugServer;
+class QTcpServerConnectionPrivate;
+class QTcpServerConnection : public QObject, public QDeclarativeDebugServerConnection
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QTcpServerConnection)
+ Q_DISABLE_COPY(QTcpServerConnection)
+ Q_INTERFACES(QDeclarativeDebugServerConnection)
+
+
+public:
+ QTcpServerConnection();
+ ~QTcpServerConnection();
+
+ void setServer(QDeclarativeDebugServer *server);
+ void setPort(int port, bool bock);
+
+ bool isConnected() const;
+ void send(const QByteArray &message);
+ void disconnect();
+
+ void listen();
+ void waitForConnection();
+
+private Q_SLOTS:
+ void readyRead();
+ void newConnection();
+
+private:
+ QTcpServerConnectionPrivate *d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTCPSERVERCONNECTION_H
diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro
new file mode 100644
index 0000000000..9b3346fb36
--- /dev/null
+++ b/src/plugins/qmltooling/qmltooling.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+
+SUBDIRS = qmldbg_tcp
+symbian:SUBDIRS += qmldbg_ost