diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-08-31 19:10:57 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-09-03 10:02:35 (GMT) |
commit | eb50ea03ab7fc41610a8945002fe19dd30ffb5d7 (patch) | |
tree | d26d378e2996b163f13562488eb2bbc31d89db04 /Swift/Controllers/Chat/ChatController.cpp | |
parent | 276d7f82ba42cdbc65ec5c9f35873a265a69bd73 (diff) | |
download | swift-contrib-eb50ea03ab7fc41610a8945002fe19dd30ffb5d7.zip swift-contrib-eb50ea03ab7fc41610a8945002fe19dd30ffb5d7.tar.bz2 |
Squash presence in chat and MUC windows.
Join/Parts will be shown in one block if they're uninterrupted, and only the last presence change in a row will be shown for chats.
Resolves: #230
Resolves: #430
Diffstat (limited to 'Swift/Controllers/Chat/ChatController.cpp')
-rw-r--r-- | Swift/Controllers/Chat/ChatController.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index d9524da..52288c2 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -25,6 +25,7 @@ namespace Swift { ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, const JID &contact, NickResolver* nickResolver, PresenceOracle* presenceOracle, AvatarManager* avatarManager, bool isInMUC, bool useDelayForLatency, UIEventStream* eventStream, EventController* eventController) : ChatControllerBase(self, stanzaChannel, iqRouter, chatWindowFactory, contact, presenceOracle, avatarManager, useDelayForLatency, eventStream, eventController) { isInMUC_ = isInMUC; + lastWasPresence_ = false; chatStateNotifier_ = new ChatStateNotifier(); chatStateMessageSender_ = new ChatStateMessageSender(chatStateNotifier_, stanzaChannel, contact); chatStateTracker_ = new ChatStateTracker(); @@ -70,6 +71,7 @@ void ChatController::preHandleIncomingMessage(boost::shared_ptr<MessageEvent> me } chatStateNotifier_->receivedMessageFromContact(message->getPayload<ChatState>()); chatStateTracker_->handleMessageReceived(message); + lastWasPresence_ = false; } void ChatController::preSendMessageRequest(boost::shared_ptr<Message> message) { @@ -80,6 +82,7 @@ void ChatController::preSendMessageRequest(boost::shared_ptr<Message> message) { void ChatController::postSendMessage(const String& body) { addMessage(body, "me", true, labelsEnabled_ ? chatWindow_->getSelectedSecurityLabel() : boost::optional<SecurityLabel>(), String(avatarManager_->getAvatarPath(selfJID_).string()), boost::posix_time::microsec_clock::universal_time()); + lastWasPresence_ = false; chatStateNotifier_->userSentMessage(); } @@ -113,7 +116,12 @@ void ChatController::handlePresenceChange(boost::shared_ptr<Presence> newPresenc chatStateTracker_->handlePresenceChange(newPresence, previousPresence); String newStatusChangeString = getStatusChangeString(newPresence); if (!previousPresence || newStatusChangeString != getStatusChangeString(previousPresence)) { - chatWindow_->addPresenceMessage(newStatusChangeString); + if (lastWasPresence_) { + chatWindow_->replaceLastMessage(newStatusChangeString); + } else { + chatWindow_->addPresenceMessage(newStatusChangeString); + } + lastWasPresence_ = true; } } |