QXmpp: QXmppFileShare.h Source File

QXmpp Version: 1.14.2

Loading...
Searching...
No Matches
QXmppFileShare.h
1// SPDX-FileCopyrightText: 2022 Linus Jahn <lnj@kaidan.im>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#ifndef QXMPPFILESHARE_H
6#define QXMPPFILESHARE_H
7
8#include "QXmppConstants_p.h"
9#include "QXmppGlobal.h"
10
11#include <any>
12#include <functional>
13#include <optional>
14
15#include <QSharedDataPointer>
16
17class QDomElement;
18class QUrl;
19class QXmlStreamWriter;
20class QXmppFileSourcesAttachmentPrivate;
21class QXmppFileSharePrivate;
22class QXmppFileMetadata;
23class QXmppHttpFileSource;
24class QXmppEncryptedFileSource;
25
26namespace QXmpp::Private {
27class XmlWriter;
28}
29
30 class QXMPP_EXPORT QXmppFileSourcesAttachment
31{
32public:
33 QXmppFileSourcesAttachment();
34 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppFileSourcesAttachment)
35
36 const QString &id() const;
37 void setId(const QString &);
38
39 const QVector<QXmppHttpFileSource> &httpSources() const;
40 void setHttpSources(const QVector<QXmppHttpFileSource> &newHttpSources);
41
42 const QVector<QXmppEncryptedFileSource> &encryptedSources() const;
43 void setEncryptedSources(const QVector<QXmppEncryptedFileSource> &newEncryptedSources);
44
45 void toXml(QXmpp::Private::XmlWriter &writer) const;
46
47private:
48 friend class QXmppMessage;
49
50 static std::optional<QXmppFileSourcesAttachment> fromDom(const QDomElement &el);
51
52 QSharedDataPointer<QXmppFileSourcesAttachmentPrivate> d;
53};
54
55 class QXMPP_EXPORT QXmppFileShare
56{
57public:
58 enum Disposition {
59 Inline,
60 Attachment,
61 };
62
63 QXmppFileShare();
64 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppFileShare)
65
66 Disposition disposition() const;
67 void setDisposition(Disposition);
68
69 const QString &id() const;
70 void setId(const QString &);
71
72 const QXmppFileMetadata &metadata() const;
73 void setMetadata(const QXmppFileMetadata &);
74
75 const QVector<QXmppHttpFileSource> &httpSources() const;
76 void setHttpSources(const QVector<QXmppHttpFileSource> &newHttpSources);
77
78 const QVector<QXmppEncryptedFileSource> &encryptedSources() const;
79 void setEncryptedSourecs(const QVector<QXmppEncryptedFileSource> &newEncryptedSources);
80
82 static constexpr std::tuple XmlTag = { u"file-sharing", QXmpp::Private::ns_sfs };
83 bool parse(const QDomElement &el);
84 void toXml(QXmlStreamWriter *writer) const;
85
86protected:
87 friend class QXmppFileSharingManager;
88 friend class QXmppFileUpload;
89
90 // Private, internally used API:
91 void visitSources(std::function<bool(const std::any &)> &&visitor) const;
92 void addSource(const std::any &source);
94
95private:
96 QSharedDataPointer<QXmppFileSharePrivate> d;
97};
98
99#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