X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_services_account.cpp;h=a11b05ca32852bcb0ae0c3bc6b7059310882b020;hb=72555992d16af9a1ca28ada1dc70591fb7653dfe;hp=b778c16ed4a143502b927fd73bb258013d432861;hpb=4fc2f7199e964ba5112ecdb2613c6fd5c2eee638;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp index b778c16ed..a11b05ca3 100644 --- a/src/modules/m_services_account.cpp +++ b/src/modules/m_services_account.cpp @@ -104,17 +104,18 @@ class AChannel_M : public SimpleChannelModeHandler class AccountExtItemImpl : public AccountExtItem { + Events::ModuleEventProvider eventprov; + public: AccountExtItemImpl(Module* mod) : AccountExtItem("accountname", ExtensionItem::EXT_USER, mod) + , eventprov(mod, "event/account") { } void unserialize(SerializeFormat format, Extensible* container, const std::string& value) { - User* user = dynamic_cast(container); - if (!user) - return; + User* user = static_cast(container); StringExtItem::unserialize(format, container, value); if (!value.empty()) @@ -125,18 +126,14 @@ class AccountExtItemImpl : public AccountExtItem user->WriteNumeric(900, "%s %s :You are now logged in as %s", user->GetFullHost().c_str(), value.c_str(), value.c_str()); } - - AccountEvent(creator, user, value).Send(); - } - else - { - // Logged out - AccountEvent(creator, user, "").Send(); } + // If value is empty then logged out + + FOREACH_MOD_CUSTOM(eventprov, AccountEventListener, OnAccountChange, (user, value)); } }; -class ModuleServicesAccount : public Module +class ModuleServicesAccount : public Module, public Whois::EventListener { AChannel_R m1; AChannel_M m2; @@ -146,8 +143,10 @@ class ModuleServicesAccount : public Module AccountExtItemImpl accountname; bool checking_ban; public: - ModuleServicesAccount() : m1(this), m2(this), m3(this), m4(this), m5(this), - accountname(this) + ModuleServicesAccount() + : Whois::EventListener(this) + , m1(this), m2(this), m3(this), m4(this), m5(this) + , accountname(this) , checking_ban(false) { } @@ -159,19 +158,19 @@ class ModuleServicesAccount : public Module } /* <- :twisted.oscnet.org 330 w00t2 w00t2 w00t :is logged in as */ - void OnWhois(User* source, User* dest) CXX11_OVERRIDE + void OnWhois(Whois::Context& whois) CXX11_OVERRIDE { - std::string *account = accountname.get(dest); + std::string* account = accountname.get(whois.GetTarget()); if (account) { - ServerInstance->SendWhoisLine(source, dest, 330, "%s %s :is logged in as", dest->nick.c_str(), account->c_str()); + whois.SendLine(330, "%s :is logged in as", account->c_str()); } - if (dest->IsModeSet(m5)) + if (whois.GetTarget()->IsModeSet(m5)) { /* user is registered */ - ServerInstance->SendWhoisLine(source, dest, 307, "%s :is a registered nick", dest->nick.c_str()); + whois.SendLine(307, ":is a registered nick"); } }