X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_watch.cpp;h=60ea79a83cb2adafae55164ab3f3493016d9eff2;hb=551d687ec6d7ce44be35fae0dd7345fe73c4f63a;hp=6aa12b4e7197fc1d8f2248eacc64fae5f5b14b07;hpb=5b9682275e384635a1fd9f7320cf4d9a604a43b4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp index 6aa12b4e7..60ea79a83 100644 --- a/src/modules/m_watch.cpp +++ b/src/modules/m_watch.cpp @@ -97,7 +97,7 @@ * Yes, it's horrid. Blame cl for being different. -- w00t */ -typedef nspace::hash_map, irc::hash> watchentries; +typedef std::tr1::unordered_map, irc::hash> watchentries; typedef std::map watchlist; /* Who's watching each nickname. @@ -242,14 +242,14 @@ class CommandWatch : public Command { (*wl)[nick] = std::string(target->ident).append(" ").append(target->dhost).append(" ").append(ConvToStr(target->age)); user->WriteNumeric(604, "%s %s %s :is online",user->nick.c_str(), nick, (*wl)[nick].c_str()); - if (IS_AWAY(target)) + if (target->IsAway()) { user->WriteNumeric(609, "%s %s %s %s %lu :is away", user->nick.c_str(), target->nick.c_str(), target->ident.c_str(), target->dhost.c_str(), (unsigned long) target->awaytime); } } else { - (*wl)[nick] = ""; + (*wl)[nick].clear(); user->WriteNumeric(605, "%s %s * * 0 :is offline",user->nick.c_str(), nick); } } @@ -320,7 +320,7 @@ class CommandWatch : public Command { user->WriteNumeric(604, "%s %s %s :is online", user->nick.c_str(), q->first.c_str(), q->second.c_str()); User *targ = ServerInstance->FindNick(q->first.c_str()); - if (IS_AWAY(targ)) + if (targ->IsAway()) { user->WriteNumeric(609, "%s %s %s %s %lu :is away", user->nick.c_str(), targ->nick.c_str(), targ->ident.c_str(), targ->dhost.c_str(), (unsigned long) targ->awaytime); } @@ -377,21 +377,24 @@ class Modulewatch : public Module public: Modulewatch() - : maxwatch(32), cmdw(this, maxwatch), sw(this) + : maxwatch(32), cmdw(this, maxwatch), sw(this) { - OnRehash(NULL); whos_watching_me = new watchentries(); - ServerInstance->AddCommand(&cmdw); - ServerInstance->AddCommand(&sw); - ServerInstance->Extensions.Register(&cmdw.ext); + } + + void init() + { + OnRehash(NULL); + ServerInstance->Modules->AddService(cmdw); + ServerInstance->Modules->AddService(sw); + ServerInstance->Modules->AddService(cmdw.ext); Implementation eventlist[] = { I_OnRehash, I_OnGarbageCollect, I_OnUserQuit, I_OnPostConnect, I_OnUserPostNick, I_On005Numeric, I_OnSetAway }; - ServerInstance->Modules->Attach(eventlist, this, 7); + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } virtual void OnRehash(User* user) { - ConfigReader Conf; - maxwatch = Conf.ReadInteger("watch", "maxentries", 0, true); + maxwatch = ServerInstance->Config->ConfValue("watch")->getInt("maxentries", 32); if (!maxwatch) maxwatch = 32; } @@ -436,7 +439,7 @@ class Modulewatch : public Module watchlist* wl = cmdw.ext.get(*n); if (wl) /* We were on somebody's notify list, set ourselves offline */ - (*wl)[user->nick.c_str()] = ""; + (*wl)[user->nick.c_str()].clear(); } } @@ -505,7 +508,7 @@ class Modulewatch : public Module if (wl) { (*n)->WriteNumeric(601, "%s %s %s %s %lu :went offline", (*n)->nick.c_str(), oldnick.c_str(), user->ident.c_str(), user->dhost.c_str(), (unsigned long) user->age); - (*wl)[oldnick.c_str()] = ""; + (*wl)[oldnick.c_str()].clear(); } } } @@ -524,10 +527,9 @@ class Modulewatch : public Module } } - virtual void On005Numeric(std::string &output) + virtual void On005Numeric(std::map& tokens) { - // we don't really have a limit... - output = output + " WATCH=" + ConvToStr(maxwatch); + tokens["WATCH"] = ConvToStr(maxwatch); } virtual ~Modulewatch() @@ -542,4 +544,3 @@ class Modulewatch : public Module }; MODULE_INIT(Modulewatch) -