From: Manuel Nickschas Date: Wed, 6 Oct 2010 09:08:14 +0000 (+0200) Subject: Event backend porting X-Git-Tag: 0.8-beta1~98 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=56b69808aa71b882aa792fadfda2733d765c2ba8 Event backend porting RPL_AWAY (301), RPL_UNAWAY (305), RPL_NOWAWAY (306) Also replacing the fixed strings from the ircd by a translateable version. --- diff --git a/src/core/coresessioneventprocessor.cpp b/src/core/coresessioneventprocessor.cpp index e3eca41c..fb9f903c 100644 --- a/src/core/coresessioneventprocessor.cpp +++ b/src/core/coresessioneventprocessor.cpp @@ -190,6 +190,49 @@ void CoreSessionEventProcessor::processIrcEvent266(IrcEvent *) { // TODO: save information in network object } +/* +WHOIS-Message: + Replies 311 - 313, 317 - 319 are all replies generated in response to a WHOIS message. + and 301 (RPL_AWAY) + " :" +WHO-Message: + Replies 352 and 315 paired are used to answer a WHO message. + +WHOWAS-Message: + Replies 314 and 369 are responses to a WHOWAS message. + +*/ + +/* RPL_AWAY - " :" */ +void CoreSessionEventProcessor::processIrcEvent301(IrcEvent *e) { + if(!checkParamCount(e, 2)) + return; + + IrcUser *ircuser = e->network()->ircUser(e->params().at(0)); + if(ircuser) { + ircuser->setAway(true); + ircuser->setAwayMessage(e->params().at(1)); + //ircuser->setLastAwayMessage(now); + } +} + +/* RPL_UNAWAY - ":You are no longer marked as being away" */ +void CoreSessionEventProcessor::processIrcEvent305(IrcEvent *e) { + IrcUser *me = e->network()->me(); + if(me) + me->setAway(false); + + if(e->network()->autoAwayActive()) + e->network()->setAutoAwayActive(false); +} + +/* RPL_NOWAWAY - ":You have been marked as being away" */ +void CoreSessionEventProcessor::processIrcEvent306(IrcEvent *e) { + IrcUser *me = e->network()->me(); + if(me) + me->setAway(true); +} + /* template void CoreSessionEventProcessor::processIrcEvent(IrcEvent *e) { if(!checkParamCount(e, 1)) diff --git a/src/core/coresessioneventprocessor.h b/src/core/coresessioneventprocessor.h index 1361205d..e164ca85 100644 --- a/src/core/coresessioneventprocessor.h +++ b/src/core/coresessioneventprocessor.h @@ -52,6 +52,9 @@ public: Q_INVOKABLE void processIrcEvent250(IrcEvent *event); // RPL_STATSCONN Q_INVOKABLE void processIrcEvent265(IrcEvent *event); // RPL_LOCALUSERS Q_INVOKABLE void processIrcEvent266(IrcEvent *event); // RPL_GLOBALUSERS + Q_INVOKABLE void processIrcEvent301(IrcEvent *event); // RPL_AWAY + Q_INVOKABLE void processIrcEvent305(IrcEvent *event); // RPL_UNAWAY + Q_INVOKABLE void processIrcEvent306(IrcEvent *event); // RPL_NOWAWAY // Q_INVOKABLE void processIrcEvent(IrcEvent *event); diff --git a/src/core/eventstringifier.cpp b/src/core/eventstringifier.cpp index 8b92da03..64e70038 100644 --- a/src/core/eventstringifier.cpp +++ b/src/core/eventstringifier.cpp @@ -53,7 +53,7 @@ void EventStringifier::processIrcEventNumeric(IrcEventNumeric *e) { case 1: case 2: case 3: case 4: case 5: case 221: case 250: case 251: case 252: case 253: case 254: case 255: case 265: case 266: case 372: case 375: - displayMsg(e, Message::Server, e->params().join(" "), e->prefix()); qDebug () << e; + displayMsg(e, Message::Server, e->params().join(" "), e->prefix()); break; // Server error messages without param, just display them @@ -101,7 +101,7 @@ void EventStringifier::processIrcEventNumeric(IrcEventNumeric *e) { default: if(_whois) { // many nets define their own WHOIS fields. we fetch those not in need of special attention here: - displayMsg(e, Message::Server, "[Whois] " + e->params().join(" "), e->prefix()); + displayMsg(e, Message::Server, tr("[Whois] ") + e->params().join(" "), e->prefix()); } else { // FIXME figure out how/where to do this in the future //if(coreSession()->ircListHelper()->requestInProgress(network()->networkId())) @@ -168,3 +168,40 @@ void EventStringifier::processIrcEventTopic(IrcEvent *e) { displayMsg(e, Message::Topic, tr("%1 has changed topic for %2 to: \"%3\"") .arg(e->nick(), e->params().at(0), e->params().at(1)), QString(), e->params().at(0)); } + +void EventStringifier::processIrcEvent301(IrcEvent *e) { + QString nick = e->params().at(0); + QString awayMsg = e->params().at(1); + QString msg, target; + bool send = true; + + // FIXME: proper redirection needed + if(_whois) { + msg = tr("[Whois] "); + } else { + target = nick; + IrcUser *ircuser = e->network()->ircUser(nick); + if(ircuser) { + int now = QDateTime::currentDateTime().toTime_t(); + const int silenceTime = 60; + if(ircuser->lastAwayMessage() + silenceTime >= now) + send = false; + ircuser->setLastAwayMessage(now); + } + } + if(send) + displayMsg(e, Message::Server, msg + tr("%1 is away: \"%2\"").arg(nick, awayMsg), QString(), target); +} + +/* RPL_UNAWAY */ +void EventStringifier::earlyProcessIrcEvent305(IrcEvent *e) { + // needs to be called early so we still get the old autoAwayActive state! + if(!e->network()->autoAwayActive()) + displayMsg(e, Message::Server, tr("You are no longer marked as being away")); +} + +/* RPL_NOWAWAY */ +void EventStringifier::processIrcEvent306(IrcEvent *e) { + if(!e->network()->autoAwayActive()) + displayMsg(e, Message::Server, tr("You have been marked as being away")); +} diff --git a/src/core/eventstringifier.h b/src/core/eventstringifier.h index 4bc7f1a5..6dbfc0ff 100644 --- a/src/core/eventstringifier.h +++ b/src/core/eventstringifier.h @@ -57,6 +57,10 @@ public: Q_INVOKABLE void processIrcEventPong(IrcEvent *event); Q_INVOKABLE void processIrcEventTopic(IrcEvent *event); + Q_INVOKABLE void processIrcEvent301(IrcEvent *event); // RPL_AWAY + Q_INVOKABLE void earlyProcessIrcEvent305(IrcEvent *event); // RPL_UNAWAY + Q_INVOKABLE void processIrcEvent306(IrcEvent *event); // RPL_NOWAWAY + // Q_INVOKABLE void processIrcEvent(IrcEvent *event); public slots: diff --git a/src/core/ircserverhandler.cpp b/src/core/ircserverhandler.cpp index 523b2153..debe2efb 100644 --- a/src/core/ircserverhandler.cpp +++ b/src/core/ircserverhandler.cpp @@ -442,69 +442,6 @@ WHOWAS-Message: */ - -/* RPL_AWAY - " :" */ -void IrcServerHandler::handle301(const QString &prefix, const QList ¶ms) { - Q_UNUSED(prefix); - if(!checkParamCount("IrcServerHandler::handle301()", params, 2)) - return; - - - QString nickName = serverDecode(params[0]); - QString awayMessage = userDecode(nickName, params[1]); - - IrcUser *ircuser = network()->ircUser(nickName); - if(ircuser) { - ircuser->setAwayMessage(awayMessage); - ircuser->setAway(true); - } - - // FIXME: proper redirection needed - if(_whois) { - emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("[Whois] %1 is away: \"%2\"").arg(nickName).arg(awayMessage)); - } else { - if(ircuser) { - int now = QDateTime::currentDateTime().toTime_t(); - int silenceTime = 60; - if(ircuser->lastAwayMessage() + silenceTime < now) { - emit displayMsg(Message::Server, BufferInfo::QueryBuffer, params[0], tr("%1 is away: \"%2\"").arg(nickName).arg(awayMessage)); - } - ircuser->setLastAwayMessage(now); - } else { - // probably should not happen - emit displayMsg(Message::Server, BufferInfo::QueryBuffer, params[0], tr("%1 is away: \"%2\"").arg(nickName).arg(awayMessage)); - } - } -} - -// 305 RPL_UNAWAY -// ":You are no longer marked as being away" -void IrcServerHandler::handle305(const QString &prefix, const QList ¶ms) { - Q_UNUSED(prefix); - IrcUser *me = network()->me(); - if(me) - me->setAway(false); - - if(!network()->autoAwayActive()) { - if(!params.isEmpty()) - emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", serverDecode(params[0])); - } else { - network()->setAutoAwayActive(false); - } -} - -// 306 RPL_NOWAWAY -// ":You have been marked as being away" -void IrcServerHandler::handle306(const QString &prefix, const QList ¶ms) { - Q_UNUSED(prefix); - IrcUser *me = network()->me(); - if(me) - me->setAway(true); - - if(!params.isEmpty() && !network()->autoAwayActive()) - emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", serverDecode(params[0])); -} - /* RPL_WHOISSERVICE - " is registered nick" */ void IrcServerHandler::handle307(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix) diff --git a/src/core/ircserverhandler.h b/src/core/ircserverhandler.h index 9854396e..d7b87500 100644 --- a/src/core/ircserverhandler.h +++ b/src/core/ircserverhandler.h @@ -41,9 +41,6 @@ public slots: void handlePrivmsg(const QString &prefix, const QList ¶ms); void handleQuit(const QString &prefix, const QList ¶ms); void handle005(const QString &prefix, const QList ¶ms); // RPL_ISUPPORT - void handle301(const QString &prefix, const QList ¶ms); // RPL_AWAY - void handle305(const QString &prefix, const QList ¶ms); // RPL_UNAWAY - void handle306(const QString &prefix, const QList ¶ms); // RPL_NOWAWAY void handle307(const QString &prefix, const QList ¶ms); // RPL_WHOISSERVICE void handle310(const QString &prefix, const QList ¶ms); // RPL_SUSERHOST void handle311(const QString &prefix, const QList ¶ms); // RPL_WHOISUSER