diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-08-23 07:55:15 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-08-23 07:55:15 +0000 |
| commit | c02547eff8d35d8cbee7869329820dc582cc3949 (patch) | |
| tree | d260690c39cd5721e42a5fb63221c3253defd7d9 /src | |
| parent | ccb60b7970adeb4d11a02d41cecb607e331ef52e (diff) | |
| download | qxmpp-c02547eff8d35d8cbee7869329820dc582cc3949.tar.gz | |
add isConnected() methods to all streams
Diffstat (limited to 'src')
| -rw-r--r-- | src/QXmppIncomingClient.cpp | 8 | ||||
| -rw-r--r-- | src/QXmppIncomingServer.cpp | 10 | ||||
| -rw-r--r-- | src/QXmppIncomingServer.h | 1 | ||||
| -rw-r--r-- | src/QXmppOutgoingClient.cpp | 11 | ||||
| -rw-r--r-- | src/QXmppOutgoingClient.h | 1 | ||||
| -rw-r--r-- | src/QXmppOutgoingServer.cpp | 4 |
6 files changed, 31 insertions, 4 deletions
diff --git a/src/QXmppIncomingClient.cpp b/src/QXmppIncomingClient.cpp index dcfe26f0..565a17c9 100644 --- a/src/QXmppIncomingClient.cpp +++ b/src/QXmppIncomingClient.cpp @@ -71,6 +71,7 @@ QXmppIncomingClient::QXmppIncomingClient(QSslSocket *socket, const QString &doma bool check = connect(d->idleTimer, SIGNAL(timeout()), this, SLOT(slotTimeout())); Q_ASSERT(check); + Q_UNUSED(check); } /// Destroys the current stream. @@ -81,12 +82,15 @@ QXmppIncomingClient::~QXmppIncomingClient() delete d; } -/// Returns true if the client is authenticated and a resource is bound. +/// Returns true if the socket is connected, the client is authenticated +/// and a resource is bound. /// bool QXmppIncomingClient::isConnected() const { - return !d->username.isEmpty() && !d->resource.isEmpty(); + return QXmppStream::isConnected() && + !d->username.isEmpty() && + !d->resource.isEmpty(); } /// Returns the client's JID. diff --git a/src/QXmppIncomingServer.cpp b/src/QXmppIncomingServer.cpp index 9fe7ee1e..32f83120 100644 --- a/src/QXmppIncomingServer.cpp +++ b/src/QXmppIncomingServer.cpp @@ -135,6 +135,7 @@ void QXmppIncomingServer::handleStanza(const QDomElement &stanza) bool check = connect(stream, SIGNAL(dialbackResponseReceived(QXmppDialback)), this, SLOT(slotDialbackResponseReceived(QXmppDialback))); Q_ASSERT(check); + Q_UNUSED(check); stream->setVerify(d->localStreamId, request.key()); stream->connectToHost(); } @@ -152,6 +153,15 @@ void QXmppIncomingServer::handleStanza(const QDomElement &stanza) } } +/// Returns true if the socket is connected and the remote server is +/// authenticated. +/// + +bool QXmppIncomingServer::isConnected() const +{ + return QXmppStream::isConnected() && d->authenticated; +} + /// Handles a dialback response received from the authority server. /// /// \param response diff --git a/src/QXmppIncomingServer.h b/src/QXmppIncomingServer.h index e82ba9d7..5041c074 100644 --- a/src/QXmppIncomingServer.h +++ b/src/QXmppIncomingServer.h @@ -42,6 +42,7 @@ public: QXmppIncomingServer(QSslSocket *socket, const QString &domain, QObject *parent); ~QXmppIncomingServer(); + bool isConnected() const; QString localStreamId() const; signals: diff --git a/src/QXmppOutgoingClient.cpp b/src/QXmppOutgoingClient.cpp index f9f939b2..145f5b1d 100644 --- a/src/QXmppOutgoingClient.cpp +++ b/src/QXmppOutgoingClient.cpp @@ -81,6 +81,7 @@ public: QString bindId; QString sessionId; bool sessionAvailable; + bool sessionStarted; QString streamId; QString streamFrom; QString streamVersion; @@ -156,6 +157,14 @@ void QXmppOutgoingClient::connectToHost() configuration().port()); } +/// Returns true if the socket is connected and a session has been started. +/// + +bool QXmppOutgoingClient::isConnected() const +{ + return QXmppStream::isConnected() && d->sessionStarted; +} + void QXmppOutgoingClient::socketSslErrors(const QList<QSslError> & error) { warning("SSL errors"); @@ -177,6 +186,7 @@ void QXmppOutgoingClient::handleStart() { // reset authentication step d->authStep = 0; + d->sessionStarted = false; // start stream QByteArray data = "<?xml version='1.0'?><stream:stream to='"; @@ -387,6 +397,7 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv) // process SessionIq // xmpp connection made + d->sessionStarted = true; emit connected(); } else if(QXmppBind::isBind(nodeRecv) && id == d->bindId) diff --git a/src/QXmppOutgoingClient.h b/src/QXmppOutgoingClient.h index 6bfb14a0..54be4aaa 100644 --- a/src/QXmppOutgoingClient.h +++ b/src/QXmppOutgoingClient.h @@ -73,6 +73,7 @@ public: ~QXmppOutgoingClient(); void connectToHost(); + bool isConnected() const; QAbstractSocket::SocketError socketError(); QXmppStanza::Error::Condition xmppStreamError(); diff --git a/src/QXmppOutgoingServer.cpp b/src/QXmppOutgoingServer.cpp index d9c603d1..b0572270 100644 --- a/src/QXmppOutgoingServer.cpp +++ b/src/QXmppOutgoingServer.cpp @@ -154,12 +154,12 @@ void QXmppOutgoingServer::handleStanza(const QDomElement &stanza) } } -/// Returns true if the remote server has been authenticated. +/// Returns true if the socket is connected and authentication succeeded. /// bool QXmppOutgoingServer::isConnected() const { - return d->ready; + return QXmppStream::isConnected() && d->ready; } QString QXmppOutgoingServer::localStreamKey() const |
