Base class of Channel.Type.FileTransfer channel type.
More...
#include <TelepathyQt/BaseChannel>
Inherits Tp::AbstractChannelInterface.
|
static BaseChannelFileTransferTypePtr | create (const QVariantMap &request) |
|
template<typename BaseChannelFileTransferTypeSubclass > |
static SharedPtr< BaseChannelFileTransferTypeSubclass > | create (const QVariantMap &request) |
|
Base class of Channel.Type.FileTransfer channel type.
Default implementation currently support only IPv4 and IPv6 sockets with localhost access control.
Usage:
- Add FileTransfer to the list of the protocol requestable channel classes.
- Add FileTransfer to the list of the connection requestable channel classes.
- Setup ContactCapabilities interface and ensure that FileTransfer requestable channel class presence matches to actual local (!) and remote contacts capabilities.
- Implement initial FileTransfer channel support in createChannel callback.
- The channel of interest are those with channelType TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER.
- Create BaseChannel and plug BaseChannelFileTransferType interface.
- If transferInterface->direction() is Outgoing, notify the remote side.
- Implement incoming file request handler:
- Properly setup the request details, take care on TargetHandle and InitiatorHandle.
- Call BaseConnection::createChannel() with the details. Do not suppress handler!
- Use remoteProvideFile() to pass the input device and its offset.
- transferredBytes property will be updated automatically on bytes written to the client socket.
- Implement "remote side accepted transfer" handler:
- Use remoteAcceptFile() to pass the requested initial offset and output device.
- Update transferredBytes property on bytes written to the remote side.
Incoming transfer process:
- Connection manager creates not requested channel with ChannelType = TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER and other properties, such as Filename, Size and ContentType.
- The channel initial state is Pending.
- At any time:
- Client calls AcceptFile method to configure the socket and request an initial offset. The implementation calls createSocket(), which should trigger (now or later) a call to setClientSocket() to setup the client socket. socketAddress() method used to return the socket address. This changes the state to Accepted.
- The connection manager calls remoteProvideFile() method to pass the input device and it's offset. The device offset is a number of bytes, already skipped by the device. The interface would skip remaining initialOffset - deviceOffset bytes.
- Client connects to the socket and triggers setClientSocket() call.
- The channel state is Open now.
- If the device is already ready to read, or emit readyRead() signal, the interface reads data from the device and write it to the clientSocket.
- Client socket emit bytesWritten() signal, the interface updates transferredBytes count.
- If transferredBytes == size, then the channel state changes to Completed. Otherwise the interface waits for further data from the device socket.
Outgoing transfer process:
- Client requests a channel with ChannelType = TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER and other properties, such as Filename, Size and ContentType.
- Connection manager creates the requested channel with initial state Pending.
- Connection manager asks remote contact to accept the transfer.
- At any time:
- Remote contact accept file, connection manager calls remoteAcceptFile() method to pass the output device and an initial offset. This changes the state to Accepted.
- Client calls ProvideFile method to configure a socket. The implementation calls createSocket(), which should trigger (now or later) a call to setClientSocket() to setup the client socket. socketAddress() method used to return the socket address.
- Client connects to the socket and triggers setClientSocket() call.
- The channel state is Open now.
- Client writes data to the socket.
- The clientSocket emits readyRead() signal, the interface reads the data from the clientSocket and write it to the io device.
- Connection manager calls updates transferredBytes property on actual data write.
- If transferredBytes == size, then the channel state changes to Completed. Otherwise the interface waits for further data from the client socket.
Subclassing:
Enumerator |
---|
Incoming |
|
Outgoing |
|
Tp::BaseChannelFileTransferType::~BaseChannelFileTransferType |
( |
| ) |
|
|
virtual |
Tp::BaseChannelFileTransferType::BaseChannelFileTransferType |
( |
const QVariantMap & |
request | ) |
|
|
protected |
static BaseChannelFileTransferTypePtr Tp::BaseChannelFileTransferType::create |
( |
const QVariantMap & |
request | ) |
|
|
inlinestatic |
template<typename BaseChannelFileTransferTypeSubclass >
static SharedPtr<BaseChannelFileTransferTypeSubclass> Tp::BaseChannelFileTransferType::create |
( |
const QVariantMap & |
request | ) |
|
|
inlinestatic |
QVariantMap Tp::BaseChannelFileTransferType::immutableProperties |
( |
| ) |
const |
|
virtual |
Return the immutable properties of this interface.
Immutable properties cannot change after the interface has been registered on a service on the bus with registerInterface().
- Returns
- The immutable properties of this interface.
Implements Tp::AbstractDBusServiceInterface.
QString Tp::BaseChannelFileTransferType::contentType |
( |
| ) |
const |
QString Tp::BaseChannelFileTransferType::filename |
( |
| ) |
const |
qulonglong Tp::BaseChannelFileTransferType::size |
( |
| ) |
const |
uint Tp::BaseChannelFileTransferType::contentHashType |
( |
| ) |
const |
QString Tp::BaseChannelFileTransferType::contentHash |
( |
| ) |
const |
QString Tp::BaseChannelFileTransferType::description |
( |
| ) |
const |
QDateTime Tp::BaseChannelFileTransferType::date |
( |
| ) |
const |
uint Tp::BaseChannelFileTransferType::state |
( |
| ) |
const |
void Tp::BaseChannelFileTransferType::setState |
( |
uint |
state, |
|
|
uint |
reason |
|
) |
| |
qulonglong Tp::BaseChannelFileTransferType::transferredBytes |
( |
| ) |
const |
void Tp::BaseChannelFileTransferType::setTransferredBytes |
( |
qulonglong |
count | ) |
|
qulonglong Tp::BaseChannelFileTransferType::initialOffset |
( |
| ) |
const |
QString Tp::BaseChannelFileTransferType::uri |
( |
| ) |
const |
QString Tp::BaseChannelFileTransferType::fileCollection |
( |
| ) |
const |
void Tp::BaseChannelFileTransferType::setFileCollection |
( |
const QString & |
fileCollection | ) |
|
bool Tp::BaseChannelFileTransferType::remoteAcceptFile |
( |
QIODevice * |
output, |
|
|
qulonglong |
offset |
|
) |
| |
bool Tp::BaseChannelFileTransferType::remoteProvideFile |
( |
QIODevice * |
input, |
|
|
qulonglong |
deviceOffset = 0 |
|
) |
| |
Connection manager should call this method to pass the input device and its offset. The interface would skip remaining initialOffset - deviceOffset bytes.
- Parameters
-
input | The input device |
deviceOffset | The number of bytes, already skipped by the device. |
- Returns
- True if success, false otherwise.
void Tp::BaseChannelFileTransferType::stateChanged |
( |
uint |
state, |
|
|
uint |
reason |
|
) |
| |
|
signal |
void Tp::BaseChannelFileTransferType::uriDefined |
( |
const QString & |
uri | ) |
|
|
signal |
bool Tp::BaseChannelFileTransferType::createSocket |
( |
uint |
addressType, |
|
|
uint |
accessControl, |
|
|
const QDBusVariant & |
accessControlParam, |
|
|
Tp::DBusError * |
error |
|
) |
| |
|
protectedvirtual |
QDBusVariant Tp::BaseChannelFileTransferType::socketAddress |
( |
| ) |
const |
|
protectedvirtual |
void Tp::BaseChannelFileTransferType::setClientSocket |
( |
QIODevice * |
socket | ) |
|
|
protected |
void Tp::BaseChannelFileTransferType::close |
( |
| ) |
|
|
protectedvirtual |