summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVlad Voicu <vladvoic@gmail.com>2011-06-01 20:36:29 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-06-12 09:59:09 (GMT)
commit29a83617e0a066ee0692d2bbcecc9335f73b8138 (patch)
tree789993173439e43c3201b4562349411b355a33ea /Swift/Controllers/Chat/ChatControllerBase.cpp
parent5839de3affdaedafdcb5d9ec7cdfe57fd373d558 (diff)
downloadswift-29a83617e0a066ee0692d2bbcecc9335f73b8138.zip
swift-29a83617e0a066ee0692d2bbcecc9335f73b8138.tar.bz2
Replace last message feature for MUC
License: This patch is BSD-licensed, see http://www.opensource.org/licenses/bsd-license.php
Diffstat (limited to 'Swift/Controllers/Chat/ChatControllerBase.cpp')
-rw-r--r--Swift/Controllers/Chat/ChatControllerBase.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp
index 0fcf901..fcaf4ce 100644
--- a/Swift/Controllers/Chat/ChatControllerBase.cpp
+++ b/Swift/Controllers/Chat/ChatControllerBase.cpp
@@ -7,6 +7,7 @@
#include "Swift/Controllers/Chat/ChatControllerBase.h"
#include <sstream>
+#include <map>
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
@@ -33,7 +34,6 @@ ChatControllerBase::ChatControllerBase(const JID& self, StanzaChannel* stanzaCha
chatWindow_->onSendMessageRequest.connect(boost::bind(&ChatControllerBase::handleSendMessageRequest, this, _1, _2));
setOnline(stanzaChannel->isAvailable() && iqRouter->isAvailable());
createDayChangeTimer();
- replacedMessage_ = false;
}
ChatControllerBase::~ChatControllerBase() {
@@ -186,8 +186,19 @@ void ChatControllerBase::handleIncomingMessage(boost::shared_ptr<MessageEvent> m
timeStamp = *messageTimeStamp;
}
onActivity(body);
- if (!replacedMessage_) {
- lastMessageUIID_ = addMessage(body, senderDisplayNameFromMessage(from), isIncomingMessageFromMe(message), label, std::string(avatarManager_->getAvatarPath(from).string()), timeStamp);
+
+ boost::shared_ptr<Replace> replace = message->getPayload<Replace>();
+ if (replace) {
+ std::string body = message->getBody();
+ // Should check if the user has a previous message
+ std::map<JID, std::string>::iterator lastMessage;
+ lastMessage = lastMessagesUIID_.find(from);
+ if (lastMessage != lastMessagesUIID_.end()) {
+ chatWindow_->replaceMessage(body, lastMessagesUIID_[from], timeStamp);
+ }
+ }
+ else {
+ lastMessagesUIID_[from] = addMessage(body, senderDisplayNameFromMessage(from), isIncomingMessageFromMe(message), label, std::string(avatarManager_->getAvatarPath(from).string()), timeStamp);
}
}
chatWindow_->show();