diff options
| author | Linus Jahn <lnj@kaidan.im> | 2022-09-29 15:01:12 +0200 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2022-09-29 15:15:50 +0200 |
| commit | 187a57269387a509e7db34c1a7d51f37acc3ee08 (patch) | |
| tree | b0dfb3f101cd8ded01148f0fee52b592dfd7ece7 /src/base/QXmppFileShare.cpp | |
| parent | b242b94ab46542027701d527167e615d3002a416 (diff) | |
| download | qxmpp-187a57269387a509e7db34c1a7d51f37acc3ee08.tar.gz | |
FileShare: Add encrypted sources
Adds new attribute for encrypted sources and parsing.
Diffstat (limited to 'src/base/QXmppFileShare.cpp')
| -rw-r--r-- | src/base/QXmppFileShare.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/src/base/QXmppFileShare.cpp b/src/base/QXmppFileShare.cpp index 9c12ed27..9dd4b686 100644 --- a/src/base/QXmppFileShare.cpp +++ b/src/base/QXmppFileShare.cpp @@ -5,6 +5,7 @@ #include "QXmppFileShare.h" #include "QXmppConstants_p.h" +#include "QXmppEncryptedFileSource.h" #include "QXmppFileMetadata.h" #include "QXmppHttpFileSource.h" @@ -44,6 +45,7 @@ class QXmppFileSharePrivate : public QSharedData public: QXmppFileMetadata metadata; QVector<QXmppHttpFileSource> httpSources; + QVector<QXmppEncryptedFileSource> encryptedSources; QXmppFileShare::Disposition disposition = Disposition::Inline; }; /// \endcond @@ -110,6 +112,18 @@ void QXmppFileShare::setHttpSources(const QVector<QXmppHttpFileSource> &newHttpS d->httpSources = newHttpSources; } +/// Returns the encrypted sources for this file. +const QVector<QXmppEncryptedFileSource> &QXmppFileShare::encryptedSources() const +{ + return d->encryptedSources; +} + +/// Sets the encrypted sources for this file. +void QXmppFileShare::setEncryptedSourecs(const QVector<QXmppEncryptedFileSource> &newEncryptedSources) +{ + d->encryptedSources = newEncryptedSources; +} + /// \cond bool QXmppFileShare::parse(const QDomElement &el) { @@ -128,12 +142,19 @@ bool QXmppFileShare::parse(const QDomElement &el) // sources: // expect that there's only one sources element with the correct namespace auto sources = el.firstChildElement("sources"); - for (auto urlEl = sources.firstChildElement("url-data"); - !urlEl.isNull(); - urlEl = urlEl.nextSiblingElement("url-data")) { - QXmppHttpFileSource source; - if (source.parse(urlEl)) { - d->httpSources.push_back(std::move(source)); + for (auto sourceEl = sources.firstChildElement(); + !sourceEl.isNull(); + sourceEl = sourceEl.nextSiblingElement()) { + if (sourceEl.tagName() == QStringLiteral("url-data")) { + QXmppHttpFileSource source; + if (source.parse(sourceEl)) { + d->httpSources.push_back(std::move(source)); + } + } else if (sourceEl.tagName() == QStringLiteral("encrypted")) { + QXmppEncryptedFileSource source; + if (source.parse(sourceEl)) { + d->encryptedSources.push_back(std::move(source)); + } } } return true; @@ -151,6 +172,9 @@ void QXmppFileShare::toXml(QXmlStreamWriter *writer) const for (const auto &source : d->httpSources) { source.toXml(writer); } + for (const auto &source : d->encryptedSources) { + source.toXml(writer); + } writer->writeEndElement(); writer->writeEndElement(); } |
