Changeset - ad858d6c8dcb
[Not reviewed]
0 4 0
Jan Kaluza - 10 years ago 2016-02-26 06:57:02
jkaluza@redhat.com
Libcommuni: Respond to VCard with empty payload, change name automatically in case of conflict
4 files changed with 30 insertions and 7 deletions:
0 comments (0 inline, 0 general)
backends/libcommuni/ircnetworkplugin.cpp
Show inline comments
 
@@ -143,12 +143,16 @@ void IRCNetworkPlugin::handleLoginRequest(const std::string &user, const std::st
 
		// network he chooses...
 
		LOG4CXX_INFO(logger, user << ": Ready for connections");
 
		handleConnected(user);
 
	}
 
}
 

	
 
void IRCNetworkPlugin::handleVCardRequest(const std::string &user, const std::string &legacyName, unsigned int id) {
 
	handleVCard(user, id, legacyName, "", "", "");
 
}
 

	
 
void IRCNetworkPlugin::handleLogoutRequest(const std::string &user, const std::string &legacyName) {
 
	if (m_sessions[user] == NULL) {
 
		LOG4CXX_WARN(logger, user << ": Already disconnected.");
 
		return;
 
	}
 
	LOG4CXX_INFO(logger, user << ": Disconnecting.");
 
@@ -250,12 +254,13 @@ void IRCNetworkPlugin::handleJoinRoomRequest(const std::string &user, const std:
 
	m_sessions[session]->addAutoJoinChannel(target, password);
 
	m_sessions[session]->sendCommand(IrcCommand::createJoin(FROM_UTF8(target), FROM_UTF8(password)));
 
	m_sessions[session]->rooms += 1;
 

	
 
	// update nickname, because we have nickname per session, no nickname per room.
 
	handleRoomNicknameChanged(user, target, TO_UTF8(m_sessions[session]->nickName()));
 
	handleParticipantChanged(user, nickname, target, 0, pbnetwork::STATUS_ONLINE, "", TO_UTF8(m_sessions[session]->nickName()));
 
}
 

	
 
void IRCNetworkPlugin::handleLeaveRoomRequest(const std::string &user, const std::string &room) {
 
	std::string session = getSessionName(user, room);
 
	std::string target = getTargetName(room);
 

	
backends/libcommuni/ircnetworkplugin.h
Show inline comments
 
@@ -44,12 +44,14 @@ class IRCNetworkPlugin : public QObject, public NetworkPlugin {
 
		void handleJoinRoomRequest(const std::string &user, const std::string &room, const std::string &nickname, const std::string &password);
 

	
 
		void handleLeaveRoomRequest(const std::string &user, const std::string &room);
 

	
 
		void handleRoomSubjectChangedRequest(const std::string &user, const std::string &room, const std::string &message);
 

	
 
		void handleVCardRequest(const std::string &user, const std::string &legacyName, unsigned int id);
 

	
 
		void tryNextServer();
 

	
 
	public slots:
 
		void readData();
 
		void sendData(const std::string &string);
 

	
backends/libcommuni/session.cpp
Show inline comments
 
@@ -386,17 +386,23 @@ void MyIrcSession::on_numericMessageReceived(IrcMessage *message) {
 
			break;
 
		case 432:
 
			m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Erroneous Nickname");
 
			break;
 
		case 433:
 
			for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
 
				m_np->handleParticipantChanged(m_user, TO_UTF8(nickName()), it->second->getChannel() + m_suffix, pbnetwork::PARTICIPANT_FLAG_CONFLICT);
 
			}
 
			if (m_suffix.empty()) {
 
				m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Nickname is already in use");
 
				m_np->handleRoomNicknameChanged(m_user, it->second->getChannel() + m_suffix, TO_UTF8(nickName() + "_"));
 
				m_np->handleParticipantChanged(m_user, TO_UTF8(nickName()), it->second->getChannel() + m_suffix, 0, pbnetwork::STATUS_ONLINE, "", TO_UTF8(nickName() + "_"));
 
			}
 
			setNickName(nickName() + "_");
 
			open();
 
// 			for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
 
// 				m_np->handleParticipantChanged(m_user, TO_UTF8(nickName()), it->second->getChannel() + m_suffix, pbnetwork::PARTICIPANT_FLAG_CONFLICT);
 
// 			}
 
// 			if (m_suffix.empty()) {
 
// 				m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Nickname is already in use");
 
// 			}
 
			break;
 
		case 436:
 
			for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
 
				m_np->handleParticipantChanged(m_user, TO_UTF8(nickName()), it->second->getChannel() + m_suffix, pbnetwork::PARTICIPANT_FLAG_CONFLICT);
 
			}
 
			m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Nickname collision KILL");
tests/start.py
Show inline comments
 
@@ -3,12 +3,16 @@ import sys
 
import time
 
import subprocess
 
import os
 

	
 
import sleekxmpp
 
import imp
 
import logging
 

	
 
#logging.basicConfig(level=logging.DEBUG,
 
                        #format='%(levelname)-8s %(message)s')
 

	
 
def registerXMPPAccount(user, password):
 
	responder = sleekxmpp.ClientXMPP(user, password)
 
	responder.register_plugin('xep_0030')  # Service Discovery
 
	responder.register_plugin('xep_0077')
 
	responder['feature_mechanisms'].unencrypted_plain = True
 
@@ -66,25 +70,26 @@ class BaseTest:
 
		client.register_plugin('xep_0045')  # Multi-User Chat
 
		client.register_plugin('xep_0199')  # XMPP Ping
 
		client.register_plugin('xep_0153')
 
		client.register_plugin('xep_0054')
 
		client['feature_mechanisms'].unencrypted_plain = True
 

	
 
		time.sleep(2)
 
		time.sleep(1)
 

	
 
		to = ("127.0.0.1", 5223)
 
		if self.responder_password != "password":
 
			to = ("127.0.0.1", 5222)
 
		if client.connect(to):
 
			client.process(block=False)
 
		else:
 
			print "connect() failed"
 
			os.system("killall spectrum2")
 
			self.post_test()
 
			sys.exit(1)
 

	
 

	
 
		max_time = 60
 
		while not client.finished and not responder.finished and max_time > 0:
 
			time.sleep(1)
 
			max_time -= 1
 
		client.disconnect()
 
		responder.disconnect()
 
@@ -110,12 +115,17 @@ class BaseTest:
 

	
 
class LibcommuniServerModeSingleServerConf(BaseTest):
 
	def __init__(self):
 
		BaseTest.__init__(self, "../libcommuni/irc_test.cfg", True, "#channel@localhost")
 
		self.directory = "../libcommuni/"
 

	
 
	def skip_test(self, test):
 
		if test in ["muc_join_nickname_used.py"]:
 
			return True
 
		return False
 

	
 
	def pre_test(self):
 
		os.system("ngircd -f ../libcommuni/ngircd.conf &")
 

	
 
	def post_test(self):
 
		os.system("killall ngircd 2>/dev/null")
 
		os.system("killall spectrum2_libcommuni_backend 2>/dev/null")
 
@@ -196,14 +206,14 @@ class TwitterServerModeConf(BaseTest):
 
		os.system("killall spectrum2_twitter_backend 2>/dev/null")
 

	
 
configurations = []
 
configurations.append(LibcommuniServerModeSingleServerConf())
 
configurations.append(LibcommuniServerModeConf())
 
configurations.append(JabberServerModeConf())
 
#configurations.append(JabberSlackServerModeConf())
 
configurations.append(TwitterServerModeConf())
 
##configurations.append(JabberSlackServerModeConf())
 
#configurations.append(TwitterServerModeConf())
 

	
 
exitcode = 0
 

	
 
for conf in configurations:
 
	for f in os.listdir(conf.directory):
 
		if not f.endswith(".py") or f == "start.py":
0 comments (0 inline, 0 general)