void SingleIRCNetworkPlugin::handleLoginRequest(const std::string &user, const std::string &legacyName, const std::string &password) { // legacy name is users nickname if (m_sessions[user] != NULL) { LOG4CXX_WARN(logger, user << ": Already logged in."); return; } LOG4CXX_INFO(logger, user << ": Connecting " << m_server << " as " << legacyName); MyIrcSession *session = new MyIrcSession(user, this); session->setUserName(FROM_UTF8(legacyName)); session->setNickName(FROM_UTF8(legacyName)); session->setRealName(FROM_UTF8(legacyName)); session->setHost(FROM_UTF8(m_server)); session->setPort(6667); session->setEncoding( "utf-8" ); if (!password.empty()) { std::string identify = m_identify; boost::replace_all(identify, "$password", password); boost::replace_all(identify, "$name", legacyName); session->setIdentify(identify); } session->open(); m_sessions[user] = session; }
MyIrcSession *IRCNetworkPlugin::createSession(const std::string &user, const std::string &hostname, const std::string &nickname, const std::string &password, const std::string &suffix) { MyIrcSession *session = new MyIrcSession(user, this, suffix); session->setUserName(FROM_UTF8(nickname)); session->setNickName(FROM_UTF8(nickname)); session->setRealName(FROM_UTF8(nickname)); session->setHost(FROM_UTF8(hostname)); session->setPort(6667); // session->setEncoding("UTF8"); if (!password.empty()) { std::string identify = m_identify; boost::replace_all(identify, "$password", password); boost::replace_all(identify, "$name", nickname); session->setIdentify(identify); } LOG4CXX_INFO(logger, user << ": Connecting " << hostname << " as " << nickname << ", suffix=" << suffix); session->open(); return session; }