X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcoresessioneventprocessor.cpp;h=2147071e55a6ce955984c16be93797dd78fcca65;hp=ebfb007a2fef1d37d07cc1685410c6cc447bf401;hb=d60c5028b49a95d3c27c35b2ea1d74cdd7bb0e46;hpb=7c45e37945b0fa3baa5e8190991c9a2e24d357ba diff --git a/src/core/coresessioneventprocessor.cpp b/src/core/coresessioneventprocessor.cpp index ebfb007a..2147071e 100644 --- a/src/core/coresessioneventprocessor.cpp +++ b/src/core/coresessioneventprocessor.cpp @@ -31,6 +31,20 @@ CoreSessionEventProcessor::CoreSessionEventProcessor(CoreSession *session) } +bool CoreSessionEventProcessor::checkParamCount(IrcEvent *e, int minParams) { + if(e->params().count() < minParams) { + if(e->type() == EventManager::IrcEventNumeric) { + qWarning() << "Command " << static_cast(e)->number() << " requires " << minParams << "params, got: " << e->params(); + } else { + QString name = coreSession()->eventManager()->enumName(e->type()); + qWarning() << qPrintable(name) << "requires" << minParams << "params, got:" << e->params(); + } + e->stop(); + return false; + } + return true; +} + void CoreSessionEventProcessor::processIrcEventNumeric(IrcEventNumeric *e) { switch(e->number()) { @@ -43,3 +57,52 @@ void CoreSessionEventProcessor::processIrcEventNumeric(IrcEventNumeric *e) { break; } } + +void CoreSessionEventProcessor::processIrcEventInvite(IrcEvent *e) { + if(checkParamCount(e, 2)) { + e->network()->updateNickFromMask(e->prefix()); + } +} + +void CoreSessionEventProcessor::processIrcEventKick(IrcEvent *e) { + if(checkParamCount(e, 2)) { + e->network()->updateNickFromMask(e->prefix()); + IrcUser *victim = e->network()->ircUser(e->params().at(1)); + if(victim) { + victim->partChannel(e->params().at(0)); + //if(e->network()->isMe(victim)) e->network()->setKickedFromChannel(channel); + } + } +} + +void CoreSessionEventProcessor::processIrcEventNick(IrcEvent *e) { + if(checkParamCount(e, 1)) { + IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix()); + if(!ircuser) { + qWarning() << Q_FUNC_INFO << "Unknown IrcUser!"; + return; + } + QString newnick = e->params().at(0); + QString oldnick = ircuser->nick(); + + // 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(e->networkId(), newnick, oldnick); + } +} + +void CoreSessionEventProcessor::processIrcEventPart(IrcEvent *e) { + if(checkParamCount(e, 1)) { + IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix()); + if(!ircuser) { + qWarning() << Q_FUNC_INFO<< "Unknown IrcUser!"; + return; + } + QString channel = e->params().at(0); + ircuser->partChannel(channel); + if(e->network()->isMe(ircuser)) + qobject_cast(e->network())->setChannelParted(channel); + } +}