diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-02-14 12:00:06 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-02-14 12:00:06 +0100 |
commit | 51b5f06c48b98a256eb56ea5f7e4d5d170555e84 (patch) | |
tree | ccc93b4b9fc7c273f7ddfb9c44b6ddc1dec2e91a | |
parent | 3111038011b7414c5068563b2abe834267a368ad (diff) |
Return a Membership* from get_first_visible_channel() in cmd_who and pass that to modules
-rw-r--r-- | include/modules.h | 4 | ||||
-rw-r--r-- | src/commands/cmd_who.cpp | 26 | ||||
-rw-r--r-- | src/modules.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_auditorium.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_hideoper.cpp | 2 | ||||
-rw-r--r-- | 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<std::string>& params, User* user, Channel* chan, std::string& line); + virtual void OnSendWhoLine(User* source, const std::vector<std::string>& 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 = "<server>|<nickname>|<channel>|<realname>|<host>|0 [ohurmMiaplf]"; } - void SendWhoLine(User* user, const std::vector<std::string>& parms, const std::string &initial, Channel* ch, User* u, std::vector<std::string> &whoresults); + void SendWhoLine(User* user, const std::vector<std::string>& parms, const std::string& initial, Membership* memb, User* u, std::vector<std::string>& 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<std::string>& parms, const std::string &initial, Channel* ch, User* u, std::vector<std::string> &whoresults) +void CommandWho::SendWhoLine(User* user, const std::vector<std::string>& parms, const std::string& initial, Membership* memb, User* u, std::vector<std::string>& 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<std::string>& 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<std::string>& 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<std::string>&, User*, Channel*, std::string&) { DetachEvent(I_OnSendWhoLine); } +void Module::OnSendWhoLine(User*, const std::vector<std::string>&, 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<std::string>& params, User* user, Channel* channel, std::string& line) CXX11_OVERRIDE + void OnSendWhoLine(User* source, const std::vector<std::string>& 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<std::string>& params, User* user, Channel* chan, std::string& line) CXX11_OVERRIDE + void OnSendWhoLine(User* source, const std::vector<std::string>& 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<std::string>& params, User* user, Channel* chan, std::string& line) CXX11_OVERRIDE + void OnSendWhoLine(User* source, const std::vector<std::string>& 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; |