aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-08-23 09:40:32 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-08-23 09:40:32 +0000
commit94bb4b3e8975371ca97a49ef4ff99d3c1da28cdb (patch)
treef1b8a7d59b41c71640f251f2446e08873653fe76 /src
parent081175e7d57557a0e233beb9cafec2fc89a917db (diff)
downloadqxmpp-94bb4b3e8975371ca97a49ef4ff99d3c1da28cdb.tar.gz
implement serialisation of QXmppArchiveChatIq
Diffstat (limited to 'src')
-rw-r--r--src/QXmppArchiveIq.cpp24
-rw-r--r--src/QXmppArchiveIq.h1
2 files changed, 22 insertions, 3 deletions
diff --git a/src/QXmppArchiveIq.cpp b/src/QXmppArchiveIq.cpp
index e82aeb60..eb4c6ccd 100644
--- a/src/QXmppArchiveIq.cpp
+++ b/src/QXmppArchiveIq.cpp
@@ -61,10 +61,10 @@ void QXmppArchiveMessage::setReceived(bool isReceived)
void QXmppArchiveChat::parse(const QDomElement &element)
{
+ m_with = element.attribute("with");
m_start = datetimeFromString(element.attribute("start"));
m_subject = element.attribute("subject");
m_version = element.attribute("version").toInt();
- m_with = element.attribute("with");
QDomElement child = element.firstChildElement();
while (!child.isNull())
@@ -81,6 +81,25 @@ void QXmppArchiveChat::parse(const QDomElement &element)
}
}
+void QXmppArchiveChat::toXml(QXmlStreamWriter *writer) const
+{
+ writer->writeStartElement("chat");
+ helperToXmlAddAttribute(writer, "xmlns", ns_archive);
+ helperToXmlAddAttribute(writer, "with", m_with);
+ if (m_start.isValid())
+ helperToXmlAddAttribute(writer, "start", datetimeToString(m_start));
+ helperToXmlAddAttribute(writer, "subject", m_subject);
+ helperToXmlAddAttribute(writer, "version", QString::number(m_version));
+ foreach (const QXmppArchiveMessage &message, m_messages)
+ {
+ writer->writeStartElement(message.isReceived() ? "from" : "to");
+ helperToXmlAddAttribute(writer, "secs", QString::number(m_start.secsTo(message.date())));
+ writer->writeTextElement("body", message.body());
+ writer->writeEndElement();
+ }
+ writer->writeEndElement();
+}
+
QList<QXmppArchiveMessage> QXmppArchiveChat::messages() const
{
return m_messages;
@@ -125,8 +144,7 @@ void QXmppArchiveChatIq::parseElementFromChild(const QDomElement &element)
void QXmppArchiveChatIq::toXmlElementFromChild(QXmlStreamWriter *writer) const
{
- // TODO : implement serialization
- Q_UNUSED(writer);
+ m_chat.toXml(writer);
}
QXmppArchiveListIq::QXmppArchiveListIq()
diff --git a/src/QXmppArchiveIq.h b/src/QXmppArchiveIq.h
index 10f28609..7f51343a 100644
--- a/src/QXmppArchiveIq.h
+++ b/src/QXmppArchiveIq.h
@@ -59,6 +59,7 @@ public:
QString with() const;
void parse(const QDomElement &element);
+ void toXml(QXmlStreamWriter *writer) const;
private:
QList<QXmppArchiveMessage> m_messages;