X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcommands%2Fcmd_who.cpp;h=c474abc3c8b2ea7c4662b3f24568181793553074;hb=3e365b60215447bc43683a4912896bac4a62bc31;hp=8afb3d6e7449c0f42ae2d2de483999c025311804;hpb=23e62cef071f8d037b2d163d60bcc85f5887776c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp index 8afb3d6e7..c474abc3c 100644 --- a/src/commands/cmd_who.cpp +++ b/src/commands/cmd_who.cpp @@ -1,16 +1,23 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2009-2010 Daniel De Graaf + * Copyright (C) 2007-2008 Robin Burchell * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + #include "inspircd.h" /** Handle /WHO. These command handlers can be reloaded by the core, @@ -51,19 +58,16 @@ class CommandWho : public Command }; -static const std::string star = "*"; - -static const std::string& get_first_visible_channel(User *u) +static Channel* get_first_visible_channel(User *u) { UCListIter i = u->chans.begin(); while (i != u->chans.end()) { Channel* c = *i++; if (!c->IsModeSet('s')) - return c->name; + return c; } - - return star; + return NULL; } bool CommandWho::whomatch(User* cuser, User* user, const char* matchtext) @@ -162,8 +166,6 @@ bool CommandWho::whomatch(User* cuser, User* user, const char* matchtext) } } - - bool CommandWho::CanView(Channel* chan, User* user) { if (!user || !chan) @@ -186,9 +188,10 @@ bool CommandWho::CanView(Channel* chan, User* user) void CommandWho::SendWhoLine(User* user, const std::vector& parms, const std::string &initial, Channel* ch, User* u, std::vector &whoresults) { - const std::string& lcn = get_first_visible_channel(u); + if (!ch) + ch = get_first_visible_channel(u); - std::string wholine = initial + (ch ? ch->name : lcn) + " " + u->ident + " " + + std::string wholine = initial + (ch ? ch->name : "*") + " " + u->ident + " " + (opt_showrealhost ? u->host : u->dhost) + " "; if (!ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex")) wholine.append(ServerInstance->Config->HideWhoisServer); @@ -215,16 +218,10 @@ void CommandWho::SendWhoLine(User* user, const std::vector& parms, if (ch) wholine.append(ch->GetPrefixChar(u)); - else - { - Channel* lch = ServerInstance->FindChan(lcn); - if (lch) - wholine.append(lch->GetPrefixChar(u)); - } wholine.append(" :0 " + u->fullname); - FOREACH_MOD(I_OnSendWhoLine, OnSendWhoLine(user, parms, u, ch, wholine)); + FOREACH_MOD(I_OnSendWhoLine, OnSendWhoLine(user, parms, u, wholine)); if (!wholine.empty()) whoresults.push_back(wholine);