Diffstat (limited to 'noncore/net/opieirc/ircmessageparser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index 90280d7..ecc7e9a 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -238,96 +238,130 @@ void IRCMessageParser::parseLiteralNick(IRCMessage *message) { | |||
238 | } else { | 238 | } else { |
239 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); | 239 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | } | 242 | } |
243 | 243 | ||
244 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { | 244 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { |
245 | IRCPerson mask(message->prefix()); | 245 | IRCPerson mask(message->prefix()); |
246 | IRCPerson *person = m_session->getPerson(mask.nick()); | 246 | IRCPerson *person = m_session->getPerson(mask.nick()); |
247 | if (person) { | 247 | if (person) { |
248 | QList<IRCChannel> channels; | 248 | QList<IRCChannel> channels; |
249 | m_session->getChannelsByPerson(person, channels); | 249 | m_session->getChannelsByPerson(person, channels); |
250 | QListIterator<IRCChannel> it(channels); | 250 | QListIterator<IRCChannel> it(channels); |
251 | for (;it.current(); ++it) { | 251 | for (;it.current(); ++it) { |
252 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); | 252 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); |
253 | it.current()->removePerson(chanperson); | 253 | it.current()->removePerson(chanperson); |
254 | delete chanperson; | 254 | delete chanperson; |
255 | } | 255 | } |
256 | m_session->removePerson(person); | 256 | m_session->removePerson(person); |
257 | IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) )); | 257 | IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) )); |
258 | output.addParam(person); | 258 | output.addParam(person); |
259 | emit outputReady(output); | 259 | emit outputReady(output); |
260 | delete person; | 260 | delete person; |
261 | } else { | 261 | } else { |
262 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); | 262 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { | 266 | void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { |
267 | IRCPerson mask(message->prefix()); | 267 | IRCPerson mask(message->prefix()); |
268 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 268 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
269 | if (channel) { | 269 | if (channel) { |
270 | IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); | 270 | IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); |
271 | output.addParam(channel); | 271 | output.addParam(channel); |
272 | emit outputReady(output); | 272 | emit outputReady(output); |
273 | } else { | 273 | } else { |
274 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); | 274 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | void IRCMessageParser::parseLiteralError(IRCMessage *message) { | 278 | void IRCMessageParser::parseLiteralError(IRCMessage *message) { |
279 | emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); | 279 | emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); |
280 | } | 280 | } |
281 | 281 | ||
282 | void IRCMessageParser::parseCTCPPing(IRCMessage *message) { | 282 | void IRCMessageParser::parseCTCPPing(IRCMessage *message) { |
283 | IRCPerson mask(message->prefix()); | 283 | IRCPerson mask(message->prefix()); |
284 | m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); | 284 | m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); |
285 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); | 285 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); |
286 | |||
287 | //IRCPerson mask(message->prefix()); | ||
288 | QString dest = message->ctcpDestination(); | ||
289 | if (dest.startsWith("#")) { | ||
290 | IRCChannel *channel = m_session->getChannel(dest.lower()); | ||
291 | if (channel) { | ||
292 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | ||
293 | if (person) { | ||
294 | IRCOutput output(OUTPUT_CHANACTION, tr("Received a CTCP PING from ")+ mask.nick()) ; | ||
295 | output.addParam(channel); | ||
296 | output.addParam(person); | ||
297 | emit outputReady(output); | ||
298 | } else { | ||
299 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown person - Desynchronized?"))); | ||
300 | } | ||
301 | } else { | ||
302 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown channel - Desynchronized?"))); | ||
303 | } | ||
304 | } else { | ||
305 | if (message->ctcpDestination() == m_session->m_server->nick()) { | ||
306 | IRCPerson *person = m_session->getPerson(mask.nick()); | ||
307 | if (!person) { | ||
308 | /* Person not yet known, create and add to the current session */ | ||
309 | person = new IRCPerson(message->prefix()); | ||
310 | m_session->addPerson(person); | ||
311 | } | ||
312 | IRCOutput output(OUTPUT_QUERYACTION, tr("Received a CTCP PING from ")+ mask.nick() ); | ||
313 | output.addParam(person); | ||
314 | emit outputReady(output); | ||
315 | } else { | ||
316 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with bad recipient"))); | ||
317 | } | ||
318 | } | ||
319 | |||
286 | } | 320 | } |
287 | 321 | ||
288 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { | 322 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { |
289 | IRCPerson mask(message->prefix()); | 323 | IRCPerson mask(message->prefix()); |
290 | m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); | 324 | m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); |
291 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); | 325 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); |
292 | } | 326 | } |
293 | 327 | ||
294 | void IRCMessageParser::parseCTCPAction(IRCMessage *message) { | 328 | void IRCMessageParser::parseCTCPAction(IRCMessage *message) { |
295 | IRCPerson mask(message->prefix()); | 329 | IRCPerson mask(message->prefix()); |
296 | QString dest = message->ctcpDestination(); | 330 | QString dest = message->ctcpDestination(); |
297 | if (dest.startsWith("#")) { | 331 | if (dest.startsWith("#")) { |
298 | IRCChannel *channel = m_session->getChannel(dest.lower()); | 332 | IRCChannel *channel = m_session->getChannel(dest.lower()); |
299 | if (channel) { | 333 | if (channel) { |
300 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 334 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
301 | if (person) { | 335 | if (person) { |
302 | IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); | 336 | IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); |
303 | output.addParam(channel); | 337 | output.addParam(channel); |
304 | output.addParam(person); | 338 | output.addParam(person); |
305 | emit outputReady(output); | 339 | emit outputReady(output); |
306 | } else { | 340 | } else { |
307 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); | 341 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); |
308 | } | 342 | } |
309 | } else { | 343 | } else { |
310 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); | 344 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); |
311 | } | 345 | } |
312 | } else { | 346 | } else { |
313 | if (message->ctcpDestination() == m_session->m_server->nick()) { | 347 | if (message->ctcpDestination() == m_session->m_server->nick()) { |
314 | IRCPerson *person = m_session->getPerson(mask.nick()); | 348 | IRCPerson *person = m_session->getPerson(mask.nick()); |
315 | if (!person) { | 349 | if (!person) { |
316 | /* Person not yet known, create and add to the current session */ | 350 | /* Person not yet known, create and add to the current session */ |
317 | person = new IRCPerson(message->prefix()); | 351 | person = new IRCPerson(message->prefix()); |
318 | m_session->addPerson(person); | 352 | m_session->addPerson(person); |
319 | } | 353 | } |
320 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); | 354 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); |
321 | output.addParam(person); | 355 | output.addParam(person); |
322 | emit outputReady(output); | 356 | emit outputReady(output); |
323 | } else { | 357 | } else { |
324 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); | 358 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); |
325 | } | 359 | } |
326 | } | 360 | } |
327 | } | 361 | } |
328 | 362 | ||
329 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { | 363 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { |
330 | IRCPerson mask(message->prefix()); | 364 | IRCPerson mask(message->prefix()); |
331 | 365 | ||
332 | if (message->param(0).startsWith("#")) { | 366 | if (message->param(0).startsWith("#")) { |
333 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 367 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |