summaryrefslogtreecommitdiff
path: root/noncore/net
Side-by-side diff
Diffstat (limited to 'noncore/net') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp48
1 files changed, 28 insertions, 20 deletions
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp
index fde156c..cfad2c1 100644
--- a/noncore/net/opieirc/ircmessageparser.cpp
+++ b/noncore/net/opieirc/ircmessageparser.cpp
@@ -50,52 +50,52 @@ IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = {
{ 263, QT_TR_NOOP("Please wait a while and try again"), 0, 0 }, // RPL_TRYAGAIN
{ 265, "%1", "1", 0 }, // RPL_LOCALUSERS
{ 266, "%1", "1", 0 }, // RPL_GLOBALUSERS
{ 311, QT_TR_NOOP("Whois %1 (%2@%3)\nReal name: %4"), "1:3,5" }, // RPL_WHOISUSER
{ 312, QT_TR_NOOP("%1 is using server %2"), "1,2", 0 }, // RPL_WHOISSERVER
{ 317, 0, 0, FUNC(parseNumericalWhoisIdle) }, // RPL_WHOISIDLE
{ 318, "%1 :%2", "1,2", 0 }, // RPL_ENDOFWHOIS
{ 320, "%1 %2", "1,2", 0}, // RPL_WHOISVIRT
{ 332, 0, 0, FUNC(parseNumericalTopic) }, // RPL_TOPIC
{ 333, 0, 0, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME*/
{ 353, QT_TR_NOOP("Names for %1: %2"), "2,3", FUNC(parseNumericalNames) }, // RPL_NAMREPLY
{ 366, "%1 :%2", "1,2", FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES
{ 369, "%1 :%2", "1,2", 0 }, // RPL_ENDOFWHOWAS
{ 372, "%1", "1", 0 }, // RPL_MOTD
{ 375, "%1", "1", 0 }, // RPL_MOTDSTART
{ 376, "%1", "1", 0 }, // RPL_ENDOFMOTD
{ 377, "%1", "1", 0 }, // RPL_MOTD2
{ 378, "%1", "1", 0 }, // RPL_MOTD3
{ 391, QT_TR_NOOP("Time on server %1 is %2"), "1,2", 0 }, // RPL_TIME
{ 401, QT_TR_NOOP("Channel or nick %1 doesn't exists"), "1", 0 }, // ERR_NOSUCHNICK
{ 406, QT_TR_NOOP("There is no history information for %1"), "1" }, // ERR_WASNOSUCHNICK
{ 409, "%1", "1", 0 }, // ERR_NOORIGIN
{ 411, "%1", "1", 0 }, // ERR_NORECIPIENT
{ 412, "%1", "1", 0 }, // ERR_NOTEXTTOSEND
- { 421, QT_TR_NOOP("Unknown command: %1"), "1", 0 }, // ERR_NOMOTD
- { 422, QT_TR_NOOP("You're not on channel %1"), "1", 0}, // ERR_NOTONCHANNEL
+ { 421, QT_TR_NOOP("Unknown command: %1"), "1", 0 }, // ERR_ERR_UNKNOWNCOMMAND
{ 422, "%1", "1", 0 }, // ERR_NOMOTD
{ 433, QT_TR_NOOP("Can't change nick to %1: %2"), "1,2", FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE
+ { 442, QT_TR_NOOP("You're not on channel %1"), "1", 0}, // ERR_NOTONCHANNEL
{ 477, "%1", "1", 0 }, // ERR_NOCHANMODES || ERR_NEEDREGGEDNICK
{ 482, QT_TR_NOOP("[%1] Operation not permitted, you don't have enough channel privileges"), "1", 0 }, //ERR_CHANOPRIVSNEEDED
{ 0, 0, 0, 0 }
};
IRCMessageParser::IRCMessageParser(IRCSession *session) {
m_session = session;
}
void IRCMessageParser::parse(IRCMessage *message) {
/* Find out what kind of message we have here and call the appropriate handler using
the parser tables. If no handler can be found, print out an error message */
if (message->isNumerical()) {
for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) {
if (message->commandNumber() == numericalParserProcTable[i].commandNumber) {
parseNumerical(message, i);
return;
}
}
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command: %1").arg( QString::number(message->commandNumber()) )));
} else if (message->isCTCP()) {
for (int i=0; ctcpParserProcTable[i].commandName; i++) {
if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) {
@@ -115,48 +115,52 @@ void IRCMessageParser::parse(IRCMessage *message) {
}
}
void IRCMessageParser::parseNumerical(IRCMessage *message, int position) {
QString out = tr(numericalParserProcTable[position].message);
QString paramString = numericalParserProcTable[position].params;
if(!out.isEmpty() && !paramString.isEmpty()) {
QStringList params = message->params(numericalParserProcTable[position].params);
QStringList::Iterator end = params.end();
for (QStringList::Iterator it = params.begin(); it != end; ++it) {
out = out.arg(*it);
}
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, out));
}
if(numericalParserProcTable[position].proc)
(this->*(numericalParserProcTable[position].proc))(message);
}
void IRCMessageParser::parseNumericalServerName(IRCMessage *message) {
emit outputReady(IRCOutput(OUTPUT_TITLE, tr("Connected to")+" <b>" + message->prefix() + "</b>"));
+ /* Register EFFECTIVE nickname, some networks (as irc-hispano) uses nick:password
+ * for authentication and the parser gets confused */
+ m_session->m_server->setNick(message->param(0));
+
}
void IRCMessageParser::parseNumericalServerFeatures(IRCMessage *message) {
m_session->setValidUsermodes(message->param(2));
m_session->setValidChannelmodes(message->param(3));
}
void IRCMessageParser::parseNumericalServerProtocol(IRCMessage *message) {
/* XXX: Add some usefull features here */
QString out = message->allParameters();
out = out.mid(out.find(' ')+1);
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, out));
}
void IRCMessageParser::parseNumericalWhoisIdle(IRCMessage *message) {
QDateTime dt;
QTime t;
t = t.addSecs(message->param(2).toInt());
dt.setTime_t(message->param(3).toInt());
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, tr("%1 has been idle for %2").arg(message->param(1)).arg(t.toString())));
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, tr("%1 signed on %2").arg(message->param(1)).arg(dt.toString())));
}
@@ -228,67 +232,71 @@ void IRCMessageParser::parseLiteralPart(IRCMessage *message) {
emit outputReady(output);
delete person;
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?")));
}
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?")));
}
}
void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) {
if (m_session->m_server->nick().lower() == message->param(0).lower() ) {
/* IRC Query message detected, verify sender and display it */
IRCPerson mask(message->prefix());
IRCPerson *person = m_session->getPerson(mask.nick());
if (!person) {
/* Person not yet known, create and add to the current session */
person = new IRCPerson(message->prefix());
m_session->addPerson(person);
}
IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1));
output.addParam(person);
emit outputReady(output);
- } else if (message->param(0).at(0) == '#' || message->param(0).at(0) == '+') {
- /* IRC Channel message detected, verify sender, channel and display it */
- IRCChannel *channel = m_session->getChannel(message->param(0).lower());
- 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
+ if (message->param(0).at(0) == '#' || message->param(0).at(0) == '+') {
+ /* IRC Channel message detected, verify sender, channel and display it */
+ IRCChannel *channel = m_session->getChannel(message->param(0).lower());
+ 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 %1").arg(message->param(0).lower()) ));
}
- } else {
- emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel %1").arg(message->param(0).lower()) ));
- }
- } else {
- emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type")));
+ }
+ else {emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type")));
}
}
void IRCMessageParser::parseLiteralNick(IRCMessage *message) {
IRCPerson mask(message->prefix());
m_session->updateNickname(mask.nick(), message->param(0));
/* this way of handling nick changes really sucks
if (mask.nick() == m_session->m_server->nick()) {
We are changing our nickname
m_session->m_server->setNick(message->param(0));
IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0)));
output.addParam(0);
emit outputReady(output);
} else {
Someone else is
RCPerson *person = m_session->getPerson(mask.nick());
if (person) {
//IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0)));
new code starts here -- this removes the person from all channels
QList<IRCChannel> channels;
m_session->getChannelsByPerson(person, channels);
QListIterator<IRCChannel> it(channels);
for (;it.current(); ++it) {