From: Marcus Eggenberger Date: Mon, 3 Nov 2008 13:46:03 +0000 (+0100) Subject: Fixing BR #233 - redirecting chanservs welcome messages to the channel buffer X-Git-Tag: 0.3.1~84 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=e9a8478aa3546063dc39cbadb9280e5566416eeb Fixing BR #233 - redirecting chanservs welcome messages to the channel buffer --- diff --git a/src/common/network.cpp b/src/common/network.cpp index 6c0d2521..ed66ee3a 100644 --- a/src/common/network.cpp +++ b/src/common/network.cpp @@ -256,7 +256,7 @@ IrcUser *Network::ircUser(QString nickname) const { IrcChannel *Network::newIrcChannel(const QString &channelname) { if(!_ircChannels.contains(channelname.toLower())) { - IrcChannel *channel = new IrcChannel(channelname, this); + IrcChannel *channel = ircChannelFactory(channelname); if(proxy()) proxy()->synchronize(channel); @@ -587,7 +587,7 @@ void Network::initSetIrcUsersAndChannels(const QVariantMap &usersAndChannels) { while(channelIter != channelIterEnd) { channelName = channelIter.key(); - ircChannel = new IrcChannel(channelName, this); + ircChannel = ircChannelFactory(channelName); ircChannel->fromVariantMap(channelIter.value().toMap()); ircChannel->setInitialized(); proxy()->synchronize(ircChannel); diff --git a/src/common/network.h b/src/common/network.h index 4bbd984b..ee6ba7fc 100644 --- a/src/common/network.h +++ b/src/common/network.h @@ -298,6 +298,9 @@ signals: void disconnectRequested(NetworkId id = 0) const; void setNetworkInfoRequested(const NetworkInfo &) const; +protected: + inline virtual IrcChannel *ircChannelFactory(const QString &channelname) { return new IrcChannel(channelname, this); } + private: QPointer _proxy; diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 21388aee..4491f568 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -16,6 +16,7 @@ set(SOURCES corebufferviewconfig.cpp corebufferviewmanager.cpp corecoreinfo.cpp + coreircchannel.cpp coreirclisthelper.cpp corenetwork.cpp coresession.cpp @@ -39,6 +40,7 @@ set(MOC_HDRS corebufferviewconfig.h corebufferviewmanager.h corecoreinfo.h + coreircchannel.h coreirclisthelper.h corenetwork.h coresession.h diff --git a/src/core/corenetwork.h b/src/core/corenetwork.h index fd96ff6c..2989932b 100644 --- a/src/core/corenetwork.h +++ b/src/core/corenetwork.h @@ -22,6 +22,7 @@ #define CORENETWORK_H #include "network.h" +#include "coreircchannel.h" class CoreSession; @@ -40,6 +41,9 @@ public slots: virtual void requestDisconnect() const; virtual void requestSetNetworkInfo(const NetworkInfo &info); +protected: + inline virtual IrcChannel *ircChannelFactory(const QString &channelname) { return new CoreIrcChannel(channelname, this); } + private: CoreSession *_coreSession; }; diff --git a/src/core/ircserverhandler.cpp b/src/core/ircserverhandler.cpp index ea0d6951..4d32f1dd 100644 --- a/src/core/ircserverhandler.cpp +++ b/src/core/ircserverhandler.cpp @@ -29,7 +29,7 @@ #include "ctcphandler.h" #include "ircuser.h" -#include "ircchannel.h" +#include "coreircchannel.h" #include "logger.h" #include @@ -41,7 +41,6 @@ IrcServerHandler::IrcServerHandler(NetworkConnection *parent) } IrcServerHandler::~IrcServerHandler() { - } /*! Handle a raw message string sent by the server. We try to find a suitable handler, otherwise we call a default handler. */ @@ -326,6 +325,24 @@ void IrcServerHandler::handleNotice(const QString &prefix, const QListisChannelName(target)) { + QString msg = serverDecode(params[1]); + QRegExp welcomeRegExp("^\\[([^\\]]+)\\] "); + if(welcomeRegExp.indexIn(msg) != -1) { + QString channelname = welcomeRegExp.cap(1); + msg = msg.mid(welcomeRegExp.matchedLength()); + CoreIrcChannel *chan = static_cast(network()->ircChannel(channelname)); // we only have CoreIrcChannels in the core, so this cast is safe + if(chan && !chan->receivedWelcomeMsg()) { + chan->setReceivedWelcomeMsg(); + emit displayMsg(Message::Notice, BufferInfo::ChannelBuffer, channelname, msg, prefix); + return; + } + } + } + if(prefix.isEmpty() || target == "AUTH") { target = ""; } else {