diff options
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/Controllers/Chat/ChatControllerBase.cpp | 6 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatControllerBase.h | 1 | ||||
-rw-r--r-- | Swift/Controllers/Chat/MUCController.cpp | 10 | ||||
-rw-r--r-- | Swift/Controllers/XMPPEvents/MessageEvent.h | 23 |
4 files changed, 26 insertions, 14 deletions
diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp index 16ff885..583a102 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.cpp +++ b/Swift/Controllers/Chat/ChatControllerBase.cpp @@ -92,6 +92,7 @@ void ChatControllerBase::setAvailableServerFeatures(boost::shared_ptr<DiscoInfo> void ChatControllerBase::handleAllMessagesRead() { if (!unreadMessages_.empty()) { + targetedUnreadMessages_.clear(); foreach (boost::shared_ptr<StanzaEvent> stanzaEvent, unreadMessages_) { stanzaEvent->conclude(); } @@ -102,7 +103,7 @@ void ChatControllerBase::handleAllMessagesRead() { } int ChatControllerBase::getUnreadCount() { - return unreadMessages_.size(); + return targetedUnreadMessages_.size(); } void ChatControllerBase::handleSendMessageRequest(const std::string &body, bool isCorrectionMessage) { @@ -181,6 +182,9 @@ void ChatControllerBase::handleIncomingMessage(boost::shared_ptr<MessageEvent> m preHandleIncomingMessage(messageEvent); if (messageEvent->isReadable() && !messageEvent->getConcluded()) { unreadMessages_.push_back(messageEvent); + if (messageEvent->targetsMe()) { + targetedUnreadMessages_.push_back(messageEvent); + } } boost::shared_ptr<Message> message = messageEvent->getStanza(); std::string body = message->getBody(); diff --git a/Swift/Controllers/Chat/ChatControllerBase.h b/Swift/Controllers/Chat/ChatControllerBase.h index 8a8161d..7dd339c 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.h +++ b/Swift/Controllers/Chat/ChatControllerBase.h @@ -91,6 +91,7 @@ namespace Swift { protected: JID selfJID_; std::vector<boost::shared_ptr<StanzaEvent> > unreadMessages_; + std::vector<boost::shared_ptr<StanzaEvent> > targetedUnreadMessages_; StanzaChannel* stanzaChannel_; IQRouter* iqRouter_; ChatWindowFactory* chatWindowFactory_; diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 775d7a2..3386877 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -393,10 +393,12 @@ void MUCController::preHandleIncomingMessage(boost::shared_ptr<MessageEvent> mes } clearPresenceQueue(); boost::shared_ptr<Message> message = messageEvent->getStanza(); - if (joined_ && messageEvent->getStanza()->getFrom().getResource() != nick_ && messageTargetsMe(message) && !message->getPayload<Delay>()) { - if (messageEvent->isReadable()) { - chatWindow_->flash(); - } + if (joined_ && messageEvent->getStanza()->getFrom().getResource() != nick_ && messageTargetsMe(message) && !message->getPayload<Delay>() && messageEvent->isReadable() +) { + chatWindow_->flash(); + } + else { + messageEvent->setTargetsMe(false); } if (joined_) { std::string nick = message->getFrom().getResource(); diff --git a/Swift/Controllers/XMPPEvents/MessageEvent.h b/Swift/Controllers/XMPPEvents/MessageEvent.h index d1021dc..1093470 100644 --- a/Swift/Controllers/XMPPEvents/MessageEvent.h +++ b/Swift/Controllers/XMPPEvents/MessageEvent.h @@ -1,26 +1,23 @@ /* - * Copyright (c) 2010 Kevin Smith + * Copyright (c) 2010-2012 Kevin Smith * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ -#ifndef SWIFTEN_MessageEvent_H -#define SWIFTEN_MessageEvent_H - +#pragma once #include <cassert> -#include "Swiften/Base/boost_bsignals.h" #include <boost/shared_ptr.hpp> -#include "Swift/Controllers/XMPPEvents/StanzaEvent.h" -#include "Swiften/Elements/Message.h" +#include <Swift/Controllers/XMPPEvents/StanzaEvent.h> +#include <Swiften/Elements/Message.h> namespace Swift { class MessageEvent : public StanzaEvent { public: typedef boost::shared_ptr<MessageEvent> ref; - MessageEvent(boost::shared_ptr<Message> stanza) : stanza_(stanza){}; + MessageEvent(boost::shared_ptr<Message> stanza) : stanza_(stanza), targetsMe_(true) {}; boost::shared_ptr<Message> getStanza() {return stanza_;} @@ -33,9 +30,17 @@ namespace Swift { conclude(); } + void setTargetsMe(bool targetsMe) { + targetsMe_ = targetsMe; + } + + bool targetsMe() const { + return targetsMe_; + } + private: boost::shared_ptr<Message> stanza_; + bool targetsMe_; }; } -#endif |