+};
+
+void CommandWhois::SendChanList(WhoisContextImpl& whois)
+{
+ WhoisChanList chanlist(whois);
+
+ User* const target = whois.GetTarget();
+ for (User::ChanList::iterator i = target->chans.begin(); i != target->chans.end(); ++i)
+ {
+ Membership* memb = *i;
+ Channel* c = memb->chan;
+ /* If the target is the sender, neither +p nor +s is set, or
+ * the channel contains the user, it is not a spy channel
+ */
+ if ((whois.IsSelfWhois()) || ((!c->IsModeSet(privatemode)) && (!c->IsModeSet(secretmode))) || (c->HasUser(whois.GetSource())))
+ chanlist.AddVisible(memb);
+ else
+ chanlist.AddHidden(memb);
+ }
+
+ chanlist.Flush(whois);