QXmppFileSharingManager Class

Header: #include <QXmppFileSharingManager>
Since: QXmpp 1.5
Inherits: QXmppClientExtension

Public Types

Public Functions

std::shared_ptr<QXmppFileDownload> downloadFile(const QXmppFileShare &fileShare, std::unique_ptr<QIODevice> output)
void setMetadataGenerator(QXmppFileSharingManager::MetadataGenerator &&generator)
std::shared_ptr<QXmppFileUpload> uploadFile(std::shared_ptr<QXmppFileSharingProvider> provider, const QString &filePath, const std::optional<QString> &description = {})

Detailed Description

The file sharing manager allows to easily send and retrieve files in a chat.

Member Type Documentation

[alias] QXmppFileSharingManager::MetadataGenerator

The function signature of a metadata generator function

generator.

Member Function Documentation

std::shared_ptr<QXmppFileDownload> QXmppFileSharingManager::downloadFile(const QXmppFileShare &fileShare, std::unique_ptr<QIODevice> output)

Download a file from a QXmppFileShare

Warning: This function currently does not check the hash of the downloaded file.

Make sure to register the provider that handles the sources used in this file share before calling this function.

fileShare is the file share object which you want to download. output is an open QIODevice that the data should be written into, in most cases a QFile.

Returns an object that allows to track the progress of the download.

void QXmppFileSharingManager::setMetadataGenerator(QXmppFileSharingManager::MetadataGenerator &&generator)

Register a function that is called when metadata needs to be gererated for a file.

The function is passed a QIODevice, so if you need the path of the file on disk, you can dynamically cast it to a QFile and access the fileName. When doing that, make sure to check the result, as in the future this function might be passed other QIODevices than QFile.

generator.

std::shared_ptr<QXmppFileUpload> QXmppFileSharingManager::uploadFile(std::shared_ptr<QXmppFileSharingProvider> provider, const QString &filePath, const std::optional<QString> &description = {})

Upload a file in a way that it can be attached to a message.

provider is the provider class that decides how the file is uploaded. filePath is the path to a file that should be uploaded. description is an optional description of the file.

Returns an object that allows to track the progress of the upload. Once the upload is finished, the finished signal is emitted on it.