From 51b5f06c48b98a256eb56ea5f7e4d5d170555e84 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Fri, 14 Feb 2014 12:00:06 +0100 Subject: Return a Membership* from get_first_visible_channel() in cmd_who and pass that to modules --- include/modules.h | 4 ++-- src/commands/cmd_who.cpp | 26 +++++++++++++------------- src/modules.cpp | 2 +- src/modules/m_auditorium.cpp | 5 ++--- src/modules/m_hideoper.cpp | 2 +- src/modules/m_namesx.cpp | 6 +++--- 6 files changed, 22 insertions(+), 23 deletions(-) diff --git a/include/modules.h b/include/modules.h index 2abed2935..7df6f4f3b 100644 --- a/include/modules.h +++ b/include/modules.h @@ -1053,10 +1053,10 @@ class CoreExport Module : public classbase, public usecountbase * @param source The user running the /WHO query * @param params The parameters to the /WHO query * @param user The user that this line of the query is about - * @param chan The channel in this line, can be NULL + * @param memb The member shown in this line, NULL if no channel is in this line * @param line The raw line to send; modifiable, if empty no line will be returned. */ - virtual void OnSendWhoLine(User* source, const std::vector& params, User* user, Channel* chan, std::string& line); + virtual void OnSendWhoLine(User* source, const std::vector& params, User* user, Membership* memb, std::string& line); /** Called whenever a local user's IP is set for the first time, or when a local user's IP changes due to * a module like m_cgiirc changing it. diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp index afc27fb9b..d7084d53b 100644 --- a/src/commands/cmd_who.cpp +++ b/src/commands/cmd_who.cpp @@ -43,13 +43,13 @@ class CommandWho : public Command ChanModeReference privatemode; UserModeReference invisiblemode; - Channel* get_first_visible_channel(User *u) + Membership* get_first_visible_channel(User* u) { for (UCListIter i = u->chans.begin(); i != u->chans.end(); ++i) { - Channel* c = (*i)->chan; - if (!c->IsModeSet(secretmode)) - return c; + Membership* memb = *i; + if (!memb->chan->IsModeSet(secretmode)) + return memb; } return NULL; } @@ -66,7 +66,7 @@ class CommandWho : public Command syntax = "|||||0 [ohurmMiaplf]"; } - void SendWhoLine(User* user, const std::vector& parms, const std::string &initial, Channel* ch, User* u, std::vector &whoresults); + void SendWhoLine(User* user, const std::vector& parms, const std::string& initial, Membership* memb, User* u, std::vector& whoresults); /** Handle command. * @param parameters The parameters to the comamnd * @param pcnt The number of parameters passed to teh command @@ -193,12 +193,12 @@ bool CommandWho::CanView(Channel* chan, User* user) return false; } -void CommandWho::SendWhoLine(User* user, const std::vector& parms, const std::string &initial, Channel* ch, User* u, std::vector &whoresults) +void CommandWho::SendWhoLine(User* user, const std::vector& parms, const std::string& initial, Membership* memb, User* u, std::vector& whoresults) { - if (!ch) - ch = get_first_visible_channel(u); + if (!memb) + memb = get_first_visible_channel(u); - std::string wholine = initial + (ch ? ch->name : "*") + " " + u->ident + " " + + std::string wholine = initial + (memb ? memb->chan->name : "*") + " " + u->ident + " " + (opt_showrealhost ? u->host : u->dhost) + " "; if (!ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex")) wholine.append(ServerInstance->Config->HideWhoisServer); @@ -223,12 +223,12 @@ void CommandWho::SendWhoLine(User* user, const std::vector& parms, wholine.push_back('*'); } - if (ch) - wholine.append(ch->GetPrefixChar(u)); + if (memb) + wholine.append(memb->chan->GetPrefixChar(u)); wholine.append(" :0 " + u->fullname); - FOREACH_MOD(OnSendWhoLine, (user, parms, u, ch, wholine)); + FOREACH_MOD(OnSendWhoLine, (user, parms, u, memb, wholine)); if (!wholine.empty()) whoresults.push_back(wholine); @@ -341,7 +341,7 @@ CmdResult CommandWho::Handle (const std::vector& parameters, User * continue; } - SendWhoLine(user, parameters, initial, ch, i->first, whoresults); + SendWhoLine(user, parameters, initial, i->second, i->first, whoresults); } } } diff --git a/src/modules.cpp b/src/modules.cpp index 2eefc957e..3baf4bc4e 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -154,7 +154,7 @@ void Module::OnText(User*, void*, int, const std::string&, char, CUList&) { De void Module::OnNamesListItem(User*, Membership*, std::string&, std::string&) { DetachEvent(I_OnNamesListItem); } ModResult Module::OnNumeric(User*, unsigned int, const std::string&) { DetachEvent(I_OnNumeric); return MOD_RES_PASSTHRU; } ModResult Module::OnAcceptConnection(int, ListenSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { DetachEvent(I_OnAcceptConnection); return MOD_RES_PASSTHRU; } -void Module::OnSendWhoLine(User*, const std::vector&, User*, Channel*, std::string&) { DetachEvent(I_OnSendWhoLine); } +void Module::OnSendWhoLine(User*, const std::vector&, User*, Membership*, std::string&) { DetachEvent(I_OnSendWhoLine); } void Module::OnSetUserIP(LocalUser*) { DetachEvent(I_OnSetUserIP); } #ifdef INSPIRCD_ENABLE_TESTSUITE diff --git a/src/modules/m_auditorium.cpp b/src/modules/m_auditorium.cpp index 21afcabad..8ec80ef46 100644 --- a/src/modules/m_auditorium.cpp +++ b/src/modules/m_auditorium.cpp @@ -152,11 +152,10 @@ class ModuleAuditorium : public Module } } - void OnSendWhoLine(User* source, const std::vector& params, User* user, Channel* channel, std::string& line) CXX11_OVERRIDE + void OnSendWhoLine(User* source, const std::vector& params, User* user, Membership* memb, std::string& line) CXX11_OVERRIDE { - if (!channel) + if (!memb) return; - Membership* memb = channel->GetUser(user); if (IsVisible(memb)) return; if (CanSee(source, memb)) diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index de4a27cae..d3c2bf444 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -63,7 +63,7 @@ class ModuleHideOper : public Module return MOD_RES_PASSTHRU; } - void OnSendWhoLine(User* source, const std::vector& params, User* user, Channel* chan, std::string& line) CXX11_OVERRIDE + void OnSendWhoLine(User* source, const std::vector& params, User* user, Membership* memb, std::string& line) CXX11_OVERRIDE { if (user->IsModeSet(hm) && !source->HasPrivPermission("users/auspex")) { diff --git a/src/modules/m_namesx.cpp b/src/modules/m_namesx.cpp index 2e2060032..820963d5b 100644 --- a/src/modules/m_namesx.cpp +++ b/src/modules/m_namesx.cpp @@ -71,9 +71,9 @@ class ModuleNamesX : public Module prefixes = memb->chan->GetAllPrefixChars(memb->user); } - void OnSendWhoLine(User* source, const std::vector& params, User* user, Channel* chan, std::string& line) CXX11_OVERRIDE + void OnSendWhoLine(User* source, const std::vector& params, User* user, Membership* memb, std::string& line) CXX11_OVERRIDE { - if ((!chan) || (!cap.ext.get(source))) + if ((!memb) || (!cap.ext.get(source))) return; // Channel names can contain ":", and ":" as a 'start-of-token' delimiter is @@ -91,7 +91,7 @@ class ModuleNamesX : public Module // pos // Don't do anything if the user has only one prefix - std::string prefixes = chan->GetAllPrefixChars(user); + std::string prefixes = memb->chan->GetAllPrefixChars(memb->user); if (prefixes.length() <= 1) return; -- cgit v1.2.3