QXmppTransferJob Class
The QXmppTransferJob class represents a single file transfer job, as defined by XEP-0096: SI File Transfer. More...
| Header: | #include <QXmppTransferManager.h> |
| Inherits: | QXmppLoggable |
Public Types
| enum | Direction { IncomingDirection, OutgoingDirection } |
| enum | Error { NoError, AbortError, FileAccessError, FileCorruptError, ProtocolError } |
| enum | Method { NoMethod, InBandMethod, SocksMethod, AnyMethod } |
| flags | Methods |
| enum | State { OfferState, StartState, TransferState, FinishedState } |
Properties
|
Public Functions
| QXmppTransferJob::Direction | direction() const |
| QXmppTransferJob::Error | error() const |
| QXmppTransferFileInfo | fileInfo() const |
| QString | fileName() const |
| qint64 | fileSize() const |
| QString | jid() const |
| QUrl | localFileUrl() const |
| QXmppTransferJob::Method | method() const |
| void | setLocalFileUrl(const QUrl &localFileUrl) |
| QString | sid() const |
| qint64 | speed() const |
| QXmppTransferJob::State | state() const |
Public Slots
Signals
| void | error(QXmppTransferJob::Error error) |
| void | finished() |
| void | localFileUrlChanged(const QUrl &localFileUrl) |
| void | progress(qint64 done, qint64 total) |
| void | stateChanged(QXmppTransferJob::State state) |
Detailed Description
See also QXmppTransferManager.
Member Type Documentation
enum QXmppTransferJob::Direction
This enum is used to describe the direction of a transfer job.
| Constant | Value | Description |
|---|---|---|
QXmppTransferJob::IncomingDirection | 0 | The file is being received. |
QXmppTransferJob::OutgoingDirection | 1 | The file is being sent. |
enum QXmppTransferJob::Error
This enum is used to describe the type of error encountered by a transfer job.
| Constant | Value | Description |
|---|---|---|
QXmppTransferJob::NoError | 0 | No error occurred. |
QXmppTransferJob::AbortError | 1 | The file transfer was aborted. |
QXmppTransferJob::FileAccessError | 2 | An error was encountered trying to access a local file. |
QXmppTransferJob::FileCorruptError | 3 | The file is corrupt: the file size or hash do not match. |
QXmppTransferJob::ProtocolError | 4 | An error was encountered in the file transfer protocol. |
enum QXmppTransferJob::Method
flags QXmppTransferJob::Methods
This enum is used to describe a transfer method.
| Constant | Value | Description |
|---|---|---|
QXmppTransferJob::NoMethod | 0 | No transfer method. |
QXmppTransferJob::InBandMethod | 1 | XEP-0047: In-Band Bytestreams |
.
| Constant | Value | Description |
|---|---|---|
QXmppTransferJob::SocksMethod | 2 | XEP-0065: SOCKS5 Bytestreams |
.
| Constant | Value | Description |
|---|---|---|
QXmppTransferJob::AnyMethod | 3 | Any supported transfer method. |
The Methods type is a typedef for QFlags<Method>. It stores an OR combination of Method values.
enum QXmppTransferJob::State
This enum is used to describe the state of a transfer job.
| Constant | Value | Description |
|---|---|---|
QXmppTransferJob::OfferState | 0 | The transfer is being offered to the remote party. |
QXmppTransferJob::StartState | 1 | The transfer is being connected. |
QXmppTransferJob::TransferState | 2 | The transfer is ongoing. |
QXmppTransferJob::FinishedState | 3 | The transfer is finished. |
Property Documentation
[read-only] direction : const Direction
The job's transfer direction
Access functions:
| QXmppTransferJob::Direction | direction() const |
[read-only] fileName : const QString
The name of the file
Access functions:
| QString | fileName() const |
[read-only] fileSize : const qint64
The size of the file
Access functions:
| qint64 | fileSize() const |
[read-only] jid : const QString
The remote party's JID
Access functions:
| QString | jid() const |
localFileUrl : QUrl
The local file URL
Access functions:
| QUrl | localFileUrl() const |
| void | setLocalFileUrl(const QUrl &localFileUrl) |
Notifier signal:
| void | localFileUrlChanged(const QUrl &localFileUrl) |
[read-only] method : const Method
The job's transfer method
Access functions:
| QXmppTransferJob::Method | method() const |
[read-only] state : State
The job's state
Access functions:
| QXmppTransferJob::State | state() const |
Notifier signal:
| void | stateChanged(QXmppTransferJob::State state) |
Member Function Documentation
[slot] void QXmppTransferJob::abort()
Call this method if you wish to abort on ongoing transfer job.
[slot] void QXmppTransferJob::accept(QIODevice *iodevice)
Call this method if you wish to accept an incoming transfer job.
iodevice.
Note: This slot is overloaded. To connect to this slot:
// Connect using qOverload:
connect(sender, &SenderClass::signal,
xmppTransferJob, qOverload(&QXmppTransferJob::accept));
// Or using a lambda as wrapper:
connect(sender, &SenderClass::signal,
xmppTransferJob, [receiver = xmppTransferJob](QIODevice *iodevice) { receiver->accept(iodevice); });
For more examples and approaches, see connecting to overloaded slots.
[slot] void QXmppTransferJob::accept(const QString &filePath)
Call this method if you wish to accept an incoming transfer job.
Note: This slot is overloaded. To connect to this slot:
// Connect using qOverload:
connect(sender, &SenderClass::signal,
xmppTransferJob, qOverload(&QXmppTransferJob::accept));
// Or using a lambda as wrapper:
connect(sender, &SenderClass::signal,
xmppTransferJob, [receiver = xmppTransferJob](const QString &filePath) { receiver->accept(filePath); });
For more examples and approaches, see connecting to overloaded slots.
QXmppTransferJob::Direction QXmppTransferJob::direction() const
Returns the job's transfer direction.
Note: Getter function for property direction.
QXmppTransferJob::Error QXmppTransferJob::error() const
Returns the last error that was encountered.
[signal] void QXmppTransferJob::error(QXmppTransferJob::Error error)
This signal is emitted when an error is encountered while processing the transfer job.
Note: This signal is overloaded. To connect to this signal:
// Connect using qOverload:
connect(xmppTransferJob, qOverload(&QXmppTransferJob::error),
receiver, &ReceiverClass::slot);
// Or using a lambda:
connect(xmppTransferJob, qOverload(&QXmppTransferJob::error),
this, [](QXmppTransferJob::Error error) { /* handle error */ });
For more examples and approaches, see connecting to overloaded signals.
QXmppTransferFileInfo QXmppTransferJob::fileInfo() const
Returns meta-data about the file being transferred.
[signal] void QXmppTransferJob::finished()
This signal is emitted when the transfer job is finished.
You can determine if the job completed successfully by testing whether error() returns QXmppTransferJob::NoError.
Note: Do not delete the job in the slot connected to this signal, instead use deleteLater().
QString QXmppTransferJob::jid() const
Returns the remote party's JID.
Note: Getter function for property jid.
QUrl QXmppTransferJob::localFileUrl() const
Returns the local file URL.
Note: Getter function for property localFileUrl.
See also setLocalFileUrl().
[signal] void QXmppTransferJob::localFileUrlChanged(const QUrl &localFileUrl)
This signal is emitted when the local file URL changes.
localFileUrl.
Note: Notifier signal for property localFileUrl.
QXmppTransferJob::Method QXmppTransferJob::method() const
Returns the job's transfer method.
Note: Getter function for property method.
[signal] void QXmppTransferJob::progress(qint64 done, qint64 total)
This signal is emitted to indicate the progress of this transfer job.
done and total.
void QXmppTransferJob::setLocalFileUrl(const QUrl &localFileUrl)
Sets the local file URL.
Note: You do not need to call this method if you called accept() with a file path.
localFileUrl.
Note: Setter function for property localFileUrl.
See also localFileUrl().
QString QXmppTransferJob::sid() const
Returns the job's session identifier.
qint64 QXmppTransferJob::speed() const
Returns the job's transfer speed in bytes per second.
If the transfer has not started yet or is already finished, returns 0.
QXmppTransferJob::State QXmppTransferJob::state() const
Returns the job's state.
Note: Getter function for property state.
[signal] void QXmppTransferJob::stateChanged(QXmppTransferJob::State state)
This signal is emitted when the transfer job changes state.
Note: Notifier signal for property state.