From 9bfa3150fe9fac684a08e584a23249f918c188d9 Mon Sep 17 00:00:00 2001
From: Tobias Markmann <tm@ayena.de>
Date: Tue, 15 Sep 2015 14:29:00 +0200
Subject: Play message incoming sound on incoming file-transfers

The moving of our sound playing to our message highlighting code
resulted in non-message events not having sound notifications played
anymore. This commit fixes this issue for incoming file-transfers,
by playing the default message received sound as long as sounds are
not globally disabled in Swift.

Test-Information:

Tested on OS X 10.9.5 with Qt 5.4.2, by exchanging files and
messages between two Swift instances.

Change-Id: Ie09473efeef8366b76f6f7b59cc941fe6a0ad8f0

diff --git a/Swift/Controllers/SoundEventController.cpp b/Swift/Controllers/SoundEventController.cpp
index 13c590e..43c8ed0 100644
--- a/Swift/Controllers/SoundEventController.cpp
+++ b/Swift/Controllers/SoundEventController.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2012 Isode Limited.
+ * Copyright (c) 2010-2015 Isode Limited.
  * All rights reserved.
  * See the COPYING file for more information.
  */
@@ -8,11 +8,12 @@
 
 #include <boost/bind.hpp>
 
-#include <Swift/Controllers/XMPPEvents/EventController.h>
+#include <Swift/Controllers/HighlightManager.h>
+#include <Swift/Controllers/SettingConstants.h>
 #include <Swift/Controllers/SoundPlayer.h>
 #include <Swift/Controllers/UIEvents/UIEventStream.h>
-#include <Swift/Controllers/SettingConstants.h>
-#include <Swift/Controllers/HighlightManager.h>
+#include <Swift/Controllers/XMPPEvents/EventController.h>
+#include <Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h>
 
 namespace Swift {
 
@@ -29,11 +30,10 @@ SoundEventController::SoundEventController(EventController* eventController, Sou
 	playSounds_ = settings->getSetting(SettingConstants::PLAY_SOUNDS);
 }
 
-void SoundEventController::handleEventQueueEventAdded(boost::shared_ptr<StanzaEvent> /*event*/) {
-	// message received sound is now played via highlighting
-	//if (playSounds_ && !event->getConcluded()) {
-	//	soundPlayer_->playSound(SoundPlayer::MessageReceived);
-	//}
+void SoundEventController::handleEventQueueEventAdded(boost::shared_ptr<StanzaEvent> event) {
+	if (playSounds_ && boost::dynamic_pointer_cast<IncomingFileTransferEvent>(event)) {
+		soundPlayer_->playSound(SoundPlayer::MessageReceived, "");
+	}
 }
 
 void SoundEventController::handleHighlight(const HighlightAction& action) {
-- 
cgit v0.10.2-6-g49f6