summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircmessageparser.cpp
Unidiff
Diffstat (limited to 'noncore/net/opieirc/ircmessageparser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp33
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
@@ -12,12 +12,13 @@ IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
12 { "PART", FUNC(parseLiteralPart) }, 12 { "PART", FUNC(parseLiteralPart) },
13 { "QUIT", FUNC(parseLiteralQuit) }, 13 { "QUIT", FUNC(parseLiteralQuit) },
14 { "ERROR", FUNC(parseLiteralError) }, 14 { "ERROR", FUNC(parseLiteralError) },
15 { "ERROR:", FUNC(parseLiteralError) }, 15 { "ERROR:", FUNC(parseLiteralError) },
16 { "MODE", FUNC(parseLiteralMode) }, 16 { "MODE", FUNC(parseLiteralMode) },
17 { "KICK", FUNC(parseLiteralKick) }, 17 { "KICK", FUNC(parseLiteralKick) },
18 { "TOPIC", FUNC(parseLiteralTopic) },
18 { 0 , 0 } 19 { 0 , 0 }
19}; 20};
20 21
21/* Lookup table for literal commands */ 22/* Lookup table for literal commands */
22IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { 23IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = {
23 { "PING", FUNC(parseCTCPPing) }, 24 { "PING", FUNC(parseCTCPPing) },
@@ -33,12 +34,14 @@ IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = {
33 { 3, FUNC(parseNumerical003) }, // RPL_CREATED 34 { 3, FUNC(parseNumerical003) }, // RPL_CREATED
34 { 4, FUNC(parseNumerical004) }, // RPL_MYINFO 35 { 4, FUNC(parseNumerical004) }, // RPL_MYINFO
35 { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL 36 { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL
36 { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT 37 { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT
37 { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS 38 { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS
38 { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME 39 { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME
40 { 332, FUNC(parseNumericalTopic) }, // RPL_TOPIC
41 { 333, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME
39 { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY 42 { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY
40 { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES 43 { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES
41 { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART 44 { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART
42 { 372, FUNC(parseNumericalStats) }, // RPL_MOTD 45 { 372, FUNC(parseNumericalStats) }, // RPL_MOTD
43 { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD 46 { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD
44 { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 47 { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2
@@ -188,13 +191,13 @@ void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) {
188 output.addParam(person); 191 output.addParam(person);
189 emit outputReady(output); 192 emit outputReady(output);
190 } else { 193 } else {
191 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); 194 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender")));
192 } 195 }
193 } else { 196 } else {
194 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel"))); 197 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel ") + message->param(0)));
195 } 198 }
196 } else { 199 } else {
197 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); 200 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type")));
198 } 201 }
199} 202}
200 203
@@ -239,12 +242,24 @@ void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
239 delete person; 242 delete person;
240 } else { 243 } else {
241 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); 244 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?")));
242 } 245 }
243} 246}
244 247
248void IRCMessageParser::parseLiteralTopic(IRCMessage *message) {
249 IRCPerson mask(message->prefix());
250 IRCChannel *channel = m_session->getChannel(message->param(0));
251 if (channel) {
252 IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\"");
253 output.addParam(channel);
254 emit outputReady(output);
255 } else {
256 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?")));
257 }
258}
259
245void IRCMessageParser::parseLiteralError(IRCMessage *message) { 260void IRCMessageParser::parseLiteralError(IRCMessage *message) {
246 emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); 261 emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters()));
247} 262}
248 263
249void IRCMessageParser::parseCTCPPing(IRCMessage *message) { 264void IRCMessageParser::parseCTCPPing(IRCMessage *message) {
250 IRCPerson mask(message->prefix()); 265 IRCPerson mask(message->prefix());
@@ -481,6 +496,22 @@ void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) {
481 m_session->endSession(); 496 m_session->endSession();
482} 497}
483 498
484void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { 499void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) {
485 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); 500 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname")));
486} 501}
502
503void IRCMessageParser::parseNumericalTopic(IRCMessage *message) {
504 IRCChannel *channel = m_session->getChannel(message->param(1));
505 if (channel) {
506 IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + channel->channelname() + " is \"" + message->param(2) + "\""));
507 output.addParam(channel);
508 emit outputReady(output);
509 } else {
510 IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + message->param(1) + " is \"" + message->param(2) + "\""));
511 output.addParam(0);
512 emit outputReady(output);
513 }
514}
515
516void IRCMessageParser::parseNumericalTopicWhoTime(IRCMessage *message) {
517}