QmlDebugging: Add service client for QmlDebugger

Qt5 has renamed the service 'QDeclarativeEngine' to 'QmlDebugger'.
Add a new client to connect to the service.

Change-Id: I3a03181c4f34c311e47d4a963283b66dc778726b
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
Aurindam Jana
2012-03-15 12:11:41 +01:00
parent 4cd2e32659
commit 66ed2b37ba
10 changed files with 243 additions and 21 deletions

View File

@@ -0,0 +1,53 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** GNU Lesser General Public License Usage
**
** 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.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef QDECLARATIVEENGINECLIENT_H
#define QDECLARATIVEENGINECLIENT_H
#include "qmlenginedebugclient.h"
namespace QmlJsDebugClient {
class QDeclarativeDebugConnection;
class QMLJSDEBUGCLIENT_EXPORT QDeclarativeEngineClient : public QmlEngineDebugClient
{
Q_OBJECT
public:
QDeclarativeEngineClient(QDeclarativeDebugConnection *conn)
: QmlEngineDebugClient(QLatin1String("QDeclarativeEngine"), conn)
{
}
};
} // namespace QmlJsDebugClient
#endif // QDECLARATIVEENGINECLIENT_H

View File

@@ -0,0 +1,92 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** GNU Lesser General Public License Usage
**
** 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.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#include "qmldebuggerclient.h"
namespace QmlJsDebugClient {
QmlDebuggerClient::QmlDebuggerClient(
QDeclarativeDebugConnection *connection)
: QmlEngineDebugClient(QLatin1String("QmlDebugger"), connection)
{
}
quint32 QmlDebuggerClient::setBindingForObject(
int objectDebugId,
const QString &propertyName,
const QVariant &bindingExpression,
bool isLiteralValue,
QString source, int line)
{
quint32 id = 0;
if (status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) {
id = getId();
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("SET_BINDING") << id << objectDebugId << propertyName
<< bindingExpression << isLiteralValue << source << line;
sendMessage(message);
}
return id;
}
quint32 QmlDebuggerClient::resetBindingForObject(
int objectDebugId,
const QString &propertyName)
{
quint32 id = 0;
if (status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) {
id = getId();
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("RESET_BINDING") << id << objectDebugId << propertyName;
sendMessage(message);
}
return id;
}
quint32 QmlDebuggerClient::setMethodBody(
int objectDebugId, const QString &methodName,
const QString &methodBody)
{
quint32 id = 0;
if (status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) {
id = getId();
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("SET_METHOD_BODY") << id << objectDebugId
<< methodName << methodBody;
sendMessage(message);
}
return id;
}
} // namespace QmlJsDebugClient

View File

@@ -0,0 +1,58 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** GNU Lesser General Public License Usage
**
** 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.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef QMLDEBUGGERCLIENT_H
#define QMLDEBUGGERCLIENT_H
#include "qmlenginedebugclient.h"
namespace QmlJsDebugClient {
class QDeclarativeDebugConnection;
class QMLJSDEBUGCLIENT_EXPORT QmlDebuggerClient : public QmlEngineDebugClient
{
Q_OBJECT
public:
explicit QmlDebuggerClient(QDeclarativeDebugConnection *conn);
quint32 setBindingForObject(int objectDebugId, const QString &propertyName,
const QVariant &bindingExpression,
bool isLiteralValue,
QString source, int line);
quint32 resetBindingForObject(int objectDebugId, const QString &propertyName);
quint32 setMethodBody(int objectDebugId, const QString &methodName,
const QString &methodBody);
};
} // namespace QmlJsDebugClient
#endif // QMLDEBUGGERCLIENT_H

View File

@@ -214,11 +214,12 @@ void QmlEngineDebugClient::messageReceived(const QByteArray &data)
} }
} }
QmlEngineDebugClient::QmlEngineDebugClient( QmlEngineDebugClient::QmlEngineDebugClient(const QString &clientName,
QDeclarativeDebugConnection *connection) QDeclarativeDebugConnection *conn)
: QDeclarativeDebugClient(QLatin1String("QDeclarativeEngine"), connection), : QDeclarativeDebugClient(clientName, conn),
m_nextId(1) m_nextId(1)
{ {
setObjectName(clientName);
} }
quint32 QmlEngineDebugClient::addWatch(const QmlDebugPropertyReference &property) quint32 QmlEngineDebugClient::addWatch(const QmlDebugPropertyReference &property)

View File

