File indexing completed on 2024-12-22 04:57:01

0001 /*
0002     SPDX-FileCopyrightText: 2015-2016 Krzysztof Nowicki <krissn@op.pl>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "ewsfoldershape.h"
0008 
0009 static const QString shapeNames[] = {
0010     QStringLiteral("IdOnly"),
0011     QStringLiteral("Default"),
0012     QStringLiteral("AllProperties"),
0013 };
0014 
0015 void EwsFolderShape::write(QXmlStreamWriter &writer) const
0016 {
0017     writer.writeStartElement(ewsMsgNsUri, QStringLiteral("FolderShape"));
0018 
0019     // Write the base shape
0020     writeBaseShape(writer);
0021 
0022     // Write properties (if any)
0023     writeProperties(writer);
0024 
0025     writer.writeEndElement();
0026 }
0027 
0028 void EwsFolderShape::writeBaseShape(QXmlStreamWriter &writer) const
0029 {
0030     writer.writeTextElement(ewsTypeNsUri, QStringLiteral("BaseShape"), shapeNames[mBaseShape]);
0031 }
0032 
0033 void EwsFolderShape::writeProperties(QXmlStreamWriter &writer) const
0034 {
0035     if (!mProps.isEmpty()) {
0036         writer.writeStartElement(ewsTypeNsUri, QStringLiteral("AdditionalProperties"));
0037 
0038         for (const EwsPropertyField &prop : std::as_const(mProps)) {
0039             prop.write(writer);
0040         }
0041 
0042         writer.writeEndElement();
0043     }
0044 }