QXmpp Version: 1.11.3
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;
25
26namespace QXmpp::Private {
27class XmlWriter;
28}
29
31{
32public:
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
55class QXMPP_EXPORT QXmppFileShare
56{
57public:
59 Inline,
60 Attachment,
61 };
62
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
Represents an encrypted file source for file sharing.
Definition QXmppEncryptedFileSource.h:21
Definition QXmppFileMetadata.h:24
Definition QXmppFileShare.h:56
Disposition
Decides whether to display the file contents (e.g. an image) inline in the chat or as a file.
Definition QXmppFileShare.h:58
Definition QXmppFileSharingManager.h:119
Definition QXmppFileShare.h:31
Provides progress of stateless file sharing uploads.
Definition QXmppFileSharingManager.h:32
Definition QXmppHttpFileSource.h:17
The QXmppMessage class represents an XMPP message.
Definition QXmppMessage.h:64