#include "util.h"
#include "coresession.h"
+#include "coreirclisthelper.h"
#include "networkconnection.h"
#include "network.h"
#include "identity.h"
#include "ircuser.h"
#include "ircchannel.h"
+#include "logger.h"
#include <QDebug>
void IrcServerHandler::handleServerMsg(QByteArray msg) {
try {
if(msg.isEmpty()) {
- qWarning() << "Received empty string from server!";
+ quWarning() << "Received empty string from server!";
return;
}
QList<QByteArray> 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;
}
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());
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();
void IrcServerHandler::defaultHandler(QString cmd, const QString &prefix, const QList<QByteArray> &rawparams) {
// we assume that all this happens in server encoding
- QStringList params;
- foreach(QByteArray r, rawparams) params << serverDecode(r);
+ QStringList params = serverDecode(rawparams);
uint num = cmd.toUInt();
if(num) {
// A lot of server messages don't really need their own handler because they don't do much.
break;
}
// Ignore these commands.
- case 366: case 376:
+ case 321: case 366: case 376:
break;
// Everything else will be marked in red, so we can add them somewhere.
default:
- emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", cmd + " " + params.join(" "), prefix);
+ if(_whois) {
+ // 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 {
+ 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 <<":"<<cmd<<params;
} else {
// IRC SERVER HANDLER
//******************************/
void IrcServerHandler::handleJoin(const QString &prefix, const QList<QByteArray> ¶ms) {
- if(params.count() < 1) return;
+ if(!checkParamCount("IrcServerHandler::handleJoin()", params, 1))
+ return;
+
QString channel = serverDecode(params[0]);
IrcUser *ircuser = network()->updateNickFromMask(prefix);
emit displayMsg(Message::Join, BufferInfo::ChannelBuffer, channel, channel, prefix);
//qDebug() << "IrcServerHandler::handleJoin()" << prefix << params;
ircuser->joinChannel(channel);
- if(network()->isMe(ircuser)) networkConnection()->setChannelJoined(channel);
+ if(network()->isMe(ircuser)) {
+ networkConnection()->setChannelJoined(channel);
+ putCmd("MODE", params[0]); // we want to know the modes of the channel we just joined, so we ask politely
+ }
}
void IrcServerHandler::handleKick(const QString &prefix, const QList<QByteArray> ¶ms) {
+ if(!checkParamCount("IrcServerHandler::handleKick()", params, 2))
+ return;
+
network()->updateNickFromMask(prefix);
IrcUser *victim = network()->ircUser(params[1]);
- if(!victim) return;
+ if(!victim)
+ return;
+
QString channel = serverDecode(params[0]);
-
victim->partChannel(channel);
QString msg;
}
void IrcServerHandler::handleMode(const QString &prefix, const QList<QByteArray> ¶ms) {
- if(params.count() < 2) {
- emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", tr("Received invalid MODE from %s: %s").arg(prefix).arg(serverDecode(params).join(" ")));
+ if(!checkParamCount("IrcServerHandler::handleMode()", params, 2))
return;
- }
if(network()->isChannelName(serverDecode(params[0]))) {
// Channel Modes
emit displayMsg(Message::Mode, BufferInfo::ChannelBuffer, serverDecode(params[0]), serverDecode(params).join(" "), prefix);
IrcChannel *channel = network()->ircChannel(params[0]);
- // FIXME: currently the IrcChannels only support PREFIX-Modes for users
- // This cannot be fixed unless the SignalProxy() doesn't rely on methodIds anymore
+ 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 modeIndex = 2;
+ int paramOffset = 2;
for(int c = 0; c < modes.length(); c++) {
if(modes[c] == '+') {
add = true;
continue;
}
- // this is the part where we restrict the mode changes to PREFIXES:
- if(network()->prefixModes().contains(modes[c]) && modeIndex < params.count()) {
- IrcUser *ircUser = network()->ircUser(params[modeIndex]);
+ if(network()->prefixModes().contains(modes[c])) {
+ // user channel modes (op, voice, etc...)
+ if(paramOffset < params.count()) {
+ IrcUser *ircUser = network()->ircUser(params[paramOffset]);
+ if(add)
+ channel->addUserMode(ircUser, QString(modes[c]));
+ else
+ channel->removeUserMode(ircUser, QString(modes[c]));
+ } else {
+ quWarning() << "Received MODE with too few parameters:" << serverDecode(params);
+ }
+ paramOffset++;
+ } else {
+ // regular channel modes
+ QString value;
+ Network::ChannelModeType modeType = network()->channelModeType(modes[c]);
+ if(modeType == Network::A_CHANMODE || modeType == Network::B_CHANMODE || (modeType == Network::C_CHANMODE && add)) {
+ if(paramOffset < params.count()) {
+ value = params[paramOffset];
+ } else {
+ quWarning() << "Received MODE with too few parameters:" << serverDecode(params);
+ }
+ paramOffset++;
+ }
+
if(add)
- channel->addUserMode(ircUser, QString(modes[c]));
+ channel->addChannelMode(modes[c], value);
else
- channel->removeUserMode(ircUser, QString(modes[c]));
+ channel->removeChannelMode(modes[c], value);
}
- modeIndex++;
}
} else {
}
void IrcServerHandler::handleNick(const QString &prefix, const QList<QByteArray> ¶ms) {
+ if(!checkParamCount("IrcServerHandler::handleNick()", params, 1))
+ return;
+
IrcUser *ircuser = network()->updateNickFromMask(prefix);
if(!ircuser) {
- qWarning() << "IrcServerHandler::handleNick(): Unknown IrcUser!";
+ quWarning() << "IrcServerHandler::handleNick(): Unknown IrcUser!";
return;
}
QString newnick = serverDecode(params[0]);
? newnick
: prefix;
-
emit nickChanged(newnick, oldnick);
foreach(QString channel, ircuser->channels())
emit displayMsg(Message::Nick, BufferInfo::ChannelBuffer, channel, newnick, sender);
}
void IrcServerHandler::handleNotice(const QString &prefix, const QList<QByteArray> ¶ms) {
- if(params.count() < 2) {
- qWarning() << "IrcServerHandler::handleNotice(): not enough Parameters:" << prefix << serverDecode(params);
+ if(!checkParamCount("IrcServerHandler::handleNotice()", params, 2))
return;
- }
QString target = serverDecode(params[0]);
if(prefix.isEmpty() || target == "AUTH")
}
void IrcServerHandler::handlePart(const QString &prefix, const QList<QByteArray> ¶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!";
+ quWarning() << "IrcServerHandler::handlePart(): Unknown IrcUser!";
return;
}
putCmd("PONG", params);
}
+void IrcServerHandler::handlePong(const QString &prefix, const QList<QByteArray> ¶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<QByteArray> ¶ms) {
+ if(!checkParamCount("IrcServerHandler::handlePrivmsg()", params, 1))
+ return;
+
IrcUser *ircuser = network()->updateNickFromMask(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;
}
if(!ircuser) return;
QString msg;
- if(params.count())
+ if(params.count() > 0)
msg = userDecode(ircuser->nick(), params[0]);
foreach(QString channel, ircuser->channels())
}
void IrcServerHandler::handleTopic(const QString &prefix, const QList<QByteArray> ¶ms) {
+ if(!checkParamCount("IrcServerHandler::handleTopic()", params, 1))
+ return;
+
IrcUser *ircuser = network()->updateNickFromMask(prefix);
- if(!ircuser) return;
- QString channel = serverDecode(params[0]);
+ if(!ircuser)
+ return;
+
+ IrcChannel *channel = network()->ircChannel(serverDecode(params[0]));
+ if(!channel)
+ return;
+
QString topic;
- if(params.count() >= 2) topic = channelDecode(channel, params[1]);
+ if(params.count() > 1)
+ topic = channelDecode(channel->name(), params[1]);
- network()->ircChannel(channel)->setTopic(topic);
+ channel->setTopic(topic);
- emit displayMsg(Message::Server, BufferInfo::ChannelBuffer, channel, tr("%1 has changed topic for %2 to: \"%3\"").arg(ircuser->nick()).arg(channel).arg(topic));
+ emit displayMsg(Message::Server, BufferInfo::ChannelBuffer, channel->name(), tr("%1 has changed topic for %2 to: \"%3\"").arg(ircuser->nick()).arg(channel->name()).arg(topic));
}
/* RPL_WELCOME */
void IrcServerHandler::handle001(const QString &prefix, const QList<QByteArray> ¶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 <nick>!<user>@<host>"
QString param = serverDecode(params[0]);
QString myhostmask = param.section(' ', -1, -1);
- network()->setCurrentServer(prefix);
+
network()->setMyNick(nickFromMask(myhostmask));
emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", param, prefix);
void IrcServerHandler::handle005(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix);
const int numParams = params.size();
- if(numParams < 1) {
- qWarning() << "IrcServerHandler::handle005(): received RPL_ISUPPORT (005) with too few parameters:" << serverDecode(params);
+ if(numParams == 0) {
+ emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", tr("Received RPL_ISUPPORT (005) without parameters!"), prefix);
return;
}
+ emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", serverDecode(params).join(" "), prefix);
+
QString rpl_isupport_suffix = serverDecode(params.last());
- if(!rpl_isupport_suffix.toLower().contains("supported")) {
- qWarning() << "Received invalid RPL_ISUPPORT! Suffix is:" << rpl_isupport_suffix << "Excpected: are supported by this server";
- return;
+ if(!rpl_isupport_suffix.toLower().contains("are supported by this server")) {
+ emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", tr("Received non RFC compliant RPL_ISUPPORT: this can lead to unexpected behavior!"), prefix);
}
QString rawSupport;
/* RPL_AWAY - "<nick> :<away message>" */
void IrcServerHandler::handle301(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix);
+ if(!checkParamCount("IrcServerHandler::handle301()", params, 2))
+ return;
+
+
QString nickName = serverDecode(params[0]);
- QString awayMessage = userDecode(nickName, params.last());
+ QString awayMessage = userDecode(nickName, params[1]);
IrcUser *ircuser = network()->ircUser(nickName);
if(ircuser) {
}
}
+// 305 RPL_UNAWAY
+// ":You are no longer marked as being away"
+void IrcServerHandler::handle305(const QString &prefix, const QList<QByteArray> ¶ms) {
+ Q_UNUSED(prefix);
+ IrcUser *me = network()->me();
+ if(me)
+ me->setAway(false);
+
+ if(!params.isEmpty())
+ emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", serverDecode(params[0]));
+}
+
+// 306 RPL_NOWAWAY
+// ":You have been marked as being away"
+void IrcServerHandler::handle306(const QString &prefix, const QList<QByteArray> ¶ms) {
+ Q_UNUSED(prefix);
+ IrcUser *me = network()->me();
+ if(me)
+ me->setAway(true);
+
+ if(!params.isEmpty())
+ emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", serverDecode(params[0]));
+}
+
/* RPL_WHOISSERVICE - "<user> is registered nick" */
void IrcServerHandler::handle307(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix)
+ if(!checkParamCount("IrcServerHandler::handle307()", params, 1))
+ return;
+
QString whoisServiceReply = serverDecode(params).join(" ");
IrcUser *ircuser = network()->ircUser(serverDecode(params[0]));
if(ircuser) {
/* RPL_SUSERHOST - "<user> is available for help." */
void IrcServerHandler::handle310(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix)
+ if(!checkParamCount("IrcServerHandler::handle310()", params, 1))
+ return;
+
QString suserHost = serverDecode(params).join(" ");
IrcUser *ircuser = network()->ircUser(serverDecode(params[0]));
if(ircuser) {
/* RPL_WHOISUSER - "<nick> <user> <host> * :<real name>" */
void IrcServerHandler::handle311(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix)
+ if(!checkParamCount("IrcServerHandler::handle311()", params, 3))
+ return;
+
_whois = true;
IrcUser *ircuser = network()->ircUser(serverDecode(params[0]));
if(ircuser) {
/* RPL_WHOISSERVER - "<nick> <server> :<server info>" */
void IrcServerHandler::handle312(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix)
+ if(!checkParamCount("IrcServerHandler::handle312()", params, 2))
+ return;
+
IrcUser *ircuser = network()->ircUser(serverDecode(params[0]));
if(ircuser) {
ircuser->setServer(serverDecode(params[1]));
/* RPL_WHOISOPERATOR - "<nick> :is an IRC operator" */
void IrcServerHandler::handle313(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix)
+ if(!checkParamCount("IrcServerHandler::handle313()", params, 1))
+ return;
+
IrcUser *ircuser = network()->ircUser(serverDecode(params[0]));
if(ircuser) {
ircuser->setIrcOperator(params.last());
/* RPL_WHOWASUSER - "<nick> <user> <host> * :<real name>" */
void IrcServerHandler::handle314(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix)
+ if(!checkParamCount("IrcServerHandler::handle314()", params, 3))
+ return;
+
QString nick = serverDecode(params[0]);
QString hostmask = QString("%1@%2").arg(serverDecode(params[1])).arg(serverDecode(params[2]));
QString realName = serverDecode(params.last());
/* RPL_ENDOFWHO: "<name> :End of WHO list" */
void IrcServerHandler::handle315(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix);
+ if(!checkParamCount("IrcServerHandler::handle315()", params, 1))
+ return;
+
QStringList p = serverDecode(params);
- if(p.count()) {
- if(networkConnection()->setAutoWhoDone(p[0])) {
- return; // stay silent
- }
- p.takeLast(); // should be "End of WHO list"
- emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("[Who] End of /WHO list for %1").arg(p.join(" ")));
+ if(networkConnection()->setAutoWhoDone(p[0])) {
+ return; // stay silent
}
+ p.takeLast(); // should be "End of WHO list"
+ emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("[Who] End of /WHO list for %1").arg(p.join(" ")));
}
/* RPL_WHOISIDLE - "<nick> <integer> :seconds idle"
(real life: "<nick> <integer> <integer> :seconds idle, signon time) */
void IrcServerHandler::handle317(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix);
+ if(!checkParamCount("IrcServerHandler::handle317()", params, 2))
+ return;
+
QString nick = serverDecode(params[0]);
IrcUser *ircuser = network()->ircUser(nick);
if(ircuser) {
int idleSecs = serverDecode(params[1]).toInt();
idleSecs *= -1;
ircuser->setIdleTime(now.addSecs(idleSecs));
- if(params.size()>3) {
+ if(params.size() > 3) { // if we have more then 3 params we have the obove mentioned "real life" situation
int loginTime = serverDecode(params[2]).toInt();
ircuser->setLoginTime(QDateTime::fromTime_t(loginTime));
emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("[Whois] %1 is logged in since %2").arg(ircuser->nick()).arg(ircuser->loginTime().toString()));
/* RPL_WHOISCHANNELS - "<nick> :*( ( "@" / "+" ) <channel> " " )" */
void IrcServerHandler::handle319(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix)
+ if(!checkParamCount("IrcServerHandler::handle319()", params, 2))
+ return;
+
QString nick = serverDecode(params.first());
QStringList op;
QStringList voice;
emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("[Whois] %1").arg(serverDecode(params).join(" ")));
}
+/* RPL_LIST - "<channel> <# visible> :<topic>" */
+void IrcServerHandler::handle322(const QString &prefix, const QList<QByteArray> ¶ms) {
+ Q_UNUSED(prefix)
+ QString channelName;
+ quint32 userCount = 0;
+ QString topic;
+
+ int paramCount = params.count();
+ switch(paramCount) {
+ case 3:
+ topic = serverDecode(params[2]);
+ case 2:
+ userCount = serverDecode(params[1]).toUInt();
+ case 1:
+ channelName = serverDecode(params[0]);
+ default:
+ break;
+ }
+ if(!networkConnection()->coreSession()->ircListHelper()->addChannel(network()->networkId(), channelName, userCount, topic))
+ emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Channel %1 has %2 users. Topic is: %3").arg(channelName).arg(userCount).arg(topic));
+}
+
+/* RPL_LISTEND ":End of LIST" */
+void IrcServerHandler::handle323(const QString &prefix, const QList<QByteArray> ¶ms) {
+ Q_UNUSED(prefix)
+ Q_UNUSED(params)
+
+ if(!networkConnection()->coreSession()->ircListHelper()->endOfChannelList(network()->networkId()))
+ emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("End of channel list"));
+}
+
+/* RPL_CHANNELMODEIS - "<channel> <mode> <mode params>" */
+void IrcServerHandler::handle324(const QString &prefix, const QList<QByteArray> ¶ms) {
+ Q_UNUSED(prefix);
+ handleMode(prefix, params);
+}
+
+/* RPL_??? - "<channel> <creation time (unix)>" */
+void IrcServerHandler::handle329(const QString &prefix, const QList<QByteArray> ¶ms) {
+ Q_UNUSED(prefix);
+ Q_UNUSED(params)
+#ifdef __GNUC__
+# warning "Implement handle329 (Channel creation time)"
+#endif
+ // FIXME implement this...
+}
+
/* RPL_NOTOPIC */
void IrcServerHandler::handle331(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix);
+ if(!checkParamCount("IrcServerHandler::handle331()", params, 1))
+ 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));
}
/* RPL_TOPIC */
void IrcServerHandler::handle332(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix);
+ if(!checkParamCount("IrcServerHandler::handle332()", params, 2))
+ return;
+
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));
}
/* Topic set by... */
void IrcServerHandler::handle333(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix);
+ if(!checkParamCount("IrcServerHandler::handle333()", params, 3))
+ return;
+
QString channel = serverDecode(params[0]);
emit displayMsg(Message::Server, BufferInfo::ChannelBuffer, channel,
tr("Topic set by %1 on %2") .arg(serverDecode(params[1]), QDateTime::fromTime_t(channelDecode(channel, params[2]).toUInt()).toString()));
( "H" / "G" > ["*"] [ ( "@" / "+" ) ] :<hopcount> <real name>" */
void IrcServerHandler::handle352(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix)
+ if(!checkParamCount("IrcServerHandler::handle352()", params, 6))
+ return;
+
QString channel = serverDecode(params[0]);
IrcUser *ircuser = network()->ircUser(serverDecode(params[4]));
if(ircuser) {
/* RPL_NAMREPLY */
void IrcServerHandler::handle353(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix);
- const int numParams = params.count();
- if(numParams < 2) {
- qWarning() << "IrcServerHandler::handler353() received not enough params:" << serverDecode(params);
+ if(!checkParamCount("IrcServerHandler::handle353()", params, 2))
return;
- }
// param[0] is either "=", "*" or "@" indicating a public, private or secret channel
// we don't use this information at the time beeing
IrcChannel *channel = network()->ircChannel(channelname);
if(!channel) {
- qWarning() << "IrcServerHandler::handle353(): received unknown target channel:" << channelname;
+ quWarning() << "IrcServerHandler::handle353(): received unknown target channel:" << channelname;
return;
}
/* ERR_NICKNAMEINUSE */
void IrcServerHandler::handle433(const QString &prefix, const QList<QByteArray> ¶ms) {
Q_UNUSED(prefix);
-
+ if(!checkParamCount("IrcServerHandler::handle433()", params, 1))
+ return;
+
QString errnick = serverDecode(params[0]);
emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", tr("Nick already in use: %1").arg(errnick));
}
}
+bool IrcServerHandler::checkParamCount(const QString &methodName, const QList<QByteArray> ¶ms, int minParams) {
+ if(params.count() < minParams) {
+ quWarning() << qPrintable(methodName) << "requires" << minParams << "parameters but received only" << params.count() << serverDecode(params);
+ return false;
+ } else {
+ return true;
+ }
+}
+
/***********************************************************************************/