summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-02-17 16:57:01 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-02-21 14:34:55 (GMT)
commit3605b6622bc8b4abb810fac6b53f7f71be0fa7de (patch)
tree638a8fd6449dd235931fe307e50119adf9c9fe22 /Swift/Controllers/Roster
parentb05f8fcb285d2d13d2be50a3eb1062048fbe30f5 (diff)
downloadswift-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/Roster')
-rw-r--r--Swift/Controllers/Roster/RosterController.cpp27
-rw-r--r--Swift/Controllers/Roster/RosterController.h1
-rw-r--r--Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp15
-rw-r--r--Swift/Controllers/Roster/RosterGroupExpandinessPersister.h3
4 files changed, 24 insertions, 22 deletions
diff --git a/Swift/Controllers/Roster/RosterController.cpp b/Swift/Controllers/Roster/RosterController.cpp
index 66948c1..d3a00dd 100644
--- a/Swift/Controllers/Roster/RosterController.cpp
+++ b/Swift/Controllers/Roster/RosterController.cpp
@@ -1,5 +1,5 @@
/*
- * 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.
*/
@@ -35,7 +35,6 @@
#include "Swift/Controllers/UIEvents/RemoveRosterItemUIEvent.h"
#include "Swift/Controllers/UIEvents/RenameRosterItemUIEvent.h"
#include "Swift/Controllers/UIEvents/RenameGroupUIEvent.h"
-#include "Swift/Controllers/UIEvents/ToggleShowOfflineUIEvent.h"
#include "Swift/Controllers/UIEvents/SendFileUIEvent.h"
#include <Swiften/FileTransfer/FileTransferManager.h>
#include <Swiften/Client/NickManager.h>
@@ -44,11 +43,10 @@
#include <Swiften/Elements/DiscoInfo.h>
#include <Swiften/Disco/EntityCapsManager.h>
#include <Swiften/Jingle/JingleSessionManager.h>
+#include <Swift/Controllers/SettingConstants.h>
namespace Swift {
-static const std::string SHOW_OFFLINE = "showOffline";
-
/**
* The controller does not gain ownership of these parameters.
*/
@@ -83,12 +81,12 @@ RosterController::RosterController(const JID& jid, XMPPRoster* xmppRoster, Avata
entityCapsManager_->onCapsChanged.connect(boost::bind(&RosterController::handleOnCapsChanged, this, _1));
- if (settings->getBoolSetting(SHOW_OFFLINE, false)) {
- uiEventStream->onUIEvent(boost::shared_ptr<UIEvent>(new ToggleShowOfflineUIEvent(true)));
- }
+ settings_->onSettingChanged.connect(boost::bind(&RosterController::handleSettingChanged, this, _1));
+
}
RosterController::~RosterController() {
+ settings_->onSettingChanged.disconnect(boost::bind(&RosterController::handleSettingChanged, this, _1));
nickManager_->onOwnNickChanged.disconnect(boost::bind(&MainWindow::setMyNick, mainWindow_, _1));
delete offlineFilter_;
@@ -109,8 +107,8 @@ void RosterController::setEnabled(bool enabled) {
}
void RosterController::handleShowOfflineToggled(bool state) {
- if (state != settings_->getBoolSetting(SHOW_OFFLINE, false)) {
- settings_->storeBool(SHOW_OFFLINE, state);
+ if (state != settings_->getSetting(SettingConstants::SHOW_OFFLINE)) {
+ settings_->storeSetting(SettingConstants::SHOW_OFFLINE, state);
}
if (state) {
roster_->removeFilter(offlineFilter_);
@@ -181,11 +179,14 @@ void RosterController::handleOnJIDUpdated(const JID& jid, const std::string& old
applyAllPresenceTo(jid);
}
-void RosterController::handleUIEvent(boost::shared_ptr<UIEvent> event) {
- if (boost::shared_ptr<ToggleShowOfflineUIEvent> showOfflineEvent = boost::dynamic_pointer_cast<ToggleShowOfflineUIEvent>(event)) {
- handleShowOfflineToggled(showOfflineEvent->getShow());
+void RosterController::handleSettingChanged(const std::string& settingPath) {
+ if (settingPath == SettingConstants::SHOW_OFFLINE.getKey()) {
+ handleShowOfflineToggled(settings_->getSetting(SettingConstants::SHOW_OFFLINE));
}
- else if (boost::shared_ptr<AddContactUIEvent> addContactEvent = boost::dynamic_pointer_cast<AddContactUIEvent>(event)) {
+}
+
+void RosterController::handleUIEvent(boost::shared_ptr<UIEvent> event) {
+ if (boost::shared_ptr<AddContactUIEvent> addContactEvent = boost::dynamic_pointer_cast<AddContactUIEvent>(event)) {
RosterItemPayload item;
item.setName(addContactEvent->getName());
item.setJID(addContactEvent->getJID());
diff --git a/Swift/Controllers/Roster/RosterController.h b/Swift/Controllers/Roster/RosterController.h
index 66748ca..5e40124 100644
--- a/Swift/Controllers/Roster/RosterController.h
+++ b/Swift/Controllers/Roster/RosterController.h
@@ -74,6 +74,7 @@ namespace Swift {
void applyAllPresenceTo(const JID& jid);
void handleEditProfileRequest();
void handleOnCapsChanged(const JID& jid);
+ void handleSettingChanged(const std::string& settingPath);
JID myJID_;
XMPPRoster* xmppRoster_;
diff --git a/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp b/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp
index 0a242ae..81f0c12 100644
--- a/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp
+++ b/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp
@@ -1,17 +1,18 @@
/*
- * 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 "RosterGroupExpandinessPersister.h"
+#include <Swift/Controllers/Roster/RosterGroupExpandinessPersister.h>
#include <boost/bind.hpp>
#include <vector>
#include <Swiften/Base/foreach.h>
-#include "Swiften/Base/String.h"
-#include "Swift/Controllers/Roster/GroupRosterItem.h"
+#include <Swiften/Base/String.h>
+#include <Swift/Controllers/Roster/GroupRosterItem.h>
+#include <Swift/Controllers/SettingConstants.h>
namespace Swift {
@@ -48,15 +49,15 @@ void RosterGroupExpandinessPersister::save() {
}
setting += group;
}
- settings_->storeString(SettingPath, setting);
+ settings_->storeSetting(SettingConstants::EXPANDED_ROSTER_GROUPS, setting);
}
void RosterGroupExpandinessPersister::load() {
- std::string saved = settings_->getStringSetting(SettingPath);
+ std::string saved = settings_->getSetting(SettingConstants::EXPANDED_ROSTER_GROUPS);
std::vector<std::string> collapsed = String::split(saved, '\n');
collapsed_.insert(collapsed.begin(), collapsed.end());
}
-const std::string RosterGroupExpandinessPersister::SettingPath = "GroupExpandiness";
+
}
diff --git a/Swift/Controllers/Roster/RosterGroupExpandinessPersister.h b/Swift/Controllers/Roster/RosterGroupExpandinessPersister.h
index 63affe4..73c4f29 100644
--- a/Swift/Controllers/Roster/RosterGroupExpandinessPersister.h
+++ b/Swift/Controllers/Roster/RosterGroupExpandinessPersister.h
@@ -1,5 +1,5 @@
/*
- * 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.
*/
@@ -22,6 +22,5 @@ namespace Swift {
std::set<std::string> collapsed_;
Roster* roster_;
SettingsProvider* settings_;
- static const std::string SettingPath;
};
}