/***************************************************************************
- * Copyright (C) 2005-2019 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 *
#include "coresessioneventprocessor.h"
+#include <algorithm>
+
#include "coreirclisthelper.h"
#include "corenetwork.h"
#include "coresession.h"
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());
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)
}
}
+// IRCv3 INVITE - ":<inviter> INVITE <target> <channel>"
+// 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)) {
// 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;
if (add) {
bool handledByNetsplit = false;
QHash<QString, Netsplit*> 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));
}
}
+
+// IRCv3 SETNAME - ":nick!user@host SETNAME :realname goes here"
+// Example: :batman!~batman@bat.cave SETNAME :Bruce Wayne <bruce@wayne.enterprises>
+//
+// 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)
{
// 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) {
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);
{
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();
}
}
QList<IrcUser*> 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);
}
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(" "));
}