QXmppUploadRequestManager Class
The QXmppUploadRequestManager implements the core of XEP-0363: HTTP File Upload. More...
| Header: | #include <QXmppUploadRequestManager.h> |
| Since: | QXmpp 1.1 |
| Inherits: | QXmppClientExtension |
- List of all members, including inherited members
- QXmppUploadRequestManager is part of Managers.
Public Types
(since QXmpp 1.5) | SlotResult |
Public Functions
(since QXmpp 1.5) QXmppTask<QXmppUploadRequestManager::SlotResult> | requestSlot(const QFileInfo &file, const QString &uploadService = {}) |
(since QXmpp 1.5) QXmppTask<QXmppUploadRequestManager::SlotResult> | requestSlot(const QFileInfo &file, const QString &customFileName, const QString &uploadService = {}) |
(since QXmpp 1.5) QXmppTask<QXmppUploadRequestManager::SlotResult> | requestSlot(const QString &fileName, qint64 fileSize, const QMimeType &mimeType, const QString &uploadService = {}) |
| 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()) |
| bool | serviceFound() const |
| QList<QXmppUploadService> | uploadServices() const |
Signals
| void | requestFailed(const QXmppHttpUploadRequestIq &request) |
| void | serviceFoundChanged() |
| void | slotReceived(const QXmppHttpUploadSlotIq &slot) |
Detailed Description
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:
auto *manager = new QXmppUploadRequestManager;
client->addExtension(manager);
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.
Member Type Documentation
[alias, since QXmpp 1.5] QXmppUploadRequestManager::SlotResult
Contains the requested upload slot from the service or a QXmppStanza::Error in case the request failed.
This typedef was introduced in QXmpp 1.5.
Member Function Documentation
[signal] void QXmppUploadRequestManager::requestFailed(const QXmppHttpUploadRequestIq &request)
Emitted when the slot request failed.
request is the sent IQ with a QXmppStanza::Error from the server.
[since QXmpp 1.5] QXmppTask<QXmppUploadRequestManager::SlotResult> QXmppUploadRequestManager::requestSlot(const QFileInfo &file, const QString &uploadService = {})
Requests an upload slot from the server.
file is the info of the file to be uploaded. uploadService is the HTTP File Upload service that is used to request the upload slot. If this is empty, the first discovered one is used.
This function was introduced in QXmpp 1.5.
[since QXmpp 1.5] QXmppTask<QXmppUploadRequestManager::SlotResult> QXmppUploadRequestManager::requestSlot(const QFileInfo &file, const QString &customFileName, const QString &uploadService = {})
Requests an upload slot from the server.
file is the info of the file to be uploaded. customFileName is used instead of the file's actual name for requesting the upload slot. uploadService is the HTTP File Upload service that is used to request the upload slot. If this is empty, the first discovered one is used.
This function was introduced in QXmpp 1.5.
[since QXmpp 1.5] QXmppTask<QXmppUploadRequestManager::SlotResult> QXmppUploadRequestManager::requestSlot(const QString &fileName, qint64 fileSize, const QMimeType &mimeType, const QString &uploadService = {})
Requests an upload slot from the server.
fileName is the name of the file to be uploaded. This may be used by the server to generate the URL. fileSize is the size of the file to be uploaded. The server may reject too large files. mimeType is the content-type of the file. This can be used by the server to set the HTTP MIME-type of the URL. uploadService is the HTTP File Upload service that is used to request the upload slot. If this is empty, the first discovered one is used.
This function was introduced in QXmpp 1.5.
QString QXmppUploadRequestManager::requestUploadSlot(const QFileInfo &file, const QString &uploadService = QString())
Requests an upload slot from the server.
file is the info of the file to be uploaded. uploadService is the HTTP File Upload service that is used to request the upload slot. If this is empty, the first discovered one is used.
Returns the id of the sent IQ. If sendPacket() isn't successful or no upload service has been discovered yet, an empty string will be returned.
QString QXmppUploadRequestManager::requestUploadSlot(const QFileInfo &file, const QString &customFileName, const QString &uploadService = QString())
Requests an upload slot from the server.
file is the info of the file to be uploaded. customFileName is used instead of the file's actual name for requesting the upload slot. uploadService is the HTTP File Upload service that is used to request the upload slot. If this is empty, the first discovered one is used.
Returns the id of the sent IQ. If sendPacket() isn't successful or no upload service has been discovered yet, an empty string will be returned.
QString QXmppUploadRequestManager::requestUploadSlot(const QString &fileName, qint64 fileSize, const QMimeType &mimeType, const QString &uploadService = QString())
Requests an upload slot from the server.
fileName is the name of the file to be uploaded. This may be used by the server to generate the URL. fileSize is the size of the file to be uploaded. The server may reject too large files. mimeType is the content-type of the file. This can be used by the server to set the HTTP MIME-type of the URL. uploadService is the HTTP File Upload service that is used to request the upload slot. If this is empty, the first discovered one is used.
Returns the id of the sent IQ. If sendPacket() isn't successful or no upload service has been discovered yet, an empty string will be returned.
bool QXmppUploadRequestManager::serviceFound() const
Returns true if an HTTP File Upload service has been discovered.
[signal] void QXmppUploadRequestManager::serviceFoundChanged()
Emitted when the first upload service has been found.
[signal] void QXmppUploadRequestManager::slotReceived(const QXmppHttpUploadSlotIq &slot)
Emitted when an upload slot was received.
QList<QXmppUploadService> QXmppUploadRequestManager::uploadServices() const
Returns all discovered HTTP File Upload services.