diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-03-04 10:09:12 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-03-04 10:09:12 +0000 |
| commit | cc1f2420a04a190b350f455e29224b354a19e118 (patch) | |
| tree | 5331909f4bea65aca806a1ff01ebf389e99a2419 /source/QXmppArchiveIq.cpp | |
| parent | ec09e22b712cc1daf0428bfca75372469de7dbea (diff) | |
| download | qxmpp-cc1f2420a04a190b350f455e29224b354a19e118.tar.gz | |
cleanup archive handling API
Diffstat (limited to 'source/QXmppArchiveIq.cpp')
| -rw-r--r-- | source/QXmppArchiveIq.cpp | 98 |
1 files changed, 78 insertions, 20 deletions
diff --git a/source/QXmppArchiveIq.cpp b/source/QXmppArchiveIq.cpp index 1b186d4e..cb6d065c 100644 --- a/source/QXmppArchiveIq.cpp +++ b/source/QXmppArchiveIq.cpp @@ -29,43 +29,102 @@ static const char *ns_archive = "urn:xmpp:archive"; -QXmppArchiveChat QXmppArchiveChatIq::chat() const +QString QXmppArchiveMessage::body() const { - return m_chat; + return m_body; } -bool QXmppArchiveChatIq::isArchiveChatIq(const QDomElement &element) +void QXmppArchiveMessage::setBody(const QString &body) { - QDomElement chatElement = element.firstChildElement("chat"); - return !chatElement.attribute("with").isEmpty(); - //return (chatElement.namespaceURI() == ns_archive); + m_body = body; } -void QXmppArchiveChatIq::parse(const QDomElement &element) +QDateTime QXmppArchiveMessage::date() const { - QXmppStanza::parse(element); + return m_date; +} - QDomElement chatElement = element.firstChildElement("chat"); - m_chat.subject = chatElement.attribute("subject"); - m_chat.start = datetimeFromString(chatElement.attribute("start")); - m_chat.version = chatElement.attribute("version").toInt(); - m_chat.with = chatElement.attribute("with"); +void QXmppArchiveMessage::setDate(const QDateTime &date) +{ + m_date = date; +} + +bool QXmppArchiveMessage::isReceived() const +{ + return m_received; +} + +void QXmppArchiveMessage::setReceived(bool isReceived) +{ + m_received = isReceived; +} + +void QXmppArchiveChat::parse(const QDomElement &element) +{ + m_start = datetimeFromString(element.attribute("start")); + m_subject = element.attribute("subject"); + m_version = element.attribute("version").toInt(); + m_with = element.attribute("with"); - QDomElement child = chatElement.firstChildElement(); + QDomElement child = element.firstChildElement(); while (!child.isNull()) { if ((child.tagName() == "from") || (child.tagName() == "to")) { QXmppArchiveMessage message; - message.datetime = m_chat.start.addSecs(child.attribute("secs").toInt()); - message.body = child.firstChildElement("body").text(); - message.local = (child.tagName() == "to"); - m_chat.messages << message; + message.setBody(child.firstChildElement("body").text()); + message.setDate(m_start.addSecs(child.attribute("secs").toInt())); + message.setReceived(child.tagName() == "from"); + m_messages << message; } child = child.nextSiblingElement(); } } +QList<QXmppArchiveMessage> QXmppArchiveChat::messages() const +{ + return m_messages; +} + +QDateTime QXmppArchiveChat::start() const +{ + return m_start; +} + +QString QXmppArchiveChat::subject() const +{ + return m_subject; +} + +int QXmppArchiveChat::version() const +{ + return m_version; +} + +QString QXmppArchiveChat::with() const +{ + return m_with; +} + +QXmppArchiveChat QXmppArchiveChatIq::chat() const +{ + return m_chat; +} + +bool QXmppArchiveChatIq::isArchiveChatIq(const QDomElement &element) +{ + QDomElement chatElement = element.firstChildElement("chat"); + return !chatElement.attribute("with").isEmpty(); + //return (chatElement.namespaceURI() == ns_archive); +} + +void QXmppArchiveChatIq::parse(const QDomElement &element) +{ + QXmppStanza::parse(element); + + m_chat.parse(element.firstChildElement("chat")); +} + QXmppArchiveListIq::QXmppArchiveListIq() : QXmppIq(QXmppIq::Get), m_max(0) { @@ -135,8 +194,7 @@ void QXmppArchiveListIq::parse(const QDomElement &element) if (child.tagName() == "chat") { QXmppArchiveChat chat; - chat.with = child.attribute("with"); - chat.start = datetimeFromString(child.attribute("start")); + chat.parse(child); m_chats << chat; } child = child.nextSiblingElement(); |
