QXmpp Version: 1.10.0
QXmppUploadRequestManager.h
1// SPDX-FileCopyrightText: 2019 Linus Jahn <lnj@kaidan.im>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#ifndef QXMPPUPLOADREQUESTMANAGER_H
6#define QXMPPUPLOADREQUESTMANAGER_H
7
8#include "QXmppClientExtension.h"
9#include "QXmppError.h"
10
11#include <variant>
12
13#include <QSharedDataPointer>
14
15class QFileInfo;
16template<typename T>
17class QXmppTask;
18class QMimeType;
21class QXmppUploadServicePrivate;
22class QXmppUploadRequestManagerPrivate;
23
29class QXMPP_EXPORT QXmppUploadService
30{
31public:
35
37
38 QString jid() const;
39 void setJid(const QString &jid);
40
41 qint64 sizeLimit() const;
42 void setSizeLimit(qint64 sizeLimit);
43
44private:
45 QSharedDataPointer<QXmppUploadServicePrivate> d;
46};
47
85{
86 Q_OBJECT
87
88public:
91
92 QString requestUploadSlot(const QFileInfo &file,
93 const QString &uploadService = QString());
94 QString requestUploadSlot(const QFileInfo &file,
95 const QString &customFileName,
96 const QString &uploadService = QString());
97 QString requestUploadSlot(const QString &fileName,
98 qint64 fileSize,
99 const QMimeType &mimeType,
100 const QString &uploadService = QString());
101
102 using SlotResult = std::variant<QXmppHttpUploadSlotIq, QXmppError>;
103 QXmppTask<SlotResult> requestSlot(const QFileInfo &file,
104 const QString &uploadService = {});
105 QXmppTask<SlotResult> requestSlot(const QFileInfo &file,
106 const QString &customFileName,
107 const QString &uploadService = {});
108 QXmppTask<SlotResult> requestSlot(const QString &fileName,
109 qint64 fileSize,
110 const QMimeType &mimeType,
111 const QString &uploadService = {});
112
113 bool serviceFound() const;
114
115 QVector<QXmppUploadService> uploadServices() const;
116
117 bool handleStanza(const QDomElement &stanza) override;
118
119Q_SIGNALS:
122
127
130
131protected:
132 void onRegistered(QXmppClient *client) override;
133 void onUnregistered(QXmppClient *client) override;
134
135private:
136 void handleDiscoInfo(const QXmppDiscoveryIq &iq);
137
138 const std::unique_ptr<QXmppUploadRequestManagerPrivate> d;
139};
140
141#endif // QXMPPUPLOADREQUESTMANAGER_H
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition: QXmppClientExtension.h:32
Main class for starting and managing connections to XMPP servers.
Definition: QXmppClient.h:62
Definition: QXmppDiscoveryIq.h:18
Represents an HTTP File Upload IQ for requesting an upload slot as defined by XEP-0363: HTTP File Upl...
Definition: QXmppHttpUploadIq.h:27
Represents an HTTP File Upload IQ result for receiving an upload slot as defined by XEP-0363: HTTP Fi...
Definition: QXmppHttpUploadIq.h:67
Definition: QXmppTask.h:62
The QXmppUploadRequestManager implements the core of XEP-0369: HTTP File Upload.
Definition: QXmppUploadRequestManager.h:85
std::variant< QXmppHttpUploadSlotIq, QXmppError > SlotResult
Definition: QXmppUploadRequestManager.h:102
void requestFailed(const QXmppHttpUploadRequestIq &request)
void serviceFoundChanged()
Emitted when the first upload service has been found.
void slotReceived(const QXmppHttpUploadSlotIq &slot)
Emitted when an upload slot was received.
QXmppUploadService represents an HTTP File Upload service.
Definition: QXmppUploadRequestManager.h:30
QXmppUploadService(const QXmppUploadService &)
Copy constructor.
QXmppUploadService & operator=(const QXmppUploadService &)
Equal operator.