From kde-commits Sat Sep 17 12:05:38 2016 From: Peter Simonsson Date: Sat, 17 Sep 2016 12:05:38 +0000 To: kde-commits Subject: [konversation] src/irc: Add support for userhost-in-names Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=147411394603202 Git commit af4783c21961acd3e17d633abe61ee80087df2b2 by Peter Simonsson. Committed on 17/09/2016 at 12:05. Pushed by psn into branch 'master'. Add support for userhost-in-names This capability lets the server include the userhost in the name reply M +18 -0 src/irc/channel.cpp M +9 -0 src/irc/server.cpp M +2 -0 src/irc/server.h http://commits.kde.org/konversation/af4783c21961acd3e17d633abe61ee80087df2b2 diff --git a/src/irc/channel.cpp b/src/irc/channel.cpp index f2018a0..a431c80 100644 --- a/src/irc/channel.cpp +++ b/src/irc/channel.cpp @@ -2507,6 +2507,19 @@ void Channel::processQueuedNicks(bool flush) while (nickname.isEmpty() && !m_nickQueue.isEmpty()) nickname =3D m_nickQueue.takeFirst(); = + QString userHost; + + if(m_server->hasUserHostInNames()) + { + int index =3D nickname.indexOf(QLatin1Char('!')); + + if(index >=3D 0) + { + userHost =3D nickname.mid(index + 1); + nickname =3D nickname.left(index); + } + } + bool admin =3D false; bool owner =3D false; bool op =3D false; @@ -2530,6 +2543,11 @@ void Channel::processQueuedNicks(bool flush) Q_ASSERT(nick); nick->setMode(mode); = + if(!userHost.isEmpty()) + { + nick->getNickInfo()->setHostmask(userHost); + } + fastAddNickname(nick); = ++m_processedNicksCount; diff --git a/src/irc/server.cpp b/src/irc/server.cpp index 905d806..750f712 100644 --- a/src/irc/server.cpp +++ b/src/irc/server.cpp @@ -91,6 +91,7 @@ Server::Server(QObject* parent, ConnectionSettings& setti= ngs) : QObject(parent) m_hasExtendedJoin =3D false; m_hasWHOX =3D false; m_hasServerTime =3D false; + m_hasUserHostInNames =3D false; = m_nickIndices.clear(); m_nickIndices.append(0); @@ -727,6 +728,10 @@ void Server::capInitiateNegotiation(bool useSASL) m_capRequested++; queue(QStringLiteral("CAP REQ :znc.in/server-time-iso"), HighPriority); m_capRequested++; + + queue(QStringLiteral("CAP REQ :userhost-in-names"), HighPriority); + m_hasUserHostInNames =3D false; + m_capRequested++; } = void Server::capReply() @@ -770,6 +775,10 @@ void Server::capAcknowledged(const QString& name, Serv= er::CapModifiers modifiers { m_hasServerTime =3D true; } + else if (name =3D=3D QStringLiteral("userhost-in-names")) + { + m_hasUserHostInNames =3D true; + } } = void Server::capDenied(const QString& name) diff --git a/src/irc/server.h b/src/irc/server.h index 30524ce..6466871 100644 --- a/src/irc/server.h +++ b/src/irc/server.h @@ -393,6 +393,7 @@ class Server : public QObject void setHasWHOX(bool state) { m_hasWHOX =3D state; } bool hasWHOX() const { return m_hasWHOX; } bool hasServerTime() const { return m_hasServerTime; } + bool hasUserHostInNames() const { return m_hasUserHostInNames; } = // IRCQueueManager bool validQueue(QueuePriority priority); ///< is this queue index = valid? @@ -860,6 +861,7 @@ class Server : public QObject bool m_hasExtendedJoin; bool m_hasWHOX; bool m_hasServerTime; + bool m_hasUserHostInNames; }; = Q_DECLARE_OPERATORS_FOR_FLAGS(Server::CapModifiers)