@@ -50,7 +50,8 @@ class QMLJSDEBUGCLIENT_EXPORT QmlEngineDebugClient : public QDeclarativeDebugCli
{ {
Q_OBJECT Q_OBJECT
public: public:
QmlEngineDebugClient(QDeclarativeDebugConnection *conn); QmlEngineDebugClient(const QString &clientName,
QDeclarativeDebugConnection *conn);
quint32 addWatch(const QmlDebugPropertyReference &property); quint32 addWatch(const QmlDebugPropertyReference &property);
quint32 addWatch(const QmlDebugContextReference &context, const QString &id); quint32 addWatch(const QmlDebugContextReference &context, const QString &id);
@@ -66,13 +67,13 @@ public:
quint32 queryObjectRecursive(const QmlDebugObjectReference &object); quint32 queryObjectRecursive(const QmlDebugObjectReference &object);
quint32 queryExpressionResult(int objectDebugId, quint32 queryExpressionResult(int objectDebugId,
const QString &expr); const QString &expr);
quint32 setBindingForObject(int objectDebugId, const QString &propertyName, virtual quint32 setBindingForObject(int objectDebugId, const QString &propertyName,
const QVariant &bindingExpression, const QVariant &bindingExpression,
bool isLiteralValue, bool isLiteralValue,
QString source, int line); QString source, int line);
quint32 resetBindingForObject(int objectDebugId, virtual quint32 resetBindingForObject(int objectDebugId,
const QString &propertyName); const QString &propertyName);
quint32 setMethodBody(int objectDebugId, const QString &methodName, virtual quint32 setMethodBody(int objectDebugId, const QString &methodName,
const QString &methodBody); const QString &methodBody);
signals: signals:
@@ -86,7 +87,6 @@ protected:
virtual void statusChanged(Status status); virtual void statusChanged(Status status);
virtual void messageReceived(const QByteArray &); virtual void messageReceived(const QByteArray &);
private:
quint32 getId() { return m_nextId++; } quint32 getId() { return m_nextId++; }
void decode(QDataStream &d, QmlDebugContextReference &context); void decode(QDataStream &d, QmlDebugContextReference &context);

View File

@@ -10,6 +10,7 @@ HEADERS += \
$$PWD/qmlprofilereventlocation.h \ $$PWD/qmlprofilereventlocation.h \
$$PWD/qdeclarativedebugclient.h \ $$PWD/qdeclarativedebugclient.h \
$$PWD/qmlenginedebugclient.h \ $$PWD/qmlenginedebugclient.h \
$$PWD/qdeclarativeengineclient.h \
$$PWD/qdeclarativeoutputparser.h \ $$PWD/qdeclarativeoutputparser.h \
$$PWD/qmljsdebugclient_global.h \ $$PWD/qmljsdebugclient_global.h \
$$PWD/qmlprofilereventtypes.h \ $$PWD/qmlprofilereventtypes.h \
@@ -17,7 +18,8 @@ HEADERS += \
$$PWD/qpacketprotocol.h \ $$PWD/qpacketprotocol.h \
$$PWD/qv8profilerclient.h \ $$PWD/qv8profilerclient.h \
$$PWD/qmljsdebugclientconstants.h \ $$PWD/qmljsdebugclientconstants.h \
$$PWD/qdebugmessageclient.h $$PWD/qdebugmessageclient.h \
$$PWD/qmldebuggerclient.h
SOURCES += \ SOURCES += \
$$PWD/qdeclarativedebugclient.cpp \ $$PWD/qdeclarativedebugclient.cpp \
@@ -26,7 +28,8 @@ SOURCES += \
$$PWD/qmlprofilertraceclient.cpp \ $$PWD/qmlprofilertraceclient.cpp \
$$PWD/qpacketprotocol.cpp \ $$PWD/qpacketprotocol.cpp \
$$PWD/qv8profilerclient.cpp \ $$PWD/qv8profilerclient.cpp \
$$PWD/qdebugmessageclient.cpp $$PWD/qdebugmessageclient.cpp \
$$PWD/qmldebuggerclient.cpp
OTHER_FILES += \ OTHER_FILES += \
$$PWD/qmljsdebugclient.pri \ $$PWD/qmljsdebugclient.pri \

View File

@@ -36,7 +36,10 @@ DynamicLibrary {
"qmlprofilertraceclient.h", "qmlprofilertraceclient.h",
"qpacketprotocol.h", "qpacketprotocol.h",
"qdebugmessageclient.cpp", "qdebugmessageclient.cpp",
"qdebugmessageclient.h" "qdebugmessageclient.h",
"qdeclarativeengineclient.h",
"qmldebuggerclient.h",
"qmldebuggerclient.cpp"
] ]
ProductModule { ProductModule {

View File

@@ -34,6 +34,8 @@
#include <qmljsdebugclient/qmlenginedebugclient.h> #include <qmljsdebugclient/qmlenginedebugclient.h>
#include <qmljsdebugclient/qdeclarativedebugclient.h> #include <qmljsdebugclient/qdeclarativedebugclient.h>
#include <qmljsdebugclient/qdeclarativeengineclient.h>
#include <qmljsdebugclient/qmldebuggerclient.h>
using namespace QmlJsDebugClient; using namespace QmlJsDebugClient;

View File

@@ -72,18 +72,20 @@ ClientProxy::~ClientProxy()
void ClientProxy::connectToServer() void ClientProxy::connectToServer()
{ {
m_engineClient = new QmlEngineDebugClient(m_adapter.data()->connection()); QmlEngineDebugClient *client1 = new QDeclarativeEngineClient(
m_adapter.data()->connection());
QmlEngineDebugClient *client2 = new QmlDebuggerClient(
m_adapter.data()->connection());
connect(m_engineClient, SIGNAL(newObjects()), this, SLOT(newObjects())); connect(client1, SIGNAL(newStatus(QDeclarativeDebugClient::Status)),
connect(m_engineClient, SIGNAL(newStatus(QDeclarativeDebugClient::Status)),
SLOT(clientStatusChanged(QDeclarativeDebugClient::Status))); SLOT(clientStatusChanged(QDeclarativeDebugClient::Status)));
connect(m_engineClient, SIGNAL(newStatus(QDeclarativeDebugClient::Status)), connect(client1, SIGNAL(newStatus(QDeclarativeDebugClient::Status)),
SLOT(engineClientStatusChanged(QDeclarativeDebugClient::Status))); SLOT(engineClientStatusChanged(QDeclarativeDebugClient::Status)));
connect(m_engineClient, SIGNAL(result(quint32,QVariant)),
SLOT(onResult(quint32,QVariant)));
connect(m_engineClient, SIGNAL(valueChanged(int,QByteArray,QVariant)),
SLOT(objectWatchTriggered(int,QByteArray,QVariant)));
connect(client2, SIGNAL(newStatus(QDeclarativeDebugClient::Status)),
SLOT(clientStatusChanged(QDeclarativeDebugClient::Status)));
connect(client2, SIGNAL(newStatus(QDeclarativeDebugClient::Status)),
SLOT(engineClientStatusChanged(QDeclarativeDebugClient::Status)));
m_inspectorClient = m_inspectorClient =
new QmlJSInspectorClient(m_adapter.data()->connection(), this); new QmlJSInspectorClient(m_adapter.data()->connection(), this);
@@ -135,8 +137,14 @@ void ClientProxy::clientStatusChanged(QDeclarativeDebugClient::Status status)
void ClientProxy::engineClientStatusChanged(QDeclarativeDebugClient::Status status) void ClientProxy::engineClientStatusChanged(QDeclarativeDebugClient::Status status)
{ {
if (status == QDeclarativeDebugClient::Enabled) { if (status == QDeclarativeDebugClient::Enabled) {
m_adapter.data()->setEngineDebugClient( m_engineClient = qobject_cast<QmlEngineDebugClient *>(sender());
qobject_cast<QmlEngineDebugClient *>(sender())); connect(m_engineClient, SIGNAL(newObjects()), this, SLOT(newObjects()));
connect(m_engineClient, SIGNAL(result(quint32,QVariant)),
SLOT(onResult(quint32,QVariant)));
connect(m_engineClient, SIGNAL(valueChanged(int,QByteArray,QVariant)),
SLOT(objectWatchTriggered(int,QByteArray,QVariant)));
m_adapter.data()->setEngineDebugClient(m_engineClient);
updateConnected();
} }
} }

View File

@@ -34,6 +34,8 @@
#include <qmljsdebugclient/qmlenginedebugclient.h> #include <qmljsdebugclient/qmlenginedebugclient.h>
#include <qmljsdebugclient/qdeclarativedebugclient.h> #include <qmljsdebugclient/qdeclarativedebugclient.h>
#include <qmljsdebugclient/qdeclarativeengineclient.h>
#include <qmljsdebugclient/qmldebuggerclient.h>
using namespace QmlJsDebugClient; using namespace QmlJsDebugClient;