summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/RosterController.cpp18
-rw-r--r--Swift/Controllers/RosterController.h2
-rw-r--r--Swift/Controllers/UIEvents/ToggleShowOfflineUIEvent.h19
-rw-r--r--Swift/Controllers/UIInterfaces/MainWindow.h1
4 files changed, 35 insertions, 5 deletions
diff --git a/Swift/Controllers/RosterController.cpp b/Swift/Controllers/RosterController.cpp
index 4df8d13..ed311d9 100644
--- a/Swift/Controllers/RosterController.cpp
+++ b/Swift/Controllers/RosterController.cpp
@@ -31,9 +31,12 @@
#include "Swift/Controllers/UIEvents/RemoveRosterItemUIEvent.h"
#include "Swift/Controllers/UIEvents/RenameRosterItemUIEvent.h"
#include "Swift/Controllers/UIEvents/RegroupRosterItemUIEvent.h"
+#include "Swift/Controllers/UIEvents/ToggleShowOfflineUIEvent.h"
namespace Swift {
-
+
+static const String SHOW_OFFLINE = "showOffline";
+
/**
* The controller does not gain ownership of these parameters.
*/
@@ -43,12 +46,12 @@ RosterController::RosterController(const JID& jid, XMPPRoster* xmppRoster, Avata
presenceOracle_ = presenceOracle;
subscriptionManager_ = subscriptionManager;
eventController_ = eventController;
+ settings_ = settings;
expandiness_ = new RosterGroupExpandinessPersister(roster_, settings);
roster_->addFilter(offlineFilter_);
mainWindow_->setRosterModel(roster_);
changeStatusConnection_ = mainWindow_->onChangeStatusRequest.connect(boost::bind(&RosterController::handleChangeStatusRequest, this, _1, _2));
- showOfflineConnection_ = mainWindow_->onShowOfflineToggled.connect(boost::bind(&RosterController::handleShowOfflineToggled, this, _1));
signOutConnection_ = mainWindow_->onSignOutRequest.connect(boost::bind(boost::ref(onSignOutRequest)));
xmppRoster_->onJIDAdded.connect(boost::bind(&RosterController::handleOnJIDAdded, this, _1));
xmppRoster_->onJIDUpdated.connect(boost::bind(&RosterController::handleOnJIDUpdated, this, _1, _2, _3));
@@ -61,7 +64,9 @@ RosterController::RosterController(const JID& jid, XMPPRoster* xmppRoster, Avata
avatarManager_->onAvatarChanged.connect(boost::bind(&RosterController::handleAvatarChanged, this, _1));
mainWindow_->setMyAvatarPath(avatarManager_->getAvatarPath(myJID_).string());
setNickResolver(nickResolver);
-
+ if (settings->getBoolSetting(SHOW_OFFLINE, false)) {
+ uiEventStream->onUIEvent(boost::shared_ptr<UIEvent>(new ToggleShowOfflineUIEvent(true)));
+ }
}
RosterController::~RosterController() {
@@ -93,6 +98,9 @@ void RosterController::setEnabled(bool enabled) {
}
void RosterController::handleShowOfflineToggled(bool state) {
+ if (state != settings_->getBoolSetting(SHOW_OFFLINE, false)) {
+ settings_->storeBool(SHOW_OFFLINE, state);
+ }
if (state) {
roster_->removeFilter(offlineFilter_);
} else {
@@ -161,6 +169,10 @@ void RosterController::handleOnJIDUpdated(const JID& jid, const String& oldName,
}
void RosterController::handleUIEvent(boost::shared_ptr<UIEvent> event) {
+ boost::shared_ptr<ToggleShowOfflineUIEvent> showOfflineEvent = boost::dynamic_pointer_cast<ToggleShowOfflineUIEvent>(event);
+ if (showOfflineEvent) {
+ handleShowOfflineToggled(showOfflineEvent->getShow());
+ }
boost::shared_ptr<AddContactUIEvent> addContactEvent = boost::dynamic_pointer_cast<AddContactUIEvent>(event);
if (addContactEvent) {
RosterItemPayload item;
diff --git a/Swift/Controllers/RosterController.h b/Swift/Controllers/RosterController.h
index 70f1288..be9e407 100644
--- a/Swift/Controllers/RosterController.h
+++ b/Swift/Controllers/RosterController.h
@@ -74,8 +74,8 @@ namespace Swift {
EventController* eventController_;
RosterGroupExpandinessPersister* expandiness_;
IQRouter* iqRouter_;
+ SettingsProvider* settings_;
boost::bsignals::scoped_connection changeStatusConnection_;
- boost::bsignals::scoped_connection showOfflineConnection_;
boost::bsignals::scoped_connection signOutConnection_;
boost::bsignals::scoped_connection uiEventConnection_;
};
diff --git a/Swift/Controllers/UIEvents/ToggleShowOfflineUIEvent.h b/Swift/Controllers/UIEvents/ToggleShowOfflineUIEvent.h
new file mode 100644
index 0000000..b45eb83
--- /dev/null
+++ b/Swift/Controllers/UIEvents/ToggleShowOfflineUIEvent.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include "Swift/Controllers/UIEvents/UIEvent.h"
+
+namespace Swift {
+ class ToggleShowOfflineUIEvent : public UIEvent {
+ public:
+ ToggleShowOfflineUIEvent(bool show) : show_(show) {};
+ bool getShow() {return show_;};
+ private:
+ bool show_;
+ };
+}
diff --git a/Swift/Controllers/UIInterfaces/MainWindow.h b/Swift/Controllers/UIInterfaces/MainWindow.h
index 26b4ae8..3f37fc8 100644
--- a/Swift/Controllers/UIInterfaces/MainWindow.h
+++ b/Swift/Controllers/UIInterfaces/MainWindow.h
@@ -33,7 +33,6 @@ namespace Swift {
virtual void setConnecting() = 0;
boost::signal<void (StatusShow::Type, const String&)> onChangeStatusRequest;
- boost::signal<void (bool)> onShowOfflineToggled;
boost::signal<void ()> onSignOutRequest;
private: