summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-10-07 19:40:16 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-10-07 19:40:27 (GMT)
commit88eab3d1d9b722590da3837e3c79839189ea58d2 (patch)
tree05709f368187657c5788ebf2d5206cb47414933d /Swift/Controllers/MainController.cpp
parente433e70d3dd015db5124ee72085e758635260168 (diff)
downloadswift-88eab3d1d9b722590da3837e3c79839189ea58d2.zip
swift-88eab3d1d9b722590da3837e3c79839189ea58d2.tar.bz2
Code cleanup from recent commits
Diffstat (limited to 'Swift/Controllers/MainController.cpp')
-rw-r--r--Swift/Controllers/MainController.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index ed28c52..37dc0a9 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -62,6 +62,7 @@
#include "Swiften/StringCodecs/SHA1.h"
#include "Swiften/StringCodecs/Hexify.h"
#include "Swift/Controllers/UIEvents/RequestChatUIEvent.h"
+#include "Swift/Controllers/UIEvents/ToggleNotificationsUIEvent.h"
namespace Swift {
@@ -162,6 +163,12 @@ MainController::MainController(
idleDetector_.onIdleChanged.connect(boost::bind(&MainController::handleInputIdleChanged, this, _1));
xmlConsoleController_ = new XMLConsoleController(uiEventStream_, xmlConsoleWidgetFactory);
+
+ bool enabled = settings_->getBoolSetting("showNotifications", true);
+ notifier_->setEnabled(enabled);
+ uiEventStream_->send(boost::shared_ptr<ToggleNotificationsUIEvent>(new ToggleNotificationsUIEvent(enabled)));
+ uiEventStream_->onUIEvent.connect(boost::bind(&MainController::handleUIEvent, this, _1));
+
if (loginAutomatically) {
profileSettings_ = new ProfileSettingsProvider(selectedLoginJID, settings_);
handleLoginRequest(selectedLoginJID, cachedPassword, cachedCertificate, true, true);
@@ -230,6 +237,17 @@ void MainController::resetClient() {
profileSettings_ = NULL;
}
+void MainController::handleUIEvent(boost::shared_ptr<UIEvent> event) {
+ boost::shared_ptr<ToggleNotificationsUIEvent> notificationsEvent = boost::dynamic_pointer_cast<ToggleNotificationsUIEvent>(event);
+ if (notificationsEvent) {
+ bool enabled = notificationsEvent->getEnabled();
+ if (enabled != notifier_->getEnabled()) {
+ notifier_->setEnabled(enabled);
+ settings_->storeBool("showNotifications", enabled);
+ }
+ }
+}
+
void MainController::resetPendingReconnects() {
timeBeforeNextReconnect_ = -1;
if (reconnectTimer_) {
@@ -402,7 +420,7 @@ void MainController::performLoginFromCachedCredentials() {
entityCapsManager_ = new EntityCapsManager(capsManager_, client_);
presenceNotifier_ = new PresenceNotifier(client_, notifier_, mucRegistry_, avatarManager_, nickResolver_, presenceOracle_, &timerFactory_);
presenceNotifier_->onNotificationActivated.connect(boost::bind(&MainController::handleNotificationClicked, this, _1));
- eventNotifier_ = new EventNotifier(eventController_, notifier_, avatarManager_, nickResolver_, uiEventStream_, settings_);
+ eventNotifier_ = new EventNotifier(eventController_, notifier_, avatarManager_, nickResolver_);
eventNotifier_->onNotificationActivated.connect(boost::bind(&MainController::handleNotificationClicked, this, _1));
client_->onDataRead.connect(boost::bind(
&XMLConsoleController::handleDataRead, xmlConsoleController_, _1));