Changeset - 74cd11e265a3
[Not reviewed]
0 2 0
HanzZ - 13 years ago 2012-09-22 08:18:38
hanzz.k@gmail.com
Fixed communi backend without irc_network option
2 files changed with 10 insertions and 1 deletions:
0 comments (0 inline, 0 general)
backends/libcommuni/ircnetworkplugin.cpp
Show inline comments
 
@@ -32,12 +32,14 @@ void IRCNetworkPlugin::handleLoginRequest(const std::string &user, const std::st
 
	// In server mode, hostname of the server we want to connect to is stored in "user" JID.
 
	// In component mode we will connect user to the IRC network once he joins the room.
 
	if (CONFIG_BOOL(config, "service.server_mode")) {
 
		MyIrcSession *session = new MyIrcSession(user, this);
 
		std::string h = user.substr(0, user.find("@"));
 
		session->setNickName(FROM_UTF8(h.substr(0, h.find("%"))));
 
		session->setUserName(FROM_UTF8(h.substr(0, h.find("%"))));
 
		session->setRealName(FROM_UTF8(h.substr(0, h.find("%"))));
 
		session->setHost(FROM_UTF8(h.substr(h.find("%") + 1)));
 
		session->setPort(6667);
 
		session->open();
 
		LOG4CXX_INFO(logger, user << ": Connecting IRC network " << h.substr(h.find("%") + 1));
 
		m_sessions[user] = session;
 
	}
 
@@ -76,12 +78,16 @@ void IRCNetworkPlugin::handleMessageSendRequest(const std::string &user, const s
 
		else {
 
			r = legacyName.substr(legacyName.find("/") + 1);
 
		}
 
	}
 
	LOG4CXX_INFO(logger, user << ": Session name: " << u << ", message to " << r);
 
	m_sessions[u]->sendCommand(IrcCommand::createMessage(FROM_UTF8(r), FROM_UTF8(message)));
 

	
 
	if (r.find("#") == 0) {
 
		handleMessage(user, legacyName, message, TO_UTF8(m_sessions[u]->nickName()));
 
	}
 
}
 

	
 
void IRCNetworkPlugin::handleJoinRoomRequest(const std::string &user, const std::string &room, const std::string &nickname, const std::string &password) {
 
	std::string r = room;
 
	std::string u = user;
 
	if (!CONFIG_BOOL(config, "service.server_mode")) {
 
@@ -93,12 +99,14 @@ void IRCNetworkPlugin::handleJoinRoomRequest(const std::string &user, const std:
 
	if (m_sessions[u] == NULL) {
 
		// in gateway mode we want to login this user to network according to legacyName
 
		if (room.find("@") != std::string::npos) {
 
			// suffix is %irc.freenode.net to let MyIrcSession return #room%irc.freenode.net
 
			MyIrcSession *session = new MyIrcSession(user, this, room.substr(room.find("@")));
 
			session->setNickName(FROM_UTF8(nickname));
 
			session->setUserName(FROM_UTF8(nickname));
 
			session->setRealName(FROM_UTF8(nickname));
 
			session->setHost(FROM_UTF8(room.substr(room.find("@") + 1)));
 
			session->setPort(6667);
 
			session->open();
 
			LOG4CXX_INFO(logger, user << ": Connecting IRC network " << room.substr(room.find("@") + 1));
 
			m_sessions[u] = session;
 
		}
backends/libcommuni/session.cpp
Show inline comments
 
@@ -158,13 +158,14 @@ void MyIrcSession::on_messageReceived(IrcMessage *message) {
 
		np->handleMessage(user, target + suffix, TO_UTF8(m->message()), nickname);
 
	}
 
	else {
 
		bool flags = 0;
 
		std::string nickname = TO_UTF8(m->sender().name());
 
		flags = correctNickname(nickname);
 
		np->handleMessage(user, nickname, TO_UTF8(m->message()));
 
		LOG4CXX_INFO(logger, nickname + suffix);
 
		np->handleMessage(user, nickname + suffix, TO_UTF8(m->message()));
 
	}
 
}
 

	
 
void MyIrcSession::on_numericMessageReceived(IrcMessage *message) {
 
	QString channel;
 
	QStringList members;
0 comments (0 inline, 0 general)