diff options
author | Kevin Smith <git@kismith.co.uk> | 2009-06-28 09:41:38 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2009-06-28 09:41:38 (GMT) |
commit | 1231acac77f2811a94f9bc83e38abb8ed85468b3 (patch) | |
tree | c5c6e99544750d13ccc41717f0f6a28694028582 /Swift/Controllers | |
parent | e2d9f9e47056a41d5e5a67ea3130ccdd860a06ed (diff) | |
download | swift-contrib-1231acac77f2811a94f9bc83e38abb8ed85468b3.zip swift-contrib-1231acac77f2811a94f9bc83e38abb8ed85468b3.tar.bz2 |
Moving resources into Swift/ and starting on Sound.
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/EventController.cpp | 1 | ||||
-rw-r--r-- | Swift/Controllers/EventController.h | 1 | ||||
-rw-r--r-- | Swift/Controllers/MainController.cpp | 6 | ||||
-rw-r--r-- | Swift/Controllers/MainController.h | 5 | ||||
-rw-r--r-- | Swift/Controllers/Makefile.inc | 1 | ||||
-rw-r--r-- | Swift/Controllers/SoundEventController.cpp | 21 | ||||
-rw-r--r-- | Swift/Controllers/SoundEventController.h | 18 | ||||
-rw-r--r-- | Swift/Controllers/SoundPlayer.h | 10 |
8 files changed, 61 insertions, 2 deletions
diff --git a/Swift/Controllers/EventController.cpp b/Swift/Controllers/EventController.cpp index 9b143dd..5141cc1 100644 --- a/Swift/Controllers/EventController.cpp +++ b/Swift/Controllers/EventController.cpp @@ -10,6 +10,7 @@ void EventController::handleIncomingEvent(boost::shared_ptr<MessageEvent> event) events_.push_back(event); event->onRead.connect(boost::bind(&EventController::handleEventRead, this, event)); onEventQueueLengthChange(events_.size()); + onEventQueueEventAdded(event); } } diff --git a/Swift/Controllers/EventController.h b/Swift/Controllers/EventController.h index ab161af..c5c924b 100644 --- a/Swift/Controllers/EventController.h +++ b/Swift/Controllers/EventController.h @@ -13,6 +13,7 @@ namespace Swift { public: void handleIncomingEvent(boost::shared_ptr<MessageEvent> event); boost::signal<void (int)> onEventQueueLengthChange; + boost::signal<void (boost::shared_ptr<MessageEvent>)> onEventQueueEventAdded; private: void handleEventRead(boost::shared_ptr<MessageEvent> event); diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 63b55af..1af689c 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -17,6 +17,8 @@ #include "Swift/Controllers/MUCController.h" #include "Swift/Controllers/NickResolver.h" #include "Swift/Controllers/RosterController.h" +#include "Swift/Controllers/SoundEventController.h" +#include "Swift/Controllers/SoundPlayer.h" #include "Swift/Controllers/SystemTray.h" #include "Swift/Controllers/SystemTrayController.h" #include "Swift/Controllers/XMPPRosterController.h" @@ -57,7 +59,7 @@ static const String CLIENT_NODE = "http://swift.im"; typedef std::pair<JID, ChatController*> JIDChatControllerPair; typedef std::pair<JID, MUCController*> JIDMUCControllerPair; -MainController::MainController(ChatWindowFactory* chatWindowFactory, MainWindowFactory *mainWindowFactory, LoginWindowFactory *loginWindowFactory, TreeWidgetFactory *treeWidgetFactory, SettingsProvider *settings, Application* application, SystemTray* systemTray) +MainController::MainController(ChatWindowFactory* chatWindowFactory, MainWindowFactory *mainWindowFactory, LoginWindowFactory *loginWindowFactory, TreeWidgetFactory *treeWidgetFactory, SettingsProvider *settings, Application* application, SystemTray* systemTray, SoundPlayer* soundPlayer) : client_(NULL), chatWindowFactory_(chatWindowFactory), mainWindowFactory_(mainWindowFactory), loginWindowFactory_(loginWindowFactory), treeWidgetFactory_(treeWidgetFactory), settings_(settings), xmppRosterController_(NULL), rosterController_(NULL), loginWindow_(NULL), clientVersionResponder_(NULL), nickResolver_(NULL), discoResponder_(NULL), serverDiscoInfo_(new DiscoInfo()), presenceOracle_(NULL), avatarManager_(NULL) { @@ -68,6 +70,7 @@ MainController::MainController(ChatWindowFactory* chatWindowFactory, MainWindowF eventController_ = new EventController(); eventController_->onEventQueueLengthChange.connect(boost::bind(&MainController::handleEventQueueLengthChange, this, _1)); systemTrayController_ = new SystemTrayController(eventController_, systemTray); + soundEventController_ = new SoundEventController(eventController_, soundPlayer); loginWindow_ = loginWindowFactory_->createLoginWindow(settings->getStringSetting("jid"), settings->getStringSetting("pass"), settings->getStringSetting("certificate")); loginWindow_->onLoginRequest.connect(boost::bind(&MainController::handleLoginRequest, this, _1, _2, _3, _4)); } @@ -88,6 +91,7 @@ MainController::~MainController() { delete nickResolver_; delete client_; delete systemTrayController_; + delete soundEventController_; delete avatarStorage_; } diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index 2b7c8b0..1fd7c4c 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -40,10 +40,12 @@ namespace Swift { class PresenceOracle; class SystemTray; class SystemTrayController; + class SoundEventController; + class SoundPlayer; class MainController : public MUCRegistry { public: - MainController(ChatWindowFactory* chatWindowFactory, MainWindowFactory *mainWindowFactory, LoginWindowFactory *loginWindowFactory, TreeWidgetFactory* treeWidgetFactory, SettingsProvider *settings, Application* application, SystemTray* systemTray); + MainController(ChatWindowFactory* chatWindowFactory, MainWindowFactory *mainWindowFactory, LoginWindowFactory *loginWindowFactory, TreeWidgetFactory* treeWidgetFactory, SettingsProvider *settings, Application* application, SystemTray* systemTray, SoundPlayer* soundPlayer); ~MainController(); @@ -90,6 +92,7 @@ namespace Swift { JID jid_; PresenceOracle* presenceOracle_; SystemTrayController* systemTrayController_; + SoundEventController* soundEventController_; AvatarManager* avatarManager_; boost::shared_ptr<Presence> lastSentPresence_; String vCardPhotoHash_; diff --git a/Swift/Controllers/Makefile.inc b/Swift/Controllers/Makefile.inc index 5e30a63..4c69e34 100644 --- a/Swift/Controllers/Makefile.inc +++ b/Swift/Controllers/Makefile.inc @@ -7,6 +7,7 @@ SWIFT_CONTROLLERS_SOURCES += \ Swift/Controllers/XMPPRosterController.cpp \ Swift/Controllers/MUCController.cpp \ Swift/Controllers/EventController.cpp \ + Swift/Controllers/SoundEventController.cpp \ Swift/Controllers/SystemTrayController.cpp include Swift/Controllers/UnitTest/Makefile.inc diff --git a/Swift/Controllers/SoundEventController.cpp b/Swift/Controllers/SoundEventController.cpp new file mode 100644 index 0000000..46d6ddb --- /dev/null +++ b/Swift/Controllers/SoundEventController.cpp @@ -0,0 +1,21 @@ +#include "Swift/Controllers/SoundEventController.h" + +#include <boost/bind.hpp> + +#include "Swift/Controllers/EventController.h" +#include "Swift/Controllers/SoundPlayer.h" + +namespace Swift { + +SoundEventController::SoundEventController(EventController* eventController, SoundPlayer* soundPlayer) { + eventController_ = eventController; + soundPlayer_ = soundPlayer; + eventController_->onEventQueueEventAdded.connect(boost::bind(&SoundEventController::handleEventQueueEventAdded, this, _1)); +} + +void SoundEventController::handleEventQueueEventAdded(boost::shared_ptr<MessageEvent> event) { + soundPlayer_->playSound(SoundPlayer::MessageReceived); +} + + +} diff --git a/Swift/Controllers/SoundEventController.h b/Swift/Controllers/SoundEventController.h new file mode 100644 index 0000000..8da057d --- /dev/null +++ b/Swift/Controllers/SoundEventController.h @@ -0,0 +1,18 @@ +#pragma once + +#include <boost/shared_ptr.hpp> + +#include "Swiften/Events/MessageEvent.h" + +namespace Swift { + class EventController; + class SoundPlayer; + class SoundEventController { + public: + SoundEventController(EventController* eventController, SoundPlayer* soundPlayer); + private: + void handleEventQueueEventAdded(boost::shared_ptr<MessageEvent> event); + EventController* eventController_; + SoundPlayer* soundPlayer_; + }; +} diff --git a/Swift/Controllers/SoundPlayer.h b/Swift/Controllers/SoundPlayer.h new file mode 100644 index 0000000..b411f24 --- /dev/null +++ b/Swift/Controllers/SoundPlayer.h @@ -0,0 +1,10 @@ +#pragma once + +namespace Swift { + class SoundPlayer { + public: + virtual ~SoundPlayer() {}; + enum SoundEffect{MessageReceived}; + virtual void playSound(SoundEffect sound) = 0; + }; +} |