diff options
author | Kevin Smith <git@kismith.co.uk> | 2012-02-17 16:57:01 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-02-21 14:34:55 (GMT) |
commit | 3605b6622bc8b4abb810fac6b53f7f71be0fa7de (patch) | |
tree | 638a8fd6449dd235931fe307e50119adf9c9fe22 /Swift/Controllers/SoundEventController.cpp | |
parent | b05f8fcb285d2d13d2be50a3eb1062048fbe30f5 (diff) | |
download | swift-3605b6622bc8b4abb810fac6b53f7f71be0fa7de.zip swift-3605b6622bc8b4abb810fac6b53f7f71be0fa7de.tar.bz2 |
Introduce system settings policies.
Release-Notes: It is now possible for sysadmins to deploy files with policies for configuration options, such as making it impossible for users to save passwords or to force sound notifications off, or to set defaults.
Also allow changing an option so that Swift disconnects on idle timeout, instead of going away.
Diffstat (limited to 'Swift/Controllers/SoundEventController.cpp')
-rw-r--r-- | Swift/Controllers/SoundEventController.cpp | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/Swift/Controllers/SoundEventController.cpp b/Swift/Controllers/SoundEventController.cpp index 26847ed..d056990 100644 --- a/Swift/Controllers/SoundEventController.cpp +++ b/Swift/Controllers/SoundEventController.cpp @@ -1,31 +1,28 @@ /* - * 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. */ -#include "Swift/Controllers/SoundEventController.h" +#include <Swift/Controllers/SoundEventController.h> #include <boost/bind.hpp> -#include "Swift/Controllers/XMPPEvents/EventController.h" -#include "Swift/Controllers/SoundPlayer.h" -#include "Swift/Controllers/UIEvents/UIEventStream.h" -#include "Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h" +#include <Swift/Controllers/XMPPEvents/EventController.h> +#include <Swift/Controllers/SoundPlayer.h> +#include <Swift/Controllers/UIEvents/UIEventStream.h> +#include <Swift/Controllers/SettingConstants.h> namespace Swift { -SoundEventController::SoundEventController(EventController* eventController, SoundPlayer* soundPlayer, SettingsProvider* settings, UIEventStream* uiEvents) { - uiEvents_ = uiEvents; +SoundEventController::SoundEventController(EventController* eventController, SoundPlayer* soundPlayer, SettingsProvider* settings) { settings_ = settings; eventController_ = eventController; soundPlayer_ = soundPlayer; - uiEvents_->onUIEvent.connect(boost::bind(&SoundEventController::handleUIEvent, this, _1)); eventController_->onEventQueueEventAdded.connect(boost::bind(&SoundEventController::handleEventQueueEventAdded, this, _1)); + settings_->onSettingChanged.connect(boost::bind(&SoundEventController::handleSettingChanged, this, _1)); - bool playSounds = settings->getBoolSetting("playSounds", true); - playSounds_ = !playSounds; - setPlaySounds(playSounds); + playSounds_ = settings->getSetting(SettingConstants::PLAY_SOUNDS); } void SoundEventController::handleEventQueueEventAdded(boost::shared_ptr<StanzaEvent> event) { @@ -35,18 +32,13 @@ void SoundEventController::handleEventQueueEventAdded(boost::shared_ptr<StanzaEv } void SoundEventController::setPlaySounds(bool playSounds) { - bool transmit = playSounds != playSounds_; playSounds_ = playSounds; - settings_->storeBool("playSounds", playSounds); - if (transmit) { - uiEvents_->send(boost::shared_ptr<ToggleSoundsUIEvent>(new ToggleSoundsUIEvent(playSounds_))); - } + settings_->storeSetting(SettingConstants::PLAY_SOUNDS, playSounds); } -void SoundEventController::handleUIEvent(boost::shared_ptr<UIEvent> event) { - boost::shared_ptr<ToggleSoundsUIEvent> soundEvent = boost::dynamic_pointer_cast<ToggleSoundsUIEvent>(event); - if (soundEvent) { - setPlaySounds(soundEvent->getEnabled()); +void SoundEventController::handleSettingChanged(const std::string& settingPath) { + if (SettingConstants::PLAY_SOUNDS.getKey() == settingPath) { + playSounds_ = settings_->getSetting(SettingConstants::PLAY_SOUNDS); } } |