Diffstat (limited to 'noncore/net/opieirc/ircmessageparser.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 158 |
1 files changed, 108 insertions, 50 deletions
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index f8ccbb6..fde156c 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -1,13 +1,15 @@ | |||
1 | #include <qtextstream.h> | 1 | #include <qtextstream.h> |
2 | #include <qdatetime.h> | ||
3 | |||
2 | #include "ircmessageparser.h" | 4 | #include "ircmessageparser.h" |
3 | #include "ircversion.h" | 5 | #include "ircversion.h" |
4 | 6 | ||
5 | /* Lookup table for literal commands */ | 7 | /* Lookup table for literal commands */ |
6 | IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { | 8 | IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { |
7 | { "PING", FUNC(parseLiteralPing) }, | 9 | { "PING", FUNC(parseLiteralPing) }, |
8 | { "NOTICE", FUNC(parseLiteralNotice) }, | 10 | { "NOTICE", FUNC(parseLiteralNotice) }, |
9 | { "JOIN", FUNC(parseLiteralJoin) }, | 11 | { "JOIN", FUNC(parseLiteralJoin) }, |
10 | { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, | 12 | { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, |
11 | { "NICK", FUNC(parseLiteralNick) }, | 13 | { "NICK", FUNC(parseLiteralNick) }, |
12 | { "PART", FUNC(parseLiteralPart) }, | 14 | { "PART", FUNC(parseLiteralPart) }, |
13 | { "QUIT", FUNC(parseLiteralQuit) }, | 15 | { "QUIT", FUNC(parseLiteralQuit) }, |
@@ -18,93 +20,154 @@ IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { | |||
18 | { "TOPIC", FUNC(parseLiteralTopic) }, | 20 | { "TOPIC", FUNC(parseLiteralTopic) }, |
19 | { 0 , 0 } | 21 | { 0 , 0 } |
20 | }; | 22 | }; |
21 | 23 | ||
22 | /* Lookup table for literal commands */ | 24 | /* Lookup table for literal commands */ |
23 | IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { | 25 | IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { |
24 | { "PING", FUNC(parseCTCPPing) }, | 26 | { "PING", FUNC(parseCTCPPing) }, |
25 | { "VERSION", FUNC(parseCTCPVersion) }, | 27 | { "VERSION", FUNC(parseCTCPVersion) }, |
26 | { "ACTION", FUNC(parseCTCPAction) }, | 28 | { "ACTION", FUNC(parseCTCPAction) }, |
27 | { 0 , 0 } | 29 | { 0 , 0 } |
28 | }; | 30 | }; |
29 | 31 | ||
30 | /* Lookup table for numerical commands */ | 32 | /* Lookup table for numerical commands |
33 | * According to: | ||
34 | * http://www.faqs.org/rfcs/rfc1459.html | ||
35 | * http://www.faqs.org/rfcs/rfc2812.html | ||
36 | */ | ||
37 | |||
31 | IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { | 38 | IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { |
32 | { 1, FUNC(parseNumericalSecondParam) }, // RPL_WELCOME | 39 | { 1, "%1", "1", FUNC(parseNumericalServerName) }, // RPL_WELCOME |
33 | { 2, FUNC(parseNumericalSecondParam) }, // RPL_YOURHOST | 40 | { 2, "%1", "1", 0 }, // RPL_YOURHOST |
34 | { 3, FUNC(parseNumericalSecondParam) }, // RPL_CREATED | 41 | { 3, "%1", "1", 0 }, // RPL_CREATED |
35 | { 4, FUNC(parseNumericalAllParams) }, // RPL_MYINFO | 42 | { 4, QT_TR_NOOP("Server %1 version %2 supports usermodes '%3' and channelmodes '%4'"), "1:4", FUNC(parseNumericalServerFeatures) }, // RPL_MYINFO |
36 | { 5, FUNC(parseNumericalSecondParam) }, // RPL_BOUNCE, RPL_PROTOCTL | 43 | { 5, 0, 0, FUNC(parseNumericalServerProtocol) }, // RPL_BOUNCE, RPL_PROTOCTL |
37 | { 250, FUNC(parseNumericalAllParams) }, // RPL_STATSCONN | 44 | { 250, "%1", "1", 0 }, // RPL_STATSCONN |
38 | { 251, FUNC(parseNumericalSecondParam) }, // RPL_LUSERCLIENT | 45 | { 251, "%1", "1", 0 }, // RPL_LUSERCLIENT |
39 | { 252, FUNC(parseNumericalAllParams) }, // RPL_LUSEROP | 46 | { 252, QT_TR_NOOP("There are %1 operators connected"), "1", 0 }, // RPL_LUSEROP |
40 | { 253, FUNC(parseNumericalAllParams) }, // RPL_LUSERUNKNOWN | 47 | { 253, QT_TR_NOOP("There are %1 unknown connection(s)"), "1", 0 }, // RPL_LUSERUNKNOWN |
41 | { 254, FUNC(parseNumericalAllParams) }, // RPL_LUSERCHANNELS | 48 | { 254, QT_TR_NOOP("There are %1 channels formed"), "1", 0 }, // RPL_LUSERCHANNELS |
42 | { 255, FUNC(parseNumericalSecondParam) }, // RPL_LUSERME | 49 | { 255, "%1", "1", 0 }, // RPL_LUSERME |
43 | { 265, FUNC(parseNumericalAllParams) }, // RPL_LOCALUSERS | 50 | { 263, QT_TR_NOOP("Please wait a while and try again"), 0, 0 }, // RPL_TRYAGAIN |
44 | { 266, FUNC(parseNumericalAllParams) }, // RPL_GLOBALUSERS | 51 | { 265, "%1", "1", 0 }, // RPL_LOCALUSERS |
45 | { 332, FUNC(parseNumericalTopic) }, // RPL_TOPIC | 52 | { 266, "%1", "1", 0 }, // RPL_GLOBALUSERS |
46 | { 333, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME | 53 | { 311, QT_TR_NOOP("Whois %1 (%2@%3)\nReal name: %4"), "1:3,5" }, // RPL_WHOISUSER |
47 | { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY | 54 | { 312, QT_TR_NOOP("%1 is using server %2"), "1,2", 0 }, // RPL_WHOISSERVER |
48 | { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES | 55 | { 317, 0, 0, FUNC(parseNumericalWhoisIdle) }, // RPL_WHOISIDLE |
49 | { 372, FUNC(parseNumericalSecondParam) }, // RPL_MOTD | 56 | { 318, "%1 :%2", "1,2", 0 }, // RPL_ENDOFWHOIS |
50 | { 375, FUNC(parseNumericalSecondParam) }, // RPL_MOTDSTART | 57 | { 320, "%1 %2", "1,2", 0}, // RPL_WHOISVIRT |
51 | { 376, FUNC(parseNumericalSecondParam) }, // RPL_ENDOFMOTD | 58 | { 332, 0, 0, FUNC(parseNumericalTopic) }, // RPL_TOPIC |
52 | { 377, FUNC(parseNumericalSecondParam) }, // RPL_MOTD2 | 59 | { 333, 0, 0, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME*/ |
53 | { 378, FUNC(parseNumericalSecondParam) }, // RPL_MOTD3 | 60 | { 353, QT_TR_NOOP("Names for %1: %2"), "2,3", FUNC(parseNumericalNames) }, // RPL_NAMREPLY |
54 | { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK | 61 | { 366, "%1 :%2", "1,2", FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES |
55 | { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK | 62 | { 369, "%1 :%2", "1,2", 0 }, // RPL_ENDOFWHOWAS |
56 | { 412, FUNC(parseNumericalSecondParam) }, // ERR_NOTEXTTOSEND | 63 | { 372, "%1", "1", 0 }, // RPL_MOTD |
57 | { 422, FUNC(parseNumericalSecondParam) }, // ERR_NOMOTD | 64 | { 375, "%1", "1", 0 }, // RPL_MOTDSTART |
58 | { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE | 65 | { 376, "%1", "1", 0 }, // RPL_ENDOFMOTD |
59 | { 0, 0 } | 66 | { 377, "%1", "1", 0 }, // RPL_MOTD2 |
67 | { 378, "%1", "1", 0 }, // RPL_MOTD3 | ||
68 | { 391, QT_TR_NOOP("Time on server %1 is %2"), "1,2", 0 }, // RPL_TIME | ||
69 | { 401, QT_TR_NOOP("Channel or nick %1 doesn't exists"), "1", 0 }, // ERR_NOSUCHNICK | ||
70 | { 406, QT_TR_NOOP("There is no history information for %1"), "1" }, // ERR_WASNOSUCHNICK | ||
71 | { 409, "%1", "1", 0 }, // ERR_NOORIGIN | ||
72 | { 411, "%1", "1", 0 }, // ERR_NORECIPIENT | ||
73 | { 412, "%1", "1", 0 }, // ERR_NOTEXTTOSEND | ||
74 | { 421, QT_TR_NOOP("Unknown command: %1"), "1", 0 }, // ERR_NOMOTD | ||
75 | { 422, QT_TR_NOOP("You're not on channel %1"), "1", 0}, // ERR_NOTONCHANNEL | ||
76 | { 422, "%1", "1", 0 }, // ERR_NOMOTD | ||
77 | { 433, QT_TR_NOOP("Can't change nick to %1: %2"), "1,2", FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE | ||
78 | { 477, "%1", "1", 0 }, // ERR_NOCHANMODES || ERR_NEEDREGGEDNICK | ||
79 | { 482, QT_TR_NOOP("[%1] Operation not permitted, you don't have enough channel privileges"), "1", 0 }, //ERR_CHANOPRIVSNEEDED | ||
80 | { 0, 0, 0, 0 } | ||
60 | }; | 81 | }; |
61 | 82 | ||
62 | 83 | ||
63 | IRCMessageParser::IRCMessageParser(IRCSession *session) { | 84 | IRCMessageParser::IRCMessageParser(IRCSession *session) { |
64 | m_session = session; | 85 | m_session = session; |
65 | } | 86 | } |
66 | 87 | ||
67 | void IRCMessageParser::parse(IRCMessage *message) { | 88 | void IRCMessageParser::parse(IRCMessage *message) { |
68 | /* Find out what kind of message we have here and call the appropriate handler using | 89 | /* Find out what kind of message we have here and call the appropriate handler using |
69 | the parser tables. If no handler can be found, print out an error message */ | 90 | the parser tables. If no handler can be found, print out an error message */ |
70 | if (message->isNumerical()) { | 91 | if (message->isNumerical()) { |
71 | for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { | 92 | for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { |
72 | if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { | 93 | if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { |
73 | (this->*(numericalParserProcTable[i].proc))(message); | 94 | parseNumerical(message, i); |
74 | return; | 95 | return; |
75 | } | 96 | } |
76 | } | 97 | } |
77 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command: %1").arg( QString::number(message->commandNumber()) ))); | 98 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command: %1").arg( QString::number(message->commandNumber()) ))); |
78 | } else if (message->isCTCP()) { | 99 | } else if (message->isCTCP()) { |
79 | for (int i=0; ctcpParserProcTable[i].commandName; i++) { | 100 | for (int i=0; ctcpParserProcTable[i].commandName; i++) { |
80 | if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { | 101 | if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { |
81 | (this->*(ctcpParserProcTable[i].proc))(message); | 102 | (this->*(ctcpParserProcTable[i].proc))(message); |
82 | return; | 103 | return; |
83 | } | 104 | } |
84 | } | 105 | } |
85 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command: %1").arg( message->ctcpCommand())) ); | 106 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command: %1").arg( message->ctcpCommand())) ); |
86 | } else { | 107 | } else { |
87 | for (int i=0; literalParserProcTable[i].commandName; i++) { | 108 | for (int i=0; literalParserProcTable[i].commandName; i++) { |
88 | if (message->command() == literalParserProcTable[i].commandName) { | 109 | if (message->command() == literalParserProcTable[i].commandName) { |
89 | (this->*(literalParserProcTable[i].proc))(message); | 110 | (this->*(literalParserProcTable[i].proc))(message); |
90 | return; | 111 | return; |
91 | } | 112 | } |
92 | } | 113 | } |
93 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command: %1").arg( message->command()) )); | 114 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command: %1").arg( message->command()) )); |
94 | } | 115 | } |
95 | } | 116 | } |
96 | 117 | ||
97 | void IRCMessageParser::nullFunc(IRCMessage *) { | 118 | void IRCMessageParser::parseNumerical(IRCMessage *message, int position) { |
98 | /* Do nothing */ | 119 | QString out = tr(numericalParserProcTable[position].message); |
120 | QString paramString = numericalParserProcTable[position].params; | ||
121 | |||
122 | if(!out.isEmpty() && !paramString.isEmpty()) { | ||
123 | QStringList params = message->params(numericalParserProcTable[position].params); | ||
124 | |||
125 | QStringList::Iterator end = params.end(); | ||
126 | for (QStringList::Iterator it = params.begin(); it != end; ++it) { | ||
127 | out = out.arg(*it); | ||
128 | } | ||
129 | |||
130 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, out)); | ||
131 | } | ||
132 | |||
133 | if(numericalParserProcTable[position].proc) | ||
134 | (this->*(numericalParserProcTable[position].proc))(message); | ||
135 | } | ||
136 | |||
137 | void IRCMessageParser::parseNumericalServerName(IRCMessage *message) { | ||
138 | emit outputReady(IRCOutput(OUTPUT_TITLE, tr("Connected to")+" <b>" + message->prefix() + "</b>")); | ||
139 | } | ||
140 | |||
141 | void IRCMessageParser::parseNumericalServerFeatures(IRCMessage *message) { | ||
142 | m_session->setValidUsermodes(message->param(2)); | ||
143 | m_session->setValidChannelmodes(message->param(3)); | ||
144 | |||
145 | } | ||
146 | |||
147 | void IRCMessageParser::parseNumericalServerProtocol(IRCMessage *message) { | ||
148 | /* XXX: Add some usefull features here */ | ||
149 | QString out = message->allParameters(); | ||
150 | out = out.mid(out.find(' ')+1); | ||
151 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, out)); | ||
152 | } | ||
153 | void IRCMessageParser::parseNumericalWhoisIdle(IRCMessage *message) { | ||
154 | QDateTime dt; | ||
155 | QTime t; | ||
156 | t = t.addSecs(message->param(2).toInt()); | ||
157 | dt.setTime_t(message->param(3).toInt()); | ||
158 | |||
159 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, tr("%1 has been idle for %2").arg(message->param(1)).arg(t.toString()))); | ||
160 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, tr("%1 signed on %2").arg(message->param(1)).arg(dt.toString()))); | ||
161 | |||
99 | } | 162 | } |
100 | 163 | ||
101 | void IRCMessageParser::parseLiteralPing(IRCMessage *message) { | 164 | void IRCMessageParser::parseLiteralPing(IRCMessage *message) { |
102 | m_session->m_connection->sendLine("PONG " + message->allParameters()); | 165 | m_session->m_connection->sendLine("PONG " + message->allParameters()); |
103 | } | 166 | } |
104 | 167 | ||
105 | void IRCMessageParser::parseLiteralNotice(IRCMessage *message) { | 168 | void IRCMessageParser::parseLiteralNotice(IRCMessage *message) { |
106 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); | 169 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); |
107 | } | 170 | } |
108 | 171 | ||
109 | void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { | 172 | void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { |
110 | QString channelName = message->param(0).lower(); | 173 | QString channelName = message->param(0).lower(); |
@@ -200,57 +263,57 @@ void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { | |||
200 | } else { | 263 | } else { |
201 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); | 264 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); |
202 | } | 265 | } |
203 | } else { | 266 | } else { |
204 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel %1").arg(message->param(0).lower()) )); | 267 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel %1").arg(message->param(0).lower()) )); |
205 | } | 268 | } |
206 | } else { | 269 | } else { |
207 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); | 270 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); |
208 | } | 271 | } |
209 | } | 272 | } |
210 | 273 | ||
211 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { | 274 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { |
212 | |||
213 | IRCPerson mask(message->prefix()); | 275 | IRCPerson mask(message->prefix()); |
214 | /* this way of handling nick changes really sucks */ | 276 | m_session->updateNickname(mask.nick(), message->param(0)); |
277 | /* this way of handling nick changes really sucks | ||
215 | if (mask.nick() == m_session->m_server->nick()) { | 278 | if (mask.nick() == m_session->m_server->nick()) { |
216 | /* We are changing our nickname */ | 279 | We are changing our nickname |
217 | m_session->m_server->setNick(message->param(0)); | 280 | m_session->m_server->setNick(message->param(0)); |
218 | IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0))); | 281 | IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0))); |
219 | output.addParam(0); | 282 | output.addParam(0); |
220 | emit outputReady(output); | 283 | emit outputReady(output); |
221 | } else { | 284 | } else { |
222 | /* Someone else is */ | 285 | Someone else is |
223 | IRCPerson *person = m_session->getPerson(mask.nick()); | 286 | RCPerson *person = m_session->getPerson(mask.nick()); |
224 | if (person) { | 287 | if (person) { |
225 | //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); | 288 | //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); |
226 | 289 | ||
227 | /* new code starts here -- this removes the person from all channels */ | 290 | new code starts here -- this removes the person from all channels |
228 | QList<IRCChannel> channels; | 291 | QList<IRCChannel> channels; |
229 | m_session->getChannelsByPerson(person, channels); | 292 | m_session->getChannelsByPerson(person, channels); |
230 | QListIterator<IRCChannel> it(channels); | 293 | QListIterator<IRCChannel> it(channels); |
231 | for (;it.current(); ++it) { | 294 | for (;it.current(); ++it) { |
232 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); | 295 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); |
233 | it.current()->removePerson(chanperson); | 296 | it.current()->removePerson(chanperson); |
234 | chanperson->person->setNick(message->param(0)); | 297 | chanperson->person->setNick(message->param(0)); |
235 | it.current()->addPerson(chanperson); | 298 | it.current()->addPerson(chanperson); |
236 | IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); | 299 | IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); |
237 | output.addParam(person); | 300 | output.addParam(person); |
238 | emit outputReady(output); | 301 | emit outputReady(output); |
239 | } | 302 | } |
240 | /* new code ends here */ | 303 | new code ends here |
241 | } else { | 304 | } else { |
242 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); | 305 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); |
243 | } | 306 | } |
244 | } | 307 | }*/ |
245 | } | 308 | } |
246 | 309 | ||
247 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { | 310 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { |
248 | IRCPerson mask(message->prefix()); | 311 | IRCPerson mask(message->prefix()); |
249 | IRCPerson *person = m_session->getPerson(mask.nick()); | 312 | IRCPerson *person = m_session->getPerson(mask.nick()); |
250 | if (person) { | 313 | if (person) { |
251 | QList<IRCChannel> channels; | 314 | QList<IRCChannel> channels; |
252 | m_session->getChannelsByPerson(person, channels); | 315 | m_session->getChannelsByPerson(person, channels); |
253 | QListIterator<IRCChannel> it(channels); | 316 | QListIterator<IRCChannel> it(channels); |
254 | for (;it.current(); ++it) { | 317 | for (;it.current(); ++it) { |
255 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); | 318 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); |
256 | it.current()->removePerson(chanperson); | 319 | it.current()->removePerson(chanperson); |
@@ -315,25 +378,25 @@ void IRCMessageParser::parseCTCPPing(IRCMessage *message) { | |||
315 | IRCOutput output(OUTPUT_QUERYACTION, tr("Received a CTCP PING from ")+ mask.nick() ); | 378 | IRCOutput output(OUTPUT_QUERYACTION, tr("Received a CTCP PING from ")+ mask.nick() ); |
316 | output.addParam(person); | 379 | output.addParam(person); |
317 | emit outputReady(output); | 380 | emit outputReady(output); |
318 | } else { | 381 | } else { |
319 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with bad recipient"))); | 382 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with bad recipient"))); |
320 | } | 383 | } |
321 | } | 384 | } |
322 | 385 | ||
323 | } | 386 | } |
324 | 387 | ||
325 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { | 388 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { |
326 | IRCPerson mask(message->prefix()); | 389 | IRCPerson mask(message->prefix()); |
327 | m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); | 390 | m_session->m_connection->sendCTCP(mask.nick(), "VERSION " APP_VERSION " " APP_COPYSTR); |
328 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); | 391 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); |
329 | } | 392 | } |
330 | 393 | ||
331 | void IRCMessageParser::parseCTCPAction(IRCMessage *message) { | 394 | void IRCMessageParser::parseCTCPAction(IRCMessage *message) { |
332 | IRCPerson mask(message->prefix()); | 395 | IRCPerson mask(message->prefix()); |
333 | QString dest = message->ctcpDestination(); | 396 | QString dest = message->ctcpDestination(); |
334 | if (dest.startsWith("#")) { | 397 | if (dest.startsWith("#")) { |
335 | IRCChannel *channel = m_session->getChannel(dest.lower()); | 398 | IRCChannel *channel = m_session->getChannel(dest.lower()); |
336 | if (channel) { | 399 | if (channel) { |
337 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 400 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
338 | if (person) { | 401 | if (person) { |
339 | IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); | 402 | IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); |
@@ -454,33 +517,24 @@ void IRCMessageParser::parseLiteralKick(IRCMessage *message) { | |||
454 | output.addParam(channel); | 517 | output.addParam(channel); |
455 | output.addParam(person); | 518 | output.addParam(person); |
456 | emit outputReady(output); | 519 | emit outputReady(output); |
457 | } | 520 | } |
458 | } else { | 521 | } else { |
459 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?"))); | 522 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?"))); |
460 | } | 523 | } |
461 | } else { | 524 | } else { |
462 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); | 525 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); |
463 | } | 526 | } |
464 | } | 527 | } |
465 | 528 | ||
466 | |||
467 | void IRCMessageParser::parseNumericalSecondParam(IRCMessage *message) { | ||
468 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | ||
469 | } | ||
470 | |||
471 | void IRCMessageParser::parseNumericalAllParams(IRCMessage *message) { | ||
472 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); | ||
473 | } | ||
474 | |||
475 | void IRCMessageParser::parseNumericalNames(IRCMessage *message) { | 529 | void IRCMessageParser::parseNumericalNames(IRCMessage *message) { |
476 | /* Name list sent when joining a channel */ | 530 | /* Name list sent when joining a channel */ |
477 | IRCChannel *channel = m_session->getChannel(message->param(2).lower()); | 531 | IRCChannel *channel = m_session->getChannel(message->param(2).lower()); |
478 | if (channel != 0) { | 532 | if (channel != 0) { |
479 | QString people = message->param(3); | 533 | QString people = message->param(3); |
480 | QTextIStream stream(&people); | 534 | QTextIStream stream(&people); |
481 | QString temp; | 535 | QString temp; |
482 | 536 | ||
483 | while (!stream.atEnd()) { | 537 | while (!stream.atEnd()) { |
484 | stream >> temp; | 538 | stream >> temp; |
485 | 539 | ||
486 | char flagch = temp.at(0).latin1(); | 540 | char flagch = temp.at(0).latin1(); |
@@ -523,24 +577,28 @@ void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) { | |||
523 | channel->setHasPeople(TRUE); | 577 | channel->setHasPeople(TRUE); |
524 | /* Yes, we want the names before anything happens inside the GUI */ | 578 | /* Yes, we want the names before anything happens inside the GUI */ |
525 | IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname()); | 579 | IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname()); |
526 | output.addParam(channel); | 580 | output.addParam(channel); |
527 | emit outputReady(output); | 581 | emit outputReady(output); |
528 | } else { | 582 | } else { |
529 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); | 583 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); |
530 | } | 584 | } |
531 | } | 585 | } |
532 | 586 | ||
533 | 587 | ||
534 | void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { | 588 | void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { |
589 | /* If we are connnected this error is not critical */ | ||
590 | if(m_session->isLoggedIn()) | ||
591 | return; | ||
592 | |||
535 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname"))); | 593 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname"))); |
536 | m_session->endSession(); | 594 | m_session->endSession(); |
537 | } | 595 | } |
538 | 596 | ||
539 | void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { | 597 | void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { |
540 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); | 598 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); |
541 | } | 599 | } |
542 | 600 | ||
543 | void IRCMessageParser::parseNumericalTopic(IRCMessage *message) { | 601 | void IRCMessageParser::parseNumericalTopic(IRCMessage *message) { |
544 | IRCChannel *channel = m_session->getChannel(message->param(1).lower()); | 602 | IRCChannel *channel = m_session->getChannel(message->param(1).lower()); |
545 | if (channel) { | 603 | if (channel) { |
546 | IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + channel->channelname() + " is \"" + message->param(2) + "\"")); | 604 | IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + channel->channelname() + " is \"" + message->param(2) + "\"")); |