X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcoresessioneventprocessor.cpp;h=c3dce758ccbdd6334b6e2722f0298db02a147bad;hp=df4a409189329d6459f5f7f484cdcb0dfaa9c484;hb=c8ddabf364eff2400c61cea395aefe69eb8ba1b3;hpb=c1cf157116de7fc3da96203aa6f03c38c7ebb650 diff --git a/src/core/coresessioneventprocessor.cpp b/src/core/coresessioneventprocessor.cpp index df4a4091..c3dce758 100644 --- a/src/core/coresessioneventprocessor.cpp +++ b/src/core/coresessioneventprocessor.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * + * Copyright (C) 2005-2022 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -20,6 +20,8 @@ #include "coresessioneventprocessor.h" +#include + #include "coreirclisthelper.h" #include "corenetwork.h" #include "coresession.h" @@ -28,7 +30,6 @@ #include "ctcpevent.h" #include "ircevent.h" #include "ircuser.h" -#include "logmessage.h" #include "messageevent.h" #include "netsplit.h" #include "quassel.h" @@ -133,9 +134,7 @@ void CoreSessionEventProcessor::processIrcEventAuthenticate(IrcEvent* e) CoreNetwork* net = coreNetwork(e); -#ifdef HAVE_SSL if (net->identityPtr()->sslCert().isNull()) { -#endif QString construct = net->saslAccount(); construct.append(QChar(QChar::Null)); construct.append(net->saslAccount()); @@ -144,12 +143,10 @@ void CoreSessionEventProcessor::processIrcEventAuthenticate(IrcEvent* e) QByteArray saslData = QByteArray(construct.toLatin1().toBase64()); saslData.prepend("AUTHENTICATE "); net->putRawLine(saslData); -#ifdef HAVE_SSL } else { net->putRawLine("AUTHENTICATE +"); } -#endif } void CoreSessionEventProcessor::processIrcEventCap(IrcEvent* e) @@ -364,6 +361,10 @@ void CoreSessionEventProcessor::processIrcEventChghost(IrcEvent* e) } } +// IRCv3 INVITE - ": INVITE " +// Example: :ChanServ!ChanServ@example.com INVITE Attila #channel +// +// See https://ircv3.net/specs/extensions/invite-notify-3.2 void CoreSessionEventProcessor::processIrcEventInvite(IrcEvent* e) { if (checkParamCount(e, 2)) { @@ -407,7 +408,7 @@ void CoreSessionEventProcessor::processIrcEventJoin(IrcEvent* e) // Else :nick!user@host JOIN #channelname bool handledByNetsplit = false; - foreach (Netsplit* n, _netsplits.value(e->network())) { + for (Netsplit* n : _netsplits.value(e->network())) { handledByNetsplit = n->userJoined(e->prefix(), channel); if (handledByNetsplit) break; @@ -489,7 +490,7 @@ void CoreSessionEventProcessor::processIrcEventMode(IrcEvent* e) if (add) { bool handledByNetsplit = false; QHash splits = _netsplits.value(e->network()); - foreach (Netsplit* n, _netsplits.value(e->network())) { + for (Netsplit* n : _netsplits.value(e->network())) { handledByNetsplit = n->userAlreadyJoined(ircUser->hostmask(), channel->name()); if (handledByNetsplit) { n->addMode(ircUser->hostmask(), channel->name(), QString(mode)); @@ -792,6 +793,25 @@ void CoreSessionEventProcessor::processIrcEventError(IrcEvent* e) } } + +// IRCv3 SETNAME - ":nick!user@host SETNAME :realname goes here" +// Example: :batman!~batman@bat.cave SETNAME :Bruce Wayne +// +// See https://ircv3.net/specs/extensions/setname +void CoreSessionEventProcessor::processIrcEventSetname(IrcEvent* e) +{ + if (checkParamCount(e, 1)) { + IrcUser* ircuser = e->network()->updateNickFromMask(e->prefix()); + if (!ircuser) { + qWarning() << Q_FUNC_INFO << "Unknown IrcUser!"; + return; + } + + QString newname = e->params().at(0); + ircuser->setRealName(newname); + } +} + #ifdef HAVE_QCA2 void CoreSessionEventProcessor::processKeyEvent(KeyEvent* e) { @@ -1177,7 +1197,7 @@ void CoreSessionEventProcessor::processIrcEvent353(IrcEvent* e) return; // param[0] is either "=", "*" or "@" indicating a public, private or secret channel - // we don't use this information at the time beeing + // we don't use this information at the time being QString channelname = e->params()[1]; IrcChannel* channel = e->network()->ircChannel(channelname); @@ -1192,7 +1212,7 @@ void CoreSessionEventProcessor::processIrcEvent353(IrcEvent* e) // Cache result of multi-prefix to avoid unneeded casts and lookups with each iteration. bool _useCapMultiPrefix = coreNetwork(e)->capEnabled(IrcCap::MULTI_PREFIX); - foreach (QString nick, e->params()[2].split(' ', QString::SkipEmptyParts)) { + for (QString nick : e->params()[2].split(' ', QString::SkipEmptyParts)) { QString mode; if (_useCapMultiPrefix) { @@ -1361,7 +1381,7 @@ void CoreSessionEventProcessor::processIrcEvent432(IrcEventNumeric* e) QString errnick; if (e->params().count() < 2) { - // handle unreal-ircd bug, where unreal ircd doesnt supply a TARGET in ERR_ERRONEUSNICKNAME during registration phase: + // handle unreal-ircd bug, where unreal ircd doesn't supply a TARGET in ERR_ERRONEUSNICKNAME during registration phase: // nick @@@ // :irc.scortum.moep.net 432 @@@ :Erroneous Nickname: Illegal characters // correct server reply: @@ -1428,7 +1448,7 @@ void CoreSessionEventProcessor::handleNetsplitJoin( QStringList newModes = modes; QStringList newUsers = users; - foreach (const QString& user, users) { + for (const QString& user : users) { IrcUser* iu = net->ircUser(nickFromMask(user)); if (iu) ircUsers.append(iu); @@ -1448,10 +1468,9 @@ void CoreSessionEventProcessor::handleNetsplitQuit(Network* net, const QString& { NetworkSplitEvent* event = new NetworkSplitEvent(EventManager::NetworkSplitQuit, net, channel, users, quitMessage); emit newEvent(event); - foreach (QString user, users) { - IrcUser* iu = net->ircUser(nickFromMask(user)); - if (iu) - iu->quit(); + for (const QString& user : users) { + IrcUser* ircUser = net->ircUser(nickFromMask(user)); + if (ircUser) ircUser->quit(); } } @@ -1466,19 +1485,19 @@ void CoreSessionEventProcessor::handleEarlyNetsplitJoin(Network* net, const QStr QList ircUsers; QStringList newModes = modes; - foreach (QString user, users) { - IrcUser* iu = net->updateNickFromMask(user); - if (iu) { - ircUsers.append(iu); + for (const QString& user : users) { + IrcUser* ircUser = net->updateNickFromMask(user); + if (ircUser) { + ircUsers.append(ircUser); // fake event for scripts that consume join events - events << new IrcEvent(EventManager::IrcEventJoin, net, iu->hostmask(), QStringList() << channel); + events << new IrcEvent(EventManager::IrcEventJoin, net, {}, ircUser->hostmask(), QStringList() << channel); } else { newModes.removeAt(users.indexOf(user)); } } ircChannel->joinIrcUsers(ircUsers, newModes); - foreach (NetworkEvent* event, events) { + for (NetworkEvent* event : events) { event->setFlag(EventManager::Fake); // ignore this in here! emit newEvent(event); } @@ -1536,9 +1555,9 @@ void CoreSessionEventProcessor::handleCtcpAction(CtcpEvent* e) void CoreSessionEventProcessor::handleCtcpClientinfo(CtcpEvent* e) { QStringList supportedHandlers; - foreach (QString handler, providesHandlers()) + for (const QString& handler : providesHandlers()) supportedHandlers << handler.toUpper(); - qSort(supportedHandlers); + std::sort(supportedHandlers.begin(), supportedHandlers.end()); e->setReply(supportedHandlers.join(" ")); } @@ -1548,7 +1567,7 @@ void CoreSessionEventProcessor::handleCtcpDcc(CtcpEvent* e) { // DCC support is unfinished, experimental and potentially dangerous, so make it opt-in if (!Quassel::isOptionSet("enable-experimental-dcc")) { - quInfo() << "DCC disabled, start core with --enable-experimental-dcc if you really want to try it out"; + qInfo() << "DCC disabled, start core with --enable-experimental-dcc if you really want to try it out"; return; }