Diffstat (limited to 'noncore/net/opieirc/ircmessageparser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 33 |
1 files changed, 32 insertions, 1 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 @@ -10,16 +10,17 @@ IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, { "NICK", FUNC(parseLiteralNick) }, { "PART", FUNC(parseLiteralPart) }, { "QUIT", FUNC(parseLiteralQuit) }, { "ERROR", FUNC(parseLiteralError) }, { "ERROR:", FUNC(parseLiteralError) }, { "MODE", FUNC(parseLiteralMode) }, { "KICK", FUNC(parseLiteralKick) }, + { "TOPIC", FUNC(parseLiteralTopic) }, { 0 , 0 } }; /* Lookup table for literal commands */ IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { { "PING", FUNC(parseCTCPPing) }, { "VERSION", FUNC(parseCTCPVersion) }, { "ACTION", FUNC(parseCTCPAction) }, @@ -31,16 +32,18 @@ IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { { 1, FUNC(parseNumerical001) }, // RPL_WELCOME { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST { 3, FUNC(parseNumerical003) }, // RPL_CREATED { 4, FUNC(parseNumerical004) }, // RPL_MYINFO { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME + { 332, FUNC(parseNumericalTopic) }, // RPL_TOPIC + { 333, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART { 372, FUNC(parseNumericalStats) }, // RPL_MOTD { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK @@ -186,17 +189,17 @@ void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); output.addParam(channel); output.addParam(person); emit outputReady(output); } else { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); } } 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))); } } else { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); } } void IRCMessageParser::parseLiteralNick(IRCMessage *message) { IRCPerson mask(message->prefix()); @@ -237,16 +240,28 @@ void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { output.addParam(person); emit outputReady(output); delete person; } else { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); } } +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) { emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); } void IRCMessageParser::parseCTCPPing(IRCMessage *message) { IRCPerson mask(message->prefix()); m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); @@ -479,8 +494,24 @@ void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) { void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname"))); m_session->endSession(); } void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); } + +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) { +} |