diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2010-09-22 19:03:57 (GMT) |
---|---|---|
committer | Kai Koehne <kai.koehne@nokia.com> | 2010-09-28 05:55:32 (GMT) |
commit | fd9771c29d401d88779ab7c5d7715c9ca41dd723 (patch) | |
tree | 0e96e0871e8914f5747bfc1a1314d76a78620b6d /tests/auto/declarative/shared | |
parent | 7b796b4dcdebfba55c4754d241edb334217fc550 (diff) | |
download | Qt-fd9771c29d401d88779ab7c5d7715c9ca41dd723.zip Qt-fd9771c29d401d88779ab7c5d7715c9ca41dd723.tar.gz Qt-fd9771c29d401d88779ab7c5d7715c9ca41dd723.tar.bz2 |
Make QmlDebug protocol more robust
The protocol so far was client->server only. That is, there was no
sane way for a client to check whether a plugin on the server (service)
was available or not. E.g. calling Client::setEnabled(true) 'succeeded',
without a check whether there is actually a service to talk to.
The new protocol replaces this shortcoming by a service discovery
mechanism: Both client & service announce their available plugins at
handshake time, and later on if there are changes. The status is
reflected in Client::status() and Service::Status() , which are either
NotConnected - no network connection, or not registered properly
Unavailable - TCP/IP connection works, but no plugin with the same
name on the other side
Enabled - You can connect to plugin on other side
The status changes happen automatically (no setEnabled() anymore).
Furthermore a version ID was added to the handshake, so that we can
extend the protocol further in the future :)
Diffstat (limited to 'tests/auto/declarative/shared')
-rw-r--r-- | tests/auto/declarative/shared/debugutil.cpp | 13 | ||||
-rw-r--r-- | tests/auto/declarative/shared/debugutil_p.h | 8 |
2 files changed, 12 insertions, 9 deletions
diff --git a/tests/auto/declarative/shared/debugutil.cpp b/tests/auto/declarative/shared/debugutil.cpp index c0c3eca..5f68e44 100644 --- a/tests/auto/declarative/shared/debugutil.cpp +++ b/tests/auto/declarative/shared/debugutil.cpp @@ -60,7 +60,7 @@ bool QDeclarativeDebugTest::waitForSignal(QObject *receiver, const char *member, } QDeclarativeDebugTestService::QDeclarativeDebugTestService(const QString &s, QObject *parent) - : QDeclarativeDebugService(s, parent), enabled(false) + : QDeclarativeDebugService(s, parent) { } @@ -69,10 +69,9 @@ void QDeclarativeDebugTestService::messageReceived(const QByteArray &ba) sendMessage(ba); } -void QDeclarativeDebugTestService::enabledChanged(bool e) +void QDeclarativeDebugTestService::statusChanged(Status) { - enabled = e; - emit enabledStateChanged(); + emit statusHasChanged(); } @@ -92,9 +91,13 @@ QByteArray QDeclarativeDebugTestClient::waitForResponse() return lastMsg; } +void QDeclarativeDebugTestClient::statusChanged(Status status) +{ + emit statusHasChanged(); +} + void QDeclarativeDebugTestClient::messageReceived(const QByteArray &ba) { lastMsg = ba; emit serverMessage(ba); } - diff --git a/tests/auto/declarative/shared/debugutil_p.h b/tests/auto/declarative/shared/debugutil_p.h index e6bb7ad..434e053 100644 --- a/tests/auto/declarative/shared/debugutil_p.h +++ b/tests/auto/declarative/shared/debugutil_p.h @@ -62,15 +62,13 @@ class QDeclarativeDebugTestService : public QDeclarativeDebugService Q_OBJECT public: QDeclarativeDebugTestService(const QString &s, QObject *parent = 0); - bool enabled; signals: - void enabledStateChanged(); + void statusHasChanged(); protected: virtual void messageReceived(const QByteArray &ba); - - virtual void enabledChanged(bool e); + virtual void statusChanged(Status status); }; class QDeclarativeDebugTestClient : public QDeclarativeDebugClient @@ -82,9 +80,11 @@ public: QByteArray waitForResponse(); signals: + void statusHasChanged(); void serverMessage(const QByteArray &); protected: + virtual void statusChanged(Status status); virtual void messageReceived(const QByteArray &ba); private: |