From 3a7c9d1180d57417ae6e9f963ba3ad51fdb26584 Mon Sep 17 00:00:00 2001 From: w00t Date: Sun, 16 Jul 2006 17:03:35 +0000 Subject: WHO refactoring. In progress currently. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4419 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/cmd_who.cpp | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/src/cmd_who.cpp b/src/cmd_who.cpp index 96add6afc..06c99ac60 100644 --- a/src/cmd_who.cpp +++ b/src/cmd_who.cpp @@ -27,8 +27,110 @@ extern user_hash clientlist; extern chan_hash chanlist; extern std::vector all_opers; +/* get the last 'visible' chan of a user */ +static char *getlastchanname(userrec *u) +{ + for (std::vector::const_iterator v = u->chans.begin(); v != u->chans.end(); v++) + { + ucrec* temp = (ucrec*)*v; + + if (temp->channel) + { + if (!temp->channel->IsModeSet('s')) + return temp->channel->name; + } + } + + return "*"; +} + void cmd_who::Handle (const char** parameters, int pcnt, userrec *user) { + bool opt_viewopersonly = false; + chanrec *ch = NULL; + std::vector whoresults; + std::string initial = "352 " + std::string(user->nick) + " "; + + if (pcnt == 2) + { + /* parse flags */ + const char *iter = parameters[1]; + + while (*iter) + { + switch (*iter) + { + case 'o': + opt_viewopersonly = true; + break; + } + + *iter++; + } + } + + + /* who on a channel? */ + ch = FindChan(parameters[0]); + + if (ch) + { + /* who on a channel. */ + CUList *cu = ch->GetUsers(); + + for (CUList::iterator i = cu->begin(); i != cu->end(); i++) + { + /* opers only, please */ + if (opt_viewopersonly && !*(i->second)->oper) + continue; + + + std::string wholine = initial; + + wholine = wholine + getlastchanname(i->second) + " " + i->second->ident + " " + i->second->dhost + " " + + i->second->server + " " + i->second->nick + " "; + + /* away? */ + if (*(i->second)->awaymsg) + { + wholine.append("G"); + } + else + { + wholine.append("H"); + } + + /* oper? */ + if (*(i->second)->oper) + { + wholine.append("*"); + } + + wholine = wholine + cmode(i->second, ch) + " :0 " + i->second->fullname; + whoresults.push_back(wholine); + } + } + else + { + /* uhggle. who on .. something else. */ + +// The passed to WHO is matched against users' host, server, real +// name and nickname + + } + + + return; + + + + + + + + + + chanrec* Ptr = NULL; char tmp[10]; -- cgit v1.2.3