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/Settings/SettingsProvider.h
parentb05f8fcb285d2d13d2be50a3eb1062048fbe30f5 (diff)
downloadswift-contrib-3605b6622bc8b4abb810fac6b53f7f71be0fa7de.zip
swift-contrib-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/Settings/SettingsProvider.h')
-rw-r--r--Swift/Controllers/Settings/SettingsProvider.h62
1 files changed, 51 insertions, 11 deletions
diff --git a/Swift/Controllers/Settings/SettingsProvider.h b/Swift/Controllers/Settings/SettingsProvider.h
index a5ff4eb..e884add 100644
--- a/Swift/Controllers/Settings/SettingsProvider.h
+++ b/Swift/Controllers/Settings/SettingsProvider.h
@@ -1,33 +1,73 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2012 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#ifndef SWIFTEN_SettingsProvider_H
-#define SWIFTEN_SettingsProvider_H
+#pragma once
-#include <string>
+#include <Swiften/Base/boost_bsignals.h>
+#include <string>
#include <vector>
namespace Swift {
class SettingsProvider {
+
+ public:
+ template <typename T>
+ class Setting {
+ public:
+ Setting(const std::string& key, const T& defaultValue) : key(key), defaultValue(defaultValue) {
+
+ }
+
+ const std::string& getKey() const {
+ return key;
+ }
+
+ const T& getDefaultValue() const {
+ return defaultValue;
+ }
+
+ private:
+ std::string key;
+ T defaultValue;
+ };
+
public:
virtual ~SettingsProvider() {}
- virtual std::string getStringSetting(const std::string &settingPath) = 0;
- virtual void storeString(const std::string &settingPath, const std::string &settingValue) = 0;
- virtual bool getBoolSetting(const std::string &settingPath, bool defaultValue) = 0;
- virtual void storeBool(const std::string &settingPath, bool settingValue) = 0;
- virtual int getIntSetting(const std::string &settingPath, int defaultValue) = 0;
- virtual void storeInt(const std::string &settingPath, int settingValue) = 0;
+ virtual std::string getSetting(const Setting<std::string>& setting) = 0;
+ virtual void storeSetting(const Setting<std::string>& setting, const std::string& value) = 0;
+ virtual bool getSetting(const Setting<bool>& setting) = 0;
+ virtual void storeSetting(const Setting<bool>& setting, const bool& value) = 0;
+ virtual int getSetting(const Setting<int>& setting) = 0;
+ virtual void storeSetting(const Setting<int>& setting, const int& value) = 0;
+
virtual std::vector<std::string> getAvailableProfiles() = 0;
virtual void createProfile(const std::string& profile) = 0;
virtual void removeProfile(const std::string& profile) = 0;
+ /** A final setting is one that this settings provider says may not be overriden by lower priority profiles.
+ * e.g. An Administrator-set configuration to disallow saving user passwords could not be overridden by the user.
+ */
+ template<typename T>
+ bool getIsSettingFinal(const Setting<T>& setting) {
+ return getIsSettingFinal(setting.getKey());
+ }
+
+ friend class SettingsProviderHierachy;
+ protected:
+ virtual bool getIsSettingFinal(const std::string& settingPath) = 0;
+
+ public:
+ /**
+ * Emitted when a setting is changed.
+ */
+ boost::signal<void (const std::string& /*Setting's Path*/)> onSettingChanged;
};
}
-#endif
+