QXmpp: QXmppUploadRequestManager.h Source File

QXmpp Version: 1.14.2

Loading...
Searching...
No Matches
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;
19class QXmppHttpUploadRequestIq;
20class QXmppHttpUploadSlotIq;
21class QXmppUploadServicePrivate;
22class QXmppUploadRequestManagerPrivate;
23
29 class QXMPP_EXPORT QXmppUploadService
30{
31public:
32 QXmppUploadService();
33 QXmppUploadService(const QXmppUploadService &);
34 ~QXmppUploadService();
35
36 QXmppUploadService &operator=(const QXmppUploadService &);
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
84 class QXMPP_EXPORT QXmppUploadRequestManager : public QXmppClientExtension
85{
86 Q_OBJECT
87
88public:
89 QXmppUploadRequestManager();
90 ~QXmppUploadRequestManager();
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 auto requestSlot(const QFileInfo &file, const QString &uploadService = {}) -> QXmppTask<SlotResult>;
104 auto requestSlot(const QFileInfo &file, const QString &customFileName, const QString &uploadService = {}) -> QXmppTask<SlotResult>;
105 auto requestSlot(const QString &fileName, qint64 fileSize, const QMimeType &mimeType, const QString &uploadService = {}) -> QXmppTask<SlotResult>;
106
107 bool serviceFound() const;
108
109 QVector<QXmppUploadService> uploadServices() const;
110
111 bool handleStanza(const QDomElement &stanza) override;
112
114 Q_SIGNAL void slotReceived(const QXmppHttpUploadSlotIq &slot);
115
119 Q_SIGNAL void requestFailed(const QXmppHttpUploadRequestIq &request);
120
122 Q_SIGNAL void serviceFoundChanged();
123
124protected:
125 void onRegistered(QXmppClient *client) override;
126 void onUnregistered(QXmppClient *client) override;
127
128private:
129 void handleDiscoInfo(const QXmppDiscoveryIq &iq);
130
131 const std::unique_ptr<QXmppUploadRequestManagerPrivate> d;
132};
133
134#endif // QXMPPUPLOADREQUESTMANAGER_H
QXmppClientExtension::client
QXmppClient * client() const
Definition QXmppClientExtension.cpp:57
QXmppClientExtension::QXmppClientExtension
QXmppClientExtension()
Definition QXmppClientExtension.cpp:12
QXmppDiscoveryIq
Definition QXmppDiscoveryIq.h:200
QXmppHttpUploadRequestIq
Represents an HTTP File Upload IQ for requesting an upload slot as defined by XEP-0363: HTTP File Upl...
Definition QXmppHttpUploadIq.h:27
QXmppHttpUploadSlotIq
Represents an HTTP File Upload IQ result for receiving an upload slot as defined by XEP-0363: HTTP Fi...
Definition QXmppHttpUploadIq.h:69
QXmppTask
Definition QXmppTask.h:46
QXmppUploadRequestManager::requestFailed
Q_SIGNAL void requestFailed(const QXmppHttpUploadRequestIq &request)
QXmppUploadRequestManager::onRegistered
void onRegistered(QXmppClient *client) override
Definition QXmppUploadRequestManager.cpp:309
QXmppUploadRequestManager::requestUploadSlot
QString requestUploadSlot(const QFileInfo &file, const QString &uploadService=QString())
Definition QXmppUploadRequestManager.cpp:109
QXmppUploadRequestManager::serviceFoundChanged
Q_SIGNAL void serviceFoundChanged()
Emitted when the first upload service has been found.
QXmppUploadRequestManager::requestSlot
auto requestSlot(const QFileInfo &file, const QString &uploadService={}) -> QXmppTask< SlotResult >
Definition QXmppUploadRequestManager.cpp:186
QXmppUploadRequestManager::onUnregistered
void onUnregistered(QXmppClient *client) override
Definition QXmppUploadRequestManager.cpp:329
QXmppUploadRequestManager::SlotResult
std::variant< QXmppHttpUploadSlotIq, QXmppError > SlotResult
Definition QXmppUploadRequestManager.h:102
QXmppUploadRequestManager::slotReceived
Q_SIGNAL void slotReceived(const QXmppHttpUploadSlotIq &slot)
Emitted when an upload slot was received.
QXmppUploadService::QXmppUploadService
QXmppUploadService(const QXmppUploadService &)
Copy constructor.
QXmppUploadService::operator=
QXmppUploadService & operator=(const QXmppUploadService &)
Equal operator.
QXmppUploadService::setJid
void setJid(const QString &jid)
Sets the JID of the HTTP File Upload service.
Definition QXmppUploadRequestManager.cpp:53
QXmppUploadService::setSizeLimit
void setSizeLimit(qint64 sizeLimit)
Sets the size limit of files that can be uploaded to this upload service.
Definition QXmppUploadRequestManager.cpp:71
QXmppUploadService::sizeLimit
qint64 sizeLimit() const
Definition QXmppUploadRequestManager.cpp:65
QXmppUploadService::jid
QString jid() const
Returns the JID of the HTTP File Upload service.
Definition QXmppUploadRequestManager.cpp:47