QXmpp Version: 1.10.0
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 "QXmppGlobal.h"
9
10#include <any>
11#include <functional>
12#include <optional>
13
14#include <QSharedDataPointer>
15
16class QDomElement;
17class QUrl;
18class QXmlStreamWriter;
19class QXmppFileSourcesAttachmentPrivate;
20class QXmppFileSharePrivate;
24
26{
27public:
29 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppFileSourcesAttachment)
30
31 const QString &id() const;
32 void setId(const QString &);
33
34 const QVector<QXmppHttpFileSource> &httpSources() const;
35 void setHttpSources(const QVector<QXmppHttpFileSource> &newHttpSources);
36
37 const QVector<QXmppEncryptedFileSource> &encryptedSources() const;
38 void setEncryptedSources(const QVector<QXmppEncryptedFileSource> &newEncryptedSources);
39
40private:
41 friend class QXmppMessage;
42
43 static std::optional<QXmppFileSourcesAttachment> fromDom(const QDomElement &el);
44 void toXml(QXmlStreamWriter *writer) const;
45
46 QSharedDataPointer<QXmppFileSourcesAttachmentPrivate> d;
47};
48
49class QXMPP_EXPORT QXmppFileShare
50{
51public:
53 Inline,
54 Attachment,
55 };
56
58 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppFileShare)
59
60 Disposition disposition() const;
61 void setDisposition(Disposition);
62
63 const QString &id() const;
64 void setId(const QString &);
65
66 const QXmppFileMetadata &metadata() const;
67 void setMetadata(const QXmppFileMetadata &);
68
69 const QVector<QXmppHttpFileSource> &httpSources() const;
70 void setHttpSources(const QVector<QXmppHttpFileSource> &newHttpSources);
71
72 const QVector<QXmppEncryptedFileSource> &encryptedSources() const;
73 void setEncryptedSourecs(const QVector<QXmppEncryptedFileSource> &newEncryptedSources);
74
76 bool parse(const QDomElement &el);
77 void toXml(QXmlStreamWriter *writer) const;
78
79protected:
80 friend class QXmppFileSharingManager;
81 friend class QXmppFileUpload;
82
83 // Private, internally used API:
84 void visitSources(std::function<bool(const std::any &)> &&visitor) const;
85 void addSource(const std::any &source);
87
88private:
89 QSharedDataPointer<QXmppFileSharePrivate> d;
90};
91
92#endif // QXMPPFILESHARE_H
Represents an encrypted file source for file sharing.
Definition: QXmppEncryptedFileSource.h:21
Definition: QXmppFileMetadata.h:24
Definition: QXmppFileShare.h:50
Disposition
Decides whether to display the file contents (e.g. an image) inline in the chat or as a file.
Definition: QXmppFileShare.h:52
Definition: QXmppFileSharingManager.h:119
Definition: QXmppFileShare.h:26
Provides progress of stateless file sharing uploads.
Definition: QXmppFileSharingManager.h:32
Definition: QXmppHttpFileSource.h:16
The QXmppMessage class represents an XMPP message.
Definition: QXmppMessage.h:64
virtual void toXml(QXmlStreamWriter *writer) const =0