X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmodules%2Fm_spanningtree%2Fidle.cpp;h=904142999370b7d1011eb1a1ef940b4728b589b6;hb=a9989ac3978bd6e1f9e915aeed399d9db327c235;hp=bf074bf7fcfc91a5e449ae8dc21b06a8d5a268fb;hpb=d9d99cd02dadf34bfcc220734ba0c422f0acb3e6;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/idle.cpp b/src/modules/m_spanningtree/idle.cpp index bf074bf7f..904142999 100644 --- a/src/modules/m_spanningtree/idle.cpp +++ b/src/modules/m_spanningtree/idle.cpp @@ -19,38 +19,35 @@ #include "inspircd.h" #include "utils.h" -#include "treesocket.h" +#include "commands.h" -bool TreeSocket::Whois(const std::string &prefix, parameterlist ¶ms) +CmdResult CommandIdle::HandleRemote(RemoteUser* issuer, Params& params) { - if (params.size() < 1) - return true; - - /* If this is a request, this user did the /whois - * If this is a reply, this user's information is in params[1] and params[2] + /** + * There are two forms of IDLE: request and reply. Requests have one parameter, + * replies have more than one. + * + * If this is a request, 'issuer' did a /whois and its server wants to learn the + * idle time of the user in params[0]. + * + * If this is a reply, params[0] is the user who did the whois and params.back() is + * the number of seconds 'issuer' has been idle. */ - User* issuer = ServerInstance->FindUUID(prefix); - if ((!issuer) || (IS_SERVER(issuer))) - return true; - /* If this is a request, this is the user whose idle information was requested - * If this is a reply, this user did the /whois - */ User* target = ServerInstance->FindUUID(params[0]); - if ((!target) || (IS_SERVER(target))) - return true; + if ((!target) || (target->registered != REG_ALL)) + return CMD_FAILURE; LocalUser* localtarget = IS_LOCAL(target); if (!localtarget) { // Forward to target's server - Utils->DoOneToOne(prefix, "IDLE", params, target->server); - return true; + return CMD_SUCCESS; } if (params.size() >= 2) { - ServerInstance->Parser->CallHandler("WHOIS", params, issuer); + ServerInstance->Parser.CallHandler("WHOIS", params, issuer); } else { @@ -60,14 +57,14 @@ bool TreeSocket::Whois(const std::string &prefix, parameterlist ¶ms) // Possible case when our clock ticked backwards idle = 0; else - idle = ((unsigned int) (localtarget->idle_lastmsg - ServerInstance->Time())); + idle = ((unsigned int) (ServerInstance->Time() - localtarget->idle_lastmsg)); - parameterlist reply; - reply.push_back(prefix); - reply.push_back(ConvToStr(target->signon)); - reply.push_back(ConvToStr(idle)); - Utils->DoOneToOne(params[0], "IDLE", reply, issuer->server); + CmdBuilder reply(target, "IDLE"); + reply.push(issuer->uuid); + reply.push(ConvToStr(target->signon)); + reply.push(ConvToStr(idle)); + reply.Unicast(issuer); } - return true; + return CMD_SUCCESS; }