diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-07-18 10:37:31 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-07-18 10:37:31 +0000 |
| commit | 4f5e71e25599c10f439f92b825ff0a247ed8ba7b (patch) | |
| tree | 640c0903a32048ca59315353e821723b925c03ad /source | |
| parent | 21bd23f418219c1a4649b0efe7cfb848a31b2922 (diff) | |
| download | qxmpp-4f5e71e25599c10f439f92b825ff0a247ed8ba7b.tar.gz | |
rework QXmppStun API to make it more socket-like
Diffstat (limited to 'source')
| -rw-r--r-- | source/QXmppStun.cpp | 11 | ||||
| -rw-r--r-- | source/QXmppStun.h | 9 |
2 files changed, 10 insertions, 10 deletions
diff --git a/source/QXmppStun.cpp b/source/QXmppStun.cpp index 00e3d2e3..8594a53f 100644 --- a/source/QXmppStun.cpp +++ b/source/QXmppStun.cpp @@ -603,12 +603,11 @@ void QXmppStunSocket::connectToHost() m_timer->start(); } -/// Returns the QIODevice::OpenMode which represents the socket's ability -/// to read and/or write data. +/// Returns true if ICE negotiation completed, false otherwise. -QIODevice::OpenMode QXmppStunSocket::openMode() const +bool QXmppStunSocket::isConnected() const { - return m_activePair ? QIODevice::ReadWrite : QIODevice::NotOpen; + return m_activePair != 0; } void QXmppStunSocket::debug(const QString &message, QXmppLogger::MessageType type) @@ -735,7 +734,7 @@ void QXmppStunSocket::readyRead() quint16 messageType = QXmppStunMessage::peekType(buffer); if (!messageType) { - emit datagramReceived(buffer, remoteHost, remotePort); + emit datagramReceived(buffer); return; } @@ -838,7 +837,7 @@ void QXmppStunSocket::readyRead() debug(QString("ICE completed %1").arg(pair->toString())); m_activePair = pair; m_timer->stop(); - emit ready(); + emit connected(); } } diff --git a/source/QXmppStun.h b/source/QXmppStun.h index 507723f7..94b179f0 100644 --- a/source/QXmppStun.h +++ b/source/QXmppStun.h @@ -60,7 +60,7 @@ public: void close(); void connectToHost(); - QIODevice::OpenMode openMode() const; + bool isConnected() const; qint64 writeDatagram(const QByteArray &datagram); private slots: @@ -68,14 +68,15 @@ private slots: void readyRead(); signals: + // This signal is emitted once ICE negotiation succeeds. + void connected(); + // This signal is emitted when a data packet is received. - void datagramReceived(const QByteArray &datagram, const QHostAddress &host, quint16 port); + void datagramReceived(const QByteArray &datagram); /// This signal is emitted to send logging messages. void logMessage(QXmppLogger::MessageType type, const QString &msg); - void ready(); - private: class Pair { public: |
