QXmpp Version: 1.10.0
Public Types | Public Member Functions | Friends | List of all members
QXmppFileSharingManager Class Reference
Inheritance diagram for QXmppFileSharingManager:
Inheritance graph
[legend]
Collaboration diagram for QXmppFileSharingManager:
Collaboration graph
[legend]

Public Types

using MetadataGenerator = std::function< QFuture< std::shared_ptr< MetadataGeneratorResult > >(std::unique_ptr< QIODevice >)>
 

Public Member Functions

void setMetadataGenerator (MetadataGenerator &&generator)
 Register a function that is called when metadata needs to be gererated for a file. More...
 
template<typename ProviderType >
void registerProvider (std::shared_ptr< ProviderType > manager)
 Register a provider for automatic downloads. More...
 
std::shared_ptr< QXmppFileUploaduploadFile (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. More...
 
std::shared_ptr< QXmppFileDownloaddownloadFile (const QXmppFileShare &fileShare, std::unique_ptr< QIODevice > output)
 Download a file from a QXmppFileShare. More...
 
- Public Member Functions inherited from QXmppClientExtension
 QXmppClientExtension ()
 
virtual QStringList discoveryFeatures () const
 
virtual QList< QXmppDiscoveryIq::IdentitydiscoveryIdentities () const
 
virtual bool handleStanza (const QDomElement &stanza)
 You need to implement this method to process incoming XMPP stanzas. More...
 
virtual bool handleStanza (const QDomElement &stanza, const std::optional< QXmppE2eeMetadata > &e2eeMetadata)
 You need to implement this method to process incoming XMPP stanzas. More...
 
- Public Member Functions inherited from QXmppLoggable
 QXmppLoggable (QObject *parent=nullptr)
 

Friends

class QXmppEncryptedFileSharingProvider
 

Additional Inherited Members

- 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.
 
- Protected Member Functions inherited from QXmppClientExtension
QXmppClientclient () const
 
virtual void setClient (QXmppClient *client)
 
virtual void onRegistered (QXmppClient *client)
 
virtual void onUnregistered (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)
 

Detailed Description

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

Since
QXmpp 1.5

Member Typedef Documentation

◆ MetadataGenerator

The function signature of a metadata generator function

Member Function Documentation

◆ downloadFile()

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.

Parameters
fileShareThe file share object which you want to download
outputAn 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.

◆ registerProvider()

template<typename ProviderType >
void QXmppFileSharingManager::registerProvider ( std::shared_ptr< ProviderType >  manager)
inline

Register a provider for automatic downloads.

Parameters
managerA shared_ptr to a QXmppFileSharingProvider subclass The provider must define SourceType to the type of the accepted file source.

◆ setMetadataGenerator()

void QXmppFileSharingManager::setMetadataGenerator ( 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.

◆ uploadFile()

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.

Parameters
providerThe provider class decides how the file is uploaded
filePathPath to a file that should be uploaded
descriptionOptional 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.

The documentation for this class was generated from the following files: