Loading...
Searching...
No Matches
QXmppHttpUploadManager Class Reference
Inheritance diagram for QXmppHttpUploadManager:
[legend]
Collaboration diagram for QXmppHttpUploadManager:
[legend]

## Public Types

enum class | Support { Unknown , Unsupported , Supported }

## Public Member Functions

| QXmppHttpUploadManager ()
| QXmppHttpUploadManager (QNetworkAccessManager *netManager)
QVector< QXmppHttpUploadService > | services () const
Q_SIGNAL void | servicesChanged ()
| Emitted when services have changed.
Support | support () const
Q_SIGNAL void | supportChanged ()
| Emitted when support has changed.
std::shared_ptr< QXmppHttpUpload > | uploadFile (std::unique_ptr< QIODevice > data, const QString &filename, const QMimeType &mimeType, qint64 fileSize=-1, const QString &uploadServiceJid={})
std::shared_ptr< QXmppHttpUpload > | uploadFile (const QFileInfo &fileInfo, const QString &filename={}, const QString &uploadServiceJid={})
Public Member Functions inherited from QXmppClientExtension
| QXmppClientExtension ()
virtual QStringList | discoveryFeatures () const
virtual QList< QXmppDiscoIdentity > | discoveryIdentities () const
virtual bool | handleStanza (const QDomElement &stanza)
| You need to implement this method to process incoming XMPP stanzas.
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)
Q_SIGNAL void | setGauge (const QString &gauge, double value)
| Sets the given gauge to value.
Q_SIGNAL void | logMessage (QXmppLogger::MessageType type, const QString &msg)
| This signal is emitted to send logging messages.
Q_SIGNAL void | updateCounter (const QString &counter, qint64 amount=1)
| Updates the given counter by amount.

## Protected Member Functions

void | onRegistered (QXmppClient *client) override
void | onUnregistered (QXmppClient *client) override
Protected Member Functions inherited from QXmppClientExtension
QXmppClient * | client () const
virtual void | setClient (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)
| Logs a debugging message.
void | info (const QString &message)
| Logs an informational message.
void | warning (const QString &message)
| Logs a warning message.
void | logReceived (const QString &message)
| Logs a received packet.
void | logSent (const QString &message)
| Logs a sent packet.

## Properties

QVector< QXmppHttpUploadService > | services
QXmppHttpUploadManager::Support | support

## Friends

struct | QXmppHttpUploadManagerPrivate

## Detailed Description

The upload manager allows to upload a file to a server via XEP-0363: HTTP File Upload. This can be used for sending files to other users.

QXmppHttpUploadManager depends on QXmppDiscoveryManager.

Since
  QXmpp 1.5

## Member Enumeration Documentation

## Support

enum class QXmppHttpUploadManager::Support

strong

Server support for the feature.

Enumerator
Unknown | Whether the server supports the feature is not known. That means, there is no corresponding information from the server (yet).
Unsupported | The server does not support the feature.

Supported

The server supports the feature.

Since
  QXmpp 1.13

## Constructor & Destructor Documentation

## QXmppHttpUploadManager() [1/2]

QXmppHttpUploadManager::QXmppHttpUploadManager | ( |  | ) |

Constructor

Creates and uses a new network access manager.

## QXmppHttpUploadManager() [2/2]

QXmppHttpUploadManager::QXmppHttpUploadManager | ( | QNetworkAccessManager * | netManager | ) |

explicit

Constructor

Parameters

  netManager | shared network access manager, needs to have at least the lifetime of this manager.

## Member Function Documentation

## onRegistered()

void QXmppHttpUploadManager::onRegistered | ( | QXmppClient * | client | ) |

override protected virtual

Called after the extension has been added to a QXmppClient.

Parameters

  client |

Reimplemented from QXmppClientExtension.

## onUnregistered()

void QXmppHttpUploadManager::onUnregistered | ( | QXmppClient * | client | ) |

