Commit e6792d33 authored by Ulf Hermann's avatar Ulf Hermann
Browse files

QmlDebugClient: Rename "status" to "state" for consistency



"state" is the more widely used term and we should follow that
convention. We also need to distinguish between the state of the
underlying network socket and the client itself. The change makes this
explicit.

As preparation for the upcoming centralized debug support the "State"
enum of the debug client is also moved into the QmlDebugClient class.

Change-Id: Ib9d7e03d23528f16ed696ed3518e813d11ea1c32
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent 7018a375
......@@ -174,9 +174,9 @@ void BaseEngineDebugClient::decode(QDataStream &ds,
}
}
void BaseEngineDebugClient::statusChanged(ClientStatus status)
void BaseEngineDebugClient::stateChanged(State state)
{
emit newStatus(status);
emit newState(state);
}
void BaseEngineDebugClient::messageReceived(const QByteArray &data)
......@@ -251,7 +251,7 @@ BaseEngineDebugClient::BaseEngineDebugClient(const QString &clientName,
quint32 BaseEngineDebugClient::addWatch(const PropertyReference &property)
{
quint32 id = 0;
if (status() == Enabled) {
if (state() == Enabled) {
id = getId();
QByteArray message;
QmlDebugStream ds(&message, QIODevice::WriteOnly);
......@@ -273,7 +273,7 @@ quint32 BaseEngineDebugClient::addWatch(const ObjectReference &object,
const QString &expr)
{
quint32 id = 0;
if (status() == Enabled) {
if (state() == Enabled) {
id = getId();
QByteArray message;
QmlDebugStream ds(&message, QIODevice::WriteOnly);
......@@ -286,7 +286,7 @@ quint32 BaseEngineDebugClient::addWatch(const ObjectReference &object,
quint32 BaseEngineDebugClient::addWatch(int objectDebugId)
{
quint32 id = 0;
if (status() == Enabled) {
if (state() == Enabled) {
id = getId();
QByteArray message;
QmlDebugStream ds(&message, QIODevice::WriteOnly);
......@@ -304,7 +304,7 @@ quint32 BaseEngineDebugClient::addWatch(const FileReference &/*file*/)
void BaseEngineDebugClient::removeWatch(quint32 id)
{
if (status() == Enabled) {
if (state() == Enabled) {
QByteArray message;
QmlDebugStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("NO_WATCH") << id;
......@@ -315,7 +315,7 @@ void BaseEngineDebugClient::removeWatch(quint32 id)
quint32 BaseEngineDebugClient::queryAvailableEngines()
{
quint32 id = 0;
if (status() == Enabled) {
if (state() == Enabled) {
id = getId();
QByteArray message;
QmlDebugStream ds(&message, QIODevice::WriteOnly);
......@@ -328,7 +328,7 @@ quint32 BaseEngineDebugClient::queryAvailableEngines()
quint32 BaseEngineDebugClient::queryRootContexts(const EngineReference &engine)
{
quint32 id = 0;
if (status() == Enabled && engine.m_debugId != -1) {
if (state() == Enabled && engine.m_debugId != -1) {
id = getId();
QByteArray message;
QmlDebugStream ds(&message, QIODevice::WriteOnly);
......@@ -341,7 +341,7 @@ quint32 BaseEngineDebugClient::queryRootContexts(const EngineReference &engine)
quint32 BaseEngineDebugClient::queryObject(int objectId)
{
quint32 id = 0;
if (status() == Enabled && objectId != -1) {
if (state() == Enabled && objectId != -1) {
id = getId();
QByteArray message;
QmlDebugStream ds(&message, QIODevice::WriteOnly);
......@@ -355,7 +355,7 @@ quint32 BaseEngineDebugClient::queryObject(int objectId)
quint32 BaseEngineDebugClient::queryObjectRecursive(int objectId)
{
quint32 id = 0;
if (status() == Enabled && objectId != -1) {
if (state() == Enabled && objectId != -1) {
id = getId();
QByteArray message;
QmlDebugStream ds(&message, QIODevice::WriteOnly);
......@@ -371,7 +371,7 @@ quint32 BaseEngineDebugClient::queryExpressionResult(int objectDebugId,
int engineId)
{
quint32 id = 0;
if (status() == Enabled && objectDebugId != -1) {
if (state() == Enabled && objectDebugId != -1) {
id = getId();
QByteArray message;
QmlDebugStream ds(&message, QIODevice::WriteOnly);
......@@ -390,7 +390,7 @@ quint32 BaseEngineDebugClient::setBindingForObject(
QString source, int line)
{
quint32 id = 0;
if (status() == Enabled && objectDebugId != -1) {
if (state() == Enabled && objectDebugId != -1) {
id = getId();
QByteArray message;
QmlDebugStream ds(&message, QIODevice::WriteOnly);
......@@ -406,7 +406,7 @@ quint32 BaseEngineDebugClient::resetBindingForObject(
const QString &propertyName)
{
quint32 id = 0;
if (status() == Enabled && objectDebugId != -1) {
if (state() == Enabled && objectDebugId != -1) {
id = getId();
QByteArray message;
QmlDebugStream ds(&message, QIODevice::WriteOnly);
......@@ -421,7 +421,7 @@ quint32 BaseEngineDebugClient::setMethodBody(
const QString &methodBody)
{
quint32 id = 0;
if (status() == Enabled && objectDebugId != -1) {
if (state() == Enabled && objectDebugId != -1) {
id = getId();
QByteArray message;
QmlDebugStream ds(&message, QIODevice::WriteOnly);
......@@ -436,7 +436,7 @@ quint32 BaseEngineDebugClient::queryObjectsForLocation(
const QString &fileName, int lineNumber, int columnNumber)
{
quint32 id = 0;
if (status() == Enabled) {
if (state() == Enabled) {
id = getId();
QByteArray message;
QmlDebugStream ds(&message, QIODevice::WriteOnly);
......
......@@ -78,14 +78,14 @@ public:
int columnNumber);
signals:
void newStatus(QmlDebug::ClientStatus status);
void newState(QmlDebug::QmlDebugClient::State status);
void newObject(int engineId, int objectId, int parentId);
void valueChanged(int debugId, const QByteArray &name,
const QVariant &value);
void result(quint32 queryId, const QVariant &result, const QByteArray &type);
protected:
virtual void statusChanged(ClientStatus status);
virtual void stateChanged(State status);
virtual void messageReceived(const QByteArray &);
quint32 getId() { return m_nextId++; }
......
......@@ -37,9 +37,9 @@ BaseToolsClient::BaseToolsClient(QmlDebugConnection* client, QLatin1String clien
setObjectName(clientName);
}
void BaseToolsClient::statusChanged(ClientStatus status)
void BaseToolsClient::stateChanged(State state)
{
emit newStatus(status);
emit newState(state);
}
void BaseToolsClient::recurseObjectIdList(const ObjectReference &ref,
......
......@@ -70,7 +70,7 @@ public:
virtual void clearComponentCache() = 0;
signals:
void newStatus(QmlDebug::ClientStatus status);
void newState(QmlDebug::QmlDebugClient::State status);
void currentObjectsChanged(const QList<int> &debugIds);
void selectToolActivated();
......@@ -86,7 +86,7 @@ signals:
void logActivity(QString client, QString message);
protected:
void statusChanged(ClientStatus status);
void stateChanged(State status);
void recurseObjectIdList(const ObjectReference &ref,
QList<int> &debugIds, QList<QString> &objectIds);
......
......@@ -47,7 +47,7 @@ quint32 DeclarativeEngineDebugClient::setBindingForObject(
QString source, int line)
{
quint32 id = 0;
if (status() == Enabled && objectDebugId != -1) {
if (state() == Enabled && objectDebugId != -1) {
id = getId();
QByteArray message;
QmlDebugStream ds(&message, QIODevice::WriteOnly);
......@@ -63,7 +63,7 @@ quint32 DeclarativeEngineDebugClient::resetBindingForObject(
const QString &propertyName)
{
quint32 id = 0;
if (status() == Enabled && objectDebugId != -1) {
if (state() == Enabled && objectDebugId != -1) {
id = getId();
QByteArray message;
QmlDebugStream ds(&message, QIODevice::WriteOnly);
......@@ -78,7 +78,7 @@ quint32 DeclarativeEngineDebugClient::setMethodBody(
const QString &methodBody)
{
quint32 id = 0;
if (status() == Enabled && objectDebugId != -1) {
if (state() == Enabled && objectDebugId != -1) {
id = getId();
QByteArray message;
QmlDebugStream ds(&message, QIODevice::WriteOnly);
......
......@@ -42,9 +42,9 @@ QDebugMessageClient::~QDebugMessageClient()
{
}
void QDebugMessageClient::statusChanged(ClientStatus status)
void QDebugMessageClient::stateChanged(State state)
{
emit newStatus(status);
emit newState(state);
}
void QDebugMessageClient::messageReceived(const QByteArray &data)
......
......@@ -52,11 +52,11 @@ public:
~QDebugMessageClient();
protected:
virtual void statusChanged(ClientStatus status);
virtual void stateChanged(State state);
virtual void messageReceived(const QByteArray &);
signals:
void newStatus(QmlDebug::ClientStatus);
void newState(QmlDebug::QmlDebugClient::State);
void message(QtMsgType, const QString &,
const QmlDebug::QDebugContextInfo &);
......
......@@ -150,10 +150,10 @@ void QmlDebugConnectionPrivate::readyRead()
QHash<QString, QmlDebugClient *>::Iterator iter = plugins.begin();
for (; iter != plugins.end(); ++iter) {
ClientStatus newStatus = Unavailable;
QmlDebugClient::State newState = QmlDebugClient::Unavailable;
if (serverPlugins.contains(iter.key()))
newStatus = Enabled;
iter.value()->statusChanged(newStatus);
newState = QmlDebugClient::Enabled;
iter.value()->stateChanged(newState);
}
}
......@@ -189,13 +189,13 @@ void QmlDebugConnectionPrivate::readyRead()
QHash<QString, QmlDebugClient *>::Iterator iter = plugins.begin();
for (; iter != plugins.end(); ++iter) {
const QString pluginName = iter.key();
ClientStatus newStatus = Unavailable;
QmlDebugClient::State newState = QmlDebugClient::Unavailable;
if (serverPlugins.contains(pluginName))
newStatus = Enabled;
newState = QmlDebugClient::Enabled;
if (oldServerPlugins.contains(pluginName)
!= serverPlugins.contains(pluginName)) {
iter.value()->statusChanged(newStatus);
iter.value()->stateChanged(newState);
}
}
} else {
......@@ -225,24 +225,24 @@ QmlDebugConnection::~QmlDebugConnection()
QHash<QString, QmlDebugClient*>::iterator iter = d->plugins.begin();
for (; iter != d->plugins.end(); ++iter) {
iter.value()->d_func()->connection = 0;
iter.value()->statusChanged(NotConnected);
iter.value()->stateChanged(QmlDebugClient::NotConnected);
}
}
bool QmlDebugConnection::isConnected() const
{
return state() == QAbstractSocket::ConnectedState;
return socketState() == QAbstractSocket::ConnectedState;
}
void QmlDebugConnection::close()
{
if (d->device->isOpen()) {
d->device->close();
emit stateChanged(QAbstractSocket::UnconnectedState);
emit socketStateChanged(QAbstractSocket::UnconnectedState);
QHash<QString, QmlDebugClient*>::iterator iter = d->plugins.begin();
for (; iter != d->plugins.end(); ++iter) {
iter.value()->statusChanged(NotConnected);
iter.value()->stateChanged(QmlDebugClient::NotConnected);
}
}
}
......@@ -254,7 +254,7 @@ QString QmlDebugConnection::errorString() const
// For ease of refactoring we use QAbstractSocket's states even if we're actually using a OstChannel underneath
// since serial ports have a subset of the socket states afaics
QAbstractSocket::SocketState QmlDebugConnection::state() const
QAbstractSocket::SocketState QmlDebugConnection::socketState() const
{
QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device);
if (socket)
......@@ -280,7 +280,7 @@ void QmlDebugConnection::connectToHost(const QString &hostName, quint16 port)
d->protocol = new QPacketProtocol(d->device, this);
connect(d->protocol, SIGNAL(readyRead()), d, SLOT(readyRead()));
d->gotHello = false;
connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SIGNAL(stateChanged(QAbstractSocket::SocketState)));
connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SIGNAL(socketStateChanged(QAbstractSocket::SocketState)));
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(error(QAbstractSocket::SocketError)));
connect(socket, SIGNAL(connected()), this, SIGNAL(connected()));
socket->connectToHost(hostName, port);
......@@ -336,7 +336,7 @@ float QmlDebugClient::serviceVersion() const
return -1;
}
ClientStatus QmlDebugClient::status() const
QmlDebugClient::State QmlDebugClient::state() const
{
Q_D(const QmlDebugClient);
if (!d->connection
......@@ -353,7 +353,7 @@ ClientStatus QmlDebugClient::status() const
void QmlDebugClient::sendMessage(const QByteArray &message)
{
Q_D(QmlDebugClient);
if (status() != Enabled)
if (state() != Enabled)
return;
QPacket pack;
......@@ -362,7 +362,7 @@ void QmlDebugClient::sendMessage(const QByteArray &message)
d->connection->flush();
}
void QmlDebugClient::statusChanged(ClientStatus)
void QmlDebugClient::stateChanged(State)
{
}
......
......@@ -49,14 +49,14 @@ public:
void connectToHost(const QString &hostName, quint16 port);
bool isConnected() const;
QAbstractSocket::SocketState state() const;
QAbstractSocket::SocketState socketState() const;
void flush();
void close();
QString errorString() const;
signals:
void connected();
void stateChanged(QAbstractSocket::SocketState socketState);
void socketStateChanged(QAbstractSocket::SocketState state);
void error(QAbstractSocket::SocketError socketError);
private:
......@@ -65,12 +65,6 @@ private:
friend class QmlDebugClientPrivate;
};
enum ClientStatus {
NotConnected,
Unavailable,
Enabled
};
class QmlDebugClientPrivate;
class QMLDEBUG_EXPORT QmlDebugClient : public QObject
{
......@@ -79,17 +73,19 @@ class QMLDEBUG_EXPORT QmlDebugClient : public QObject
Q_DISABLE_COPY(QmlDebugClient)
public:
enum State { NotConnected, Unavailable, Enabled };
QmlDebugClient(const QString &, QmlDebugConnection *parent);
~QmlDebugClient();
QString name() const;
float serviceVersion() const;
ClientStatus status() const;
State state() const;
virtual void sendMessage(const QByteArray &);
protected:
virtual void statusChanged(ClientStatus);
virtual void stateChanged(State);
virtual void messageReceived(const QByteArray &);
private:
......
......@@ -103,7 +103,7 @@ void QmlProfilerTraceClient::sendRecordingStatus()
bool QmlProfilerTraceClient::isEnabled() const
{
return status() == Enabled;
return state() == Enabled;
}
bool QmlProfilerTraceClient::isRecording() const
......@@ -118,7 +118,7 @@ void QmlProfilerTraceClient::setRecording(bool v)
d->recording = v;
if (status() == Enabled)
if (state() == Enabled)
sendRecordingStatus();
emit recordingChanged(v);
......@@ -132,7 +132,7 @@ void QmlProfilerTraceClient::setRecordingFromServer(bool v)
emit recordingChanged(v);
}
void QmlProfilerTraceClient::statusChanged(ClientStatus /*status*/)
void QmlProfilerTraceClient::stateChanged(State /*status*/)
{
emit enabledChanged();
}
......
......@@ -111,7 +111,7 @@ signals:
void cleared();
protected:
virtual void statusChanged(ClientStatus status);
virtual void stateChanged(State status);
virtual void messageReceived(const QByteArray &);
private:
......
......@@ -87,7 +87,7 @@ void QV8ProfilerClient::clearData()
bool QV8ProfilerClient::isEnabled() const
{
return status() == Enabled;
return state() == Enabled;
}
void QV8ProfilerClient::sendRecordingStatus()
......@@ -107,7 +107,7 @@ void QV8ProfilerClient::setRecording(bool v)
d->recording = v;
if (status() == Enabled)
if (state() == Enabled)
sendRecordingStatus();
emit recordingChanged(v);
......@@ -123,7 +123,7 @@ void QV8ProfilerClient::setRecordingFromServer(bool v)
emit recordingChanged(v);
}
void QV8ProfilerClient::statusChanged(ClientStatus /*status*/)
void QV8ProfilerClient::stateChanged(State /*status*/)
{
emit enabledChanged();
}
......
......@@ -81,7 +81,7 @@ private:
void setRecordingFromServer(bool);
protected:
virtual void statusChanged(ClientStatus);
virtual void stateChanged(State);
virtual void messageReceived(const QByteArray &);
private:
......
......@@ -56,14 +56,14 @@ bool BaseQmlDebuggerClient::acceptsBreakpoint(const BreakpointModelId &/*id*/)
return false;
}
void BaseQmlDebuggerClient::statusChanged(QmlDebug::ClientStatus status)
void BaseQmlDebuggerClient::stateChanged(State state)
{
emit newStatus(status);
emit newState(state);
}
void BaseQmlDebuggerClient::sendMessage(const QByteArray &msg)
{
if (status() == QmlDebug::Enabled)
if (state() == Enabled)
QmlDebugClient::sendMessage(msg);
else
d->sendBuffer.append(msg);
......@@ -71,7 +71,7 @@ void BaseQmlDebuggerClient::sendMessage(const QByteArray &msg)
void BaseQmlDebuggerClient::flushSendBuffer()
{
QTC_ASSERT(status() == QmlDebug::Enabled, return);
QTC_ASSERT(state() == Enabled, return);
foreach (const QByteArray &msg, d->sendBuffer)
QmlDebugClient::sendMessage(msg);
d->sendBuffer.clear();
......
......@@ -91,11 +91,11 @@ public:
void flushSendBuffer();
signals:
void newStatus(QmlDebug::ClientStatus status);
void newState(QmlDebug::QmlDebugClient::State state);
void stackFrameCompleted();
protected:
virtual void statusChanged(QmlDebug::ClientStatus status);
virtual void stateChanged(State state);
void sendMessage(const QByteArray &msg);
private:
......
......@@ -59,15 +59,15 @@ QmlAdapter::QmlAdapter(DebuggerEngine *engine, QObject *parent)
connect(&m_connectionTimer, SIGNAL(timeout()), SLOT(checkConnectionState()));
m_conn = new QmlDebugConnection(this);
connect(m_conn, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
connect(m_conn, SIGNAL(socketStateChanged(QAbstractSocket::SocketState)),
SLOT(connectionStateChanged()));
connect(m_conn, SIGNAL(error(QAbstractSocket::SocketError)),
SLOT(connectionErrorOccurred(QAbstractSocket::SocketError)));
createDebuggerClients();
m_msgClient = new QDebugMessageClient(m_conn);
connect(m_msgClient, SIGNAL(newStatus(QmlDebug::ClientStatus)),
this, SLOT(clientStatusChanged(QmlDebug::ClientStatus)));
connect(m_msgClient, SIGNAL(newState(QmlDebug::QmlDebugClient::State)),
this, SLOT(clientStateChanged(QmlDebug::QmlDebugClient::State)));
}
......@@ -78,10 +78,10 @@ QmlAdapter::~QmlAdapter()
void QmlAdapter::beginConnectionTcp(const QString &address, quint16 port)
{
if (m_engine.isNull()
|| (m_conn && m_conn->state() != QAbstractSocket::UnconnectedState))
|| (m_conn && m_conn->socketState() != QAbstractSocket::UnconnectedState))
return;
showConnectionStatusMessage(tr("Connecting to debug server %1:%2").arg(address).arg(
showConnectionStateMessage(tr("Connecting to debug server %1:%2").arg(address).arg(
QString::number(port)));
m_conn->connectToHost(address, port);
......@@ -101,7 +101,7 @@ void QmlAdapter::closeConnection()
void QmlAdapter::connectionErrorOccurred(QAbstractSocket::SocketError socketError)
{
showConnectionStatusMessage(tr("Error: (%1) %2", "%1=error code, %2=error message")
showConnectionStateMessage(tr("Error: (%1) %2", "%1=error code, %2=error message")
.arg(socketError).arg(m_conn->errorString()));
// this is only an error if we are already connected and something goes wrong.
......@@ -113,7 +113,7 @@ void QmlAdapter::connectionErrorOccurred(QAbstractSocket::SocketError socketErro
}
}
void QmlAdapter::clientStatusChanged(QmlDebug::ClientStatus status)
void QmlAdapter::clientStateChanged(QmlDebugClient::State state)
{
QString serviceName;
float version = 0;
......@@ -122,12 +122,12 @@ void QmlAdapter::clientStatusChanged(QmlDebug::ClientStatus status)
version = client->serviceVersion();
}
logServiceStatusChange(serviceName, version, status);
logServiceStateChange(serviceName, version, state);
}
void QmlAdapter::debugClientStatusChanged(QmlDebug::ClientStatus status)
void QmlAdapter::debugClientStateChanged(QmlDebugClient::State state)
{
if (status != QmlDebug::Enabled)
if (state != QmlDebug::QmlDebugClient::Enabled)
return;
QmlDebugClient *client = qobject_cast<QmlDebugClient*>(sender());
QTC_ASSERT(client, return);
......@@ -138,23 +138,23 @@ void QmlAdapter::debugClientStatusChanged(QmlDebug::ClientStatus status)
void QmlAdapter::connectionStateChanged()
{
switch (m_conn->state()) {
switch (m_conn->socketState()) {
case QAbstractSocket::UnconnectedState:
{
showConnectionStatusMessage(tr("Disconnected.") + QLatin1String("\n\n"));
showConnectionStateMessage(tr("Disconnected.") + QLatin1String("\n\n"));
emit disconnected();
break;
}
case QAbstractSocket::HostLookupState:
showConnectionStatusMessage(tr("Resolving host."));
showConnectionStateMessage(tr("Resolving host."));
break;
case QAbstractSocket::ConnectingState:
showConnectionStatusMessage(tr("Connecting to debug server."));
showConnectionStateMessage(tr("Connecting to debug server."));
break;
case QAbstractSocket::ConnectedState:
{
showConnectionStatusMessage(tr("Connected.") + QLatin1Char('\n'));
showConnectionStateMessage(tr("Connected.") + QLatin1Char('\n'));
m_connectionTimer.stop();
......@@ -163,7 +163,7 @@ void QmlAdapter::connectionStateChanged()
break;
}
case QAbstractSocket::ClosingState:
showConnectionStatusMessage(tr("Closing."));