aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-06-04 16:32:19 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-06-04 16:32:19 +0000
commitfa78a507c22f9c117f2fdd49cd2207d3ebe25e5d (patch)
tree3e26209ed1dc78e963d2161d46c5f333c1ddd617 /source
parentcfd31d99c1747d7757cdd507b88b2bf7da751aa9 (diff)
downloadqxmpp-fa78a507c22f9c117f2fdd49cd2207d3ebe25e5d.tar.gz
make QXmppStream independent from QXmppClient
Diffstat (limited to 'source')
-rw-r--r--source/QXmppClient.cpp24
-rw-r--r--source/QXmppClient.h14
-rw-r--r--source/QXmppStream.cpp9
-rw-r--r--source/QXmppStream.h4
4 files changed, 25 insertions, 26 deletions
diff --git a/source/QXmppClient.cpp b/source/QXmppClient.cpp
index 3b514214..41e3d1b6 100644
--- a/source/QXmppClient.cpp
+++ b/source/QXmppClient.cpp
@@ -47,7 +47,11 @@ QXmppClient::QXmppClient(QObject *parent)
{
m_stream = new QXmppStream(this);
- bool check = connect(m_stream, SIGNAL(messageReceived(const QXmppMessage&)),
+ bool check = connect(m_stream, SIGNAL(elementReceived(const QDomElement&, bool&)),
+ this, SIGNAL(elementReceived(const QDomElement&, bool&)));
+ Q_ASSERT(check);
+
+ check = connect(m_stream, SIGNAL(messageReceived(const QXmppMessage&)),
this, SIGNAL(messageReceived(const QXmppMessage&)));
Q_ASSERT(check);
@@ -536,24 +540,6 @@ QXmppTransferManager& QXmppClient::getTransferManager()
return *m_transferManager;
}
-/// Reimplement in your subclass of QXmppClient if you want to handle
-/// raw XML elements yourself.
-///
-/// WARNING: you can seriously disrupt packet handling when doing this,
-/// so use with care and at your own risk.
-///
-/// Return true if you handled the element yourself, or false if
-/// you want to use the default handling for the element.
-///
-/// If you handle the element yourself, QXmpp will do absolutely no
-/// processing itself, so do not expect the usual signals to trigger.
-
-bool QXmppClient::handleStreamElement(const QDomElement &element)
-{
- Q_UNUSED(element);
- return false;
-}
-
/// Returns the QXmppLogger associated with the current QXmppClient.
QXmppLogger *QXmppClient::logger()
diff --git a/source/QXmppClient.h b/source/QXmppClient.h
index 9f771de9..321e9d15 100644
--- a/source/QXmppClient.h
+++ b/source/QXmppClient.h
@@ -144,6 +144,18 @@ signals:
/// know the error.
void error(QXmppClient::Error);
+ /// This signal is emitted when a raw XML element is received. You can
+ /// connect to this signal if you want to handle raw XML elements yourself.
+ ///
+ /// WARNING: this signal is experimental and you can seriously disrupt
+ /// packet handling when using it, so use with care and at your own risk.
+ ///
+ /// Set 'handled' to true if you handled the element yourself and you wish
+ /// to bypass normal handling for the element. If you do this, QXmpp will
+ /// do absolutely no processing itself, so do not expect the usual signals
+ /// to be emitted.
+ void elementReceived(const QDomElement &element, bool &handled);
+
/// Notifies that an XMPP message stanza is received. The QXmppMessage
/// parameter contains the details of the message sent to this client.
/// In other words whenever someone sends you a message this signal is
@@ -187,8 +199,6 @@ public:
QXmppLogger *logger();
void setLogger(QXmppLogger *logger);
- virtual bool handleStreamElement(const QDomElement &element);
-
public slots:
bool sendPacket(const QXmppPacket&);
void sendMessage(const QString& bareJid, const QString& message);
diff --git a/source/QXmppStream.cpp b/source/QXmppStream.cpp
index 146b46bf..775763fb 100644
--- a/source/QXmppStream.cpp
+++ b/source/QXmppStream.cpp
@@ -59,8 +59,8 @@
static const QByteArray streamRootElementStart = "<?xml version=\"1.0\"?><stream:stream xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\" xmlns=\"jabber:client\" xml:lang=\"en\" xmlns:xml=\"http://www.w3.org/XML/1998/namespace\">\n";
static const QByteArray streamRootElementEnd = "</stream:stream>";
-QXmppStream::QXmppStream(QXmppClient* client)
- : QObject(client), m_client(client),
+QXmppStream::QXmppStream(QObject *parent)
+ : QObject(parent),
m_sessionAvailable(false),
m_authStep(0)
{
@@ -278,7 +278,10 @@ void QXmppStream::parser(const QByteArray& data)
// if we receive any kind of data, stop the timeout timer
m_timeoutTimer->stop();
- if(m_client->handleStreamElement(nodeRecv))
+ bool handled = false;
+ emit elementReceived(nodeRecv, handled);
+
+ if(handled)
{
// already handled by client, do nothing
}
diff --git a/source/QXmppStream.h b/source/QXmppStream.h
index 87c7f376..c5c23cdf 100644
--- a/source/QXmppStream.h
+++ b/source/QXmppStream.h
@@ -61,7 +61,7 @@ class QXmppStream : public QObject
Q_OBJECT
public:
- QXmppStream(QXmppClient* client);
+ QXmppStream(QObject *parent);
~QXmppStream();
void connect();
void acceptSubscriptionRequest(const QString& from, bool accept = true);
@@ -93,6 +93,7 @@ signals:
void error(QXmppClient::Error);
void subscriptionRequestReceived(const QString& from);
+ void elementReceived(const QDomElement &element, bool &handled);
void presenceReceived(const QXmppPresence&);
void messageReceived(const QXmppMessage&);
void iqReceived(const QXmppIq&);
@@ -130,7 +131,6 @@ private slots:
void pingTimeout();
private:
- QXmppClient* m_client; // reverse pointer
QXmppConfiguration m_config; ///< This object provides the configuration
///< required for connecting to the XMPP server.
QXmppLogger* m_logger;