X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fircserverhandler.cpp;h=f46606564293b15a99f8bee6cd1e591f2be9d839;hp=ae7736d9ae1bdc4dbd25b3cc316ea8f4e738289e;hb=4d97c55d7f8864041b891b2d2f13c909f8b548f8;hpb=257ca0d5f944a8f63d002e1dcaaa3902258d85e0 diff --git a/src/core/ircserverhandler.cpp b/src/core/ircserverhandler.cpp index ae7736d9..f4660656 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 @@ -47,7 +48,7 @@ IrcServerHandler::~IrcServerHandler() { void IrcServerHandler::handleServerMsg(QByteArray msg) { try { if(msg.isEmpty()) { - qWarning() << "Received empty string from server!"; + quWarning() << "Received empty string from server!"; return; } @@ -67,7 +68,7 @@ void IrcServerHandler::handleServerMsg(QByteArray msg) { QList params = msg.split(' '); if(!trailing.isEmpty()) params << trailing; if(params.count() < 1) { - qWarning() << "Received invalid string from server!"; + quWarning() << "Received invalid string from server!"; return; } @@ -78,7 +79,7 @@ void IrcServerHandler::handleServerMsg(QByteArray msg) { foo.remove(0, 1); prefix = foo; if(params.count() < 1) { - qWarning() << "Received invalid string from server!"; + quWarning() << "Received invalid string from server!"; return; } foo = serverDecode(params.takeFirst()); @@ -91,7 +92,7 @@ void IrcServerHandler::handleServerMsg(QByteArray msg) { uint num = cmd.toUInt(); if(num > 0) { if(params.count() == 0) { - qWarning() << "Message received from server violates RFC and is ignored!"; + quWarning() << "Message received from server violates RFC and is ignored!"; return; } params.removeFirst(); @@ -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; @@ -234,7 +244,7 @@ void IrcServerHandler::handleMode(const QString &prefix, const QList else channel->removeUserMode(ircUser, QString(modes[c])); } else { - qWarning() << "Received MODE with too few parameters:" << serverDecode(params); + quWarning() << "Received MODE with too few parameters:" << serverDecode(params); } paramOffset++; } else { @@ -245,7 +255,7 @@ void IrcServerHandler::handleMode(const QString &prefix, const QList if(paramOffset < params.count()) { value = params[paramOffset]; } else { - qWarning() << "Received MODE with too few parameters:" << serverDecode(params); + quWarning() << "Received MODE with too few parameters:" << serverDecode(params); } paramOffset++; } @@ -294,7 +304,7 @@ void IrcServerHandler::handleNick(const QString &prefix, const QList IrcUser *ircuser = network()->updateNickFromMask(prefix); if(!ircuser) { - qWarning() << "IrcServerHandler::handleNick(): Unknown IrcUser!"; + quWarning() << "IrcServerHandler::handleNick(): Unknown IrcUser!"; return; } QString newnick = serverDecode(params[0]); @@ -331,7 +341,7 @@ void IrcServerHandler::handlePart(const QString &prefix, const QList IrcUser *ircuser = network()->updateNickFromMask(prefix); QString channel = serverDecode(params[0]); if(!ircuser) { - qWarning() << "IrcServerHandler::handlePart(): Unknown IrcUser!"; + quWarning() << "IrcServerHandler::handlePart(): Unknown IrcUser!"; return; } @@ -373,12 +383,12 @@ void IrcServerHandler::handlePrivmsg(const QString &prefix, const QListupdateNickFromMask(prefix); if(!ircuser) { - qWarning() << "IrcServerHandler::handlePrivmsg(): Unknown IrcUser!"; + quWarning() << "IrcServerHandler::handlePrivmsg(): Unknown IrcUser!"; return; } if(params.isEmpty()) { - qWarning() << "IrcServerHandler::handlePrivmsg(): received PRIVMSG without target or message from:" << prefix; + quWarning() << "IrcServerHandler::handlePrivmsg(): received PRIVMSG without target or message from:" << prefix; return; } @@ -786,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... } @@ -796,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)); } @@ -808,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)); } @@ -850,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 @@ -859,7 +879,7 @@ void IrcServerHandler::handle353(const QString &prefix, const QList IrcChannel *channel = network()->ircChannel(channelname); if(!channel) { - qWarning() << "IrcServerHandler::handle353(): received unknown target channel:" << channelname; + quWarning() << "IrcServerHandler::handle353(): received unknown target channel:" << channelname; return; } @@ -943,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); + quWarning() << qPrintable(methodName) << "requires" << minParams << "parameters but received only" << params.count() << serverDecode(params); return false; } else { return true;