aboutsummaryrefslogtreecommitdiff
path: root/src/client/QXmppTransferManager.cpp
diff options
context:
space:
mode:
author0xd34df00d <0xd34df00d@gmail.com>2012-09-10 21:43:43 +0400
committer0xd34df00d <0xd34df00d@gmail.com>2012-09-10 21:43:43 +0400
commit898c2d79287e5fbfb2f6dc37de161f13f7c22792 (patch)
tree043b2918faeef17e8482078af92333c668b3eac6 /src/client/QXmppTransferManager.cpp
parentdfbb501a928b0eb0dec1582a2e124aea95296a35 (diff)
Added description field to file transfers.
Diffstat (limited to 'src/client/QXmppTransferManager.cpp')
-rw-r--r--src/client/QXmppTransferManager.cpp22
1 files changed, 21 insertions, 1 deletions
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());
}
}