diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-03-04 19:26:02 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-03-04 19:26:02 +0000 |
| commit | ceba84212f030f2126ff7ad953594d164a0d8229 (patch) | |
| tree | a377de77e2f1023d05b29bede5cecd344346c6fc /source | |
| parent | f16f6107e1056f522b285f2275f0768f969ebcc0 (diff) | |
| download | qxmpp-ceba84212f030f2126ff7ad953594d164a0d8229.tar.gz | |
make it possible to override handling of XML elements
Diffstat (limited to 'source')
| -rw-r--r-- | source/QXmppClient.cpp | 17 | ||||
| -rw-r--r-- | source/QXmppClient.h | 2 | ||||
| -rw-r--r-- | source/QXmppStream.cpp | 6 |
3 files changed, 24 insertions, 1 deletions
diff --git a/source/QXmppClient.cpp b/source/QXmppClient.cpp index 9bbc62c0..454302b2 100644 --- a/source/QXmppClient.cpp +++ b/source/QXmppClient.cpp @@ -504,3 +504,20 @@ QXmppTransferManager& QXmppClient::getTransferManager() { return m_stream->getTransferManager(); } + +/// 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) +{ + return false; +} diff --git a/source/QXmppClient.h b/source/QXmppClient.h index 3eb2f09d..d3af2547 100644 --- a/source/QXmppClient.h +++ b/source/QXmppClient.h @@ -194,6 +194,8 @@ public: QXmppClient::StreamError getXmppStreamError(); + virtual bool handleStreamElement(const QDomElement &element); + public slots: void sendPacket(const QXmppPacket&); void sendMessage(const QString& bareJid, const QString& message); diff --git a/source/QXmppStream.cpp b/source/QXmppStream.cpp index 83ed747d..d843a17d 100644 --- a/source/QXmppStream.cpp +++ b/source/QXmppStream.cpp @@ -292,7 +292,11 @@ void QXmppStream::parser(const QByteArray& data) QString ns = nodeRecv.namespaceURI(); log("Namespace: " + ns + " Tag: " + nodeRecv.tagName() ); - if(ns == ns_stream && nodeRecv.tagName() == "features") + if(m_client->handleStreamElement(nodeRecv)) + { + // already handled by client, do nothing + } + else if(ns == ns_stream && nodeRecv.tagName() == "features") { bool nonSaslAvailable = nodeRecv.firstChildElement("auth"). namespaceURI() == ns_authFeature; |
