summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircmessageparser.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/opieirc/ircmessageparser.cpp') (more/less context) (show 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
@@ -6,45 +6,48 @@
IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
{ "PING", FUNC(parseLiteralPing) },
{ "NOTICE", FUNC(parseLiteralNotice) },
{ "JOIN", FUNC(parseLiteralJoin) },
{ "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) },
{ 0 , 0 }
};
/* Lookup table for numerical commands */
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
{ 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK
{ 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND
{ 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE
{ 0, 0 }
@@ -182,25 +185,25 @@ void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) {
if (channel) {
IRCPerson mask(message->prefix());
IRCChannelPerson *person = channel->getPerson(mask.nick());
if (person) {
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());
if (mask.nick() == m_session->m_server->nick()) {
/* We are changing our nickname */
m_session->m_server->setNick(message->param(0));
@@ -233,24 +236,36 @@ void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
delete chanperson;
}
m_session->removePerson(person);
IRCOutput output(OUTPUT_QUIT, mask.nick() + tr(" has quit ") + "(" + message->param(0) + ")");
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()));
}
void IRCMessageParser::parseCTCPVersion(IRCMessage *message) {
IRCPerson mask(message->prefix());
@@ -475,12 +490,28 @@ 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) {
+}