From 0ef3588af37a7eb28af1dd33c9c3ad06b29f80d7 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Sat, 16 Nov 2019 23:02:57 +0100 Subject: Implement XEP-0231: Bits of Binary: stanza extension This adds a type that may be used as a stanza extension. It is useful, when a stanza contains (possibly multiple) XEP-0231: Bits of Binary data elements. --- src/base/QXmppBitsOfBinaryDataList.cpp | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/base/QXmppBitsOfBinaryDataList.cpp (limited to 'src/base/QXmppBitsOfBinaryDataList.cpp') diff --git a/src/base/QXmppBitsOfBinaryDataList.cpp b/src/base/QXmppBitsOfBinaryDataList.cpp new file mode 100644 index 00000000..a9de33e1 --- /dev/null +++ b/src/base/QXmppBitsOfBinaryDataList.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2008-2019 The QXmpp developers + * + * Author: + * Linus Jahn + * + * Source: + * https://github.com/qxmpp-project/qxmpp + * + * This file is a part of QXmpp library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#include "QXmppBitsOfBinaryDataList.h" + +#include + +#include "QXmppBitsOfBinaryData.h" +#include "QXmppConstants_p.h" + +QXmppBitsOfBinaryDataList::QXmppBitsOfBinaryDataList() = default; + +QXmppBitsOfBinaryDataList::~QXmppBitsOfBinaryDataList() = default; + +/// \cond +void QXmppBitsOfBinaryDataList::parse(const QDomElement &element) +{ + // clear previous data elements + clear(); + + // parse all elements + QDomElement child = element.firstChildElement(); + while (!child.isNull()) { + if (QXmppBitsOfBinaryData::isBitsOfBinaryData(child)) { + QXmppBitsOfBinaryData data; + data.parseElementFromChild(child); + append(data); + } + child = child.nextSiblingElement(); + } +} + +void QXmppBitsOfBinaryDataList::toXml(QXmlStreamWriter *writer) const +{ + for (const auto &bitsOfBinaryData : *this) + bitsOfBinaryData.toXmlElementFromChild(writer); +} +/// \endcond -- cgit v1.2.3