diff options
-rw-r--r-- | include/commands/cmd_whowas.h | 69 | ||||
-rw-r--r-- | src/coremods/core_whowas.cpp | 15 |
2 files changed, 45 insertions, 39 deletions
diff --git a/include/commands/cmd_whowas.h b/include/commands/cmd_whowas.h index a17785c22..d443f172b 100644 --- a/include/commands/cmd_whowas.h +++ b/include/commands/cmd_whowas.h @@ -23,18 +23,48 @@ #include "modules.h" -/* Forward ref for typedefs */ -class WhoWasGroup; - namespace WhoWas { + /** One entry for a nick. There may be multiple entries for a nick. + */ + struct Entry + { + /** Real host + */ + const std::string host; + + /** Displayed host + */ + const std::string dhost; + + /** Ident + */ + const std::string ident; + + /** Server name + */ + const std::string server; + + /** Full name (GECOS) + */ + const std::string gecos; + + /** Signon time + */ + const time_t signon; + + /** Initialize this Entry with a user + */ + Entry(User* user); + }; + /** Everything known about one nick */ struct Nick : public intrusive_list_node<Nick> { /** A group of users related by nickname */ - typedef std::deque<WhoWasGroup*> List; + typedef std::deque<Entry*> List; /** Container where each element has information about one occurrence of this nick */ @@ -62,7 +92,7 @@ namespace WhoWas public: struct Stats { - /** Number of currently existing WhoWasGroup objects + /** Number of currently existing WhoWas::Entry objects */ size_t entrycount; }; @@ -166,32 +196,3 @@ class CommandWhowas : public Command */ CmdResult Handle(const std::vector<std::string>& parameters, User *user); }; - -/** Used to hold WHOWAS information - */ -class WhoWasGroup -{ - public: - /** Real host - */ - std::string host; - /** Displayed host - */ - std::string dhost; - /** Ident - */ - std::string ident; - /** Server name - */ - std::string server; - /** Fullname (GECOS) - */ - std::string gecos; - /** Signon time - */ - time_t signon; - - /** Initialize this WhoWasFroup with a user - */ - WhoWasGroup(User* user); -}; diff --git a/src/coremods/core_whowas.cpp b/src/coremods/core_whowas.cpp index 18c419c75..d73fdf491 100644 --- a/src/coremods/core_whowas.cpp +++ b/src/coremods/core_whowas.cpp @@ -51,7 +51,7 @@ CmdResult CommandWhowas::Handle (const std::vector<std::string>& parameters, Use { for (WhoWas::Nick::List::const_iterator i = list.begin(); i != list.end(); ++i) { - WhoWasGroup* u = *i; + WhoWas::Entry* u = *i; user->WriteNumeric(RPL_WHOWASUSER, "%s %s %s * :%s", parameters[0].c_str(), u->ident.c_str(),u->dhost.c_str(),u->gecos.c_str()); @@ -115,7 +115,7 @@ void WhoWas::Manager::Add(User* user) { // This nick is new, create a list for it and add the first record to it WhoWas::Nick* nick = new WhoWas::Nick(ret.first->first); - nick->entries.push_back(new WhoWasGroup(user)); + nick->entries.push_back(new Entry(user)); ret.first->second = nick; // Add this nick to the fifo too @@ -134,7 +134,7 @@ void WhoWas::Manager::Add(User* user) { // We've met this nick before, add a new record to the list WhoWas::Nick::List& list = ret.first->second->entries; - list.push_back(new WhoWasGroup(user)); + list.push_back(new Entry(user)); // If there are too many records for this nick, remove the oldest (front) if (list.size() > this->GroupSize) @@ -223,8 +223,13 @@ void WhoWas::Manager::UpdateConfig(unsigned int NewGroupSize, unsigned int NewMa Prune(); } -WhoWasGroup::WhoWasGroup(User* user) : host(user->host), dhost(user->dhost), ident(user->ident), - server(user->server->GetName()), gecos(user->fullname), signon(user->signon) +WhoWas::Entry::Entry(User* user) + : host(user->host) + , dhost(user->dhost) + , ident(user->ident) + , server(user->server->GetName()) + , gecos(user->fullname) + , signon(user->signon) { } |