Commit 66ed2b37 authored by Aurindam Jana's avatar Aurindam Jana
Browse files

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: default avatarKai Koehne <kai.koehne@nokia.com>
parent 4cd2e326
/**************************************************************************
**
** 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
/**************************************************************************
**
** 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
/**************************************************************************
**
** 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
......@@ -214,11 +214,12 @@ void QmlEngineDebugClient::messageReceived(const QByteArray &data)
}
}
QmlEngineDebugClient::QmlEngineDebugClient(
QDeclarativeDebugConnection *connection)
: QDeclarativeDebugClient(QLatin1String("QDeclarativeEngine"), connection),
QmlEngineDebugClient::QmlEngineDebugClient(const QString &clientName,
QDeclarativeDebugConnection *conn)
: QDeclarativeDebugClient(clientName, conn),
m_nextId(1)
{
setObjectName(clientName);
}
quint32 QmlEngineDebugClient::addWatch(const QmlDebugPropertyReference &property)
......
......@@ -50,7 +50,8 @@ class QMLJSDEBUGCLIENT_EXPORT QmlEngineDebugClient : public QDeclarativeDebugCli
{
Q_OBJECT
public:
QmlEngineDebugClient(QDeclarativeDebugConnection *conn);
QmlEngineDebugClient(const QString &clientName,
QDeclarativeDebugConnection *conn);
quint32 addWatch(const QmlDebugPropertyReference &property);
quint32 addWatch(const QmlDebugContextReference &context, const QString &id);
......@@ -66,13 +67,13 @@ public:
quint32 queryObjectRecursive(const QmlDebugObjectReference &object);
quint32 queryExpressionResult(int objectDebugId,
const QString &expr);
quint32 setBindingForObject(int objectDebugId, const QString &propertyName,
virtual quint32 setBindingForObject(int objectDebugId, const QString &propertyName,
const QVariant &bindingExpression,
bool isLiteralValue,
QString source, int line);
quint32 resetBindingForObject(int objectDebugId,
virtual quint32 resetBindingForObject(int objectDebugId,
const QString &propertyName);
quint32 setMethodBody(int objectDebugId, const QString &methodName,
virtual quint32 setMethodBody(int objectDebugId, const QString &methodName,
const QString &methodBody);
signals:
......@@ -86,7 +87,6 @@ protected:
virtual void statusChanged(Status status);
virtual void messageReceived(const QByteArray &);
private:
quint32 getId() { return m_nextId++; }
void decode(QDataStream &d, QmlDebugContextReference &context);
......
......@@ -10,6 +10,7 @@ HEADERS += \
$$PWD/qmlprofilereventlocation.h \
$$PWD/qdeclarativedebugclient.h \
$$PWD/qmlenginedebugclient.h \
$$PWD/qdeclarativeengineclient.h \
$$PWD/qdeclarativeoutputparser.h \
$$PWD/qmljsdebugclient_global.h \
$$PWD/qmlprofilereventtypes.h \
......@@ -17,7 +18,8 @@ HEADERS += \
$$PWD/qpacketprotocol.h \
$$PWD/qv8profilerclient.h \
$$PWD/qmljsdebugclientconstants.h \
$$PWD/qdebugmessageclient.h
$$PWD/qdebugmessageclient.h \
$$PWD/qmldebuggerclient.h
SOURCES += \
$$PWD/qdeclarativedebugclient.cpp \
......@@ -26,7 +28,8 @@ SOURCES += \
$$PWD/qmlprofilertraceclient.cpp \
$$PWD/qpacketprotocol.cpp \
$$PWD/qv8profilerclient.cpp \
$$PWD/qdebugmessageclient.cpp
$$PWD/qdebugmessageclient.cpp \
$$PWD/qmldebuggerclient.cpp
OTHER_FILES += \
$$PWD/qmljsdebugclient.pri \
......
......@@ -36,7 +36,10 @@ DynamicLibrary {
"qmlprofilertraceclient.h",
"qpacketprotocol.h",
"qdebugmessageclient.cpp",
"qdebugmessageclient.h"
"qdebugmessageclient.h",
"qdeclarativeengineclient.h",
"qmldebuggerclient.h",
"qmldebuggerclient.cpp"
]
ProductModule {
......
......@@ -34,6 +34,8 @@
#include <qmljsdebugclient/qmlenginedebugclient.h>
#include <qmljsdebugclient/qdeclarativedebugclient.h>
#include <qmljsdebugclient/qdeclarativeengineclient.h>
#include <qmljsdebugclient/qmldebuggerclient.h>
using namespace QmlJsDebugClient;
......
......@@ -72,18 +72,20 @@ ClientProxy::~ClientProxy()
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(m_engineClient, SIGNAL(newStatus(QDeclarativeDebugClient::Status)),
connect(client1, SIGNAL(newStatus(QDeclarativeDebugClient::Status)),
SLOT(clientStatusChanged(QDeclarativeDebugClient::Status)));
connect(m_engineClient, SIGNAL(newStatus(QDeclarativeDebugClient::Status)),
connect(client1, SIGNAL(newStatus(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 =
new QmlJSInspectorClient(m_adapter.data()->connection(), this);
......@@ -135,8 +137,14 @@ void ClientProxy::clientStatusChanged(QDeclarativeDebugClient::Status status)
void ClientProxy::engineClientStatusChanged(QDeclarativeDebugClient::Status status)
{
if (status == QDeclarativeDebugClient::Enabled) {
m_adapter.data()->setEngineDebugClient(
qobject_cast<QmlEngineDebugClient *>(sender()));
m_engineClient = 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();
}
}
......
......@@ -34,6 +34,8 @@
#include <qmljsdebugclient/qmlenginedebugclient.h>
#include <qmljsdebugclient/qdeclarativedebugclient.h>
#include <qmljsdebugclient/qdeclarativeengineclient.h>
#include <qmljsdebugclient/qmldebuggerclient.h>
using namespace QmlJsDebugClient;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment