X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcoresessioneventprocessor.cpp;h=59565a08399336f52cf409959559c991ceaccc4f;hp=7d5d24445e5ff23f8236363680622b10278698c4;hb=36ea1791352d34e34b6c6cdef02455a4c43acc17;hpb=1a2a0f1880d6c30166928addbfb7b11849ff15cc diff --git a/src/core/coresessioneventprocessor.cpp b/src/core/coresessioneventprocessor.cpp index 7d5d2444..59565a08 100644 --- a/src/core/coresessioneventprocessor.cpp +++ b/src/core/coresessioneventprocessor.cpp @@ -23,13 +23,15 @@ #include "coreirclisthelper.h" #include "corenetwork.h" #include "coresession.h" +#include "ctcpevent.h" #include "ircevent.h" #include "ircuser.h" #include "messageevent.h" #include "netsplit.h" +#include "quassel.h" CoreSessionEventProcessor::CoreSessionEventProcessor(CoreSession *session) - : QObject(session), + : BasicHandler("handleCtcp", session), _coreSession(session) { connect(coreSession(), SIGNAL(networkDisconnected(NetworkId)), this, SLOT(destroyNetsplits(NetworkId))); @@ -804,3 +806,49 @@ void CoreSessionEventProcessor::destroyNetsplits(NetworkId netId) { QHash splits = _netsplits.take(net); qDeleteAll(splits); } + +/*******************************/ +/******** CTCP HANDLING ********/ +/*******************************/ + +void CoreSessionEventProcessor::processCtcpEvent(CtcpEvent *e) { + if(e->testFlag(EventManager::Self)) + return; // ignore ctcp events generated by user input + + if(e->type() != EventManager::CtcpEvent || e->ctcpType() != CtcpEvent::Query) + return; + + handle(e->ctcpCmd(), Q_ARG(CtcpEvent *, e)); +} + +void CoreSessionEventProcessor::defaultHandler(const QString &ctcpCmd, CtcpEvent *e) { + // This handler is only there to avoid warnings for unknown CTCPs + Q_UNUSED(e); + Q_UNUSED(ctcpCmd); +} + +void CoreSessionEventProcessor::handleCtcpAction(CtcpEvent *e) { + // This handler is only there to feed CLIENTINFO + Q_UNUSED(e); +} + +void CoreSessionEventProcessor::handleCtcpClientinfo(CtcpEvent *e) { + QStringList supportedHandlers; + foreach(QString handler, providesHandlers()) + supportedHandlers << handler.toUpper(); + qSort(supportedHandlers); + e->setReply(supportedHandlers.join(" ")); +} + +void CoreSessionEventProcessor::handleCtcpPing(CtcpEvent *e) { + e->setReply(e->param()); +} + +void CoreSessionEventProcessor::handleCtcpTime(CtcpEvent *e) { + e->setReply(QDateTime::currentDateTime().toString()); +} + +void CoreSessionEventProcessor::handleCtcpVersion(CtcpEvent *e) { + e->setReply(QString("Quassel IRC %1 (built on %2) -- http://www.quassel-irc.org") + .arg(Quassel::buildInfo().plainVersionString).arg(Quassel::buildInfo().buildDate)); +}