]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_services_account.cpp
m_ssl_openssl Specify TLS client/server role on session creation, switch to SSL_do_ha...
[user/henk/code/inspircd.git] / src / modules / m_services_account.cpp
index 8ab9c9a3ba37a79e7933e7e5e4b235672013ad85..26a53b4d7038eaabf881dcb124ca20d456e5840e 100644 (file)
@@ -102,37 +102,20 @@ class AChannel_M : public SimpleChannelModeHandler
        AChannel_M(Module* Creator) : SimpleChannelModeHandler(Creator, "regmoderated", 'M') { }
 };
 
-static bool ReadCGIIRCExt(const char* extname, User* user, const std::string*& out)
-{
-       ExtensionItem* wiext = ServerInstance->Extensions.GetItem(extname);
-       if (!wiext)
-               return false;
-
-       if (wiext->creator->ModuleSourceFile != "m_cgiirc.so")
-               return false;
-
-       StringExtItem* stringext = static_cast<StringExtItem*>(wiext);
-       std::string* addr = stringext->get(user);
-       if (!addr)
-               return false;
-
-       out = addr;
-       return true;
-}
-
 class AccountExtItemImpl : public AccountExtItem
 {
+       Events::ModuleEventProvider eventprov;
+
  public:
        AccountExtItemImpl(Module* mod)
-               : AccountExtItem("accountname", 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<User*>(container);
-               if (!user)
-                       return;
+               User* user = static_cast<User*>(container);
 
                StringExtItem::unserialize(format, container, value);
                if (!value.empty())
@@ -140,26 +123,13 @@ class AccountExtItemImpl : public AccountExtItem
                        // Logged in
                        if (IS_LOCAL(user))
                        {
-                               const std::string* host = &user->dhost;
-                               if (user->registered != REG_ALL)
-                               {
-                                       if (!ReadCGIIRCExt("cgiirc_webirc_hostname", user, host))
-                                       {
-                                               ReadCGIIRCExt("cgiirc_webirc_ip", user, host);
-                                       }
-                               }
-
-                               user->WriteNumeric(900, "%s!%s@%s %s :You are now logged in as %s",
-                                       user->nick.c_str(), user->ident.c_str(), host->c_str(), value.c_str(), value.c_str());
+                               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));
        }
 };
 
@@ -175,6 +145,7 @@ class ModuleServicesAccount : public Module
  public:
        ModuleServicesAccount() : m1(this), m2(this), m3(this), m4(this), m5(this),
                accountname(this)
+               , checking_ban(false)
        {
        }
 
@@ -205,12 +176,7 @@ class ModuleServicesAccount : public Module
        {
                /* On nickchange, if they have +r, remove it */
                if (user->IsModeSet(m5) && assign(user->nick) != oldnick)
-               {
-                       std::vector<std::string> modechange;
-                       modechange.push_back(user->nick);
-                       modechange.push_back("-r");
-                       ServerInstance->Modes->Process(modechange, ServerInstance->FakeClient, ModeParser::MODE_LOCALONLY);
-               }
+                       m5.RemoveMode(user);
        }
 
        ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
@@ -317,4 +283,3 @@ class ModuleServicesAccount : public Module
 };
 
 MODULE_INIT(ModuleServicesAccount)
-