Loading...
Searching...
No Matches
QXmppFileShare.h
// SPDX-FileCopyrightText: 2022 Linus Jahn <lnj@kaidan.im>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#ifndef QXMPPFILESHARE_H
#define QXMPPFILESHARE_H
#include "QXmppConstants_p.h"
#include "QXmppGlobal.h"
#include <any>
#include <functional>
#include <optional>
#include <QSharedDataPointer>
class QDomElement;
class QUrl;
class QXmlStreamWriter;
class QXmppFileSourcesAttachmentPrivate;
class QXmppFileSharePrivate;
class QXmppFileMetadata;
class QXmppHttpFileSource;
class QXmppEncryptedFileSource;
namespace QXmpp::Private {
class XmlWriter;
}
class QXMPP_EXPORT QXmppFileSourcesAttachment
{
public:
QXmppFileSourcesAttachment();
QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppFileSourcesAttachment)
const QString &id() const;
void setId(const QString &);
const QVector<QXmppHttpFileSource> &httpSources() const;
void setHttpSources(const QVector<QXmppHttpFileSource> &newHttpSources);
const QVector<QXmppEncryptedFileSource> &encryptedSources() const;
void setEncryptedSources(const QVector<QXmppEncryptedFileSource> &newEncryptedSources);
void toXml(QXmpp::Private::XmlWriter &writer) const;
private:
friend class QXmppMessage;
static std::optional<QXmppFileSourcesAttachment> fromDom(const QDomElement &el);
QSharedDataPointer<QXmppFileSourcesAttachmentPrivate> d;
};
class QXMPP_EXPORT QXmppFileShare
{
public:
enum Disposition {
Inline,
Attachment,
};
QXmppFileShare();
QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppFileShare)
Disposition disposition() const;
void setDisposition(Disposition);
const QString &id() const;
void setId(const QString &);
const QXmppFileMetadata &metadata() const;
void setMetadata(const QXmppFileMetadata &);
const QVector<QXmppHttpFileSource> &httpSources() const;
void setHttpSources(const QVector<QXmppHttpFileSource> &newHttpSources);
const QVector<QXmppEncryptedFileSource> &encryptedSources() const;
void setEncryptedSourecs(const QVector<QXmppEncryptedFileSource> &newEncryptedSources);
static constexpr std::tuple XmlTag = { u"file-sharing", QXmpp::Private::ns_sfs };
bool parse(const QDomElement &el);
void toXml(QXmlStreamWriter *writer) const;
protected:
friend class QXmppFileSharingManager;
friend class QXmppFileUpload;
// Private, internally used API:
void visitSources(std::function<bool(const std::any &)> &&visitor) const;
void addSource(const std::any &source);
private:
QSharedDataPointer<QXmppFileSharePrivate> d;
};
#endif // QXMPPFILESHARE_H
QXmppEncryptedFileSource
Represents an encrypted file source for file sharing.
Definition QXmppEncryptedFileSource.h:21
QXmppFileMetadata
Definition QXmppFileMetadata.h:24
QXmppFileShare
Definition QXmppFileShare.h:56
QXmppFileShare::Disposition
Disposition
Decides whether to display the file contents (e.g. an image) inline in the chat or as a file.
Definition QXmppFileShare.h:58
QXmppFileShare::QXmppFileShare
QXmppFileShare()
Default constructor.
Definition QXmppFileShare.cpp:182
QXmppFileSourcesAttachment::QXmppFileSourcesAttachment
QXmppFileSourcesAttachment()
Default constructor.
Definition QXmppFileShare.cpp:78
QXmppFileSourcesAttachment::setHttpSources
void setHttpSources(const QVector< QXmppHttpFileSource > &newHttpSources)
Definition QXmppFileShare.cpp:112
QXmppFileSourcesAttachment::setId
void setId(const QString &)
Definition QXmppFileShare.cpp:96
QXmppFileSourcesAttachment::setEncryptedSources
void setEncryptedSources(const QVector< QXmppEncryptedFileSource > &newEncryptedSources)
Definition QXmppFileShare.cpp:128
QXmppFileSourcesAttachment::toXml
void toXml(QXmpp::Private::XmlWriter &writer) const
Serialize to XML.
Definition QXmppFileShare.cpp:145
QXmppFileSourcesAttachment::httpSources
const QVector< QXmppHttpFileSource > & httpSources() const
Definition QXmppFileShare.cpp:104
QXmppFileSourcesAttachment::id
const QString & id() const
Definition QXmppFileShare.cpp:88
QXmppFileSourcesAttachment::encryptedSources
const QVector< QXmppEncryptedFileSource > & encryptedSources() const
Definition QXmppFileShare.cpp:120
QXmppHttpFileSource
Definition QXmppHttpFileSource.h:17