diff --git a/libtransport/Config.cpp b/libtransport/Config.cpp index 70974379..f9324113 100644 --- a/libtransport/Config.cpp +++ b/libtransport/Config.cpp @@ -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 list; diff --git a/spectrum/src/frontends/xmpp/adhocmanager.cpp b/spectrum/src/frontends/xmpp/adhocmanager.cpp index d88beccf..6b43bc8f 100644 --- a/spectrum/src/frontends/xmpp/adhocmanager.cpp +++ b/spectrum/src/frontends/xmpp/adhocmanager.cpp @@ -73,6 +73,9 @@ void AdHocManager::handleUserCreated(User *user) { for (std::map::const_iterator it = m_factories.begin(); it != m_factories.end(); it++) { for (std::map::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); diff --git a/spectrum/src/frontends/xmpp/settingsadhoccommand.cpp b/spectrum/src/frontends/xmpp/settingsadhoccommand.cpp index f8b3e7d0..5fdcff50 100644 --- a/spectrum/src/frontends/xmpp/settingsadhoccommand.cpp +++ b/spectrum/src/frontends/xmpp/settingsadhoccommand.cpp @@ -67,11 +67,11 @@ boost::shared_ptr 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"); diff --git a/tests/libtransport/config.cpp b/tests/libtransport/config.cpp index fea9ada1..8062b6e5 100644 --- a/tests/libtransport/config.cpp +++ b/tests/libtransport/config.cpp @@ -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")); diff --git a/tests/tests_output/localhost/vcard/client.dat b/tests/tests_output/localhost/vcard/client.dat index 96c1073d..a5b37957 100644 --- a/tests/tests_output/localhost/vcard/client.dat +++ b/tests/tests_output/localhost/vcard/client.dat @@ -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";