-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 33 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.h | 3 | ||||
-rw-r--r-- | noncore/net/opieirc/ircoutput.h | 3 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 12 |
4 files changed, 49 insertions, 2 deletions
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index 5c70753..d1b70a5 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp @@ -17,2 +17,3 @@ IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { { "KICK", FUNC(parseLiteralKick) }, + { "TOPIC", FUNC(parseLiteralTopic) }, { 0 , 0 } @@ -38,2 +39,4 @@ IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME + { 332, FUNC(parseNumericalTopic) }, // RPL_TOPIC + { 333, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY @@ -193,3 +196,3 @@ void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { } else { - emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel"))); + emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel ") + message->param(0))); } @@ -244,2 +247,14 @@ void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { +void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { + IRCPerson mask(message->prefix()); + IRCChannel *channel = m_session->getChannel(message->param(0)); + if (channel) { + IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); + output.addParam(channel); + emit outputReady(output); + } else { + emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); + } +} + void IRCMessageParser::parseLiteralError(IRCMessage *message) { @@ -486 +501,17 @@ void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { } + +void IRCMessageParser::parseNumericalTopic(IRCMessage *message) { + IRCChannel *channel = m_session->getChannel(message->param(1)); + if (channel) { + IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + channel->channelname() + " is \"" + message->param(2) + "\"")); + output.addParam(channel); + emit outputReady(output); + } else { + IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + message->param(1) + " is \"" + message->param(2) + "\"")); + output.addParam(0); + emit outputReady(output); + } +} + +void IRCMessageParser::parseNumericalTopicWhoTime(IRCMessage *message) { +} diff --git a/noncore/net/opieirc/ircmessageparser.h b/noncore/net/opieirc/ircmessageparser.h index f774047..c4dd96c 100644 --- a/noncore/net/opieirc/ircmessageparser.h +++ b/noncore/net/opieirc/ircmessageparser.h @@ -74,2 +74,3 @@ private: void parseLiteralKick(IRCMessage *message); + void parseLiteralTopic(IRCMessage *message); void parseNumerical001(IRCMessage *message); @@ -84,2 +85,4 @@ private: void parseNumericalNoSuchNick(IRCMessage *message); + void parseNumericalTopic(IRCMessage *message); + void parseNumericalTopicWhoTime(IRCMessage *message); void parseCTCPPing(IRCMessage *message); diff --git a/noncore/net/opieirc/ircoutput.h b/noncore/net/opieirc/ircoutput.h index e8cc524..9c0b8bb 100644 --- a/noncore/net/opieirc/ircoutput.h +++ b/noncore/net/opieirc/ircoutput.h @@ -46,3 +46,4 @@ enum IRCOutputType { OUTPUT_QUERYACTION = 15, /* parameters : person (IRCPerson) */ - OUTPUT_CHANPERSONMODE = 16 /* parameters : channel (IRCCHannel) person (IRCChannelPerson) */ + OUTPUT_CHANPERSONMODE = 16, /* parameters : channel (IRCCHannel) person (IRCChannelPerson) */ + OUTPUT_TOPIC = 17 /* parameters : channel (IRCChannel) */ }; diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index 4be60ef..aea58a3 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp @@ -221,2 +221,14 @@ void IRCServerTab::display(IRCOutput output) { break; + case OUTPUT_TOPIC: { + IRCChannel *channel = (IRCChannel *) output.getParam(0); + if (channel) { + IRCChannelTab *channelTab = getTabForChannel(channel); + if (channelTab) { + channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); + return; + } + } + appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); + } + break; case OUTPUT_QUIT: { |