aboutsummaryrefslogtreecommitdiff
path: root/src/QXmppArchiveIq.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2011-01-11 16:49:01 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2011-01-11 16:49:01 +0000
commit41714bb928dfab0e3cafcf061109998f6a2f0880 (patch)
tree3996b9cbe9a874a2985ae9acca7d4ed0a944a3cc /src/QXmppArchiveIq.cpp
parente70f2b5c4455f733830019757777d0b4b8a543ed (diff)
downloadqxmpp-41714bb928dfab0e3cafcf061109998f6a2f0880.tar.gz
add setters for archive IQ's, for server-side support of archiving
Diffstat (limited to 'src/QXmppArchiveIq.cpp')
-rw-r--r--src/QXmppArchiveIq.cpp88
1 files changed, 86 insertions, 2 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");