summaryrefslogtreecommitdiff
path: root/noncore
authorwazlaf <wazlaf>2002-09-29 19:54:12 (UTC)
committer wazlaf <wazlaf>2002-09-29 19:54:12 (UTC)
commit1dd254c95a582c2c86c816516a1b4433d8142d8a (patch) (side-by-side diff)
treea3225293a4b399494a04e5bb07154bd673ba0acf /noncore
parentf91ea4e068f38e9df17b06c87cd8635628837a4f (diff)
downloadopie-1dd254c95a582c2c86c816516a1b4433d8142d8a.zip
opie-1dd254c95a582c2c86c816516a1b4433d8142d8a.tar.gz
opie-1dd254c95a582c2c86c816516a1b4433d8142d8a.tar.bz2
some more message types supported to make this work more smoothly with freenode.net
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp33
-rw-r--r--noncore/net/opieirc/ircmessageparser.h3
-rw-r--r--noncore/net/opieirc/ircoutput.h3
-rw-r--r--noncore/net/opieirc/ircservertab.cpp12
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
@@ -12,12 +12,13 @@ IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
{ "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) },
@@ -33,12 +34,14 @@ IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = {
{ 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
@@ -188,13 +191,13 @@ void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) {
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")));
}
}
@@ -239,12 +242,24 @@ void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
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());
@@ -481,6 +496,22 @@ void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) {
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) {
+}
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
@@ -69,22 +69,25 @@ private:
void parseLiteralNick(IRCMessage *message);
void parseLiteralPart(IRCMessage *message);
void parseLiteralQuit(IRCMessage *message);
void parseLiteralError(IRCMessage *message);
void parseLiteralMode(IRCMessage *message);
void parseLiteralKick(IRCMessage *message);
+ void parseLiteralTopic(IRCMessage *message);
void parseNumerical001(IRCMessage *message);
void parseNumerical002(IRCMessage *message);
void parseNumerical003(IRCMessage *message);
void parseNumerical004(IRCMessage *message);
void parseNumerical005(IRCMessage *message);
void parseNumericalStats(IRCMessage *message);
void parseNumericalNames(IRCMessage *message);
void parseNumericalEndOfNames(IRCMessage *message);
void parseNumericalNicknameInUse(IRCMessage *message);
void parseNumericalNoSuchNick(IRCMessage *message);
+ void parseNumericalTopic(IRCMessage *message);
+ void parseNumericalTopicWhoTime(IRCMessage *message);
void parseCTCPPing(IRCMessage *message);
void parseCTCPVersion(IRCMessage *message);
void parseCTCPAction(IRCMessage *message);
protected:
IRCSession *m_session;
/* Parser tables */
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
@@ -41,13 +41,14 @@ enum IRCOutputType {
OUTPUT_CONNCLOSE = 10, /* parameters : none */
OUTPUT_CTCP = 11, /* parameters : none */
OUTPUT_SELFKICK = 12, /* parameters : channel (IRCChannel) */
OUTPUT_OTHERKICK = 13, /* parameters : channel (IRCChannel) person (IRCChannelPerson) */
OUTPUT_CHANACTION = 14, /* parameters : channel (IRCChannel) person (IRCChannelPerson) */
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) */
};
/* The IRCOutput class is used as a kind of message which is sent by the
IRC parser to inform the GUI of changes. This could for example be a
channel message or a nickname change */
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
@@ -216,12 +216,24 @@ void IRCServerTab::display(IRCOutput output) {
break;
case OUTPUT_CHANACTION: {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>");
}
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: {
QString nick = ((IRCPerson *)output.getParam(0))->nick();
QListIterator<IRCChannelTab> it(m_channelTabs);
for (; it.current(); ++it) {
if (it.current()->list()->hasPerson(nick)) {
it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");