summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-11-30 08:02:15 (GMT)
committerSwift Review <review@swift.im>2015-12-17 18:41:04 (GMT)
commit523dbfb769069663eda19e381ad35f466b1ef27c (patch)
tree0fb00c1655274b8734de517bd1761931eddb5b49 /Swift/QtUI/QtPlainChatView.cpp
parent359799239fe61fae51a3a005e588af03a18d8a10 (diff)
downloadswift-523dbfb769069663eda19e381ad35f466b1ef27c.zip
swift-523dbfb769069663eda19e381ad35f466b1ef27c.tar.bz2
Show file-transfer description if provided
Test-Information: Tested by transferring a file between two Swift instances. Tested in WebKit chat views and in plain chat views. Change-Id: Ie46cbd7bac8a36478f64b4557cf55926e6d4af37
Diffstat (limited to 'Swift/QtUI/QtPlainChatView.cpp')
-rw-r--r--Swift/QtUI/QtPlainChatView.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/Swift/QtUI/QtPlainChatView.cpp b/Swift/QtUI/QtPlainChatView.cpp
index e062efc..a794167 100644
--- a/Swift/QtUI/QtPlainChatView.cpp
+++ b/Swift/QtUI/QtPlainChatView.cpp
@@ -177,7 +177,7 @@ void QtPlainChatView::setAckState(const std::string& /*id*/, ChatWindow::AckStat
}
}
-std::string QtPlainChatView::addFileTransfer(const std::string& senderName, bool senderIsSelf, const std::string& filename, const boost::uintmax_t sizeInBytes)
+std::string QtPlainChatView::addFileTransfer(const std::string& senderName, bool senderIsSelf, const std::string& filename, const boost::uintmax_t sizeInBytes, const std::string& description)
{
const std::string ftId = "ft" + boost::lexical_cast<std::string>(idGenerator_++);
const std::string sizeString = formatSize(sizeInBytes);
@@ -187,11 +187,13 @@ std::string QtPlainChatView::addFileTransfer(const std::string& senderName, bool
QString description = QInputDialog::getText(this, tr("File transfer description"),
tr("Description:"), QLineEdit::Normal, "");
/* NOTE: it is not possible to abort if description is not provided, since we must always return a valid transfer id */
- const std::string message = std::string() + "Confirm file transfer: <i>" + filename + " (" + sizeString + " bytes)</i>";
+ const std::string descriptionMessage = description.isEmpty() ? "" : (" \"" + Q2PSTRING(description) + "\"");
+ const std::string message = std::string() + "Confirm file transfer: <i>" + filename + " (" + sizeString + " bytes)</i>" + descriptionMessage;
transfer = new FileTransfer(this, senderIsSelf, ftId, filename, ChatWindow::WaitingForAccept, Q2PSTRING(description), message, true);
addSystemMessage(ChatWindow::ChatMessage("Preparing to start file transfer..."), ChatWindow::DefaultDirection);
} else { /* incoming transfer */
- const std::string message = std::string() + "Incoming file transfer: <i>" + filename + " (" + sizeString + " bytes)</i>";
+ const std::string descriptionMessage = description.empty() ? "" : (" \"" + description + "\"");
+ const std::string message = std::string() + "Incoming file transfer: <i>" + filename + " (" + sizeString + " bytes)</i>" + descriptionMessage;
transfer = new FileTransfer(this, senderIsSelf, ftId, filename, ChatWindow::WaitingForAccept, "", message, true);
addSystemMessage("Incoming file transfer from " + senderName + "...", ChatWindow::DefaultDirection);
}
@@ -285,6 +287,8 @@ void QtPlainChatView::fileTransferAccept()
FileTransfer* transfer = transferIter->second;
+ const std::string message = transfer->message_;
+
if (transfer->senderIsSelf_) { /* if we are the sender, kick of the transfer */
window_->onFileTransferStart(transfer->ftId_, transfer->description_);
} else { /* ask the user where to save the file first */
@@ -296,7 +300,7 @@ void QtPlainChatView::fileTransferAccept()
window_->onFileTransferAccept(transfer->ftId_, Q2PSTRING(path));
}
- setFileTransferStatus(transfer->ftId_, ChatWindow::Negotiating, transfer->message_);
+ setFileTransferStatus(transfer->ftId_, ChatWindow::Negotiating, message);
}
void QtPlainChatView::fileTransferReject()