X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcoresessioneventprocessor.cpp;h=e0fa8921389a22c3cfdc8423a589a0dda5a5fc93;hp=a461491c976d3dafe5ddc1f59052ad6b90858dbd;hb=714b39660fe19e7f092880019429c8da76ee2bd5;hpb=41a136e99bffde8e203fb1abff7c9affbbb16a8b diff --git a/src/core/coresessioneventprocessor.cpp b/src/core/coresessioneventprocessor.cpp index a461491c..e0fa8921 100644 --- a/src/core/coresessioneventprocessor.cpp +++ b/src/core/coresessioneventprocessor.cpp @@ -402,11 +402,16 @@ void CoreSessionEventProcessor::processIrcEventJoin(IrcEvent *e) break; } - // If using away-notify, check new users. Works around buggy IRC servers - // forgetting to send :away messages for users who join channels when away. - if (net->capEnabled(IrcCap::AWAY_NOTIFY)) { - net->queueAutoWhoOneshot(ircuser->nick()); - } + // With "away-notify" enabled, some IRC servers forget to send :away messages for users who join + // channels while away. Unfortunately, working around this involves WHO'ng every single user as + // they join, which is not very efficient. If at all possible, it's better to get the issue + // fixed in the IRC server instead. + // + // If pursuing a workaround instead, this is where you'd do it. Check the version control + // history for the commit that added this comment to see how to implement it - there's some + // unexpected situations to watch out for! + // + // See https://ircv3.net/specs/extensions/away-notify-3.1.html if (!handledByNetsplit) ircuser->joinChannel(channel); @@ -454,17 +459,17 @@ void CoreSessionEventProcessor::processIrcEventMode(IrcEvent *e) QString modes = e->params()[1]; bool add = true; int paramOffset = 2; - for (int c = 0; c < modes.length(); c++) { - if (modes[c] == '+') { + for (auto mode : modes) { + if (mode == '+') { add = true; continue; } - if (modes[c] == '-') { + if (mode == '-') { add = false; continue; } - if (e->network()->prefixModes().contains(modes[c])) { + if (e->network()->prefixModes().contains(mode)) { // user channel modes (op, voice, etc...) if (paramOffset < e->params().count()) { IrcUser *ircUser = e->network()->ircUser(e->params()[paramOffset]); @@ -478,15 +483,15 @@ void CoreSessionEventProcessor::processIrcEventMode(IrcEvent *e) foreach(Netsplit* n, _netsplits.value(e->network())) { handledByNetsplit = n->userAlreadyJoined(ircUser->hostmask(), channel->name()); if (handledByNetsplit) { - n->addMode(ircUser->hostmask(), channel->name(), QString(modes[c])); + n->addMode(ircUser->hostmask(), channel->name(), QString(mode)); break; } } if (!handledByNetsplit) - channel->addUserMode(ircUser, QString(modes[c])); + channel->addUserMode(ircUser, QString(mode)); } else - channel->removeUserMode(ircUser, QString(modes[c])); + channel->removeUserMode(ircUser, QString(mode)); } } else { @@ -497,7 +502,7 @@ void CoreSessionEventProcessor::processIrcEventMode(IrcEvent *e) else { // regular channel modes QString value; - Network::ChannelModeType modeType = e->network()->channelModeType(modes[c]); + Network::ChannelModeType modeType = e->network()->channelModeType(mode); if (modeType == Network::A_CHANMODE || modeType == Network::B_CHANMODE || (modeType == Network::C_CHANMODE && add)) { if (paramOffset < e->params().count()) { value = e->params()[paramOffset]; @@ -509,9 +514,9 @@ void CoreSessionEventProcessor::processIrcEventMode(IrcEvent *e) } if (add) - channel->addChannelMode(modes[c], value); + channel->addChannelMode(mode, value); else - channel->removeChannelMode(modes[c], value); + channel->removeChannelMode(mode, value); } } } @@ -796,7 +801,7 @@ void CoreSessionEventProcessor::processKeyEvent(KeyEvent *e) emit newEvent(new MessageEvent(Message::Error, e->network(), tr("Unable to perform key exchange, missing qca-ossl plugin."), e->prefix(), e->target(), Message::None, e->timestamp())); return; } - CoreNetwork *net = qobject_cast(e->network()); + auto *net = qobject_cast(e->network()); Cipher *c = net->cipher(e->target()); if (!c) // happens when there is no CoreIrcChannel for the target (i.e. never?) return; @@ -1134,9 +1139,7 @@ void CoreSessionEventProcessor::processIrcEvent352(IrcEvent *e) return; QString channel = e->params()[0]; - // Store the nick separate from ircuser for AutoWho check below - QString nick = e->params()[4]; - IrcUser *ircuser = e->network()->ircUser(nick); + IrcUser *ircuser = e->network()->ircUser(e->params()[4]); if (ircuser) { // Only process the WHO information if an IRC user exists. Don't create an IRC user here; // there's no way to track when the user quits, which would leave a phantom IrcUser lying @@ -1148,10 +1151,7 @@ void CoreSessionEventProcessor::processIrcEvent352(IrcEvent *e) } // Check if channel name has a who in progress. - // If not, then check if user nickname has a who in progress. Use nick directly; don't use - // ircuser as that may be deleted (e.g. nick joins channel, leaves before WHO reply received). - if (coreNetwork(e)->isAutoWhoInProgress(channel) || - (coreNetwork(e)->isAutoWhoInProgress(nick))) { + if (coreNetwork(e)->isAutoWhoInProgress(channel)) { e->setFlag(EventManager::Silent); } } @@ -1238,8 +1238,7 @@ void CoreSessionEventProcessor::processIrcEvent354(IrcEvent *e) return; QString channel = e->params()[1]; - QString nick = e->params()[5]; - IrcUser *ircuser = e->network()->ircUser(nick); + IrcUser *ircuser = e->network()->ircUser(e->params()[5]); if (ircuser) { // Only process the WHO information if an IRC user exists. Don't create an IRC user here; // there's no way to track when the user quits, which would leave a phantom IrcUser lying @@ -1263,10 +1262,7 @@ void CoreSessionEventProcessor::processIrcEvent354(IrcEvent *e) } // Check if channel name has a who in progress. - // If not, then check if user nickname has a who in progress. Use nick directly; don't use - // ircuser as that may be deleted (e.g. nick joins channel, leaves before WHO reply received). - if (coreNetwork(e)->isAutoWhoInProgress(channel) || - (coreNetwork(e)->isAutoWhoInProgress(nick))) { + if (coreNetwork(e)->isAutoWhoInProgress(channel)) { e->setFlag(EventManager::Silent); } } @@ -1482,7 +1478,7 @@ void CoreSessionEventProcessor::handleEarlyNetsplitJoin(Network *net, const QStr void CoreSessionEventProcessor::handleNetsplitFinished() { - Netsplit *n = qobject_cast(sender()); + auto *n = qobject_cast(sender()); Q_ASSERT(n); QHash splithash = _netsplits.take(n->network()); splithash.remove(splithash.key(n));