summaryrefslogtreecommitdiff
authorskyhusker <skyhusker>2005-02-01 19:12:34 (UTC)
committer skyhusker <skyhusker>2005-02-01 19:12:34 (UTC)
commit17a8d1d5d2d9ec7a5e09da00e055d566fbd85353 (patch) (unidiff)
tree7e645b05a471b9139303e3ceb34a45514ed475c0
parente8eee0b7b169c5ed79f0eb9e0a76df06ec3fdcb4 (diff)
downloadopie-17a8d1d5d2d9ec7a5e09da00e055d566fbd85353.zip
opie-17a8d1d5d2d9ec7a5e09da00e055d566fbd85353.tar.gz
opie-17a8d1d5d2d9ec7a5e09da00e055d566fbd85353.tar.bz2
Added proper action on ctcp ping reply
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp
index 9c1492c..ad9de2b 100644
--- a/noncore/net/opieirc/ircmessageparser.cpp
+++ b/noncore/net/opieirc/ircmessageparser.cpp
@@ -303,130 +303,138 @@ void IRCMessageParser::parseLiteralNick(IRCMessage *message) {
303 RCPerson *person = m_session->getPerson(mask.nick()); 303 RCPerson *person = m_session->getPerson(mask.nick());
304 if (person) { 304 if (person) {
305 //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); 305 //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0)));
306 306
307 new code starts here -- this removes the person from all channels 307 new code starts here -- this removes the person from all channels
308 QList<IRCChannel> channels; 308 QList<IRCChannel> channels;
309 m_session->getChannelsByPerson(person, channels); 309 m_session->getChannelsByPerson(person, channels);
310 QListIterator<IRCChannel> it(channels); 310 QListIterator<IRCChannel> it(channels);
311 for (;it.current(); ++it) { 311 for (;it.current(); ++it) {
312 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); 312 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
313 it.current()->removePerson(chanperson); 313 it.current()->removePerson(chanperson);
314 chanperson->person->setNick(message->param(0)); 314 chanperson->person->setNick(message->param(0));
315 it.current()->addPerson(chanperson); 315 it.current()->addPerson(chanperson);
316 IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); 316 IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0)));
317 output.addParam(person); 317 output.addParam(person);
318 emit outputReady(output); 318 emit outputReady(output);
319 } 319 }
320 new code ends here 320 new code ends here
321 } else { 321 } else {
322 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); 322 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person")));
323 } 323 }
324 }*/ 324 }*/
325} 325}
326 326
327void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { 327void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
328 IRCPerson mask(message->prefix()); 328 IRCPerson mask(message->prefix());
329 IRCPerson *person = m_session->getPerson(mask.nick()); 329 IRCPerson *person = m_session->getPerson(mask.nick());
330 if (person) { 330 if (person) {
331 QList<IRCChannel> channels; 331 QList<IRCChannel> channels;
332 m_session->getChannelsByPerson(person, channels); 332 m_session->getChannelsByPerson(person, channels);
333 QListIterator<IRCChannel> it(channels); 333 QListIterator<IRCChannel> it(channels);
334 for (;it.current(); ++it) { 334 for (;it.current(); ++it) {
335 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); 335 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
336 it.current()->removePerson(chanperson); 336 it.current()->removePerson(chanperson);
337 delete chanperson; 337 delete chanperson;
338 } 338 }
339 m_session->removePerson(person); 339 m_session->removePerson(person);
340 IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) )); 340 IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) ));
341 output.addParam(person); 341 output.addParam(person);
342 emit outputReady(output); 342 emit outputReady(output);
343 delete person; 343 delete person;
344 } else { 344 } else {
345 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); 345 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?")));
346 } 346 }
347} 347}
348 348
349void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { 349void IRCMessageParser::parseLiteralTopic(IRCMessage *message) {
350 IRCPerson mask(message->prefix()); 350 IRCPerson mask(message->prefix());
351 IRCChannel *channel = m_session->getChannel(message->param(0).lower()); 351 IRCChannel *channel = m_session->getChannel(message->param(0).lower());
352 if (channel) { 352 if (channel) {
353 IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); 353 IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\"");
354 output.addParam(channel); 354 output.addParam(channel);
355 emit outputReady(output); 355 emit outputReady(output);
356 } else { 356 } else {
357 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); 357 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?")));
358 } 358 }
359} 359}
360 360
361void IRCMessageParser::parseLiteralError(IRCMessage *message) { 361void IRCMessageParser::parseLiteralError(IRCMessage *message) {
362 emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); 362 emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters()));
363} 363}
364 364
365void IRCMessageParser::parseCTCPPing(IRCMessage *message) { 365void IRCMessageParser::parseCTCPPing(IRCMessage *message) {
366 IRCPerson mask(message->prefix()); 366 IRCPerson mask(message->prefix());
367 if(message->isCTCPReply()) {
368 unsigned int sentTime = message->param(0).toUInt();
369 QDateTime tm;
370 tm.setTime_t(0);
371 unsigned int receivedTime = tm.secsTo(QDateTime::currentDateTime());
372 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING reply from %1: %2 seconds").arg(mask.nick()).arg(receivedTime-sentTime)));
373 return;
374 }
367 m_session->m_connection->sendCTCPReply(mask.nick(), "PING", message->allParameters()); 375 m_session->m_connection->sendCTCPReply(mask.nick(), "PING", message->allParameters());
368 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ") + mask.nick())); 376 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING request from %1").arg(mask.nick())));
369 377
370 //IRCPerson mask(message->prefix()); 378 //IRCPerson mask(message->prefix());
371 QString dest = message->ctcpDestination(); 379 QString dest = message->ctcpDestination();
372 if (dest.startsWith("#")) { 380 if (dest.startsWith("#")) {
373 IRCChannel *channel = m_session->getChannel(dest.lower()); 381 IRCChannel *channel = m_session->getChannel(dest.lower());
374 if (channel) { 382 if (channel) {
375 IRCChannelPerson *person = channel->getPerson(mask.nick()); 383 IRCChannelPerson *person = channel->getPerson(mask.nick());
376 if (person) { 384 if (person) {
377 IRCOutput output(OUTPUT_CHANACTION, tr("Received a CTCP PING from ")+ mask.nick()) ; 385 IRCOutput output(OUTPUT_CHANACTION, tr("Received a CTCP PING from ")+ mask.nick()) ;
378 output.addParam(channel); 386 output.addParam(channel);
379 output.addParam(person); 387 output.addParam(person);
380 emit outputReady(output); 388 emit outputReady(output);
381 } else { 389 } else {
382 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown person - Desynchronized?"))); 390 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown person - Desynchronized?")));
383 } 391 }
384 } else { 392 } else {
385 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown channel - Desynchronized?"))); 393 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown channel - Desynchronized?")));
386 } 394 }
387 } else { 395 } else {
388 if (message->ctcpDestination() == m_session->m_server->nick()) { 396 if (message->ctcpDestination() == m_session->m_server->nick()) {
389 IRCPerson *person = m_session->getPerson(mask.nick()); 397 IRCPerson *person = m_session->getPerson(mask.nick());
390 if (!person) { 398 if (!person) {
391 /* Person not yet known, create and add to the current session */ 399 /* Person not yet known, create and add to the current session */
392 person = new IRCPerson(message->prefix()); 400 person = new IRCPerson(message->prefix());
393 m_session->addPerson(person); 401 m_session->addPerson(person);
394 } 402 }
395 IRCOutput output(OUTPUT_QUERYACTION, tr("Received a CTCP PING from ")+ mask.nick() ); 403 IRCOutput output(OUTPUT_QUERYACTION, tr("Received a CTCP PING from ")+ mask.nick() );
396 output.addParam(person); 404 output.addParam(person);
397 emit outputReady(output); 405 emit outputReady(output);
398 } else { 406 } else {
399 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with bad recipient"))); 407 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with bad recipient")));
400 } 408 }
401 } 409 }
402 410
403} 411}
404 412
405void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { 413void IRCMessageParser::parseCTCPVersion(IRCMessage *message) {
406 IRCPerson mask(message->prefix()); 414 IRCPerson mask(message->prefix());
407 IRCOutput output(OUTPUT_CTCP); 415 IRCOutput output(OUTPUT_CTCP);
408 if(message->isCTCPRequest()) { 416 if(message->isCTCPRequest()) {
409 m_session->m_connection->sendCTCPReply(mask.nick(), "VERSION", APP_VERSION " " APP_COPYSTR); 417 m_session->m_connection->sendCTCPReply(mask.nick(), "VERSION", APP_VERSION " " APP_COPYSTR);
410 output.setMessage(tr("Received a CTCP VERSION request from ") + mask.nick()); 418 output.setMessage(tr("Received a CTCP VERSION request from ") + mask.nick());
411 } 419 }
412 420
413 else { 421 else {
414 output.setMessage("Received CTCP VERSION reply from " + mask.nick() + ":" + message->param(0)); 422 output.setMessage("Received CTCP VERSION reply from " + mask.nick() + ":" + message->param(0));
415 } 423 }
416 emit outputReady(output); 424 emit outputReady(output);
417} 425}
418 426
419void IRCMessageParser::parseCTCPAction(IRCMessage *message) { 427void IRCMessageParser::parseCTCPAction(IRCMessage *message) {
420 IRCPerson mask(message->prefix()); 428 IRCPerson mask(message->prefix());
421 QString dest = message->ctcpDestination(); 429 QString dest = message->ctcpDestination();
422 if (dest.startsWith("#")) { 430 if (dest.startsWith("#")) {
423 IRCChannel *channel = m_session->getChannel(dest.lower()); 431 IRCChannel *channel = m_session->getChannel(dest.lower());
424 if (channel) { 432 if (channel) {
425 IRCChannelPerson *person = channel->getPerson(mask.nick()); 433 IRCChannelPerson *person = channel->getPerson(mask.nick());
426 if (person) { 434 if (person) {
427 IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); 435 IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0));
428 output.addParam(channel); 436 output.addParam(channel);
429 output.addParam(person); 437 output.addParam(person);
430 emit outputReady(output); 438 emit outputReady(output);
431 } else { 439 } else {
432 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); 440 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?")));