summaryrefslogtreecommitdiffstats
path: root/Swift
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
parente433e70d3dd015db5124ee72085e758635260168 (diff)
downloadswift-contrib-88eab3d1d9b722590da3837e3c79839189ea58d2.zip
swift-contrib-88eab3d1d9b722590da3837e3c79839189ea58d2.tar.bz2
Code cleanup from recent commits
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/EventNotifier.cpp17
-rw-r--r--Swift/Controllers/EventNotifier.h6
-rw-r--r--Swift/Controllers/MainController.cpp20
-rw-r--r--Swift/Controllers/MainController.h2
-rw-r--r--Swift/Controllers/RosterGroupExpandinessPersister.cpp8
-rw-r--r--Swift/Controllers/XMPPEvents/EventController.h2
6 files changed, 28 insertions, 27 deletions
diff --git a/Swift/Controllers/EventNotifier.cpp b/Swift/Controllers/EventNotifier.cpp
index 7743d6f..7c8adaf 100644
--- a/Swift/Controllers/EventNotifier.cpp
+++ b/Swift/Controllers/EventNotifier.cpp
@@ -16,17 +16,12 @@
#include "Swift/Controllers/XMPPEvents/MessageEvent.h"
#include "Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h"
#include "Swift/Controllers/XMPPEvents/ErrorEvent.h"
-#include "Swift/Controllers/UIEvents/UIEventStream.h"
-#include "Swift/Controllers/UIEvents/ToggleNotificationsUIEvent.h"
#include "Swiften/Settings/SettingsProvider.h"
namespace Swift {
-EventNotifier::EventNotifier(EventController* eventController, Notifier* notifier, AvatarManager* avatarManager, NickResolver* nickResolver, UIEventStream* uiEvents, SettingsProvider* settings) : eventController(eventController), notifier(notifier), avatarManager(avatarManager), nickResolver(nickResolver), uiEvents(uiEvents), settings(settings) {
+EventNotifier::EventNotifier(EventController* eventController, Notifier* notifier, AvatarManager* avatarManager, NickResolver* nickResolver) : eventController(eventController), notifier(notifier), avatarManager(avatarManager), nickResolver(nickResolver) {
eventController->onEventQueueEventAdded.connect(boost::bind(&EventNotifier::handleEventAdded, this, _1));
- bool enabled = settings->getBoolSetting("showNotifications", true);
- notifier->setEnabled(enabled);
- uiEvents->send(boost::shared_ptr<ToggleNotificationsUIEvent>(new ToggleNotificationsUIEvent(enabled)));
}
EventNotifier::~EventNotifier() {
@@ -55,14 +50,4 @@ void EventNotifier::handleNotificationActivated(JID jid) {
onNotificationActivated(jid);
}
-void EventNotifier::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);
- }
- }
-}
}
diff --git a/Swift/Controllers/EventNotifier.h b/Swift/Controllers/EventNotifier.h
index ae01f24..d88fa80 100644
--- a/Swift/Controllers/EventNotifier.h
+++ b/Swift/Controllers/EventNotifier.h
@@ -11,7 +11,6 @@
#include "SwifTools/Notifier/Notifier.h"
#include "Swiften/Base/boost_bsignals.h"
#include "Swift/Controllers/XMPPEvents/StanzaEvent.h"
-#include "Swift/Controllers/UIEvents/UIEvent.h"
#include "Swiften/JID/JID.h"
namespace Swift {
@@ -25,7 +24,7 @@ namespace Swift {
class EventNotifier {
public:
- EventNotifier(EventController* eventController, Notifier* notifier, AvatarManager* avatarManager, NickResolver* nickResolver, UIEventStream* uiEvents, SettingsProvider* settings);
+ EventNotifier(EventController* eventController, Notifier* notifier, AvatarManager* avatarManager, NickResolver* nickResolver);
~EventNotifier();
boost::signal<void (const JID&)> onNotificationActivated;
@@ -33,14 +32,11 @@ namespace Swift {
private:
void handleEventAdded(boost::shared_ptr<StanzaEvent>);
void handleNotificationActivated(JID jid);
- void handleUIEvent(boost::shared_ptr<UIEvent> event);
private:
EventController* eventController;
Notifier* notifier;
AvatarManager* avatarManager;
NickResolver* nickResolver;
- UIEventStream* uiEvents;
- SettingsProvider* settings;
};
}
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));
diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h
index ed2cee2..d5a8406 100644
--- a/Swift/Controllers/MainController.h
+++ b/Swift/Controllers/MainController.h
@@ -26,6 +26,7 @@
#include "Swiften/Elements/CapsInfo.h"
#include "Swift/Controllers/XMPPEvents/ErrorEvent.h"
#include "Swiften/Roster/XMPPRoster.h"
+#include "Swift/Controllers/UIEvents/UIEvent.h"
namespace Swift {
class AvatarStorage;
@@ -106,6 +107,7 @@ namespace Swift {
void handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo>, const boost::optional<ErrorPayload>&);
void handleEventQueueLengthChange(int count);
void handleVCardReceived(const JID& j, VCard::ref vCard);
+ void handleUIEvent(boost::shared_ptr<UIEvent> event);
void sendPresence(boost::shared_ptr<Presence> presence);
void handleInputIdleChanged(bool);
void logout();
diff --git a/Swift/Controllers/RosterGroupExpandinessPersister.cpp b/Swift/Controllers/RosterGroupExpandinessPersister.cpp
index a2953a5..d532fcb 100644
--- a/Swift/Controllers/RosterGroupExpandinessPersister.cpp
+++ b/Swift/Controllers/RosterGroupExpandinessPersister.cpp
@@ -29,7 +29,9 @@ void RosterGroupExpandinessPersister::handleGroupAdded(GroupRosterItem* group) {
void RosterGroupExpandinessPersister::handleExpandedChanged(GroupRosterItem* group, bool expanded) {
if (expanded) {
- collapsed_.erase(collapsed_.find(group->getDisplayName()));
+ String displayName = group->getDisplayName();
+ //collapsed_.erase(std::remove(collapsed_.begin(), collapsed_.end(), displayName), collapsed_.end());
+ collapsed_.erase(displayName);
} else {
collapsed_.insert(group->getDisplayName());
}
@@ -50,9 +52,7 @@ void RosterGroupExpandinessPersister::save() {
void RosterGroupExpandinessPersister::load() {
String saved = settings_->getStringSetting(SettingPath);
std::vector<String> collapsed = saved.split('\n');
- foreach (const String& group, collapsed) {
- collapsed_.insert(group);
- }
+ collapsed_.insert(collapsed.begin(), collapsed.end());
}
const String RosterGroupExpandinessPersister::SettingPath = "GroupExpandiness";
diff --git a/Swift/Controllers/XMPPEvents/EventController.h b/Swift/Controllers/XMPPEvents/EventController.h
index ba3fd5b..59bc55f 100644
--- a/Swift/Controllers/XMPPEvents/EventController.h
+++ b/Swift/Controllers/XMPPEvents/EventController.h
@@ -24,7 +24,7 @@ namespace Swift {
void handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceEvent);
boost::signal<void (int)> onEventQueueLengthChange;
boost::signal<void (boost::shared_ptr<StanzaEvent>)> onEventQueueEventAdded;
- const EventList getEvents() const {return events_;}
+ const EventList& getEvents() const {return events_;}
private:
void handleEventConcluded(boost::shared_ptr<StanzaEvent> event);