| 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
Service-side implementation » Connection manager service implementation

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

`#include <TelepathyQt/BaseChannel>`

Inheritance diagram for Tp::BaseChannelFileTransferType:
[legend]

## 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
DBusObject * | dbusObject () 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 QObject
| QObject (QObject *parent)
virtual | ~QObject ()
virtual bool | event (QEvent *e)
virtual bool | eventFilter (QObject *watched, QEvent *event)
virtual const QMetaObject * | metaObject () const
QString | objectName () const
void | setObjectName (const QString &name)
bool | isWidgetType () const
bool | signalsBlocked () const
bool | blockSignals (bool block)
QThread * | thread () const
void | moveToThread (QThread *targetThread)
int | startTimer (int interval)
void | killTimer (int id)
T | findChild (const QString &name) const
QList< T > | findChildren (const QString &name) const
QList< T > | findChildren (const QRegExp &regExp) const
QObject * | child (const char *objName, const char *inheritsClass, bool recursiveSearch) const
const QObjectList & | children () const
void | setParent (QObject *parent)
void | installEventFilter (QObject *filterObj)
void | removeEventFilter (QObject *obj)
bool | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
bool | disconnect (const char *signal, const QObject *receiver, const char *method)
bool | disconnect (const QObject *receiver, const char *method)
void | dumpObjectTree ()
void | dumpObjectInfo ()
bool | setProperty (const char *name, const QVariant &value)
QVariant | property (const char *name) const
QList< QByteArray > | dynamicPropertyNames () const
void | destroyed (QObject *obj)
QObject * | parent () const
bool | inherits (const char *className) const
void | deleteLater ()
| QObject (QObject *parent, const char *name)
void | insertChild (QObject *object)
void | removeChild (QObject *object)
bool | isA (const char *className) const
const char * | className () const
const char * | name () const
const char * | name (const char *defaultName) const
void | setName (const char *name)
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)
Static Public Member Functions inherited from QObject
QString | tr (const char *sourceText, const char *disambiguation, int n)
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n)
bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)

## 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)
Protected Member Functions inherited from QObject
QObject * | sender () const
int | senderSignalIndex () const
int | receivers (const char *signal) const
virtual void | timerEvent (QTimerEvent *event)
virtual void | childEvent (QChildEvent *event)
virtual void | customEvent (QEvent *event)
virtual void | connectNotify (const char *signal)
virtual void | disconnectNotify (const char *signal)
bool | checkConnectArgs (const char *signal, const QObject *object, const char *method)

## Additional Inherited Members

Static Protected Member Functions inherited from QObject
QByteArray | normalizeSignalSlot (const char *signalSlot)
Properties inherited from QObject
| objectName

## 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:

- Reimplement a public virtual method availableSocketTypes() to expose extra socket types.
- Overload protected createSocket() method to provide own socket address type, access control and its param implementation.
- Custom createSocket() implementation MUST be paired with custom socketAddress() method implementation.
- Use setClientSocket() method to pass the client socket.

## Member Enumeration Documentation

## § Direction

enum Tp::BaseChannelFileTransferType::Direction

Enumerator
Incoming |
Outgoing |

## Constructor & Destructor Documentation

## § ~BaseChannelFileTransferType()

Tp::BaseChannelFileTransferType::~BaseChannelFileTransferType | ( |  | ) |

virtual

Class destructor.

## § BaseChannelFileTransferType()

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

protected

Class constructor.

## Member Function Documentation

## § create() [1/2]

static BaseChannelFileTransferTypePtr Tp::BaseChannelFileTransferType::create | ( | const QVariantMap & | request | ) |

inline static

## § create() [2/2]

template<typename BaseChannelFileTransferTypeSubclass >

static SharedPtr<BaseChannelFileTransferTypeSubclass> Tp::BaseChannelFileTransferType::create | ( | const QVariantMap & | request | ) |

inline static

## § immutableProperties()

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.

## § direction()

BaseChannelFileTransferType::Direction Tp::BaseChannelFileTransferType::direction | ( |  | ) | const

## § contentType()

QString Tp::BaseChannelFileTransferType::contentType | ( |  | ) | const

## § filename()

QString Tp::BaseChannelFileTransferType::filename | ( |  | ) | const

## § size()

qulonglong Tp::BaseChannelFileTransferType::size | ( |  | ) | const

## § contentHashType()

uint Tp::BaseChannelFileTransferType::contentHashType | ( |  | ) | const

## § contentHash()

QString Tp::BaseChannelFileTransferType::contentHash | ( |  | ) | const

## § description()

QString Tp::BaseChannelFileTransferType::description | ( |  | ) | const

## § date()

QDateTime Tp::BaseChannelFileTransferType::date | ( |  | ) | const

## § availableSocketTypes()

Tp::SupportedSocketMap Tp::BaseChannelFileTransferType::availableSocketTypes | ( |  | ) | const

virtual

## § state()

uint Tp::BaseChannelFileTransferType::state | ( |  | ) | const

## § setState()

void Tp::BaseChannelFileTransferType::setState | ( | uint | state,
|  | uint | reason
| ) |  |

## § transferredBytes()

qulonglong Tp::BaseChannelFileTransferType::transferredBytes | ( |  | ) | const

## § setTransferredBytes()

void Tp::BaseChannelFileTransferType::setTransferredBytes | ( | qulonglong | count | ) |

## § initialOffset()

qulonglong Tp::BaseChannelFileTransferType::initialOffset | ( |  | ) | const

## § uri()

QString Tp::BaseChannelFileTransferType::uri | ( |  | ) | const

## § fileCollection()

QString Tp::BaseChannelFileTransferType::fileCollection | ( |  | ) | const

## § setFileCollection()

void Tp::BaseChannelFileTransferType::setFileCollection | ( | const QString & | fileCollection | ) |

## § remoteAcceptFile()

bool Tp::BaseChannelFileTransferType::remoteAcceptFile | ( | QIODevice * | output,
|  | qulonglong | offset
| ) |  |

## § remoteProvideFile()

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.

## § stateChanged

void Tp::BaseChannelFileTransferType::stateChanged | ( | uint | state,
|  | uint | reason
| ) |  |

signal

## § uriDefined

void Tp::BaseChannelFileTransferType::uriDefined | ( | const QString & | uri | ) |

signal

## § createSocket()

bool Tp::BaseChannelFileTransferType::createSocket | ( | uint | addressType,
|  | uint | accessControl,
|  | const QDBusVariant & | accessControlParam,
|  | Tp::DBusError * | error
| ) |  |

protected virtual

## § socketAddress()

QDBusVariant Tp::BaseChannelFileTransferType::socketAddress | ( |  | ) | const

protected virtual

## § setClientSocket()

void Tp::BaseChannelFileTransferType::setClientSocket | ( | QIODevice * | socket | ) |

protected

## § close()

void Tp::BaseChannelFileTransferType::close | ( |  | ) |

protected virtual

Reimplemented from Tp::AbstractChannelInterface.