X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fircserverhandler.cpp;h=93076ec50ea43b0787bb74631e625445c0966de2;hp=288a8ab594826e8fdb7907a5c17535bd6b673207;hb=034708a59ca1ee3195263a90941a2b145c520fef;hpb=9ad4372382f59d13f8073e7599b06b57a7c0d2b6 diff --git a/src/core/ircserverhandler.cpp b/src/core/ircserverhandler.cpp index 288a8ab5..93076ec5 100644 --- a/src/core/ircserverhandler.cpp +++ b/src/core/ircserverhandler.cpp @@ -30,6 +30,7 @@ #include "ircuser.h" #include "ircchannel.h" +#include "logger.h" #include @@ -153,7 +154,10 @@ void IrcServerHandler::defaultHandler(QString cmd, const QString &prefix, const // many nets define their own WHOIS fields. we fetch those not in need of special attention here: emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", "[Whois] " + params.join(" "), prefix); } else { - emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", cmd + " " + params.join(" "), prefix); + if(networkConnection()->coreSession()->ircListHelper()->requestInProgress(network()->networkId())) + networkConnection()->coreSession()->ircListHelper()->reportError(params.join(" ")); + else + emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", cmd + " " + params.join(" "), prefix); } } //qDebug() << prefix <<":"< emit displayMsg(Message::Mode, BufferInfo::ChannelBuffer, serverDecode(params[0]), serverDecode(params).join(" "), prefix); IrcChannel *channel = network()->ircChannel(params[0]); + if(!channel) { + // we received mode information for a channel we're not in. that means probably we've just been kicked out or something like that + // anyways: we don't have a place to store the data --> discard the info. + return; + } + QString modes = params[1]; bool add = true; int paramOffset = 2; @@ -350,6 +360,23 @@ void IrcServerHandler::handlePing(const QString &prefix, const QList 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; @@ -769,6 +796,10 @@ void IrcServerHandler::handle324(const QString &prefix, const QList /* RPL_??? - " " */ void IrcServerHandler::handle329(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix); + Q_UNUSED(params) +#ifdef __GNUC__ +# warning "Implement handle329 (Channel creation time)" +#endif // FIXME implement this... } @@ -779,7 +810,10 @@ void IrcServerHandler::handle331(const QString &prefix, const QList return; QString channel = serverDecode(params[0]); - network()->ircChannel(channel)->setTopic(QString()); + IrcChannel *chan = network()->ircChannel(channel); + if(chan) + chan->setTopic(QString()); + emit displayMsg(Message::Server, BufferInfo::ChannelBuffer, channel, tr("No topic is set for %1.").arg(channel)); } @@ -791,7 +825,10 @@ void IrcServerHandler::handle332(const QString &prefix, const QList QString channel = serverDecode(params[0]); QString topic = channelDecode(channel, params[1]); - network()->ircChannel(channel)->setTopic(topic); + IrcChannel *chan = network()->ircChannel(channel); + if(chan) + chan->setTopic(topic); + emit displayMsg(Message::Server, BufferInfo::ChannelBuffer, channel, tr("Topic for %1 is \"%2\"").arg(channel, topic)); } @@ -833,7 +870,7 @@ void IrcServerHandler::handle352(const QString &prefix, const QList /* RPL_NAMREPLY */ void IrcServerHandler::handle353(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix); - if(!checkParamCount("IrcServerHandler::handle353()", params, 2)) + if(!checkParamCount("IrcServerHandler::handle353()", params, 3)) return; // param[0] is either "=", "*" or "@" indicating a public, private or secret channel @@ -926,7 +963,7 @@ void IrcServerHandler::tryNextNick(const QString &errnick) { bool IrcServerHandler::checkParamCount(const QString &methodName, const QList ¶ms, int minParams) { if(params.count() < minParams) { - qWarning() << qPrintable(methodName) << "requieres" << minParams << "parameters but received only" << params.count() << serverDecode(params); + qWarning() << qPrintable(methodName) << "requires" << minParams << "parameters but received only" << params.count() << serverDecode(params); return false; } else { return true;