QmlJsInspector: remove private header dependencies

A copy of the client debugging code is made in src/libs/qmljsdebugclient/
(this comes from the qt code from commit 65642dd343bf61)

So the qmljsinspector plugin does not require anymore Qt private headers.
This commit is contained in:
Olivier Goffart
2010-07-29 14:15:12 +02:00
parent 333334c64c
commit f3cdbeff63
16 changed files with 2350 additions and 30 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,377 @@
/****************************************************************************
**
** 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 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 QDECLARATIVEDEBUG_H
#define QDECLARATIVEDEBUG_H
#include <QtCore/qobject.h>
#include <QtCore/qurl.h>
#include <QtCore/qvariant.h>
QT_BEGIN_HEADER
namespace QmlJsDebugClient {
class QDeclarativeDebugConnection;
class QDeclarativeDebugWatch;
class QDeclarativeDebugPropertyWatch;
class QDeclarativeDebugObjectExpressionWatch;
class QDeclarativeDebugEnginesQuery;
class QDeclarativeDebugRootContextQuery;
class QDeclarativeDebugObjectQuery;
class QDeclarativeDebugExpressionQuery;
class QDeclarativeDebugPropertyReference;
class QDeclarativeDebugContextReference;
class QDeclarativeDebugObjectReference;
class QDeclarativeDebugFileReference;
class QDeclarativeDebugEngineReference;
class QDeclarativeEngineDebugPrivate;
class QDeclarativeEngineDebug;
class QDeclarativeEngineDebug : public QObject
{
Q_OBJECT
public:
QDeclarativeEngineDebug(QDeclarativeDebugConnection *, QObject * = 0);
QDeclarativeDebugPropertyWatch *addWatch(const QDeclarativeDebugPropertyReference &,
QObject *parent = 0);
QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugContextReference &, const QString &,
QObject *parent = 0);
QDeclarativeDebugObjectExpressionWatch *addWatch(const QDeclarativeDebugObjectReference &, const QString &,
QObject *parent = 0);
QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugObjectReference &,
QObject *parent = 0);
QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugFileReference &,
QObject *parent = 0);
void removeWatch(QDeclarativeDebugWatch *watch);
QDeclarativeDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0);
QDeclarativeDebugRootContextQuery *queryRootContexts(const QDeclarativeDebugEngineReference &,
QObject *parent = 0);
QDeclarativeDebugObjectQuery *queryObject(const QDeclarativeDebugObjectReference &,
QObject *parent = 0);
QDeclarativeDebugObjectQuery *queryObjectRecursive(const QDeclarativeDebugObjectReference &,
QObject *parent = 0);
QDeclarativeDebugExpressionQuery *queryExpressionResult(int objectDebugId,
const QString &expr,
QObject *parent = 0);
bool setBindingForObject(int objectDebugId, const QString &propertyName,
const QVariant &bindingExpression, bool isLiteralValue);
bool resetBindingForObject(int objectDebugId, const QString &propertyName);
bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody);
private:
Q_DECLARE_PRIVATE(QDeclarativeEngineDebug)
};
class QDeclarativeDebugWatch : public QObject
{
Q_OBJECT
public:
enum State { Waiting, Active, Inactive, Dead };
QDeclarativeDebugWatch(QObject *);
~QDeclarativeDebugWatch();
int queryId() const;
int objectDebugId() const;
State state() const;
Q_SIGNALS:
void stateChanged(QDeclarativeDebugWatch::State);
//void objectChanged(int, const QDeclarativeDebugObjectReference &);
//void valueChanged(int, const QVariant &);
// Server sends value as string if it is a user-type variant
void valueChanged(const QByteArray &name, const QVariant &value);
private:
friend class QDeclarativeEngineDebug;
friend class QDeclarativeEngineDebugPrivate;
void setState(State);
State m_state;
int m_queryId;
QDeclarativeEngineDebug *m_client;
int m_objectDebugId;
};
class QDeclarativeDebugPropertyWatch : public QDeclarativeDebugWatch
{
Q_OBJECT
public:
QDeclarativeDebugPropertyWatch(QObject *parent);
QString name() const;
private:
friend class QDeclarativeEngineDebug;
QString m_name;
};
class QDeclarativeDebugObjectExpressionWatch : public QDeclarativeDebugWatch
{
Q_OBJECT
public:
QDeclarativeDebugObjectExpressionWatch(QObject *parent);
QString expression() const;
private:
friend class QDeclarativeEngineDebug;
QString m_expr;
int m_debugId;
};
class QDeclarativeDebugQuery : public QObject
{
Q_OBJECT
public:
enum State { Waiting, Error, Completed };
State state() const;
bool isWaiting() const;
// bool waitUntilCompleted();
Q_SIGNALS:
void stateChanged(QDeclarativeDebugQuery::State);
protected:
QDeclarativeDebugQuery(QObject *);
private:
friend class QDeclarativeEngineDebug;
friend class QDeclarativeEngineDebugPrivate;
void setState(State);
State m_state;
};
class QDeclarativeDebugFileReference
{
public:
QDeclarativeDebugFileReference();
QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &);
QDeclarativeDebugFileReference &operator=(const QDeclarativeDebugFileReference &);
QUrl url() const;
void setUrl(const QUrl &);
int lineNumber() const;
void setLineNumber(int);
int columnNumber() const;
void setColumnNumber(int);
private:
friend class QDeclarativeEngineDebugPrivate;
QUrl m_url;
int m_lineNumber;
int m_columnNumber;
};
class QDeclarativeDebugEngineReference
{
public:
QDeclarativeDebugEngineReference();
QDeclarativeDebugEngineReference(int);
QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &);
QDeclarativeDebugEngineReference &operator=(const QDeclarativeDebugEngineReference &);
int debugId() const;
QString name() const;
private:
friend class QDeclarativeEngineDebugPrivate;
int m_debugId;
QString m_name;
};
class QDeclarativeDebugObjectReference
{
public:
QDeclarativeDebugObjectReference();
QDeclarativeDebugObjectReference(int);
QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &);
QDeclarativeDebugObjectReference &operator=(const QDeclarativeDebugObjectReference &);
int debugId() const;
QString className() const;
QString idString() const;
QString name() const;
QDeclarativeDebugFileReference source() const;
int contextDebugId() const;
QList<QDeclarativeDebugPropertyReference> properties() const;
QList<QDeclarativeDebugObjectReference> children() const;
private:
friend class QDeclarativeEngineDebugPrivate;
int m_debugId;
QString m_class;
QString m_idString;
QString m_name;
QDeclarativeDebugFileReference m_source;
int m_contextDebugId;
QList<QDeclarativeDebugPropertyReference> m_properties;
QList<QDeclarativeDebugObjectReference> m_children;
};
class QDeclarativeDebugContextReference
{
public:
QDeclarativeDebugContextReference();
QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &);
QDeclarativeDebugContextReference &operator=(const QDeclarativeDebugContextReference &);
int debugId() const;
QString name() const;
QList<QDeclarativeDebugObjectReference> objects() const;
QList<QDeclarativeDebugContextReference> contexts() const;
private:
friend class QDeclarativeEngineDebugPrivate;
int m_debugId;
QString m_name;
QList<QDeclarativeDebugObjectReference> m_objects;
QList<QDeclarativeDebugContextReference> m_contexts;
};
class QDeclarativeDebugPropertyReference
{
public:
QDeclarativeDebugPropertyReference();
QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &);
QDeclarativeDebugPropertyReference &operator=(const QDeclarativeDebugPropertyReference &);
int objectDebugId() const;
QString name() const;
QVariant value() const;
QString valueTypeName() const;
QString binding() const;
bool hasNotifySignal() const;
private:
friend class QDeclarativeEngineDebugPrivate;
int m_objectDebugId;
QString m_name;
QVariant m_value;
QString m_valueTypeName;
QString m_binding;
bool m_hasNotifySignal;
};
class QDeclarativeDebugEnginesQuery : public QDeclarativeDebugQuery
{
Q_OBJECT
public:
virtual ~QDeclarativeDebugEnginesQuery();
QList<QDeclarativeDebugEngineReference> engines() const;
private:
friend class QDeclarativeEngineDebug;
friend class QDeclarativeEngineDebugPrivate;
QDeclarativeDebugEnginesQuery(QObject *);
QDeclarativeEngineDebug *m_client;
int m_queryId;
QList<QDeclarativeDebugEngineReference> m_engines;
};
class QDeclarativeDebugRootContextQuery : public QDeclarativeDebugQuery
{
Q_OBJECT
public:
virtual ~QDeclarativeDebugRootContextQuery();
QDeclarativeDebugContextReference rootContext() const;
private:
friend class QDeclarativeEngineDebug;
friend class QDeclarativeEngineDebugPrivate;
QDeclarativeDebugRootContextQuery(QObject *);
QDeclarativeEngineDebug *m_client;
int m_queryId;
QDeclarativeDebugContextReference m_context;
};
class QDeclarativeDebugObjectQuery : public QDeclarativeDebugQuery
{
Q_OBJECT
public:
virtual ~QDeclarativeDebugObjectQuery();
QDeclarativeDebugObjectReference object() const;
private:
friend class QDeclarativeEngineDebug;
friend class QDeclarativeEngineDebugPrivate;
QDeclarativeDebugObjectQuery(QObject *);
QDeclarativeEngineDebug *m_client;
int m_queryId;
QDeclarativeDebugObjectReference m_object;
};
class QDeclarativeDebugExpressionQuery : public QDeclarativeDebugQuery
{
Q_OBJECT
public:
virtual ~QDeclarativeDebugExpressionQuery();
QVariant expression() const;
QVariant result() const;
private:
friend class QDeclarativeEngineDebug;
friend class QDeclarativeEngineDebugPrivate;
QDeclarativeDebugExpressionQuery(QObject *);
QDeclarativeEngineDebug *m_client;
int m_queryId;
QVariant m_expr;
QVariant m_result;
};
}
Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugEngineReference)
Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugObjectReference)
Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugContextReference)
Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugPropertyReference)
QT_END_HEADER
#endif // QDECLARATIVEDEBUG_H

View File

@@ -0,0 +1,198 @@
/****************************************************************************
**
** 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 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 "qdeclarativedebugclient_p.h"
#include "qpacketprotocol_p.h"
#include <QtCore/qdebug.h>
#include <QtCore/qstringlist.h>
namespace QmlJsDebugClient {
class QDeclarativeDebugConnectionPrivate : public QObject
{
Q_OBJECT
public:
QDeclarativeDebugConnectionPrivate(QDeclarativeDebugConnection *c);
QDeclarativeDebugConnection *q;
QPacketProtocol *protocol;
QStringList enabled;
QHash<QString, QDeclarativeDebugClient *> plugins;
public Q_SLOTS:
void connected();
void readyRead();
};
QDeclarativeDebugConnectionPrivate::QDeclarativeDebugConnectionPrivate(QDeclarativeDebugConnection *c)
: QObject(c), q(c), protocol(0)
{
protocol = new QPacketProtocol(q, this);
QObject::connect(c, SIGNAL(connected()), this, SLOT(connected()));
QObject::connect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
}
void QDeclarativeDebugConnectionPrivate::connected()
{
QPacket pack;
pack << QString(QLatin1String("QDeclarativeDebugServer")) << enabled;
protocol->send(pack);
}
void QDeclarativeDebugConnectionPrivate::readyRead()
{
QPacket pack = protocol->read();
QString name; QByteArray message;
pack >> name >> message;
QHash<QString, QDeclarativeDebugClient *>::Iterator iter =
plugins.find(name);
if (iter == plugins.end()) {
qWarning() << "QDeclarativeDebugConnection: Message received for missing plugin" << name;
} else {
(*iter)->messageReceived(message);
}
}
QDeclarativeDebugConnection::QDeclarativeDebugConnection(QObject *parent)
: QTcpSocket(parent), d(new QDeclarativeDebugConnectionPrivate(this))
{
}
bool QDeclarativeDebugConnection::isConnected() const
{
return state() == ConnectedState;
}
class QDeclarativeDebugClientPrivate
{
public:
QDeclarativeDebugClientPrivate();
QString name;
QDeclarativeDebugConnection *client;
bool enabled;
};
QDeclarativeDebugClientPrivate::QDeclarativeDebugClientPrivate()
: client(0), enabled(false)
{
}
QDeclarativeDebugClient::QDeclarativeDebugClient(const QString &name,
QDeclarativeDebugConnection *parent)
: QObject(parent), d(new QDeclarativeDebugClientPrivate)
{
d->name = name;
d->client = parent;
if (!d->client)
return;
if (d->client->d->plugins.contains(name)) {
qWarning() << "QDeclarativeDebugClient: Conflicting plugin name" << name;
d->client = 0;
} else {
d->client->d->plugins.insert(name, this);
}
}
QDeclarativeDebugClient::~QDeclarativeDebugClient() {}
QString QDeclarativeDebugClient::name() const
{
return d->name;
}
bool QDeclarativeDebugClient::isEnabled() const
{
return d->enabled;
}
void QDeclarativeDebugClient::setEnabled(bool e)
{
if (e == d->enabled)
return;
d->enabled = e;
if (d->client) {
if (e)
d->client->d->enabled.append(d->name);
else
d->client->d->enabled.removeAll(d->name);
if (d->client->state() == QTcpSocket::ConnectedState) {
QPacket pack;
pack << QString(QLatin1String("QDeclarativeDebugServer"));
if (e) pack << (int)1;
else pack << (int)2;
pack << d->name;
d->client->d->protocol->send(pack);
}
}
}
bool QDeclarativeDebugClient::isConnected() const
{
if (!d->client)
return false;
return d->client->isConnected();
}
void QDeclarativeDebugClient::sendMessage(const QByteArray &message)
{
if (!d->client || !d->client->isConnected())
return;
QPacket pack;
pack << d->name << message;
d->client->d->protocol->send(pack);
}
void QDeclarativeDebugClient::messageReceived(const QByteArray &)
{
}
}
#include <qdeclarativedebugclient.moc>

View File

@@ -0,0 +1,99 @@
/****************************************************************************
**
** 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 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 QDECLARATIVEDEBUGCLIENT_H
#define QDECLARATIVEDEBUGCLIENT_H
#include <QtNetwork/qtcpsocket.h>
QT_BEGIN_HEADER
namespace QmlJsDebugClient {
class QDeclarativeDebugConnectionPrivate;
class QDeclarativeDebugConnection : public QTcpSocket
{
Q_OBJECT
Q_DISABLE_COPY(QDeclarativeDebugConnection)
public:
QDeclarativeDebugConnection(QObject * = 0);
bool isConnected() const;
private:
QDeclarativeDebugConnectionPrivate *d;
friend class QDeclarativeDebugClient;
friend class QDeclarativeDebugClientPrivate;
};
class QDeclarativeDebugClientPrivate;
class QDeclarativeDebugClient : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QDeclarativeDebugClient)
Q_DISABLE_COPY(QDeclarativeDebugClient)
public:
QDeclarativeDebugClient(const QString &, QDeclarativeDebugConnection *parent);
~QDeclarativeDebugClient();
QString name() const;
bool isEnabled() const;
void setEnabled(bool);
bool isConnected() const;
void sendMessage(const QByteArray &);
protected:
virtual void messageReceived(const QByteArray &);
private:
friend class QDeclarativeDebugConnection;
friend class QDeclarativeDebugConnectionPrivate;
QScopedPointer<QDeclarativeDebugClientPrivate> d;
};
}
QT_END_HEADER
#endif // QDECLARATIVEDEBUGCLIENT_H

View File

@@ -0,0 +1,15 @@
## Input
HEADERS += \
../../libs/qmljsdebugclient/qdeclarativedebug_p.h \
../../libs/qmljsdebugclient/qpacketprotocol_p.h \
../../libs/qmljsdebugclient/qdeclarativedebugclient_p.h
SOURCES += \
../../libs/qmljsdebugclient/qdeclarativedebug.cpp \
../../libs/qmljsdebugclient/qpacketprotocol.cpp \
../../libs/qmljsdebugclient/qdeclarativedebugclient.cpp

View File

@@ -0,0 +1,498 @@
/****************************************************************************
**
** 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 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 "qpacketprotocol_p.h"
#include <QBuffer>
namespace QmlJsDebugClient {
#define MAX_PACKET_SIZE 0x7FFFFFFF
/*!
\class QPacketProtocol
\internal
\brief The QPacketProtocol class encapsulates communicating discrete packets
across fragmented IO channels, such as TCP sockets.
QPacketProtocol makes it simple to send arbitrary sized data "packets" across
fragmented transports such as TCP and UDP.
As transmission boundaries are not respected, sending packets over protocols
like TCP frequently involves "stitching" them back together at the receiver.
QPacketProtocol makes this easier by performing this task for you. Packet
data sent using QPacketProtocol is prepended with a 4-byte size header
allowing the receiving QPacketProtocol to buffer the packet internally until
it has all been received. QPacketProtocol does not perform any sanity
checking on the size or on the data, so this class should only be used in
prototyping or trusted situations where DOS attacks are unlikely.
QPacketProtocol does not perform any communications itself. Instead it can
operate on any QIODevice that supports the QIODevice::readyRead() signal. A
logical "packet" is encapsulated by the companion QPacket class. The
following example shows two ways to send data using QPacketProtocol. The
transmitted data is equivalent in both.
\code
QTcpSocket socket;
// ... connect socket ...
QPacketProtocol protocol(&socket);
// Send packet the quick way
protocol.send() << "Hello world" << 123;
// Send packet the longer way
QPacket packet;
packet << "Hello world" << 123;
protocol.send(packet);
\endcode
Likewise, the following shows how to read data from QPacketProtocol, assuming
that the QPacketProtocol::readyRead() signal has been emitted.
\code
// ... QPacketProtocol::readyRead() is emitted ...
int a;
QByteArray b;
// Receive packet the quick way
protocol.read() >> a >> b;
// Receive packet the longer way
QPacket packet = protocol.read();
p >> a >> b;
\endcode
\ingroup io
\sa QPacket
*/
class QPacketProtocolPrivate : public QObject
{
Q_OBJECT
public:
QPacketProtocolPrivate(QPacketProtocol * parent, QIODevice * _dev)
: QObject(parent), inProgressSize(-1), maxPacketSize(MAX_PACKET_SIZE),
dev(_dev)
{
Q_ASSERT(4 == sizeof(qint32));
QObject::connect(this, SIGNAL(readyRead()),
parent, SIGNAL(readyRead()));
QObject::connect(this, SIGNAL(packetWritten()),
parent, SIGNAL(packetWritten()));
QObject::connect(this, SIGNAL(invalidPacket()),
parent, SIGNAL(invalidPacket()));
QObject::connect(dev, SIGNAL(readyRead()),
this, SLOT(readyToRead()));
QObject::connect(dev, SIGNAL(aboutToClose()),
this, SLOT(aboutToClose()));
QObject::connect(dev, SIGNAL(bytesWritten(qint64)),
this, SLOT(bytesWritten(qint64)));
}
Q_SIGNALS:
void readyRead();
void packetWritten();
void invalidPacket();
public Q_SLOTS:
void aboutToClose()
{
inProgress.clear();
sendingPackets.clear();
inProgressSize = -1;
}
void bytesWritten(qint64 bytes)
{
Q_ASSERT(!sendingPackets.isEmpty());
while(bytes) {
if(sendingPackets.at(0) > bytes) {
sendingPackets[0] -= bytes;
bytes = 0;
} else {
bytes -= sendingPackets.at(0);
sendingPackets.removeFirst();
emit packetWritten();
}
}
}
void readyToRead()
{
if(-1 == inProgressSize) {
// We need a size header of sizeof(qint32)
if(sizeof(qint32) > (uint)dev->bytesAvailable())
return;
// Read size header
int read = dev->read((char *)&inProgressSize, sizeof(qint32));
Q_ASSERT(read == sizeof(qint32));
Q_UNUSED(read);
// Check sizing constraints
if(inProgressSize > maxPacketSize) {
QObject::disconnect(dev, SIGNAL(readyRead()),
this, SLOT(readyToRead()));
QObject::disconnect(dev, SIGNAL(aboutToClose()),
this, SLOT(aboutToClose()));
QObject::disconnect(dev, SIGNAL(bytesWritten(qint64)),
this, SLOT(bytesWritten(qint64)));
dev = 0;
emit invalidPacket();
return;
}
inProgressSize -= sizeof(qint32);
// Need to get trailing data
readyToRead();
} else {
inProgress.append(dev->read(inProgressSize - inProgress.size()));
if(inProgressSize == inProgress.size()) {
// Packet has arrived!
packets.append(inProgress);
inProgressSize = -1;
inProgress.clear();
emit readyRead();
// Need to get trailing data
readyToRead();
}
}
}
public:
QList<qint64> sendingPackets;
QList<QByteArray> packets;
QByteArray inProgress;
qint32 inProgressSize;
qint32 maxPacketSize;
QIODevice * dev;
};
/*!
Construct a QPacketProtocol instance that works on \a dev with the
specified \a parent.
*/
QPacketProtocol::QPacketProtocol(QIODevice * dev, QObject * parent)
: QObject(parent), d(new QPacketProtocolPrivate(this, dev))
{
Q_ASSERT(dev);
}
/*!
Destroys the QPacketProtocol instance.
*/
QPacketProtocol::~QPacketProtocol()
{
}
/*!
Returns the maximum packet size allowed. By default this is
2,147,483,647 bytes.
If a packet claiming to be larger than the maximum packet size is received,
the QPacketProtocol::invalidPacket() signal is emitted.
\sa QPacketProtocol::setMaximumPacketSize()
*/
qint32 QPacketProtocol::maximumPacketSize() const
{
return d->maxPacketSize;
}
/*!
Sets the maximum allowable packet size to \a max.
\sa QPacketProtocol::maximumPacketSize()
*/
qint32 QPacketProtocol::setMaximumPacketSize(qint32 max)
{
if(max > (signed)sizeof(qint32))
d->maxPacketSize = max;
return d->maxPacketSize;
}
/*!
Returns a streamable object that is transmitted on destruction. For example
\code
protocol.send() << "Hello world" << 123;
\endcode
will send a packet containing "Hello world" and 123. To construct more
complex packets, explicitly construct a QPacket instance.
*/
QPacketAutoSend QPacketProtocol::send()
{
return QPacketAutoSend(this);
}
/*!
\fn void QPacketProtocol::send(const QPacket & packet)
Transmit the \a packet.
*/
void QPacketProtocol::send(const QPacket & p)
{
if(p.b.isEmpty())
return; // We don't send empty packets
qint64 sendSize = p.b.size() + sizeof(qint32);
d->sendingPackets.append(sendSize);
qint32 sendSize32 = sendSize;
qint64 writeBytes = d->dev->write((char *)&sendSize32, sizeof(qint32));
Q_ASSERT(writeBytes == sizeof(qint32));
writeBytes = d->dev->write(p.b);
Q_ASSERT(writeBytes == p.b.size());
}
/*!
Returns the number of received packets yet to be read.
*/
qint64 QPacketProtocol::packetsAvailable() const
{
return d->packets.count();
}
/*!
Discard any unread packets.
*/
void QPacketProtocol::clear()
{
d->packets.clear();
}
/*!
Return the next unread packet, or an invalid QPacket instance if no packets
are available. This method does NOT block.
*/
QPacket QPacketProtocol::read()
{
if(0 == d->packets.count())
return QPacket();
QPacket rv(d->packets.at(0));
d->packets.removeFirst();
return rv;
}
/*!
Return the QIODevice passed to the QPacketProtocol constructor.
*/
QIODevice * QPacketProtocol::device()
{
return d->dev;
}
/*!
\fn void QPacketProtocol::readyRead()
Emitted whenever a new packet is received. Applications may use
QPacketProtocol::read() to retrieve this packet.
*/
/*!
\fn void QPacketProtocol::invalidPacket()
A packet larger than the maximum allowable packet size was received. The
packet will be discarded and, as it indicates corruption in the protocol, no
further packets will be received.
*/
/*!
\fn void QPacketProtocol::packetWritten()
Emitted each time a packet is completing written to the device. This signal
may be used for communications flow control.
*/
/*!
\class QPacket
\internal
\brief The QPacket class encapsulates an unfragmentable packet of data to be
transmitted by QPacketProtocol.
The QPacket class works together with QPacketProtocol to make it simple to
send arbitrary sized data "packets" across fragmented transports such as TCP
and UDP.
QPacket provides a QDataStream interface to an unfragmentable packet.
Applications should construct a QPacket, propagate it with data and then
transmit it over a QPacketProtocol instance. For example:
\code
QPacketProtocol protocol(...);
QPacket myPacket;
myPacket << "Hello world!" << 123;
protocol.send(myPacket);
\endcode
As long as both ends of the connection are using the QPacketProtocol class,
the data within this packet will be delivered unfragmented at the other end,
ready for extraction.
\code
QByteArray greeting;
int count;
QPacket myPacket = protocol.read();
myPacket >> greeting >> count;
\endcode
Only packets returned from QPacketProtocol::read() may be read from. QPacket
instances constructed by directly by applications are for transmission only
and are considered "write only". Attempting to read data from them will
result in undefined behavior.
\ingroup io
\sa QPacketProtocol
*/
/*!
Constructs an empty write-only packet.
*/
QPacket::QPacket()
: QDataStream(), buf(0)
{
buf = new QBuffer(&b);
buf->open(QIODevice::WriteOnly);
setDevice(buf);
}
/*!
Destroys the QPacket instance.
*/
QPacket::~QPacket()
{
if(buf) {
delete buf;
buf = 0;
}
}
/*!
Creates a copy of \a other. The initial stream positions are shared, but the
two packets are otherwise independant.
*/
QPacket::QPacket(const QPacket & other)
: QDataStream(), b(other.b), buf(0)
{
buf = new QBuffer(&b);
buf->open(other.buf->openMode());
setDevice(buf);
}
/*!
\internal
*/
QPacket::QPacket(const QByteArray & ba)
: QDataStream(), b(ba), buf(0)
{
buf = new QBuffer(&b);
buf->open(QIODevice::ReadOnly);
setDevice(buf);
}
/*!
Returns true if this packet is empty - that is, contains no data.
*/
bool QPacket::isEmpty() const
{
return b.isEmpty();
}
/*!
Clears data in the packet. This is useful for reusing one writable packet.
For example
\code
QPacketProtocol protocol(...);
QPacket packet;
packet << "Hello world!" << 123;
protocol.send(packet);
packet.clear();
packet << "Goodbyte world!" << 789;
protocol.send(packet);
\endcode
*/
void QPacket::clear()
{
QBuffer::OpenMode oldMode = buf->openMode();
buf->close();
b.clear();
buf->setBuffer(&b); // reset QBuffer internals with new size of b.
buf->open(oldMode);
}
/*!
\class QPacketAutoSend
\internal
\internal
*/
QPacketAutoSend::QPacketAutoSend(QPacketProtocol * _p)
: QPacket(), p(_p)
{
}
QPacketAutoSend::~QPacketAutoSend()
{
if(!b.isEmpty())
p->send(*this);
}
}
#include <qpacketprotocol.moc>

