aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-09-20 13:45:32 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-09-20 13:45:32 +0000
commit3f7103cfa0a6004cce74de81bcdf63f821ab01d4 (patch)
treefc0498ad166c95898add857aa28c602893c969c5 /src
parentab192b801c6db3e3f33a590f0edf24f5dbcc0551 (diff)
downloadqxmpp-3f7103cfa0a6004cce74de81bcdf63f821ab01d4.tar.gz
make QXmppArchiveManager a QXmppClientExtension
Diffstat (limited to 'src')
-rw-r--r--src/QXmppArchiveManager.cpp58
-rw-r--r--src/QXmppArchiveManager.h16
-rw-r--r--src/QXmppClient.cpp4
-rw-r--r--src/QXmppOutgoingClient.cpp19
-rw-r--r--src/QXmppOutgoingClient.h8
5 files changed, 47 insertions, 58 deletions
diff --git a/src/QXmppArchiveManager.cpp b/src/QXmppArchiveManager.cpp
index c46e2dc9..db2098f5 100644
--- a/src/QXmppArchiveManager.cpp
+++ b/src/QXmppArchiveManager.cpp
@@ -21,29 +21,12 @@
*
*/
+#include <QDomElement>
+
#include "QXmppArchiveIq.h"
#include "QXmppArchiveManager.h"
#include "QXmppOutgoingClient.h"
-#include <QDebug>
-
-QXmppArchiveManager::QXmppArchiveManager(QXmppOutgoingClient *stream, QObject *parent)
- : QObject(parent),
- m_stream(stream)
-{
- bool check = QObject::connect(m_stream, SIGNAL(archiveChatIqReceived(const QXmppArchiveChatIq&)),
- this, SLOT(archiveChatIqReceived(const QXmppArchiveChatIq&)));
- Q_ASSERT(check);
-
- check = QObject::connect(m_stream, SIGNAL(archiveListIqReceived(const QXmppArchiveListIq&)),
- this, SLOT(archiveListIqReceived(const QXmppArchiveListIq&)));
- Q_ASSERT(check);
-
- check = QObject::connect(m_stream, SIGNAL(archivePrefIqReceived(const QXmppArchivePrefIq&)),
- this, SLOT(archivePrefIqReceived(const QXmppArchivePrefIq&)));
- Q_ASSERT(check);
-}
-
void QXmppArchiveManager::archiveChatIqReceived(const QXmppArchiveChatIq &chatIq)
{
emit archiveChatReceived(chatIq.chat());
@@ -59,6 +42,37 @@ void QXmppArchiveManager::archivePrefIqReceived(const QXmppArchivePrefIq &prefIq
Q_UNUSED(prefIq);
}
+bool QXmppArchiveManager::handleStanza(QXmppStream *stream, const QDomElement &element)
+{
+ if (element.tagName() != "iq")
+ return false;
+
+ // XEP-0136: Message Archiving
+ if(QXmppArchiveChatIq::isArchiveChatIq(element))
+ {
+ QXmppArchiveChatIq archiveIq;
+ archiveIq.parse(element);
+ archiveChatIqReceived(archiveIq);
+ return true;
+ }
+ else if(QXmppArchiveListIq::isArchiveListIq(element))
+ {
+ QXmppArchiveListIq archiveIq;
+ archiveIq.parse(element);
+ archiveListIqReceived(archiveIq);
+ return true;
+ }
+ else if(QXmppArchivePrefIq::isArchivePrefIq(element))
+ {
+ QXmppArchivePrefIq archiveIq;
+ archiveIq.parse(element);
+ archivePrefIqReceived(archiveIq);
+ return true;
+ }
+
+ return false;
+}
+
/// Retrieves the list of available collections. Once the results are
/// received, the archiveListReceived() signal will be emitted.
///
@@ -74,7 +88,7 @@ void QXmppArchiveManager::listCollections(const QString &jid, const QDateTime &s
packet.setWith(jid);
packet.setStart(start);
packet.setEnd(end);
- m_stream->sendPacket(packet);
+ client()->sendPacket(packet);
}
/// Retrieves the specified collection. Once the results are received,
@@ -90,13 +104,13 @@ void QXmppArchiveManager::retrieveCollection(const QString &jid, const QDateTime
packet.setMax(max);
packet.setStart(start);
packet.setWith(jid);
- m_stream->sendPacket(packet);
+ client()->sendPacket(packet);
}
#if 0
void QXmppArchiveManager::getPreferences()
{
QXmppArchivePrefIq packet;
- m_stream->sendPacket(packet);
+ client()->sendPacket(packet);
}
#endif
diff --git a/src/QXmppArchiveManager.h b/src/QXmppArchiveManager.h
index 0fba89c8..5265e007 100644
--- a/src/QXmppArchiveManager.h
+++ b/src/QXmppArchiveManager.h
@@ -25,7 +25,8 @@
#define QXMPPARCHIVEMANAGER_H
#include <QDateTime>
-#include <QObject>
+
+#include "QXmppClientExtension.h"
class QXmppArchiveChat;
class QXmppArchiveChatIq;
@@ -41,15 +42,18 @@ class QXmppOutgoingClient;
///
/// \ingroup Managers
-class QXmppArchiveManager : public QObject
+class QXmppArchiveManager : public QXmppClientExtension
{
Q_OBJECT
public:
- QXmppArchiveManager(QXmppOutgoingClient* stream, QObject *parent = 0);
void listCollections(const QString &jid, const QDateTime &start = QDateTime(), const QDateTime &end = QDateTime(), int max = 0);
void retrieveCollection(const QString &jid, const QDateTime &start, int max = 0);
+ /// \cond
+ bool handleStanza(QXmppStream *stream, const QDomElement &element);
+ /// \endcond
+
signals:
/// This signal is emitted when archive list is received
/// after calling listCollections()
@@ -59,14 +63,10 @@ signals:
/// after calling retrieveCollection()
void archiveChatReceived(const QXmppArchiveChat&);
-private slots:
+private:
void archiveChatIqReceived(const QXmppArchiveChatIq&);
void archiveListIqReceived(const QXmppArchiveListIq&);
void archivePrefIqReceived(const QXmppArchivePrefIq&);
-
-private:
- // reference to xmpp stream (no ownership)
- QXmppOutgoingClient* m_stream;
};
#endif
diff --git a/src/QXmppClient.cpp b/src/QXmppClient.cpp
index 236c2480..82d1596b 100644
--- a/src/QXmppClient.cpp
+++ b/src/QXmppClient.cpp
@@ -200,7 +200,9 @@ QXmppClient::QXmppClient(QObject *parent)
// create managers
// TODO move manager references to d->extensions
d->rosterManager = new QXmppRosterManager(d->stream, this);
- d->archiveManager = new QXmppArchiveManager(d->stream, this);
+
+ d->archiveManager = new QXmppArchiveManager;
+ addExtension(d->archiveManager);
d->callManager = new QXmppCallManager(this);
addExtension(d->callManager);
diff --git a/src/QXmppOutgoingClient.cpp b/src/QXmppOutgoingClient.cpp
index f2788538..957d9288 100644
--- a/src/QXmppOutgoingClient.cpp
+++ b/src/QXmppOutgoingClient.cpp
@@ -571,25 +571,6 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
siIq.parse(nodeRecv);
emit streamInitiationIqReceived(siIq);
}
- // XEP-0136: Message Archiving
- else if(QXmppArchiveChatIq::isArchiveChatIq(nodeRecv))
- {
- QXmppArchiveChatIq archiveIq;
- archiveIq.parse(nodeRecv);
- emit archiveChatIqReceived(archiveIq);
- }
- else if(QXmppArchiveListIq::isArchiveListIq(nodeRecv))
- {
- QXmppArchiveListIq archiveIq;
- archiveIq.parse(nodeRecv);
- emit archiveListIqReceived(archiveIq);
- }
- else if(QXmppArchivePrefIq::isArchivePrefIq(nodeRecv))
- {
- QXmppArchivePrefIq archiveIq;
- archiveIq.parse(nodeRecv);
- emit archivePrefIqReceived(archiveIq);
- }
// XEP-0199: XMPP Ping
else if(QXmppPingIq::isPingIq(nodeRecv))
{
diff --git a/src/QXmppOutgoingClient.h b/src/QXmppOutgoingClient.h
index cd6d81f7..51a88300 100644
--- a/src/QXmppOutgoingClient.h
+++ b/src/QXmppOutgoingClient.h
@@ -44,9 +44,6 @@ class QXmppVCardIq;
class QXmppMessage;
class QXmppRpcResponseIq;
class QXmppRpcErrorIq;
-class QXmppArchiveChatIq;
-class QXmppArchiveListIq;
-class QXmppArchivePrefIq;
class QXmppByteStreamIq;
class QXmppDiscoveryIq;
class QXmppIbbCloseIq;
@@ -107,11 +104,6 @@ signals:
// XEP-0095: Stream Initiation
void streamInitiationIqReceived(const QXmppStreamInitiationIq&);
- // XEP-0136: Message Archiving
- void archiveChatIqReceived(const QXmppArchiveChatIq&);
- void archiveListIqReceived(const QXmppArchiveListIq&);
- void archivePrefIqReceived(const QXmppArchivePrefIq&);
-
protected:
/// \cond
// Overridable methods