aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-07-18 10:37:31 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-07-18 10:37:31 +0000
commit4f5e71e25599c10f439f92b825ff0a247ed8ba7b (patch)
tree640c0903a32048ca59315353e821723b925c03ad /source
parent21bd23f418219c1a4649b0efe7cfb848a31b2922 (diff)
downloadqxmpp-4f5e71e25599c10f439f92b825ff0a247ed8ba7b.tar.gz
rework QXmppStun API to make it more socket-like
Diffstat (limited to 'source')
-rw-r--r--source/QXmppStun.cpp11
-rw-r--r--source/QXmppStun.h9
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: