Changeset - 68527d73e2b8
[Not reviewed]
0 5 0
Jan Kaluza - 9 years ago 2016-02-24 17:06:10
jkaluza@redhat.com
Libtransport: Allow unregistered boolean variables in Config
5 files changed with 24 insertions and 4 deletions:
0 comments (0 inline, 0 general)
libtransport/Config.cpp
Show inline comments
 
@@ -219,7 +219,15 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description
 
		if (opt.unregistered) {
 
			if (std::find(has_key.begin(), has_key.end(), opt.string_key) == has_key.end()) {
 
				has_key.push_back(opt.string_key);
 
				m_unregistered[opt.string_key] = variable_value(opt.value[0], false);
 
				if (opt.value[0] == "true" || opt.value[0] == "1") {
 
					m_unregistered[opt.string_key] = variable_value(true, false);
 
				}
 
				else if (opt.value[0] == "true" || opt.value[0] == "1") {
 
					m_unregistered[opt.string_key] = variable_value(false, false);
 
				}
 
				else {
 
					m_unregistered[opt.string_key] = variable_value(opt.value[0], false);
 
				}
 
			}
 
			else {
 
				std::list<std::string> list;
spectrum/src/frontends/xmpp/adhocmanager.cpp
Show inline comments
 
@@ -73,6 +73,9 @@ void AdHocManager::handleUserCreated(User *user) {
 
	for (std::map<std::string, AdHocCommandFactory *>::const_iterator it = m_factories.begin(); it != m_factories.end(); it++) {
 
		for (std::map<std::string, std::string>::const_iterator it2 = it->second->getUserSettings().begin(); it2 != it->second->getUserSettings().end(); it2++) {
 
			std::string value = CONFIG_STRING_DEFAULTED(m_component->getConfig(), it->second->getNode() + "." + it2->first, it2->second);
 
			if (it2->second == "true" || it2->second == "1" || it2->second == "false" || it2->second == "0") {
 
				value = CONFIG_BOOL_DEFAULTED(m_component->getConfig(), it->second->getNode() + "." + it2->first, it2->second == "true" || it2->second == "1") ? "1" : "0";
 
			}
 
			if (m_storageBackend) {
 
				int type = (int) TYPE_BOOLEAN;
 
				m_storageBackend->getUserSetting(user->getUserInfo().id, it2->first, type, value);
spectrum/src/frontends/xmpp/settingsadhoccommand.cpp
Show inline comments
 
@@ -67,11 +67,11 @@ boost::shared_ptr<Swift::Command> SettingsAdHocCommand::getForm() {
 
	m_storageBackend->getUserSetting(user.id, "enable_transport", type, value);
 
	FormUtils::addBooleanField(form, "enable_transport", value, "Enable transport");
 

	
 
	value = CONFIG_STRING_DEFAULTED(m_component->getConfig(), "settings.send_headlines", "0");
 
	value = CONFIG_BOOL_DEFAULTED(m_component->getConfig(), "settings.send_headlines", false) ? "1" : "0";
 
	m_storageBackend->getUserSetting(user.id, "send_headlines", type, value);
 
	FormUtils::addBooleanField(form, "send_headlines", value, "Allow sending messages as headlines");
 

	
 
	value = CONFIG_STRING_DEFAULTED(m_component->getConfig(), "settings.stay_connected", "0");
 
	value = CONFIG_BOOL_DEFAULTED(m_component->getConfig(), "settings.stay_connected", false) ? "1" : "0";
 
	m_storageBackend->getUserSetting(user.id, "stay_connected", type, value);
 
	FormUtils::addBooleanField(form, "stay_connected", value, "Stay connected to legacy network when offline on XMPP");
 

	
tests/libtransport/config.cpp
Show inline comments
 
@@ -16,6 +16,7 @@ using namespace Transport;
 
class ConfigTest : public CPPUNIT_NS :: TestFixture{
 
	CPPUNIT_TEST_SUITE(ConfigTest);
 
	CPPUNIT_TEST(setStringTwice);
 
	CPPUNIT_TEST(setUnknownBool);
 
	CPPUNIT_TEST(updateBackendConfig);
 
	CPPUNIT_TEST(updateBackendConfigJIDEscaping);
 
	CPPUNIT_TEST(unregisteredList);
 
@@ -40,6 +41,14 @@ class ConfigTest : public CPPUNIT_NS :: TestFixture{
 
		CPPUNIT_ASSERT_EQUAL(std::string("localhost"), CONFIG_STRING(&cfg, "service.jids"));
 
	}
 

	
 
	void setUnknownBool() {
 
		char *argv[3] = {"binary", "--service.jids=localhost", NULL};
 
		Config cfg(2, argv);
 
		std::istringstream ifs("service.irc_send_pass = 1\n");
 
		cfg.load(ifs);
 
		CPPUNIT_ASSERT_EQUAL(true, CONFIG_BOOL_DEFAULTED(&cfg, "service.irc_send_pass", false));
 
	}
 

	
 
	void updateBackendConfig() {
 
		Config cfg;
 
		CPPUNIT_ASSERT(!cfg.hasKey("registration.needPassword"));
tests/tests_output/localhost/vcard/client.dat
Show inline comments
 
@@ -20,8 +20,8 @@ return {
 
		};
 
	};
 
	["attr"] = {
 
		["prodid"] = "-//HandGen//NONSGML vGen v1.0//EN";
 
		["version"] = "2.0";
 
		["prodid"] = "-//HandGen//NONSGML vGen v1.0//EN";
 
		["xmlns"] = "vcard-temp";
 
	};
 
	["name"] = "vCard";
0 comments (0 inline, 0 general)