Loading...
Searching...
No Matches
QXmppUploadRequestManager.h
// SPDX-FileCopyrightText: 2019 Linus Jahn <lnj@kaidan.im>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#ifndef QXMPPUPLOADREQUESTMANAGER_H
#define QXMPPUPLOADREQUESTMANAGER_H
#include "QXmppClientExtension.h"
#include "QXmppError.h"
#include <variant>
#include <QSharedDataPointer>
class QFileInfo;
template<typename T>
class QXmppTask;
class QMimeType;
class QXmppHttpUploadRequestIq;
class QXmppHttpUploadSlotIq;
class QXmppUploadServicePrivate;
class QXmppUploadRequestManagerPrivate;
class QXMPP_EXPORT QXmppUploadService
{
public:
QXmppUploadService();
QXmppUploadService(const QXmppUploadService &);
~QXmppUploadService();
QXmppUploadService &operator=(const QXmppUploadService &);
QString jid() const;
void setJid(const QString &jid);
qint64 sizeLimit() const;
void setSizeLimit(qint64 sizeLimit);
private:
QSharedDataPointer<QXmppUploadServicePrivate> d;
};
class QXMPP_EXPORT QXmppUploadRequestManager : public QXmppClientExtension
{
Q_OBJECT
public:
QXmppUploadRequestManager();
~QXmppUploadRequestManager();
QString requestUploadSlot(const QFileInfo &file,
const QString &uploadService = QString());
QString requestUploadSlot(const QFileInfo &file,
const QString &customFileName,
const QString &uploadService = QString());
QString requestUploadSlot(const QString &fileName,
qint64 fileSize,
const QMimeType &mimeType,
const QString &uploadService = QString());
using SlotResult = std::variant<QXmppHttpUploadSlotIq, QXmppError>;
QXmppTask<SlotResult> requestSlot(const QFileInfo &file,
const QString &uploadService = {});
QXmppTask<SlotResult> requestSlot(const QFileInfo &file,
const QString &customFileName,
const QString &uploadService = {});
QXmppTask<SlotResult> requestSlot(const QString &fileName,
qint64 fileSize,
const QMimeType &mimeType,
const QString &uploadService = {});
bool serviceFound() const;
QVector<QXmppUploadService> uploadServices() const;
bool handleStanza(const QDomElement &stanza) override;
Q_SIGNALS:
void slotReceived(const QXmppHttpUploadSlotIq &slot);
void requestFailed(const QXmppHttpUploadRequestIq &request);
void serviceFoundChanged();
protected:
void onRegistered(QXmppClient *client) override;
void onUnregistered(QXmppClient *client) override;
private:
void handleDiscoInfo(const QXmppDiscoveryIq &iq);
const std::unique_ptr<QXmppUploadRequestManagerPrivate> d;
};
#endif // QXMPPUPLOADREQUESTMANAGER_H
QXmppClientExtension
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition QXmppClientExtension.h:32
QXmppClient
Main class for starting and managing connections to XMPP servers.
Definition QXmppClient.h:62
QXmppDiscoveryIq
Definition QXmppDiscoveryIq.h:18
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:67
QXmppTask
Definition QXmppTask.h:62
QXmppUploadRequestManager
The QXmppUploadRequestManager implements the core of XEP-0369: HTTP File Upload.
Definition QXmppUploadRequestManager.h:85
QXmppUploadRequestManager::SlotResult
std::variant< QXmppHttpUploadSlotIq, QXmppError > SlotResult
Definition QXmppUploadRequestManager.h:102
QXmppUploadRequestManager::requestFailed
void requestFailed(const QXmppHttpUploadRequestIq &request)
QXmppUploadRequestManager::serviceFoundChanged
void serviceFoundChanged()
Emitted when the first upload service has been found.
QXmppUploadRequestManager::slotReceived
void slotReceived(const QXmppHttpUploadSlotIq &slot)
Emitted when an upload slot was received.
QXmppUploadService
QXmppUploadService represents an HTTP File Upload service.
Definition QXmppUploadRequestManager.h:30
QXmppUploadService::QXmppUploadService
QXmppUploadService(const QXmppUploadService &)
Copy constructor.
QXmppUploadService::operator=
QXmppUploadService & operator=(const QXmppUploadService &)
Equal operator.