QIODevice *device;
bool gotHello;
- QStringList serverPlugins;
+ QHash <QString, float> serverPlugins;
QHash<QString, QDeclarativeDebugClient *> plugins;
void advertisePlugins();
int version = -1;
pack >> version;
if (version == protocolVersion) {
- pack >> serverPlugins;
+ QStringList pluginNames;
+ QList<float> pluginVersions;
+ pack >> pluginNames;
+ if (!pack.isEmpty())
+ pack >> pluginVersions;
+
+ const int pluginNamesSize = pluginNames.size();
+ const int pluginVersionsSize = pluginVersions.size();
+ for (int i = 0; i < pluginNamesSize; ++i) {
+ float pluginVersion = 1.0;
+ if (i < pluginVersionsSize)
+ pluginVersion = pluginVersions.at(i);
+ serverPlugins.insert(pluginNames.at(i), pluginVersion);
+ }
+
validHello = true;
}
}
if (op == 1) {
// Service Discovery
- QStringList oldServerPlugins = serverPlugins;
- pack >> serverPlugins;
+ QHash<QString, float> oldServerPlugins = serverPlugins;
+ serverPlugins.clear();
+
+ QStringList pluginNames;
+ QList<float> pluginVersions;
+ pack >> pluginNames;
+ if (!pack.isEmpty())
+ pack >> pluginVersions;
+
+ const int pluginNamesSize = pluginNames.size();
+ const int pluginVersionsSize = pluginVersions.size();
+ for (int i = 0; i < pluginNamesSize; ++i) {
+ float pluginVersion = 1.0;
+ if (i < pluginVersionsSize)
+ pluginVersion = pluginVersions.at(i);
+ serverPlugins.insert(pluginNames.at(i), pluginVersion);
+ }
QHash<QString, QDeclarativeDebugClient *>::Iterator iter = plugins.begin();
for (; iter != plugins.end(); ++iter) {
return d->name;
}
+float QDeclarativeDebugClient::serviceVersion() const
+{
+ Q_D(const QDeclarativeDebugClient);
+ if (d->connection->d->serverPlugins.contains(d->name))
+ return d->connection->d->serverPlugins.value(d->name);
+ return -1;
+}
+
QDeclarativeDebugClient::Status QDeclarativeDebugClient::status() const
{
Q_D(const QDeclarativeDebugClient);
~QDeclarativeDebugClient();
QString name() const;
-
+ float serviceVersion() const;
Status status() const;
virtual void sendMessage(const QByteArray &);
version: an int representing the highest protocol version the client knows
pluginNames: plugins available on client side
2. Server sends
- "QDeclarativeDebugClient" 0 version pluginNames
+ "QDeclarativeDebugClient" 0 version pluginNames pluginVersions
version: an int representing the highest protocol version the client & server know
pluginNames: plugins available on server side. plugins both in the client and server message are enabled.
client plugin advertisement
"QDeclarativeDebugServer" 1 pluginNames
server plugin advertisement
1. Server sends
- "QDeclarativeDebugClient" 1 pluginNames
+ "QDeclarativeDebugClient" 1 pluginNames pluginVersions
plugin communication:
Everything send with a header different to "QDeclarativeDebugServer" is sent to the appropriate plugin.
*/
QByteArray message;
{
QDataStream out(&message, QIODevice::WriteOnly);
- out << QString(QLatin1String("QDeclarativeDebugClient")) << 1 << plugins.keys();
+ QStringList pluginNames;
+ QList<float> pluginVersions;
+ foreach (QDeclarativeDebugService *service, plugins.values()) {
+ pluginNames << service->name();
+ pluginVersions << service->version();
+ }
+ out << QString(QLatin1String("QDeclarativeDebugClient")) << 1 << pluginNames << pluginVersions;
}
QMetaObject::invokeMethod(q, "_q_sendMessage", Qt::QueuedConnection, Q_ARG(QByteArray, message));
QByteArray helloAnswer;
{
QDataStream out(&helloAnswer, QIODevice::WriteOnly);
- out << QString(QLatin1String("QDeclarativeDebugClient")) << 0 << protocolVersion << d->plugins.keys();
+ QStringList pluginNames;
+ QList<float> pluginVersions;
+ foreach (QDeclarativeDebugService *service, d->plugins.values()) {
+ pluginNames << service->name();
+ pluginVersions << service->version();
+ }
+
+ out << QString(QLatin1String("QDeclarativeDebugClient")) << 0 << protocolVersion << pluginNames << pluginVersions;
}
d->connection->send(helloAnswer);
{
}
-QDeclarativeDebugService::QDeclarativeDebugService(const QString &name, QObject *parent)
+QDeclarativeDebugService::QDeclarativeDebugService(const QString &name, float version, QObject *parent)
: QObject(*(new QDeclarativeDebugServicePrivate), parent)
{
Q_D(QDeclarativeDebugService);
d->name = name;
+ d->version = version;
d->server = QDeclarativeDebugServer::instance();
d->status = QDeclarativeDebugService::NotConnected;
}
QDeclarativeDebugService::QDeclarativeDebugService(QDeclarativeDebugServicePrivate &dd,
- const QString &name, QObject *parent)
+ const QString &name, float version, QObject *parent)
: QObject(dd, parent)
{
Q_D(QDeclarativeDebugService);
d->name = name;
+ d->version = version;
d->server = QDeclarativeDebugServer::instance();
d->status = QDeclarativeDebugService::NotConnected;
}
return d->name;
}
+float QDeclarativeDebugService::version() const
+{
+ Q_D(const QDeclarativeDebugService);
+ return d->version;
+}
+
QDeclarativeDebugService::Status QDeclarativeDebugService::status() const
{
Q_D(const QDeclarativeDebugService);
Q_DISABLE_COPY(QDeclarativeDebugService)
public:
- explicit QDeclarativeDebugService(const QString &, QObject *parent = 0);
+ explicit QDeclarativeDebugService(const QString &, float version, QObject *parent = 0);
~QDeclarativeDebugService();
QString name() const;
+ float version() const;
enum Status { NotConnected, Unavailable, Enabled };
Status status() const;
static bool hasDebuggingClient();
protected:
- QDeclarativeDebugService(QDeclarativeDebugServicePrivate &dd, const QString &, QObject *parent = 0);
+ QDeclarativeDebugService(QDeclarativeDebugServicePrivate &dd, const QString &name, float version, QObject *parent = 0);
Status registerService();
QDeclarativeDebugServicePrivate();
QString name;
+ float version;
QDeclarativeDebugServer *server;
QDeclarativeDebugService::Status status;
};
}
QDeclarativeDebugTrace::QDeclarativeDebugTrace()
- : QDeclarativeDebugService(QLatin1String("CanvasFrameRate")),
+ : QDeclarativeDebugService(QLatin1String("CanvasFrameRate"), 1),
m_enabled(false), m_messageReceived(false)
{
m_timer.start();
}
QDeclarativeEngineDebugService::QDeclarativeEngineDebugService(QObject *parent)
- : QDeclarativeDebugService(QLatin1String("QDeclarativeEngine"), parent),
+ : QDeclarativeDebugService(QLatin1String("QDeclarativeEngine"), 1, parent),
m_watch(new QDeclarativeWatcher(this)),
m_statesDelegate(0)
{
Q_GLOBAL_STATIC(QDeclarativeInspectorService, serviceInstance)
QDeclarativeInspectorService::QDeclarativeInspectorService()
- : QDeclarativeDebugService(QLatin1String("QDeclarativeObserverMode"))
+ : QDeclarativeDebugService(QLatin1String("QDeclarativeObserverMode"), 1)
, m_currentInspectorPlugin(0)
{
registerService();
//V8 DEBUG SERVICE PROTOCOL
// <HEADER><COMMAND><DATA>
// <HEADER> : "V8DEBUG"
-// <COMMAND> : ["connect", "disconnect", "interrupt", "version",
+// <COMMAND> : ["connect", "disconnect", "interrupt",
// "v8request", "v8message", "breakonsignal",
// "breakaftercompile"]
// <DATA> : connect, disconnect, interrupt: empty
-// version: <version_string>
// v8request, v8message: <JSONrequest_string>
// breakonsignal: <signalname_string><enabled_bool>
// breakaftercompile: <enabled_bool>
-const char *V8_DEBUGGER_KEY_VERSION_NUMBER = "1.1";
const char *V8_DEBUGGER_KEY_VERSION = "version";
const char *V8_DEBUGGER_KEY_CONNECT = "connect";
const char *V8_DEBUGGER_KEY_INTERRUPT = "interrupt";
QV8DebugService::QV8DebugService(QObject *parent)
: QDeclarativeDebugService(*(new QV8DebugServicePrivate()),
- QLatin1String("V8Debugger"), parent)
+ QLatin1String("V8Debugger"), 2, parent)
{
Q_D(QV8DebugService);
v8ServiceInstancePtr = this;
rs >> d->breakAfterCompile;
sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_BREAK_AFTER_COMPILE)));
- } else if (command == V8_DEBUGGER_KEY_VERSION) {
- //We dont check the client version
- //just send the debugger version
- sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_VERSION),
- QLatin1String(V8_DEBUGGER_KEY_VERSION_NUMBER)));
-
}
}
}
};
QV8ProfilerService::QV8ProfilerService(QObject *parent)
- : QDeclarativeDebugService(*(new QV8ProfilerServicePrivate()), QLatin1String("V8Profiler"), parent)
+ : QDeclarativeDebugService(*(new QV8ProfilerServicePrivate()), QLatin1String("V8Profiler"), 1, parent)
{
Q_D(QV8ProfilerService);
QDeclarativeDebugConnection dummyConn;
QDeclarativeDebugClient client("tst_QDeclarativeDebugClient::status()", &dummyConn);
QCOMPARE(client.status(), QDeclarativeDebugClient::NotConnected);
+ QCOMPARE(client.serviceVersion(), -1.0f);
}
QDeclarativeDebugTestClient client("tst_QDeclarativeDebugClient::status()", m_conn);
QCOMPARE(client.status(), QDeclarativeDebugClient::Unavailable);
{
- QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::status()");
+ QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::status()", 2);
QTRY_COMPARE(client.status(), QDeclarativeDebugClient::Enabled);
+ QCOMPARE(client.serviceVersion(), 2.0f);
}
QTRY_COMPARE(client.status(), QDeclarativeDebugClient::Unavailable);
void connect();
void interrupt();
void breakAfterCompile();
- void getDebuggerVersion();
void getVersion();
void getVersionWhenAttaching();
void connect();
void interrupt();
void breakAfterCompile(bool enabled);
- void debuggerVersion();
void continueDebugging(StepAction stepAction, int stepCount = 1);
void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
void connected();
void interruptRequested();
void breakAfterCompileRequested();
- void gotVersion();
void result();
void stopped();
sendMessage(packMessage(BREAKAFTERCOMPILE, request));
}
-void QJSDebugClient::debuggerVersion()
-{
- sendMessage(packMessage(VERSION));
-}
-
void QJSDebugClient::continueDebugging(StepAction action, int count)
{
// { "seq" : <number>,
} else if (type == BREAKAFTERCOMPILE) {
emit breakAfterCompileRequested();
- } else if (type == VERSION) {
- emit gotVersion();
}
}
}
QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
}
-void tst_QDeclarativeDebugJS::getDebuggerVersion()
-{
- QVERIFY(init());
- client->debuggerVersion();
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(gotVersion())));
-
- QString version(client->response);
- QCOMPARE(version, QLatin1String("1.1"));
-}
-
void tst_QDeclarativeDebugJS::getVersion()
{
//void version()
void initTestCase();
void name();
+ void version();
void status();
void sendMessage();
void idForObject();
{
QString name = "tst_QDeclarativeDebugService::name()";
- QDeclarativeDebugService service(name);
+ QDeclarativeDebugService service(name, 1);
QCOMPARE(service.name(), name);
}
+void tst_QDeclarativeDebugService::version()
+{
+ QString name = "tst_QDeclarativeDebugService::name()";
+
+ QDeclarativeDebugService service(name, 2);
+ QCOMPARE(service.version(), 2.0f);
+}
+
void tst_QDeclarativeDebugService::status()
{
QDeclarativeDebugTestService service("tst_QDeclarativeDebugService::status()");
return timer.isActive();
}
-QDeclarativeDebugTestService::QDeclarativeDebugTestService(const QString &s, QObject *parent)
- : QDeclarativeDebugService(s, parent)
+QDeclarativeDebugTestService::QDeclarativeDebugTestService(const QString &s, float version, QObject *parent)
+ : QDeclarativeDebugService(s, version, parent)
{
registerService();
}
{
Q_OBJECT
public:
- QDeclarativeDebugTestService(const QString &s, QObject *parent = 0);
+ QDeclarativeDebugTestService(const QString &s, float version = 1, QObject *parent = 0);
signals:
void statusHasChanged();