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: