Home · All Classes · All Namespaces · Modules · Functions · Files
Public Types | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Tp::BaseChannelFileTransferType Class Reference

Base class of Channel.Type.FileTransfer channel type. More...

#include <TelepathyQt/BaseChannel>

Inherits Tp::AbstractChannelInterface.

Public Types

enum  Direction { Incoming, Outgoing }
 

Signals

void stateChanged (uint state, uint reason)
 
void uriDefined (const QString &uri)
 
- Signals inherited from Tp::Object
void propertyChanged (const QString &propertyName)
 

Public Member Functions

virtual ~BaseChannelFileTransferType ()
 
QVariantMap immutableProperties () const
 
Direction direction () const
 
QString contentType () const
 
QString filename () const
 
qulonglong size () const
 
uint contentHashType () const
 
QString contentHash () const
 
QString description () const
 
QDateTime date () const
 
virtual Tp::SupportedSocketMap availableSocketTypes () const
 
uint state () const
 
void setState (uint state, uint reason)
 
qulonglong transferredBytes () const
 
void setTransferredBytes (qulonglong count)
 
qulonglong initialOffset () const
 
QString uri () const
 
QString fileCollection () const
 
void setFileCollection (const QString &fileCollection)
 
bool remoteAcceptFile (QIODevice *output, qulonglong offset)
 
bool remoteProvideFile (QIODevice *input, qulonglong deviceOffset=0)
 
- Public Member Functions inherited from Tp::AbstractChannelInterface
 AbstractChannelInterface (const QString &interfaceName)
 
virtual ~AbstractChannelInterface ()
 
- Public Member Functions inherited from Tp::AbstractDBusServiceInterface
 AbstractDBusServiceInterface (const QString &interfaceName)
 
virtual ~AbstractDBusServiceInterface ()
 
QString interfaceName () const
 
DBusObjectdbusObject () const
 
bool isRegistered () const
 
bool notifyPropertyChanged (const QString &propertyName, const QVariant &propertyValue)
 
- Public Member Functions inherited from Tp::Object
virtual ~Object ()
 
- Public Member Functions inherited from Tp::RefCounted
 RefCounted ()
 
virtual ~RefCounted ()
 

Static Public Member Functions

static BaseChannelFileTransferTypePtr create (const QVariantMap &request)
 
template<typename BaseChannelFileTransferTypeSubclass >
static SharedPtr< BaseChannelFileTransferTypeSubclass > create (const QVariantMap &request)
 

Protected Member Functions

 BaseChannelFileTransferType (const QVariantMap &request)
 
virtual bool createSocket (uint addressType, uint accessControl, const QDBusVariant &accessControlParam, DBusError *error)
 
virtual QDBusVariant socketAddress () const
 
void setClientSocket (QIODevice *socket)
 
void close ()
 
- Protected Member Functions inherited from Tp::AbstractChannelInterface
virtual void setBaseChannel (BaseChannel *channel)
 
- Protected Member Functions inherited from Tp::AbstractDBusServiceInterface
virtual bool registerInterface (DBusObject *dbusObject)
 
- Protected Member Functions inherited from Tp::Object
 Object ()
 
void notify (const char *propertyName)
 

Detailed Description

Base class of Channel.Type.FileTransfer channel type.

Default implementation currently support only IPv4 and IPv6 sockets with localhost access control.

Usage:

  1. Add FileTransfer to the list of the protocol requestable channel classes.
  2. Add FileTransfer to the list of the connection requestable channel classes.
  3. Setup ContactCapabilities interface and ensure that FileTransfer requestable channel class presence matches to actual local (!) and remote contacts capabilities.
  4. Implement initial FileTransfer channel support in createChannel callback.
    1. The channel of interest are those with channelType TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER.
    2. Create BaseChannel and plug BaseChannelFileTransferType interface.
    3. If transferInterface->direction() is Outgoing, notify the remote side.
  5. Implement incoming file request handler:
    1. Properly setup the request details, take care on TargetHandle and InitiatorHandle.
    2. Call BaseConnection::createChannel() with the details. Do not suppress handler!
    3. Use remoteProvideFile() to pass the input device and its offset.
    4. transferredBytes property will be updated automatically on bytes written to the client socket.
  6. Implement "remote side accepted transfer" handler:
    1. Use remoteAcceptFile() to pass the requested initial offset and output device.
    2. Update transferredBytes property on bytes written to the remote side.

Incoming transfer process:

  1. Connection manager creates not requested channel with ChannelType = TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER and other properties, such as Filename, Size and ContentType.
  2. The channel initial state is Pending.
  3. At any time:
    1. 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.
    2. 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.
    3. Client connects to the socket and triggers setClientSocket() call.
  4. The channel state is Open now.
  5. 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.
  6. Client socket emit bytesWritten() signal, the interface updates transferredBytes count.
  7. If transferredBytes == size, then the channel state changes to Completed. Otherwise the interface waits for further data from the device socket.

Outgoing transfer process:

  1. Client requests a channel with ChannelType = TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER and other properties, such as Filename, Size and ContentType.
  2. Connection manager creates the requested channel with initial state Pending.
  3. Connection manager asks remote contact to accept the transfer.
  4. At any time:
    1. Remote contact accept file, connection manager calls remoteAcceptFile() method to pass the output device and an initial offset. This changes the state to Accepted.
    2. 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.
    3. Client connects to the socket and triggers setClientSocket() call.
  5. The channel state is Open now.
  6. Client writes data to the socket.
  7. The clientSocket emits readyRead() signal, the interface reads the data from the clientSocket and write it to the io device.
  8. Connection manager calls updates transferredBytes property on actual data write.
  9. If transferredBytes == size, then the channel state changes to Completed. Otherwise the interface waits for further data from the client socket.

Subclassing:

Member Enumeration Documentation

Enumerator
Incoming 
Outgoing 

Constructor & Destructor Documentation

Tp::BaseChannelFileTransferType::~BaseChannelFileTransferType ( )
virtual

Class destructor.

Tp::BaseChannelFileTransferType::BaseChannelFileTransferType ( const QVariantMap &  request)
protected

Class constructor.

Member Function Documentation

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.

BaseChannelFileTransferType::Direction Tp::BaseChannelFileTransferType::direction ( ) const
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
Tp::SupportedSocketMap Tp::BaseChannelFileTransferType::availableSocketTypes ( ) const
virtual
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
inputThe input device
deviceOffsetThe 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

Reimplemented from Tp::AbstractChannelInterface.


Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation
Telepathy-Qt 0.9.7