[telepathy-qt4/master] Account: Added initial methods to create a file transfer channel using ChannelRequest.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Mon Sep 28 19:03:39 PDT 2009
The methods signature are not set and may change.
---
TelepathyQt4/account.cpp | 128 +++++++++++++++++++++++++++++++++++++++++++++-
TelepathyQt4/account.h | 23 ++++++++
2 files changed, 150 insertions(+), 1 deletions(-)
diff --git a/TelepathyQt4/account.cpp b/TelepathyQt4/account.cpp
index 9f1fa2f..92be756 100644
--- a/TelepathyQt4/account.cpp
+++ b/TelepathyQt4/account.cpp
@@ -184,7 +184,7 @@ Account::Private::~Private()
/**
* \class Account
* \ingroup clientaccount
- * \headerfile TelepathyQt4/account.h> <TelepathyQt4/Account>
+ * \headerfile <TelepathyQt4/account.h> <TelepathyQt4/Account>
*
* Object representing a Telepathy account.
*
@@ -860,6 +860,132 @@ PendingChannelRequest *Account::ensureMediaCall(
}
/**
+ * Start a request to create a file transfer channel with the given
+ * contact \a contact.
+ *
+ * \param contactIdentifier The identifier of the contact to send a file.
+ * \param fileName The suggested filename for the receiver.
+ * \param contentType The file's MIME type.
+ * \param size The size of the file.
+ * \param contentHashType The type of the \a contentHash.
+ * \param contentHash The hash of the contents of the file.
+ * \param description Description of the file transfer.
+ * \param lastModificationTime The last modification time of the file.
+ * \param userActionTime The time at which user action occurred, or QDateTime()
+ * if this channel request is for some reason not
+ * involving user action.
+ * \param preferredHandler Either the well-known bus name (starting with
+ * org.freedesktop.Telepathy.Client.) of the preferred
+ * handler for this channel, or an empty string to
+ * indicate that any handler would be acceptable.
+ * \sa ensureChannel(), createChannel()
+ */
+PendingChannelRequest *Account::createFileTransfer(
+ const QString &contactIdentifier,
+ const QString &fileName,
+ const QString &contentType,
+ qulonglong size,
+ FileHashType contentHashType,
+ const QString &contentHash,
+ const QString &description,
+ QDateTime lastModificationTime,
+ QDateTime userActionTime,
+ const QString &preferredHandler)
+{
+ QVariantMap request;
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".ChannelType"),
+ TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA);
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandleType"),
+ Tp::HandleTypeContact);
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetID"),
+ contactIdentifier);
+
+ QFileInfo fileInfo(fileName);
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_FILE_TRANSFER ".Filename"),
+ fileInfo.fileName());
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_FILE_TRANSFER ".ContentType"),
+ contentType);
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_FILE_TRANSFER ".Size"),
+ size);
+ if (contentHashType != (FileHashType) -1) {
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_FILE_TRANSFER ".ContentHashType"),
+ (uint) contentHashType);
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_FILE_TRANSFER ".ContentHash"),
+ contentHash);
+ }
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_FILE_TRANSFER ".Description"),
+ description);
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_FILE_TRANSFER ".Date"),
+ (qulonglong) lastModificationTime.toTime_t());
+
+ return new PendingChannelRequest(dbusConnection(), objectPath(),
+ request, userActionTime, preferredHandler, true, this);
+}
+
+/**
+ * Start a request to create a file transfer channel with the given
+ * contact \a contact.
+ *
+ * \param contact The contact to send a file.
+ * \param fileName The suggested filename for the receiver.
+ * \param contentType The file's MIME type.
+ * \param size The size of the file.
+ * \param contentHashType The type of the \a contentHash.
+ * \param contentHash The hash of the contents of the file.
+ * \param description Description of the file transfer.
+ * \param lastModificationTime The last modification time of the file.
+ * \param userActionTime The time at which user action occurred, or QDateTime()
+ * if this channel request is for some reason not
+ * involving user action.
+ * \param preferredHandler Either the well-known bus name (starting with
+ * org.freedesktop.Telepathy.Client.) of the preferred
+ * handler for this channel, or an empty string to
+ * indicate that any handler would be acceptable.
+ * \sa ensureChannel(), createChannel()
+ */
+PendingChannelRequest *Account::createFileTransfer(
+ const ContactPtr &contact,
+ const QString &fileName,
+ const QString &contentType,
+ qulonglong size,
+ FileHashType contentHashType,
+ const QString &contentHash,
+ const QString &description,
+ QDateTime lastModificationTime,
+ QDateTime userActionTime,
+ const QString &preferredHandler)
+{
+ QVariantMap request;
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".ChannelType"),
+ TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA);
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandleType"),
+ Tp::HandleTypeContact);
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandle"),
+ contact ? contact->handle().at(0) : 0);
+
+ QFileInfo fileInfo(fileName);
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_FILE_TRANSFER ".Filename"),
+ fileInfo.fileName());
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_FILE_TRANSFER ".ContentType"),
+ contentType);
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_FILE_TRANSFER ".Size"),
+ size);
+ if (contentHashType != (FileHashType) -1) {
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_FILE_TRANSFER ".ContentHashType"),
+ (uint) contentHashType);
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_FILE_TRANSFER ".ContentHash"),
+ contentHash);
+ }
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_FILE_TRANSFER ".Description"),
+ description);
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_FILE_TRANSFER ".Date"),
+ (qulonglong) lastModificationTime.toTime_t());
+
+ return new PendingChannelRequest(dbusConnection(), objectPath(),
+ request, userActionTime, preferredHandler, true, this);
+}
+
+/**
* Start a request to create a channel.
* This initially just creates a PendingChannelRequest object,
* which can be used to track the success or failure of the request,
diff --git a/TelepathyQt4/account.h b/TelepathyQt4/account.h
index 3630540..6cce694 100644
--- a/TelepathyQt4/account.h
+++ b/TelepathyQt4/account.h
@@ -159,6 +159,29 @@ public:
QDateTime userActionTime = QDateTime::currentDateTime(),
const QString &preferredHandler = QString());
+ 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());
+
// advanced
PendingChannelRequest *createChannel(
const QVariantMap &requestedProperties,
--
1.5.6.5
More information about the telepathy-commits
mailing list