From 898c2d79287e5fbfb2f6dc37de161f13f7c22792 Mon Sep 17 00:00:00 2001 From: 0xd34df00d <0xd34df00d@gmail.com> Date: Mon, 10 Sep 2012 21:43:43 +0400 Subject: Added description field to file transfers. --- src/client/QXmppTransferManager.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/client/QXmppTransferManager.cpp') diff --git a/src/client/QXmppTransferManager.cpp b/src/client/QXmppTransferManager.cpp index 20905a02..44fbe72c 100644 --- a/src/client/QXmppTransferManager.cpp +++ b/src/client/QXmppTransferManager.cpp @@ -61,6 +61,7 @@ public: QDateTime date; QByteArray hash; QString name; + QString description; qint64 size; }; @@ -113,6 +114,16 @@ void QXmppTransferFileInfo::setName(const QString &name) d->name = name; } +QString QXmppTransferFileInfo::description() const +{ + return d->description; +} + +void QXmppTransferFileInfo::setDescription(const QString &description) +{ + d->description = description; +} + qint64 QXmppTransferFileInfo::size() const { return d->size; @@ -1252,7 +1263,7 @@ void QXmppTransferManager::_q_jobStateChanged(QXmppTransferJob::State state) /// /// The remote party will be given the choice to accept or refuse the transfer. /// -QXmppTransferJob *QXmppTransferManager::sendFile(const QString &jid, const QString &filePath, const QString &sid) +QXmppTransferJob *QXmppTransferManager::sendFile(const QString &jid, const QString &filePath, const QString &sid, const QString &description) { if (jid.isEmpty()) { warning("Refusing to send file to an empty jid"); @@ -1265,6 +1276,7 @@ QXmppTransferJob *QXmppTransferManager::sendFile(const QString &jid, const QStri fileInfo.setDate(info.lastModified()); fileInfo.setName(info.fileName()); fileInfo.setSize(info.size()); + fileInfo.setDescription(description); // open file QIODevice *device = new QFile(filePath); @@ -1343,6 +1355,13 @@ QXmppTransferJob *QXmppTransferManager::sendFile(const QString &jid, QIODevice * file.setAttribute("hash", job->fileHash().toHex()); file.setAttribute("name", job->fileName()); file.setAttribute("size", QString::number(job->fileSize())); + if (!fileInfo.description().isEmpty()) + { + QXmppElement desc; + desc.setTagName("desc"); + desc.setValue(fileInfo.description()); + file.appendChild(desc); + } items.append(file); QXmppElement feature; @@ -1628,6 +1647,7 @@ void QXmppTransferManager::streamInitiationSetReceived(const QXmppStreamInitiati job->d->fileInfo.setHash(QByteArray::fromHex(item.attribute("hash").toAscii())); job->d->fileInfo.setName(item.attribute("name")); job->d->fileInfo.setSize(item.attribute("size").toLongLong()); + job->d->fileInfo.setDescription(item.firstChildElement("desc").value()); } } -- cgit v1.2.3