Changeset - fd4946efe48c
[Not reviewed]
0 5 0
HanzZ - 13 years ago 2013-02-11 21:24:19
hanzz.k@gmail.com
Libcommuni: Do not enable JID escaping for IRC
5 files changed with 28 insertions and 4 deletions:
0 comments (0 inline, 0 general)
backends/libcommuni/ircnetworkplugin.cpp
Show inline comments
 
@@ -53,12 +53,13 @@ void IRCNetworkPlugin::readData() {
 
		m_firstPing = false;
 
		// Users can join the network without registering if we allow
 
		// one user to connect multiple IRC networks.
 
		NetworkPlugin::PluginConfig cfg;
 
		if (m_servers.empty()) {
 
			NetworkPlugin::PluginConfig cfg;
 
			cfg.setNeedRegistration(false);
 
			cfg.setSupportMUC(true);
 
			sendConfig(cfg);
 
		}
 
		cfg.setSupportMUC(true);
 
		cfg.disableJIDEscaping();
 
		sendConfig(cfg);
 
	}
 

	
 
	std::string d = std::string(m_socket->readAll().data(), availableBytes);
include/transport/networkplugin.h
Show inline comments
 
@@ -39,7 +39,8 @@ class NetworkPlugin {
 

	
 
		class PluginConfig {
 
			public:
 
				PluginConfig() : m_needPassword(true), m_needRegistration(false), m_supportMUC(false), m_rawXML(false) {}
 
				PluginConfig() : m_needPassword(true), m_needRegistration(false), m_supportMUC(false), m_rawXML(false),
 
				m_disableJIDEscaping(false) {}
 
				virtual ~PluginConfig() {}
 

	
 
				void setNeedRegistration(bool needRegistration = false) { m_needRegistration = needRegistration; }
 
@@ -47,12 +48,14 @@ class NetworkPlugin {
 
				void setSupportMUC(bool supportMUC = true) { m_supportMUC = supportMUC; }
 
				void setExtraFields(const std::vector<std::string> &fields) { m_extraFields = fields; }
 
				void setRawXML(bool rawXML = false) { m_rawXML = rawXML; }
 
				void disableJIDEscaping() { m_disableJIDEscaping = true; }
 

	
 
			private:
 
				bool m_needPassword;
 
				bool m_needRegistration;
 
				bool m_supportMUC;
 
				bool m_rawXML;
 
				bool m_disableJIDEscaping;
 
				std::vector<std::string> m_extraFields;
 

	
 
				friend class NetworkPlugin;
plugin/cpp/networkplugin.cpp
Show inline comments
 
@@ -74,6 +74,8 @@ void NetworkPlugin::sendConfig(const PluginConfig &cfg) {
 
	data += "[features]\n";
 
	data += std::string("muc=") + (cfg.m_supportMUC ? "1" : "0") + "\n";
 
	data += std::string("rawxml=") + (cfg.m_rawXML ? "1" : "0") + "\n";
 
	data += std::string("disable_jid_escaping=") + (cfg.m_disableJIDEscaping ? "1" : "0") + "\n";
 
	
 

	
 
	pbnetwork::BackendConfig m;
 
	m.set_config(data);
src/config.cpp
Show inline comments
 
@@ -316,6 +316,7 @@ void Config::updateBackendConfig(const std::string &backendConfig) {
 
		("features.receipts", value<bool>()->default_value(false), "")
 
		("features.muc", value<bool>()->default_value(false), "")
 
		("features.rawxml", value<bool>()->default_value(false), "")
 
		("features.disable_jid_escaping", value<bool>()->default_value(false), "")
 
	;
 

	
 
	std::stringstream ifs(backendConfig);
 
@@ -325,6 +326,12 @@ void Config::updateBackendConfig(const std::string &backendConfig) {
 
	notify(m_backendConfig);
 

	
 
	onBackendConfigUpdated();
 

	
 
	if (CONFIG_BOOL_DEFAULTED(this, "features.disable_jid_escaping", false)) {
 
		Variables::iterator it(m_variables.find("service.jid_escaping"));
 
		boost::program_options::variable_value& vx(it->second);
 
		vx.value() = false;
 
	}
 
}
 

	
 
Config *Config::createFromArgs(int argc, char **argv, std::string &error, std::string &host, int &port) {
src/tests/config.cpp
Show inline comments
 
@@ -26,6 +26,7 @@ class ConfigTest : public CPPUNIT_NS :: TestFixture{
 
	CPPUNIT_TEST_SUITE(ConfigTest);
 
	CPPUNIT_TEST(setStringTwice);
 
	CPPUNIT_TEST(updateBackendConfig);
 
	CPPUNIT_TEST(updateBackendConfigJIDEscaping);
 
	CPPUNIT_TEST(unregisteredList);
 
	CPPUNIT_TEST(unregisteredString);
 
	CPPUNIT_TEST(unregisteredListAsString);
 
@@ -57,6 +58,16 @@ class ConfigTest : public CPPUNIT_NS :: TestFixture{
 
		CPPUNIT_ASSERT_EQUAL(false, CONFIG_BOOL(&cfg, "registration.needPassword"));
 
	}
 

	
 
	void updateBackendConfigJIDEscaping() {
 
		Config cfg;
 
		std::istringstream ifs("service.jids = irc.freenode.org\n");
 
		cfg.load(ifs);
 
		CPPUNIT_ASSERT_EQUAL(true, CONFIG_BOOL(&cfg, "service.jid_escaping"));
 

	
 
		cfg.updateBackendConfig("[features]\ndisable_jid_escaping=1\n");
 
		CPPUNIT_ASSERT_EQUAL(false, CONFIG_BOOL(&cfg, "service.jid_escaping"));
 
	}
 

	
 
	void unregisteredList() {
 
		Config cfg;
 
		std::istringstream ifs("service.irc_server = irc.freenode.org\nservice.irc_server=localhost\n");
0 comments (0 inline, 0 general)