diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-04-26 18:26:28 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-04-26 18:38:55 (GMT) |
commit | 6f30d20883b303f3bd536b2d8164963d61b9897a (patch) | |
tree | 0f5829de558ce9ef4a6601f626da85016deab3cf /Swift/Controllers/Chat | |
parent | 37de16e21bf73d1dea16343f04d061d3cb389acf (diff) | |
download | swift-contrib-6f30d20883b303f3bd536b2d8164963d61b9897a.zip swift-contrib-6f30d20883b303f3bd536b2d8164963d61b9897a.tar.bz2 |
Make stanza ack handling safer in case of a view without stanza acking support.
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r-- | Swift/Controllers/Chat/ChatController.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index 22ef68d..911f3e2 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -117,7 +117,7 @@ void ChatController::preSendMessageRequest(boost::shared_ptr<Message> message) { void ChatController::postSendMessage(const std::string& body, boost::shared_ptr<Stanza> sentStanza) { std::string id = addMessage(body, QT_TRANSLATE_NOOP("", "me"), true, labelsEnabled_ ? chatWindow_->getSelectedSecurityLabel().getLabel() : boost::shared_ptr<SecurityLabel>(), std::string(avatarManager_->getAvatarPath(selfJID_).string()), boost::posix_time::microsec_clock::universal_time()); - if (stanzaChannel_->getStreamManagementEnabled()) { + if (stanzaChannel_->getStreamManagementEnabled() && !id.empty()) { chatWindow_->setAckState(id, ChatWindow::Pending); unackedStanzas_[sentStanza] = id; } @@ -126,11 +126,11 @@ void ChatController::postSendMessage(const std::string& body, boost::shared_ptr< } void ChatController::handleStanzaAcked(boost::shared_ptr<Stanza> stanza) { - std::string id = unackedStanzas_[stanza]; - if (id != "") { - chatWindow_->setAckState(id, ChatWindow::Received); + std::map<boost::shared_ptr<Stanza>, std::string>::iterator unackedStanza = unackedStanzas_.find(stanza); + if (unackedStanza != unackedStanzas_.end()) { + chatWindow_->setAckState(unackedStanza->second, ChatWindow::Received); + unackedStanzas_.erase(unackedStanza); } - unackedStanzas_.erase(unackedStanzas_.find(stanza)); } void ChatController::setOnline(bool online) { |