summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--SwifTools/Notifier/Notifier.h2
-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
-rw-r--r--Swiften/Roster/ContactRosterItem.cpp2
8 files changed, 30 insertions, 29 deletions
diff --git a/SwifTools/Notifier/Notifier.h b/SwifTools/Notifier/Notifier.h
index aacaf7e..e609867 100644
--- a/SwifTools/Notifier/Notifier.h
+++ b/SwifTools/Notifier/Notifier.h
@@ -33,7 +33,7 @@ namespace Swift {
enabled = b;
}
- bool getEnabled() {return enabled;}
+ bool getEnabled() const {return enabled;}
private:
virtual void doShowMessage(
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);
diff --git a/Swiften/Roster/ContactRosterItem.cpp b/Swiften/Roster/ContactRosterItem.cpp
index bbf3928..37fc6af 100644
--- a/Swiften/Roster/ContactRosterItem.cpp
+++ b/Swiften/Roster/ContactRosterItem.cpp
@@ -107,7 +107,7 @@ void ContactRosterItem::addGroup(const String& group) {
groups_.push_back(group);
}
void ContactRosterItem::removeGroup(const String& group) {
- groups_.erase(std::find(groups_.begin(), groups_.end(), group));
+ groups_.erase(std::remove(groups_.begin(), groups_.end(), group), groups_.end());
}
}