override protected virtual

Called after the extension has been removed from a QXmppClient.

Parameters

  client |

Reimplemented from QXmppClientExtension.

## services()

QVector< QXmppHttpUploadService > QXmppHttpUploadManager::services | ( |  | ) | const

Returns all discovered HTTP File Upload services.

Since
  QXmpp 1.13

## support()

QXmppHttpUploadManager::Support QXmppHttpUploadManager::support | ( |  | ) | const

Returns the server's support for upload services.

Since
  QXmpp 1.13

## uploadFile() [1/2]

std::shared_ptr< QXmppHttpUpload > QXmppHttpUploadManager::uploadFile | ( | const QFileInfo & | fileInfo,
|  | const QString & | filename = {},
|  | const QString & | uploadServiceJid = {} )

Upload data from a local file.

Parameters

  fileInfo | QFileInfo about a local file
  filename | filename How the file on the server should be called. This is commonly used as last part of the resulting url.
  uploadServiceJid | optionally, the jid from which an upload url can be requested (upload service)

Returns
  an object representing the ongoing upload. The object is passed as a shared_ptr, which means it will be stored as long as there is a reference to it. While this avoids errors from accessing it after it was deleted, you should try not store it unneccesarily long to keep the memory usage down. You can for example use std::weak_ptr to not increase the lifetime, for example when capturing in long living lambdas, for example in connects. You should also make sure to use the 4-arg QObject::connect, so the connection and the connected lambda can be deleted after the upload finished.
  std::weak_ptr<QXmppHttpUpload> uploadPtr = upload;
  connect(upload.get(), &QXmppHttpUpload::progressChanged, this, [uploadPtr]() {
  auto upload = uploadPtr.lock();
  if (upload) {
  qDebug() << upload->progress();
  }
  });
  QXmppHttpUpload::progressChanged
  Q_SIGNAL void progressChanged()

## uploadFile() [2/2]

std::shared_ptr< QXmppHttpUpload > QXmppHttpUploadManager::uploadFile | ( | std::unique_ptr< QIODevice > | data,
|  | const QString & | filename,
|  | const QMimeType & | mimeType,
|  | qint64 | fileSize = -1,
|  | const QString & | uploadServiceJid = {} )

Uploads the data from a QIODevice.

Parameters

  data | QIODevice to read the data from. This can for example be a QFile. It can be sequential or non-sequential.
  filename | How the file on the server should be called. This is commonly used as last part of the resulting url.
  fileSize | The size of the file, in byte. If negative the size from the IO device is used.
  mimeType | The mime type of the file
  uploadServiceJid | optionally, the jid from which an upload url can be requested (upload service)

Returns
  an object representing the ongoing upload. The object is passed as a shared_ptr, which means it will be stored as long as there is a reference to it. While this avoids errors from accessing it after it was deleted, you should try not store it unneccesarily long to keep the memory usage down. You can for example use std::weak_ptr to not increase the lifetime, for example when capturing in long living lambdas, for example in connects. You should also make sure to use the 4-arg QObject::connect, so the connection and the connected lambda can be deleted after the upload finished.
  std::weak_ptr<QXmppHttpUpload> uploadPtr = upload;
  connect(upload.get(), &QXmppHttpUpload::progressChanged, this, [uploadPtr]() {
  auto upload = uploadPtr.lock();
  if (upload) {
  qDebug() << upload->progress();
  }
  });

## Property Documentation

## services

QVector<QXmppHttpUploadService> QXmppHttpUploadManager::services

read

See also
  QXmppHttpUploadManager::services()

Since
  QXmpp 1.13

## support

QXmppHttpUploadManager::Support QXmppHttpUploadManager::support

read

See also
  QXmppHttpUploadManager::support()

Since
  QXmpp 1.13

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

- QXmppHttpUploadManager.h
- QXmppHttpUploadManager.cpp