QXmpp Version: 1.5.6
|
The QXmppUploadRequestManager implements the core of XEP-0369: HTTP File Upload. More...
#include <QXmppUploadRequestManager.h>
Public Types | |
using | SlotResult = std::variant< QXmppHttpUploadSlotIq, QXmppError > |
Signals | |
void | slotReceived (const QXmppHttpUploadSlotIq &slot) |
Emitted when an upload slot was received. | |
void | requestFailed (const QXmppHttpUploadRequestIq &request) |
void | serviceFoundChanged () |
Emitted when the first upload service has been found. | |
Signals inherited from QXmppLoggable | |
void | setGauge (const QString &gauge, double value) |
Sets the given gauge to value. | |
void | logMessage (QXmppLogger::MessageType type, const QString &msg) |
This signal is emitted to send logging messages. | |
void | updateCounter (const QString &counter, qint64 amount=1) |
Updates the given counter by amount. | |
Public Member Functions | |
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()) |
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 |
Returns true if an HTTP File Upload service has been discovered. | |
QVector< QXmppUploadService > | uploadServices () const |
Returns all discovered HTTP File Upload services. | |
bool | handleStanza (const QDomElement &stanza) override |
You need to implement this method to process incoming XMPP stanzas. | |
Public Member Functions inherited from QXmppClientExtension | |
QXmppClientExtension () | |
virtual QStringList | discoveryFeatures () const |
virtual QList< QXmppDiscoveryIq::Identity > | discoveryIdentities () const |
virtual bool | handleStanza (const QDomElement &stanza, const std::optional< QXmppE2eeMetadata > &e2eeMetadata) |
You need to implement this method to process incoming XMPP stanzas. | |
Public Member Functions inherited from QXmppLoggable | |
QXmppLoggable (QObject *parent=nullptr) | |
Protected Member Functions | |
void | setClient (QXmppClient *client) override |
Protected Member Functions inherited from QXmppClientExtension | |
QXmppClient * | client () |
void | injectIq (const QDomElement &element, const std::optional< QXmppE2eeMetadata > &e2eeMetadata) |
bool | injectMessage (QXmppMessage &&message) |
Protected Member Functions inherited from QXmppLoggable | |
void | debug (const QString &message) |
void | info (const QString &message) |
void | warning (const QString &message) |
void | logReceived (const QString &message) |
void | logSent (const QString &message) |
The QXmppUploadRequestManager implements the core of XEP-0369: HTTP File Upload.
It handles the discovery of QXmppUploadServices and can send upload requests and outputs the upload slots. It doesn't do the actual upload via. HTTP.
To make use of this manager, you need to instantiate it and load it into the QXmppClient instance as follows:
Apart from that, you also need to discover HTTP File Upload service(s) by requesting the Service Discovery info for each Service Discovery item of the server. The QXmppUploadManager will then automatically recognize upload services and add them to the list of discovered services uploadServices()
.
Keep in mind that theoretically any XMPP entity could promote to be an upload service and so is recognized by this manager. A potential attacker could exploit this vulnerability, so the client could be uploading files to the attacker (e.g. a normal user JID) instead of the own server.
As soon as at least one upload service has been discovered, you can start to request upload slots by using requestUploadSlot()
. Alternatively you can provide the JID of the upload service which should be used for uploading.
Contains the requested upload slot from the service or a QXmppStanza::Error in case the request failed.
|
overridevirtual |
You need to implement this method to process incoming XMPP stanzas.
You should return true if the stanza was handled and no further processing should occur, or false to let other extensions process the stanza.
End-to-end encrypted stanzas are not passed to this overload, for that purpose use the new overload instead.
Reimplemented from QXmppClientExtension.
|
signal |
Emitted when the slot request failed.
request | The sent IQ with an QXmppStanza::Error from the server. |
auto QXmppUploadRequestManager::requestSlot | ( | const QFileInfo & | file, |
const QString & | customFileName, | ||
const QString & | uploadService = {} |
||
) |
Requests an upload slot from the server.
file | The info of the file to be uploaded. |
customFileName | This name is used instead of the file's actual name for requesting the upload slot. |
uploadService | The HTTP File Upload service that is used to request the upload slot. If this is empty, the first discovered one is used. |
auto QXmppUploadRequestManager::requestSlot | ( | const QFileInfo & | file, |
const QString & | uploadService = {} |
||
) |
Requests an upload slot from the server.
file | The info of the file to be uploaded. |
uploadService | The HTTP File Upload service that is used to request the upload slot. If this is empty, the first discovered one is used. |
auto QXmppUploadRequestManager::requestSlot | ( | const QString & | fileName, |
qint64 | fileSize, | ||
const QMimeType & | mimeType, | ||
const QString & | uploadService = {} |
||
) |
Requests an upload slot from the server.
fileName | The name of the file to be uploaded. This may be used by the server to generate the URL. |
fileSize | The size of the file to be uploaded. The server may reject too large files. |
mimeType | The content-type of the file. This can be used by the server to set the HTTP MIME-type of the URL. |
uploadService | The HTTP File Upload service that is used to request the upload slot. If this is empty, the first discovered one is used. |
QString QXmppUploadRequestManager::requestUploadSlot | ( | const QFileInfo & | file, |
const QString & | customFileName, | ||
const QString & | uploadService = QString() |
||
) |
Requests an upload slot from the server.
file | The info of the file to be uploaded. |
customFileName | This name is used instead of the file's actual name for requesting the upload slot. |
uploadService | The HTTP File Upload service that is used to request the upload slot. If this is empty, the first discovered one is used. |
QString QXmppUploadRequestManager::requestUploadSlot | ( | const QFileInfo & | file, |
const QString & | uploadService = QString() |
||
) |
Requests an upload slot from the server.
file | The info of the file to be uploaded. |
uploadService | The HTTP File Upload service that is used to request the upload slot. If this is empty, the first discovered one is used. |
QString QXmppUploadRequestManager::requestUploadSlot | ( | const QString & | fileName, |
qint64 | fileSize, | ||
const QMimeType & | mimeType, | ||
const QString & | uploadService = QString() |
||
) |
Requests an upload slot from the server.
fileName | The name of the file to be uploaded. This may be used by the server to generate the URL. |
fileSize | The size of the file to be uploaded. The server may reject too large files. |
mimeType | The content-type of the file. This can be used by the server to set the HTTP MIME-type of the URL. |
uploadService | The HTTP File Upload service that is used to request the upload slot. If this is empty, the first discovered one is used. |
|
overrideprotectedvirtual |
Sets the client which loaded this extension.
client |
Reimplemented from QXmppClientExtension.