View File

@@ -0,0 +1,122 @@
/****************************************************************************
**
** 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 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 QPACKETPROTOCOL_H
#define QPACKETPROTOCOL_H
#include <QtCore/qobject.h>
#include <QtCore/qdatastream.h>
QT_BEGIN_HEADER
class QIODevice;
class QBuffer;
namespace QmlJsDebugClient {
class QPacket;
class QPacketAutoSend;
class QPacketProtocolPrivate;
class QPacketProtocol : public QObject
{
Q_OBJECT
public:
explicit QPacketProtocol(QIODevice * dev, QObject * parent = 0);
virtual ~QPacketProtocol();
qint32 maximumPacketSize() const;
qint32 setMaximumPacketSize(qint32);
QPacketAutoSend send();
void send(const QPacket &);
qint64 packetsAvailable() const;
QPacket read();
void clear();
QIODevice * device();
Q_SIGNALS:
void readyRead();
void invalidPacket();
void packetWritten();
private:
QPacketProtocolPrivate * d;
};
class QPacket : public QDataStream
{
public:
QPacket();
QPacket(const QPacket &);
virtual ~QPacket();
void clear();
bool isEmpty() const;
protected:
friend class QPacketProtocol;
QPacket(const QByteArray & ba);
QByteArray b;
QBuffer * buf;
};
class QPacketAutoSend : public QPacket
{
public:
virtual ~QPacketAutoSend();
private:
friend class QPacketProtocol;
QPacketAutoSend(QPacketProtocol *);
QPacketProtocol * p;
};
}
QT_END_HEADER
#endif

View File

@@ -7,7 +7,6 @@ TARGET = Debugger
include(../../qtcreatorplugin.pri)
include(debugger_dependencies.pri)
include(../../private_headers.pri)
DEFINES += DEBUGGER_LIBRARY

View File

@@ -1,11 +1,13 @@
HEADERS += $$PWD/qmlengine.h
SOURCES += $$PWD/qmlengine.cpp
include(../../../private_headers.pri)
exists($${QT_PRIVATE_HEADERS}/QtDeclarative/private/qdeclarativecontext_p.h) {
HEADERS += \
$$PWD/qmlengine.h \
$$PWD/canvasframerate.h \
SOURCES += \
$$PWD/qmlengine.cpp \
$$PWD/canvasframerate.cpp \
QT += declarative

View File

@@ -32,10 +32,6 @@
#include "debuggerengine.h"
#include "private/qdeclarativedebug_p.h"
#include "private/qdeclarativedebugclient_p.h"
#include "private/qdeclarativeenginedebug_p.h"
#include <QtCore/QByteArray>
#include <QtCore/QHash>
#include <QtCore/QObject>
@@ -49,14 +45,6 @@
#include <QtNetwork/QTcpSocket>
QT_BEGIN_NAMESPACE
class QTcpSocket;
class QDeclarativeDebugConnection;
class QDeclarativeEngineDebug;
class QDeclarativeDebugEnginesQuery;
class QDeclarativeDebugRootContextQuery;
QT_END_NAMESPACE
namespace Debugger {
namespace Internal {

View File

@@ -35,6 +35,7 @@ SUBDIRS = plugin_coreplugin \
plugin_qmljseditor \
plugin_mercurial \
plugin_classview \
plugin_qmljsinspector \
debugger/dumper.pro
contains(QT_CONFIG, declarative) {
@@ -43,11 +44,11 @@ contains(QT_CONFIG, declarative) {
include(../private_headers.pri)
exists($${QT_PRIVATE_HEADERS}/QtDeclarative/private/qdeclarativecontext_p.h) {
SUBDIRS += plugin_qmldesigner plugin_qmljsinspector
SUBDIRS += plugin_qmldesigner
} else {
warning()
warning("QmlDesigner and QmlJSInspector plugins have been disabled")
warning("The plugins depend on on private headers from QtDeclarative module.")
warning("QmlDesigner plugin have been disabled")
warning("The plugin depend on on private headers from QtDeclarative module.")
warning("To enable them, pass 'QT_PRIVATE_HEADERS=$QTDIR/include' to qmake, where $QTDIR is the source directory of qt.")
warning()
}

View File

@@ -34,9 +34,6 @@
#include <QtCore/QObject>
QT_FORWARD_DECLARE_CLASS(QUrl)
QT_FORWARD_DECLARE_CLASS(QDeclarativeEngineDebug)
QT_FORWARD_DECLARE_CLASS(QDeclarativeDebugConnection)
QT_FORWARD_DECLARE_CLASS(QDeclarativeDebugExpressionQuery)
namespace QmlJSInspector {
namespace Internal {

View File

@@ -42,8 +42,7 @@
#ifndef QMLJSDESIGNDEBUGCLIENT_H
#define QMLJSDESIGNDEBUGCLIENT_H
#include "private/qdeclarativedebug_p.h"
#include "private/qdeclarativedebugclient_p.h"
#include "qmljsprivateapi.h"
namespace QmlJSInspector {
namespace Internal {

View File

@@ -4,8 +4,6 @@ INCLUDEPATH += .
DEPENDPATH += .
QT += declarative network
include(../../private_headers.pri)
DEFINES += QMLJSINSPECTOR_LIBRARY
HEADERS += \
@@ -31,7 +29,9 @@ qmljsinspector.cpp \
qmlinspectortoolbar.cpp \
qmljslivetextpreview.cpp \
qmljstoolbarcolorbox.cpp \
qmljsdesigndebugclient.cpp
qmljsdesigndebugclient.cpp \
include(../../libs/qmljsdebugclient/qmljsdebugclient-lib.pri)
OTHER_FILES += QmlJSInspector.pluginspec
RESOURCES += qmljsinspector.qrc
@@ -42,3 +42,4 @@ include(../../plugins/qmlprojectmanager/qmlprojectmanager.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../plugins/texteditor/texteditor.pri)
include(../../plugins/debugger/debugger.pri)

View File

@@ -33,12 +33,11 @@
#include <QObject>
#include <QWeakPointer>
#include <private/qdeclarativedebug_p.h>
#include <qmljs/parser/qmljsastfwd_p.h>
#include <qmljs/qmljsdocument.h>
#include "qmljsprivateapi.h"
QT_FORWARD_DECLARE_CLASS(QTextDocument)
QT_FORWARD_DECLARE_CLASS(QDeclarativeDebugObjectReference)
namespace Core {
class IEditor;

View File

@@ -29,7 +29,9 @@
#ifndef QMLJSPRIVATEAPI_H
#define QMLJSPRIVATEAPI_H
#include <private/qdeclarativedebug_p.h>
#include <private/qdeclarativedebugclient_p.h>
#include <qmljsdebugclient/qdeclarativedebug_p.h>
#include <qmljsdebugclient/qdeclarativedebugclient_p.h>
using namespace QmlJsDebugClient;
#endif // QMLJSPRIVATEAPI_H