[Telepathy] tp-qt4 FileTransfer API proposal
Andre Moreira Magalhaes
andre.magalhaes at collabora.co.uk
Tue Sep 1 07:36:51 PDT 2009
Hi,
One more API sketch for review. This time we are going to implement
FileTransfer
support on tp-qt4 and I would like to have some review comments on the API.
For those not familiar with FileTransfer please refer to
http://telepathy.freedesktop.org/spec.html#org.freedesktop.Telepathy.Channel.Type.FileTransfer
Aditional methods that will be added to Account:
class Account ...
{
...
PendingChannelRequest *createFileTransfer(
const QString &contactIdentifier,
const QString &fileName,
const QString &contentType,
qulonglong size,
FileHashType contentHashType = (FileHashType) -1,
const QString &contentHash = QString(),
const QString &description = QString(),
QDateTime lastModificationTime = QDateTime(),
QDateTime userActionTime = QDateTime::currentDateTime(),
const QString &preferredHandler = QString());
PendingChannelRequest *createFileTransfer(
const ContactPtr &contact,
const QString &fileName,
const QString &contentType,
qulonglong size,
FileHashType contentHashType = (FileHashType) -1,
const QString &contentHash = QString(),
const QString &description = QString(),
QDateTime lastModificationTime = QDateTime(),
QDateTime userActionTime = QDateTime::currentDateTime(),
const QString &preferredHandler = QString());
...
}
Additional methods added to FileTransferChannel
class FileTransferChannel ...
{
...
QString fileName() const;
QString contentType() const;
qulonglong size() const;
FileHashType contentHashType() const;
QString contentHash() const;
QString description() const;
QDateTime lastModificationTime() const;
qulonglong initialOffset() const;
qulonglong transferredBytes() const;
PendingOperation *profileFile(QIODevice *device);
PendingIODevice *acceptFile(qulonglong offset);
Q_SIGNALS:
void stateChanged(FileTransferState state, FileTransferStateReason
reason);
void transferredBytesChanged(qulonglong count);
void initialOffsetDefined(qulonglong offset);
...
}
In order to provide a file one has to call
FileTransferChannel::provideFile with
a QIODevice as param. The idea is that internally we will create a
socket to be
used to transfer the file, but this is transparent to the user.
QIODevice was
choosen because it abstracts I/O devices access (file, buffer, socket, ...).
To accept a file, FileTransferChannel::acceptFile should be called,
which will return
a PendingIODevice, that will contain a QIODevice where the user can read
from it,
when the method returns.
I am not sure if we should provide more "low-level" methods to provide
file and
accept file that should take sockets as params, but I believe the above
methods
should be enough.
Ideas, suggestions are welcome.
BR
Andrunko
More information about the telepathy
mailing list