X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fctcphandler.cpp;h=655f1700408189af13cf3f9cd81b36b10b8cc1b1;hb=6e02e38993d9b2d3c5e36359dcb6f6969e4caf39;hp=8b17de19d7c73436e4b1d13106f21002554fb9a9;hpb=d329046faaae47c39af14d9019b542b945e628d7;p=quassel.git diff --git a/src/core/ctcphandler.cpp b/src/core/ctcphandler.cpp index 8b17de19..655f1700 100644 --- a/src/core/ctcphandler.cpp +++ b/src/core/ctcphandler.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-09 by the Quassel Project * + * Copyright (C) 2005-10 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -26,7 +26,7 @@ #include "coreignorelistmanager.h" CtcpHandler::CtcpHandler(CoreNetwork *parent) - : BasicHandler(parent), + : CoreBasicHandler(parent), XDELIM("\001"), _ignoreListManager(parent->ignoreListManager()) { @@ -162,6 +162,9 @@ void CtcpHandler::parse(Message::Type messageType, const QString &prefix, const } QByteArray CtcpHandler::pack(const QByteArray &ctcpTag, const QByteArray &message) { + if(message.isEmpty()) + return XDELIM + ctcpTag + XDELIM; + return XDELIM + ctcpTag + ' ' + xdelimQuote(message) + XDELIM; } @@ -188,30 +191,46 @@ void CtcpHandler::handleAction(CtcpType ctcptype, const QString &prefix, const Q void CtcpHandler::handlePing(CtcpType ctcptype, const QString &prefix, const QString &target, const QString ¶m) { Q_UNUSED(target) if(ctcptype == CtcpQuery) { - if(!_ignoreListManager->ctcpMatch(prefix, network()->networkName(), "PING")) { - reply(nickFromMask(prefix), "PING", param); - emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP PING request from %1").arg(prefix)); - } + if(_ignoreListManager->ctcpMatch(prefix, network()->networkName(), "PING")) + return; + reply(nickFromMask(prefix), "PING", param); + emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP PING request from %1").arg(prefix)); } else { // display ping answer uint now = QDateTime::currentDateTime().toTime_t(); uint then = QDateTime().fromTime_t(param.toInt()).toTime_t(); - emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP PING answer from %1 with %2 seconds round trip time").arg(prefix).arg(now-then)); + emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP PING answer from %1 with %2 seconds round trip time") + .arg(nickFromMask(prefix)).arg(now-then)); } } void CtcpHandler::handleVersion(CtcpType ctcptype, const QString &prefix, const QString &target, const QString ¶m) { Q_UNUSED(target) if(ctcptype == CtcpQuery) { - if(!_ignoreListManager->ctcpMatch(prefix, network()->networkName(), "VERSION")) { - reply(nickFromMask(prefix), "VERSION", QString("Quassel IRC %1 (built on %2) -- http://www.quassel-irc.org") + if(_ignoreListManager->ctcpMatch(prefix, network()->networkName(), "VERSION")) + return; + reply(nickFromMask(prefix), "VERSION", QString("Quassel IRC %1 (built on %2) -- http://www.quassel-irc.org") .arg(Quassel::buildInfo().plainVersionString) .arg(Quassel::buildInfo().buildDate)); - emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP VERSION request by %1").arg(prefix)); - } + emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP VERSION request by %1").arg(prefix)); } else { // display Version answer - emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP VERSION answer from %1: %2").arg(prefix).arg(param)); + emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP VERSION answer from %1: %2") + .arg(nickFromMask(prefix)).arg(param)); + } +} + +void CtcpHandler::handleTime(CtcpType ctcptype, const QString &prefix, const QString &target, const QString ¶m) { + Q_UNUSED(target) + if(ctcptype == CtcpQuery) { + if(_ignoreListManager->ctcpMatch(prefix, network()->networkName(), "TIME")) + return; + reply(nickFromMask(prefix), "TIME", QDateTime::currentDateTime().toString()); + emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP TIME request by %1").arg(prefix)); + } + else { + emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP TIME answer from %1: %2") + .arg(nickFromMask(prefix)).arg(param)); } } @@ -226,4 +245,3 @@ void CtcpHandler::defaultHandler(const QString &cmd, CtcpType ctcptype, const QS } } -