X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fircserverhandler.cpp;h=523b2153d20226719a43cae906d7f73723ae987c;hp=341dd003567b38c56231f42fb7db9d40131b1ea6;hb=68478cb98a582e4a5b9b8cc188de51287d0da6b0;hpb=bd6311ec1d07e4daf082b5f752ef6b46d7808430 diff --git a/src/core/ircserverhandler.cpp b/src/core/ircserverhandler.cpp index 341dd003..523b2153 100644 --- a/src/core/ircserverhandler.cpp +++ b/src/core/ircserverhandler.cpp @@ -89,11 +89,12 @@ void IrcServerHandler::handleServerMsg(QByteArray msg) { QString foo = serverDecode(params.takeFirst()); // with SASL, the command is 'AUTHENTICATE +' and we should check for this here. + /* obsolete because of events if(foo == QString("AUTHENTICATE +")) { handleAuthenticate(); return; } - + */ // a colon as the first chars indicates the existence of a prefix if(foo[0] == ':') { foo.remove(0, 1); @@ -138,20 +139,6 @@ void IrcServerHandler::defaultHandler(QString cmd, const QString &prefix, const //******************************/ // IRC SERVER HANDLER //******************************/ -void IrcServerHandler::handleInvite(const QString &prefix, const QList ¶ms) { - if(!checkParamCount("IrcServerHandler::handleInvite()", params, 2)) - return; -// qDebug() << "IrcServerHandler::handleInvite()" << prefix << params; - - IrcUser *ircuser = network()->updateNickFromMask(prefix); - if(!ircuser) { - return; - } - - QString channel = serverDecode(params[1]); - - emit displayMsg(Message::Invite, BufferInfo::StatusBuffer, "", tr("%1 invited you to channel %2").arg(ircuser->nick()).arg(channel)); -} void IrcServerHandler::handleJoin(const QString &prefix, const QList ¶ms) { if(!checkParamCount("IrcServerHandler::handleJoin()", params, 1)) @@ -182,28 +169,6 @@ void IrcServerHandler::handleJoin(const QString &prefix, const QList } } -void IrcServerHandler::handleKick(const QString &prefix, const QList ¶ms) { - if(!checkParamCount("IrcServerHandler::handleKick()", params, 2)) - return; - - network()->updateNickFromMask(prefix); - IrcUser *victim = network()->ircUser(params[1]); - if(!victim) - return; - - QString channel = serverDecode(params[0]); - victim->partChannel(channel); - - QString msg; - if(params.count() > 2) // someone got a reason! - msg = QString("%1 %2").arg(victim->nick()).arg(channelDecode(channel, params[2])); - else - msg = victim->nick(); - - emit displayMsg(Message::Kick, BufferInfo::ChannelBuffer, channel, msg, prefix); - //if(network()->isMe(victim)) network()->setKickedFromChannel(channel); -} - void IrcServerHandler::handleMode(const QString &prefix, const QList ¶ms) { if(!checkParamCount("IrcServerHandler::handleMode()", params, 2)) return; @@ -315,33 +280,6 @@ void IrcServerHandler::handleMode(const QString &prefix, const QList } } -void IrcServerHandler::handleNick(const QString &prefix, const QList ¶ms) { - if(!checkParamCount("IrcServerHandler::handleNick()", params, 1)) - return; - - IrcUser *ircuser = network()->updateNickFromMask(prefix); - if(!ircuser) { - qWarning() << "IrcServerHandler::handleNick(): Unknown IrcUser!"; - return; - } - QString newnick = serverDecode(params[0]); - QString oldnick = ircuser->nick(); - - QString sender = network()->isMyNick(oldnick) - ? newnick - : prefix; - - - // the order is cruicial - // otherwise the client would rename the buffer, see that the assigned ircuser doesn't match anymore - // and remove the ircuser from the querybuffer leading to a wrong on/offline state - ircuser->setNick(newnick); - coreSession()->renameBuffer(network()->networkId(), newnick, oldnick); - - foreach(QString channel, ircuser->channels()) - emit displayMsg(Message::Nick, BufferInfo::ChannelBuffer, channel, newnick, sender); -} - void IrcServerHandler::handleNotice(const QString &prefix, const QList ¶ms) { if(!checkParamCount("IrcServerHandler::handleNotice()", params, 2)) return; @@ -383,49 +321,11 @@ void IrcServerHandler::handleNotice(const QString &prefix, const QList ¶ms) { - if(!checkParamCount("IrcServerHandler::handlePart()", params, 1)) - return; - - IrcUser *ircuser = network()->updateNickFromMask(prefix); - QString channel = serverDecode(params[0]); - if(!ircuser) { - qWarning() << "IrcServerHandler::handlePart(): Unknown IrcUser!"; - return; - } - - ircuser->partChannel(channel); - - QString msg; - if(params.count() > 1) - msg = userDecode(ircuser->nick(), params[1]); - - emit displayMsg(Message::Part, BufferInfo::ChannelBuffer, channel, msg, prefix); - if(network()->isMe(ircuser)) network()->setChannelParted(channel); -} - void IrcServerHandler::handlePing(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix); putCmd("PONG", params); } -void IrcServerHandler::handlePong(const QString &prefix, const QList ¶ms) { - Q_UNUSED(prefix); - // the server is supposed to send back what we passed as param. and we send a timestamp - // but using quote and whatnought one can send arbitrary pings, so we have to do some sanity checks - if(params.count() < 2) - return; - - QString timestamp = serverDecode(params[1]); - QTime sendTime = QTime::fromString(timestamp, "hh:mm:ss.zzz"); - if(!sendTime.isValid()) { - emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", "PONG " + serverDecode(params).join(" "), prefix); - return; - } - - network()->setLatency(sendTime.msecsTo(QTime::currentTime()) / 2); -} - void IrcServerHandler::handlePrivmsg(const QString &prefix, const QList ¶ms) { if(!checkParamCount("IrcServerHandler::handlePrivmsg()", params, 1)) return; @@ -499,73 +399,6 @@ void IrcServerHandler::handleQuit(const QString &prefix, const QList } } -void IrcServerHandler::handleTopic(const QString &prefix, const QList ¶ms) { - if(!checkParamCount("IrcServerHandler::handleTopic()", params, 1)) - return; - - IrcUser *ircuser = network()->updateNickFromMask(prefix); - if(!ircuser) - return; - - IrcChannel *channel = network()->ircChannel(serverDecode(params[0])); - if(!channel) - return; - - QString topic; - if(params.count() > 1) { - QByteArray rawTopic = params[1]; -#ifdef HAVE_QCA2 - rawTopic = decrypt(channel->name(), rawTopic, true); -#endif - topic = channelDecode(channel->name(), rawTopic); - } - - channel->setTopic(topic); - - emit displayMsg(Message::Topic, BufferInfo::ChannelBuffer, channel->name(), tr("%1 has changed topic for %2 to: \"%3\"").arg(ircuser->nick()).arg(channel->name()).arg(topic)); -} - -void IrcServerHandler::handleCap(const QString &prefix, const QList ¶ms) { - // for SASL, there will only be a single param of 'sasl', however you can check here for - // additional CAP messages (ls, multi-prefix, et cetera). - - Q_UNUSED(prefix); - - if(params.size() == 3) { - QString param = serverDecode(params[2]); - if(param == QString("sasl")) { // SASL Ready - network()->putRawLine(serverEncode("AUTHENTICATE PLAIN")); // Only working with PLAIN atm, blowfish later - } - } -} - -void IrcServerHandler::handleAuthenticate() { - QString construct = network()->saslAccount(); - construct.append(QChar(QChar::Null)); - construct.append(network()->saslAccount()); - construct.append(QChar(QChar::Null)); - construct.append(network()->saslPassword()); - QByteArray saslData = QByteArray(construct.toAscii().toBase64()); - saslData.prepend(QString("AUTHENTICATE ").toAscii()); - network()->putRawLine(saslData); -} - -/* RPL_WELCOME */ -void IrcServerHandler::handle001(const QString &prefix, const QList ¶ms) { - network()->setCurrentServer(prefix); - - if(params.isEmpty()) { - emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", QString("%1 didn't supply a valid welcome message... expect some serious issues...")); - } - // there should be only one param: "Welcome to the Internet Relay Network !@" - QString param = serverDecode(params[0]); - QString myhostmask = param.section(' ', -1, -1); - - network()->setMyNick(nickFromMask(myhostmask)); - - emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", param, prefix); -} - /* RPL_ISUPPORT */ // TODO Complete 005 handling, also use sensible defaults for non-sent stuff void IrcServerHandler::handle005(const QString &prefix, const QList ¶ms) { @@ -596,34 +429,6 @@ void IrcServerHandler::handle005(const QString &prefix, const QList network()->determinePrefixes(); } -/* RPL_UMODEIS - " []" */ -void IrcServerHandler::handle221(const QString &prefix, const QList ¶ms) { - Q_UNUSED(prefix) - //TODO: save information in network object - emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("%1").arg(serverDecode(params).join(" "))); -} - -/* RPL_STATSCONN - "Highest connection cout: 8000 (7999 clients)" */ -void IrcServerHandler::handle250(const QString &prefix, const QList ¶ms) { - Q_UNUSED(prefix) - //TODO: save information in network object - emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("%1").arg(serverDecode(params).join(" "))); -} - -/* RPL_LOCALUSERS - "Current local user: 5024 Max: 7999 */ -void IrcServerHandler::handle265(const QString &prefix, const QList ¶ms) { - Q_UNUSED(prefix) - //TODO: save information in network object - emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("%1").arg(serverDecode(params).join(" "))); -} - -/* RPL_GLOBALUSERS - "Current global users: 46093 Max: 47650" */ -void IrcServerHandler::handle266(const QString &prefix, const QList ¶ms) { - Q_UNUSED(prefix) - //TODO: save information in network object - emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("%1").arg(serverDecode(params).join(" "))); -} - /* WHOIS-Message: Replies 311 - 313, 317 - 319 are all replies generated in response to a WHOIS message.