QQmlDebugStream rs(&response, QIODevice::WriteOnly);
rs << QByteArray(RESPONSE) << ids.first << true << ids.second;
- m_debugService->sendMessage(response);
+ emit m_debugService->messageToClient(m_debugService->name(), response);
}
void AbstractViewInspector::handleMessage(const QByteArray &message)
QByteArray response;
QQmlDebugStream rs(&response, QIODevice::WriteOnly);
rs << QByteArray(RESPONSE) << requestId << success;
- m_debugService->sendMessage(response);
+ emit m_debugService->messageToClient(m_debugService->name(), response);
}
void AbstractViewInspector::sendCurrentObjects(const QList<QObject*> &objects)
debugIds << QQmlDebugService::idForObject(object);
ds << debugIds;
- m_debugService->sendMessage(message);
+ emit m_debugService->messageToClient(m_debugService->name(), message);
}
void AbstractViewInspector::sendQmlFileReloaded(bool success)
QQmlDebugStream rs(&response, QIODevice::WriteOnly);
rs << QByteArray(RESPONSE) << m_reloadEventId << success;
- m_debugService->sendMessage(response);
+ emit m_debugService->messageToClient(m_debugService->name(), response);
}
QString AbstractViewInspector::idStringForObject(QObject *obj) const
ws << QString::fromLatin1(ctxt.file).toUtf8();
ws << ctxt.line << QString::fromLatin1(ctxt.function).toUtf8();
- sendMessage(message);
+ emit messageToClient(name(), message);
if (d->oldMsgHandler)
(*d->oldMsgHandler)(type, ctxt, buf);
}
virtual bool addService(QQmlDebugService *service) = 0;
virtual bool removeService(QQmlDebugService *service) = 0;
- virtual void sendMessages(QQmlDebugService *service, const QList<QByteArray> &messages) = 0;
virtual bool open(const QVariantHash &configuration = QVariantHash()) = 0;
};
bool open(const QVariantHash &configuration);
void receiveMessage(const QByteArray &message);
- void sendMessages(QQmlDebugService *service, const QList<QByteArray> &messages);
template<class Action>
bool enable(Action action);
private slots:
void wakeEngine(QQmlEngine *engine);
- void sendMessages(const QList<QByteArray> &messages);
+ void sendMessage(const QString &name, const QByteArray &message);
+ void sendMessages(const QString &name, const QList<QByteArray> &messages);
void changeServiceState(const QString &serviceName, QQmlDebugService::State state);
void removeThread();
m_changeServiceStateCalls.deref();
}
-void QQmlDebugServerImpl::sendMessages(const QList<QByteArray> &messages)
-{
- // to be executed in debugger thread
- Q_ASSERT(QThread::currentThread() == thread());
-
- if (m_connection)
- m_connection->send(messages);
-}
-
void QQmlDebugServerImpl::removeThread()
{
Q_ASSERT(m_thread->isFinished());
// to be executed before thread starts
Q_ASSERT(!m_thread);
+ connect(service, SIGNAL(messageToClient(QString,QByteArray)),
+ this, SLOT(sendMessage(QString,QByteArray)));
+ connect(service, SIGNAL(messagesToClient(QString,QList<QByteArray>)),
+ this, SLOT(sendMessages(QString,QList<QByteArray>)));
+
connect(service, SIGNAL(attachedToEngine(QQmlEngine*)),
this, SLOT(wakeEngine(QQmlEngine*)), Qt::QueuedConnection);
connect(service, SIGNAL(detachedFromEngine(QQmlEngine*)),
if (!service || !m_plugins.contains(service->name()))
return false;
+
+ disconnect(service, SIGNAL(messagesToClient(QString,QList<QByteArray>)),
+ this, SLOT(sendMessages(QString,QList<QByteArray>)));
+ disconnect(service, SIGNAL(messageToClient(QString,QByteArray)),
+ this, SLOT(sendMessage(QString,QByteArray)));
+
m_plugins.remove(service->name());
return true;
}
-void QQmlDebugServerImpl::sendMessages(QQmlDebugService *service, const QList<QByteArray> &messages)
+void QQmlDebugServerImpl::sendMessage(const QString &name, const QByteArray &message)
{
- QList<QByteArray> prefixedMessages;
- prefixedMessages.reserve(messages.count());
- foreach (const QByteArray &message, messages) {
- QByteArray prefixed;
- QQmlDebugStream out(&prefixed, QIODevice::WriteOnly);
- out << service->name() << message;
- prefixedMessages << prefixed;
- }
+ sendMessages(name, QList<QByteArray>() << message);
+}
- QMetaObject::invokeMethod(this, "sendMessages", Qt::QueuedConnection,
- Q_ARG(QList<QByteArray>, prefixedMessages));
+void QQmlDebugServerImpl::sendMessages(const QString &name, const QList<QByteArray> &messages)
+{
+ // to be executed in debugger thread
+ Q_ASSERT(QThread::currentThread() == thread());
+
+ if (!m_connection)
+ return;
+
+ if (!name.isEmpty()) {
+ if (!m_clientPlugins.contains(name))
+ return;
+ QList<QByteArray> prefixedMessages;
+ prefixedMessages.reserve(messages.count());
+ foreach (const QByteArray &message, messages) {
+ QByteArray prefixed;
+ QQmlDebugStream out(&prefixed, QIODevice::WriteOnly);
+ out << name << message;
+ prefixedMessages << prefixed;
+ }
+
+ m_connection->send(prefixedMessages);
+ } else {
+ m_connection->send(messages);
+ }
}
template<class Action>
return objectReferenceHash()->ids;
}
-void QQmlDebugService::sendMessage(const QByteArray &message)
-{
- sendMessages(QList<QByteArray>() << message);
-}
-
-void QQmlDebugService::sendMessages(const QList<QByteArray> &messages)
-{
- if (state() != Enabled)
- return;
-
- if (QQmlDebugConnector *inst = QQmlDebugConnector::instance())
- inst->sendMessages(this, messages);
-}
-
void QQmlDebugService::stateAboutToBeChanged(State)
{
}
virtual void engineAdded(QQmlEngine *);
virtual void engineRemoved(QQmlEngine *);
- void sendMessage(const QByteArray &);
- void sendMessages(const QList<QByteArray> &);
-
static const QHash<int, QObject *> &objectsForIds();
static int idForObject(QObject *);
static QObject *objectForId(int id) { return objectsForIds().value(id); }
signals:
void attachedToEngine(QQmlEngine *);
void detachedFromEngine(QQmlEngine *);
+
+ void messageToClient(const QString &name, const QByteArray &message);
+ void messagesToClient(const QString &name, const QList<QByteArray> &messages);
};
class Q_QML_PRIVATE_EXPORT QQmlDebugStream : public QDataStream
QByteArray message;
QQmlDebugStream d(&message, QIODevice::WriteOnly);
d << type << idForObject(engine);
- QQmlDebugService::sendMessage(message);
+ emit messageToClient(name(), message);
}
void QQmlEngineControlService::stateChanged(State)
rs << QByteArray("SET_METHOD_BODY_R") << queryId << ok;
}
- sendMessage(reply);
+ emit messageToClient(name(), reply);
}
bool QQmlEngineDebugService::setBinding(int objectId,
rs << QByteArray("UPDATE_WATCH") << id << objectId << QByteArray(property.name()) << valueContents(value);
- sendMessage(reply);
+ emit messageToClient(name(), reply);
}
void QQmlEngineDebugService::engineAboutToBeAdded(QQmlEngine *engine)
//unique queryId -1
rs << QByteArray("OBJECT_CREATED") << -1 << engineId << objectId << parentId;
- sendMessage(reply);
+ emit messageToClient(name(), reply);
}
void QQmlEngineDebugService::setStatesDelegate(QQmlDebugStatesDelegate *delegate)
updateState();
}
-void QQmlInspectorService::sendMessage(const QByteArray &message)
-{
- if (state() != Enabled)
- return;
-
- QQmlDebugService::sendMessage(message);
-}
-
void QQmlInspectorService::stateChanged(State /*state*/)
{
QMetaObject::invokeMethod(this, "updateState", Qt::QueuedConnection);
void addView(QObject *);
void removeView(QObject *);
- void sendMessage(const QByteArray &message);
-
protected:
virtual void stateChanged(State state);
virtual void messageReceived(const QByteArray &);
}
}
- QQmlDebugService::sendMessage(message);
+ emit messageToClient(name(), message);
}
/*!
ds << (qint64)-1 << (int)Complete;
messages << data;
- QQmlDebugService::sendMessages(messages);
+ emit messagesToClient(name(), messages);
}
void QQmlProfilerService::stateAboutToBeChanged(QQmlDebugService::State newState)
TRACE_PROTOCOL(qDebug() << "sending response for:" << responseData.constData() << endl);
- q_func()->sendMessage(packMessage("v8message", responseData));
+ emit q_func()->messageToClient(name, packMessage("v8message", responseData));
}
void processCommand(const QByteArray &command, const QByteArray &data);
TRACE_PROTOCOL(qDebug() << "... type:" << type);
if (type == V4_CONNECT) {
- sendMessage(d->packMessage(type));
+ emit messageToClient(name(), d->packMessage(type));
stopWaiting();
} else if (type == V4_PAUSE) {
d->debuggerAgent.pauseAll();
QQmlDebugStream rs(&response, QIODevice::WriteOnly);
rs << QByteArray(type)
<< QByteArray::number(d->version) << QByteArray::number(magicNumber);
- sendMessage(d->packMessage(type, response));
+ emit messageToClient(name(), d->packMessage(type, response));
}
void QV4DebuggerAgent::debuggerPaused(QV4::Debugging::Debugger *debugger, QV4::Debugging::PauseReason reason)
QTest::ignoreMessage(QtWarningMsg,
"QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService\"");
QQmlDebugTestService duplicate("tst_QQmlDebugService");
- duplicate.sendMessage("msg");
+ emit duplicate.messageToClient(duplicate.name(), "msg");
QTest::ignoreMessage(QtWarningMsg,
"QQmlDebugService: Plugin \"tst_QQmlDebugService\" is not registered.");
}
void QQmlDebugTestService::messageReceived(const QByteArray &ba)
{
Q_ASSERT(QThread::currentThread() != thread());
- QMetaObject::invokeMethod(this, "_sendMessage", Qt::QueuedConnection, Q_ARG(QByteArray, ba));
+ emit messageToClient(name(), ba);
}
void QQmlDebugTestService::stateAboutToBeChanged(QQmlDebugService::State)
Q_ASSERT(QThread::currentThread() != thread());
emit stateHasChanged();
}
-
-void QQmlDebugTestService::_sendMessage(const QByteArray &msg)
-{
- QQmlDebugService::sendMessage(msg);
-}
signals:
void stateHasChanged();
-private slots:
- void _sendMessage(const QByteArray &msg);
-
protected:
virtual void messageReceived(const QByteArray &ba);
virtual void stateAboutToBeChanged(State state);