From 912dbcf226e361f23b82a77372038865ffebbd02 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Wed, 9 Mar 2011 07:39:21 +0000
Subject: Fix marking notices as read.

Resolves: #775

diff --git a/Swift/Controllers/EventWindowController.cpp b/Swift/Controllers/EventWindowController.cpp
index 18c37f4..a6ff061 100644
--- a/Swift/Controllers/EventWindowController.cpp
+++ b/Swift/Controllers/EventWindowController.cpp
@@ -25,7 +25,7 @@ EventWindowController::~EventWindowController() {
 
 void EventWindowController::handleEventQueueEventAdded(boost::shared_ptr<StanzaEvent> event) {
 	event->onConclusion.connect(boost::bind(&EventWindowController::handleEventConcluded, this, event));
-	window_->addEvent(event, true);
+	window_->addEvent(event, event->getConcluded());
 }
 
 void EventWindowController::handleEventConcluded(boost::shared_ptr<StanzaEvent> event) {
diff --git a/Swift/Controllers/SoundEventController.cpp b/Swift/Controllers/SoundEventController.cpp
index 0351445..26847ed 100644
--- a/Swift/Controllers/SoundEventController.cpp
+++ b/Swift/Controllers/SoundEventController.cpp
@@ -28,8 +28,10 @@ SoundEventController::SoundEventController(EventController* eventController, Sou
 	setPlaySounds(playSounds);	
 }
 
-void SoundEventController::handleEventQueueEventAdded(boost::shared_ptr<StanzaEvent>) {
-	if (playSounds_) soundPlayer_->playSound(SoundPlayer::MessageReceived);
+void SoundEventController::handleEventQueueEventAdded(boost::shared_ptr<StanzaEvent> event) {
+	if (playSounds_ && !event->getConcluded()) {
+		soundPlayer_->playSound(SoundPlayer::MessageReceived);
+	}
 }
 
 void SoundEventController::setPlaySounds(bool playSounds) {
diff --git a/Swift/Controllers/XMPPEvents/EventController.cpp b/Swift/Controllers/XMPPEvents/EventController.cpp
index 8e31d30..157be86 100644
--- a/Swift/Controllers/XMPPEvents/EventController.cpp
+++ b/Swift/Controllers/XMPPEvents/EventController.cpp
@@ -30,6 +30,9 @@ void EventController::handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceE
 	boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(sourceEvent);
 	if ((messageEvent && messageEvent->isReadable()) || subscriptionEvent || errorEvent) {
 		events_.push_back(sourceEvent);
+		if (sourceEvent->getConcluded()) {
+			handleEventConcluded(sourceEvent);
+		}
 		sourceEvent->onConclusion.connect(boost::bind(&EventController::handleEventConcluded, this, sourceEvent));
 		onEventQueueLengthChange(events_.size());
 		onEventQueueEventAdded(sourceEvent);
-- 
cgit v0.10.2-6-g49f6