Version: (using KDE KDE 3.4.2) Installed from: Debian testing/unstable Packages OS: Linux Let's put that I'm in channel #A and I want to know the topic of the channel #B, where I'm NOT. In channel #A I enter: /topic #B but I've no output. If I'm in channel #A and #B and I repeat the command, the output is displayed in #B even if I'm in #A at that moment. With xchat it works fine.
SVN commit 495133 by hein: Have /topic <channel> make a honest attempt at retrieving <channel>'s topic regardless of whether or not we are on <channel>. Some ircds will not allow us to do that, which is why we implemented 442 (ERR_NOTONCHANNEL) allowing us to fail gracefully (i.e. with a pretty and localizable error message). BUG:112074 M +35 -7 inputfilter.cpp M +1 -1 outputfilter.cpp M +6 -0 server.cpp M +1 -0 server.h --- trunk/extragear/network/konversation/src/inputfilter.cpp #495132:495133 @@ -800,9 +800,22 @@ // Topic set messages case RPL_TOPIC: { - // Update channel window QString topic = Konversation::removeIrcMarkup(trailing); - server->setChannelTopic(parameterList[1],topic); + + // FIXME: This is an abuse of the automaticRequest system: We're + // using it in an inverted manner, i.e. the automaticRequest is + // set to true by a manual invocation of /topic. Bad bad bad - + // needs rethinking of automaticRequest. + if(getAutomaticRequest("TOPIC",parameterList[1])==0) + { + // Update channel window + server->setChannelTopic(parameterList[1],topic); + } + else + { + server->appendMessageToFrontmost(i18n("Topic"),i18n("The channel topic for %1 is: \"%2\"").arg(parameterList[1]).arg(topic)); + } + break; } case RPL_TOPICSETBY: @@ -810,12 +823,27 @@ // Inform user who set the topic and when QDateTime when; when.setTime_t(parameterList[3].toUInt()); - server->appendCommandMessageToChannel(parameterList[1],i18n("Topic"), - i18n("Topic was set by %1 on %2.") - .arg(parameterList[2]).arg(when.toString(Qt::LocalDate)) - ); - emit topicAuthor(parameterList[1],parameterList[2]); + // See FIXME in RPL_TOPIC + if(getAutomaticRequest("TOPIC",parameterList[1])==0) + { + server->appendCommandMessageToChannel(parameterList[1],i18n("Topic"), + i18n("The topic was set by %1 on %2.") + .arg(parameterList[2]).arg(when.toString(Qt::LocalDate)) + ); + + emit topicAuthor(parameterList[1],parameterList[2]); + } + else + { + server->appendMessageToFrontmost(i18n("Topic"),i18n("The topic for %1 was set by %2 on %3.") + .arg(parameterList[1]) + .arg(parameterList[2]) + .arg(when.toString(Qt::LocalDate)) + ); + setAutomaticRequest("TOPIC",parameterList[1],false); + } + break; } case ERR_NOSUCHNICK: --- trunk/extragear/network/konversation/src/outputfilter.cpp #495132:495133 @@ -405,7 +405,7 @@ // if no topic given, retrieve topic if(topic.isEmpty()) { - result.toServer = "TOPIC " + channel; + m_server->requestTopic(channel); } // otherwise set topic there else --- trunk/extragear/network/konversation/src/server.cpp #495132:495133 @@ -1670,6 +1670,12 @@ queue("USERHOST "+nicks); } +void Server::requestTopic(const QString& channel) +{ + inputFilter.setAutomaticRequest("TOPIC", channel, true); + queue("TOPIC "+channel); +} + void Server::resolveUserhost(const QString& nickname) { inputFilter.setAutomaticRequest("WHOIS", nickname, true); --- trunk/extragear/network/konversation/src/server.h #495132:495133 @@ -415,6 +415,7 @@ void requestWhois(const QString& nickname); void requestWho(const QString& channel); void requestUserhost(const QString& nicks); + void requestTopic(const QString& channel); void resolveUserhost(const QString& nickname); void addRawLog(bool show); void closeRawLog();
commit 6a0653c03220abaa8a089db34cecac4a06172cb9 Author: Eike Hein <hein@kde.org> Date: Sat Jan 7 09:02:42 2006 +0000 Have /topic <channel> make a honest attempt at retrieving <channel>'s topic regardless of whether or not we are on <channel>. Some ircds will not allow us to do that, which is why we implemented 442 (ERR_NOTONCHANNEL) allowing us to fail gracefully (i.e. with a pretty and localizable error message). BUG:112074 svn path=/trunk/extragear/network/konversation/; revision=495133 diff --git a/src/inputfilter.cpp b/src/inputfilter.cpp index f8585a6..d852f3d 100644 --- a/src/inputfilter.cpp +++ b/src/inputfilter.cpp @@ -800,9 +800,22 @@ void InputFilter::parseServerCommand(const QString &prefix, const QString &comma // Topic set messages case RPL_TOPIC: { - // Update channel window QString topic = Konversation::removeIrcMarkup(trailing); - server->setChannelTopic(parameterList[1],topic); + + // FIXME: This is an abuse of the automaticRequest system: We're + // using it in an inverted manner, i.e. the automaticRequest is + // set to true by a manual invocation of /topic. Bad bad bad - + // needs rethinking of automaticRequest. + if(getAutomaticRequest("TOPIC",parameterList[1])==0) + { + // Update channel window + server->setChannelTopic(parameterList[1],topic); + } + else + { + server->appendMessageToFrontmost(i18n("Topic"),i18n("The channel topic for %1 is: \"%2\"").arg(parameterList[1]).arg(topic)); + } + break; } case RPL_TOPICSETBY: @@ -810,12 +823,27 @@ void InputFilter::parseServerCommand(const QString &prefix, const QString &comma // Inform user who set the topic and when QDateTime when; when.setTime_t(parameterList[3].toUInt()); - server->appendCommandMessageToChannel(parameterList[1],i18n("Topic"), - i18n("Topic was set by %1 on %2.") - .arg(parameterList[2]).arg(when.toString(Qt::LocalDate)) - ); - emit topicAuthor(parameterList[1],parameterList[2]); + // See FIXME in RPL_TOPIC + if(getAutomaticRequest("TOPIC",parameterList[1])==0) + { + server->appendCommandMessageToChannel(parameterList[1],i18n("Topic"), + i18n("The topic was set by %1 on %2.") + .arg(parameterList[2]).arg(when.toString(Qt::LocalDate)) + ); + + emit topicAuthor(parameterList[1],parameterList[2]); + } + else + { + server->appendMessageToFrontmost(i18n("Topic"),i18n("The topic for %1 was set by %2 on %3.") + .arg(parameterList[1]) + .arg(parameterList[2]) + .arg(when.toString(Qt::LocalDate)) + ); + setAutomaticRequest("TOPIC",parameterList[1],false); + } + break; } case ERR_NOSUCHNICK: diff --git a/src/outputfilter.cpp b/src/outputfilter.cpp index eeb4264..09cfff9 100644 --- a/src/outputfilter.cpp +++ b/src/outputfilter.cpp @@ -405,7 +405,7 @@ namespace Konversation // if no topic given, retrieve topic if(topic.isEmpty()) { - result.toServer = "TOPIC " + channel; + m_server->requestTopic(channel); } // otherwise set topic there else diff --git a/src/server.cpp b/src/server.cpp index 71a5588..fe538dd 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1670,6 +1670,12 @@ void Server::requestUserhost(const QString& nicks) queue("USERHOST "+nicks); } +void Server::requestTopic(const QString& channel) +{ + inputFilter.setAutomaticRequest("TOPIC", channel, true); + queue("TOPIC "+channel); +} + void Server::resolveUserhost(const QString& nickname) { inputFilter.setAutomaticRequest("WHOIS", nickname, true); diff --git a/src/server.h b/src/server.h index 5d9fd5f..612e431 100644 --- a/src/server.h +++ b/src/server.h @@ -415,6 +415,7 @@ class Server : public QObject void requestWhois(const QString& nickname); void requestWho(const QString& channel); void requestUserhost(const QString& nicks); + void requestTopic(const QString& channel); void resolveUserhost(const QString& nickname); void addRawLog(bool show); void closeRawLog();