QXmpp Version: 1.5.6
Loading...
Searching...
No Matches
QXmppHttpUploadManager.h
1// SPDX-FileCopyrightText: 2022 Linus Jahn <lnj@kaidan.im>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#ifndef QXMPPHTTPUPLOADMANAGER_H
6#define QXMPPHTTPUPLOADMANAGER_H
7
8#include "QXmppClientExtension.h"
9#include "QXmppError.h"
10
11#include <variant>
12
13#include <QUrl>
14
15class QFileInfo;
16class QNetworkAccessManager;
17struct QXmppHttpUploadPrivate;
18struct QXmppHttpUploadManagerPrivate;
19
20class QXMPP_EXPORT QXmppHttpUpload : public QObject
21{
22 Q_OBJECT
23 Q_PROPERTY(float progress READ progress NOTIFY progressChanged)
24 Q_PROPERTY(quint64 bytesSent READ bytesSent NOTIFY progressChanged)
25 Q_PROPERTY(quint64 bytesTotal READ bytesTotal NOTIFY progressChanged)
26
27public:
28 using Result = std::variant<QUrl, QXmpp::Cancelled, QXmppError>;
29
31
32 float progress() const;
33 quint64 bytesSent() const;
34 quint64 bytesTotal() const;
35
36 void cancel();
37 bool isFinished() const;
38 std::optional<Result> result() const;
39
40 Q_SIGNAL void progressChanged();
41 Q_SIGNAL void finished(const QXmppHttpUpload::Result &result);
42
43private:
44 friend class QXmppHttpUploadManager;
45
47
48 std::unique_ptr<QXmppHttpUploadPrivate> d;
49};
50
51Q_DECLARE_METATYPE(QXmppHttpUpload::Result);
52
54{
55 Q_OBJECT
56public:
58 explicit QXmppHttpUploadManager(QNetworkAccessManager *netManager);
60
61 std::shared_ptr<QXmppHttpUpload> uploadFile(std::unique_ptr<QIODevice> data, const QString &filename, const QMimeType &mimeType, qint64 fileSize = -1, const QString &uploadServiceJid = {});
62 std::shared_ptr<QXmppHttpUpload> uploadFile(const QFileInfo &fileInfo, const QString &filename = {}, const QString &uploadServiceJid = {});
63
64private:
65 std::unique_ptr<QXmppHttpUploadManagerPrivate> d;
66};
67
68#endif // QXMPPHTTPUPLOADMANAGER_H
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition QXmppClientExtension.h:33
Definition QXmppHttpUploadManager.h:54
Definition QXmppHttpUploadManager.h:21
std::variant< QUrl, QXmpp::Cancelled, QXmppError > Result
Definition QXmppHttpUploadManager.h:28
Definition QXmppError.h:18