diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2011-01-11 16:49:01 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2011-01-11 16:49:01 +0000 |
| commit | 41714bb928dfab0e3cafcf061109998f6a2f0880 (patch) | |
| tree | 3996b9cbe9a874a2985ae9acca7d4ed0a944a3cc /src | |
| parent | e70f2b5c4455f733830019757777d0b4b8a543ed (diff) | |
| download | qxmpp-41714bb928dfab0e3cafcf061109998f6a2f0880.tar.gz | |
add setters for archive IQ's, for server-side support of archiving
Diffstat (limited to 'src')
| -rw-r--r-- | src/QXmppArchiveIq.cpp | 88 | ||||
| -rw-r--r-- | src/QXmppArchiveIq.h | 23 |
2 files changed, 107 insertions, 4 deletions
diff --git a/src/QXmppArchiveIq.cpp b/src/QXmppArchiveIq.cpp index c1b5d62c..c72403c0 100644 --- a/src/QXmppArchiveIq.cpp +++ b/src/QXmppArchiveIq.cpp @@ -29,6 +29,11 @@ static const char *ns_archive = "urn:xmpp:archive"; static const char *ns_rsm = "http://jabber.org/protocol/rsm"; +QXmppArchiveMessage::QXmppArchiveMessage() + : m_received(false) +{ +} + /// Returns the archived message's body. QString QXmppArchiveMessage::body() const @@ -76,11 +81,17 @@ void QXmppArchiveMessage::setReceived(bool isReceived) m_received = isReceived; } +QXmppArchiveChat::QXmppArchiveChat() + : m_version(0) +{ +} + void QXmppArchiveChat::parse(const QDomElement &element) { m_with = element.attribute("with"); m_start = datetimeFromString(element.attribute("start")); m_subject = element.attribute("subject"); + m_thread = element.attribute("thread"); m_version = element.attribute("version").toInt(); QDomElement child = element.firstChildElement(); @@ -106,7 +117,9 @@ void QXmppArchiveChat::toXml(QXmlStreamWriter *writer) const if (m_start.isValid()) helperToXmlAddAttribute(writer, "start", datetimeToString(m_start)); helperToXmlAddAttribute(writer, "subject", m_subject); - helperToXmlAddAttribute(writer, "version", QString::number(m_version)); + helperToXmlAddAttribute(writer, "thread", m_thread); + if (m_version) + helperToXmlAddAttribute(writer, "version", QString::number(m_version)); foreach (const QXmppArchiveMessage &message, m_messages) { writer->writeStartElement(message.isReceived() ? "from" : "to"); @@ -124,6 +137,13 @@ QList<QXmppArchiveMessage> QXmppArchiveChat::messages() const return m_messages; } +/// Sets the conversation's messages. + +void QXmppArchiveChat::setMessages(const QList<QXmppArchiveMessage> &messages) +{ + m_messages = messages; +} + /// Returns the start of this conversation. QDateTime QXmppArchiveChat::start() const @@ -131,6 +151,13 @@ QDateTime QXmppArchiveChat::start() const return m_start; } +/// Sets the start of this conversation. + +void QXmppArchiveChat::setStart(const QDateTime &start) +{ + m_start = start; +} + /// Returns the conversation's subject. QString QXmppArchiveChat::subject() const @@ -138,6 +165,27 @@ QString QXmppArchiveChat::subject() const return m_subject; } +/// Sets the conversation's subject. + +void QXmppArchiveChat::setSubject(const QString &subject) +{ + m_subject = subject; +} + +/// Returns the conversation's thread. + +QString QXmppArchiveChat::thread() const +{ + return m_thread; +} + +/// Sets the conversation's thread. + +void QXmppArchiveChat::setThread(const QString &thread) +{ + m_thread = thread; +} + /// Returns the conversation's version. int QXmppArchiveChat::version() const @@ -145,13 +193,27 @@ int QXmppArchiveChat::version() const return m_version; } +/// Sets the conversation's version. + +void QXmppArchiveChat::setVersion(int version) +{ + m_version = version; +} + /// Returns the JID of the remote party. - + QString QXmppArchiveChat::with() const { return m_with; } +/// Sets the JID of the remote party. + +void QXmppArchiveChat::setWith(const QString &with) +{ + m_with = with; +} + /// Returns the chat conversation carried by this IQ. QXmppArchiveChat QXmppArchiveChatIq::chat() const @@ -159,6 +221,13 @@ QXmppArchiveChat QXmppArchiveChatIq::chat() const return m_chat; } +/// Sets the chat conversation carried by this IQ. + +void QXmppArchiveChatIq::setChat(const QXmppArchiveChat &chat) +{ + m_chat = chat; +} + bool QXmppArchiveChatIq::isArchiveChatIq(const QDomElement &element) { QDomElement chatElement = element.firstChildElement("chat"); @@ -190,6 +259,13 @@ QList<QXmppArchiveChat> QXmppArchiveListIq::chats() const return m_chats; } +/// Sets the list of chat conversations. + +void QXmppArchiveListIq::setChats(const QList<QXmppArchiveChat> &chats) +{ + m_chats = chats; +} + /// Returns the maximum number of results. /// @@ -305,6 +381,8 @@ void QXmppArchiveListIq::toXmlElementFromChild(QXmlStreamWriter *writer) const helperToXmlAddTextElement(writer, "max", QString::number(m_max)); writer->writeEndElement(); } + foreach (const QXmppArchiveChat &chat, m_chats) + chat.toXml(writer); writer->writeEndElement(); } @@ -383,6 +461,12 @@ void QXmppArchiveRetrieveIq::setWith(const QString &with) m_with = with; } +bool QXmppArchiveRetrieveIq::isArchiveRetrieveIq(const QDomElement &element) +{ + QDomElement retrieveElement = element.firstChildElement("retrieve"); + return (retrieveElement.namespaceURI() == ns_archive); +} + void QXmppArchiveRetrieveIq::parseElementFromChild(const QDomElement &element) { QDomElement retrieveElement = element.firstChildElement("retrieve"); diff --git a/src/QXmppArchiveIq.h b/src/QXmppArchiveIq.h index 8395afef..97ee8516 100644 --- a/src/QXmppArchiveIq.h +++ b/src/QXmppArchiveIq.h @@ -31,12 +31,14 @@ class QXmlStreamWriter; class QDomElement; -/// \brief The QXmppArchiveMessage class represents an archived message +/// \brief The QXmppArchiveMessage represents an archived message /// as defined by XEP-0136: Message Archiving. class QXmppArchiveMessage { public: + QXmppArchiveMessage(); + QString body() const; void setBody(const QString &body); @@ -52,17 +54,31 @@ private: bool m_received; }; -/// \brief The QXmppArchiveChat class represents an archived conversation +/// \brief The QXmppArchiveChat represents an archived conversation /// as defined by XEP-0136: Message Archiving. class QXmppArchiveChat { public: + QXmppArchiveChat(); + QList<QXmppArchiveMessage> messages() const; + void setMessages(const QList<QXmppArchiveMessage> &messages); + QDateTime start() const; + void setStart(const QDateTime &start); + QString subject() const; + void setSubject(const QString &subject); + + QString thread() const; + void setThread(const QString &thread); + int version() const; + void setVersion(int version); + QString with() const; + void setWith(const QString &with); /// \cond void parse(const QDomElement &element); @@ -73,6 +89,7 @@ private: QList<QXmppArchiveMessage> m_messages; QDateTime m_start; QString m_subject; + QString m_thread; int m_version; QString m_with; }; @@ -87,6 +104,7 @@ class QXmppArchiveChatIq : public QXmppIq { public: QXmppArchiveChat chat() const; + void setChat(const QXmppArchiveChat &chat); /// \cond static bool isArchiveChatIq(const QDomElement &element); @@ -112,6 +130,7 @@ public: QXmppArchiveListIq(); QList<QXmppArchiveChat> chats() const; + void setChats(const QList<QXmppArchiveChat> &chats); int max() const; void setMax(int max); |
