diff options
author | Kevin Smith <git@kismith.co.uk> | 2012-02-17 16:57:01 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-02-21 14:34:55 (GMT) |
commit | 3605b6622bc8b4abb810fac6b53f7f71be0fa7de (patch) | |
tree | 638a8fd6449dd235931fe307e50119adf9c9fe22 /Swift/Controllers/Settings/DummySettingsProvider.h | |
parent | b05f8fcb285d2d13d2be50a3eb1062048fbe30f5 (diff) | |
download | swift-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/DummySettingsProvider.h')
-rw-r--r-- | Swift/Controllers/Settings/DummySettingsProvider.h | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/Swift/Controllers/Settings/DummySettingsProvider.h b/Swift/Controllers/Settings/DummySettingsProvider.h index 90e1921..bb7d2e6 100644 --- a/Swift/Controllers/Settings/DummySettingsProvider.h +++ b/Swift/Controllers/Settings/DummySettingsProvider.h @@ -6,22 +6,44 @@ #pragma once -#include "Swift/Controllers/Settings/SettingsProvider.h" +#include <Swift/Controllers/Settings/SettingsProvider.h> + +#include <map> namespace Swift { class DummySettingsProvider : public SettingsProvider { public: virtual ~DummySettingsProvider() {} - virtual std::string getStringSetting(const std::string&) {return "";} - virtual void storeString(const std::string &, const std::string &) {} - virtual bool getBoolSetting(const std::string &, bool ) {return true;} - virtual void storeBool(const std::string &, bool ) {} - virtual int getIntSetting(const std::string &, int ) {return 0;} - virtual void storeInt(const std::string &, int ) {} + virtual std::string getSetting(const Setting<std::string>& setting) { + return stringValues.find(setting.getKey()) != stringValues.end() ? stringValues[setting.getKey()] : setting.getDefaultValue(); + }; + virtual void storeSetting(const Setting<std::string>& setting, const std::string& value) { + stringValues[setting.getKey()] = value; + onSettingChanged(setting.getKey()); + }; + virtual bool getSetting(const Setting<bool>& setting) { + return boolValues.find(setting.getKey()) != boolValues.end() ? boolValues[setting.getKey()] : setting.getDefaultValue(); + }; + virtual void storeSetting(const Setting<bool>& setting, const bool& value) { + boolValues[setting.getKey()] = value; + onSettingChanged(setting.getKey()); + }; + virtual int getSetting(const Setting<int>& setting) { + return intValues.find(setting.getKey()) != intValues.end() ? intValues[setting.getKey()] : setting.getDefaultValue(); + }; + virtual void storeSetting(const Setting<int>& setting, const int& value) { + intValues[setting.getKey()] = value; + onSettingChanged(setting.getKey()); + }; virtual std::vector<std::string> getAvailableProfiles() {return std::vector<std::string>();} virtual void createProfile(const std::string& ) {} virtual void removeProfile(const std::string& ) {} + virtual bool getIsSettingFinal(const std::string& ) {return false;} + private: + std::map<std::string, std::string> stringValues; + std::map<std::string, int> intValues; + std::map<std::string, bool> boolValues; }; } |