]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_services_account.cpp
Rename the spanningtree module header to server.
[user/henk/code/inspircd.git] / src / modules / m_services_account.cpp
index 4f43ada3eb1d59ace1a2799e6a5149b4a9f377c8..2a5915f252334ccf45db020cb1443d2575200b6a 100644 (file)
@@ -28,6 +28,9 @@
 
 enum
 {
+       // From ircd-hybrid?
+       ERR_NEEDREGGEDNICK = 477,
+
        // From IRCv3 sasl-3.1.
        RPL_LOGGEDIN = 900,
        RPL_LOGGEDOUT = 901
@@ -40,7 +43,7 @@ class Channel_r : public ModeHandler
  public:
        Channel_r(Module* Creator) : ModeHandler(Creator, "c_registered", 'r', PARAM_NONE, MODETYPE_CHANNEL) { }
 
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
+       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& parameter, bool adding) CXX11_OVERRIDE
        {
                // only a u-lined server may add or remove the +r mode.
                if (!IS_LOCAL(source))
@@ -68,7 +71,7 @@ class User_r : public ModeHandler
  public:
        User_r(Module* Creator) : ModeHandler(Creator, "u_registered", 'r', PARAM_NONE, MODETYPE_USER) { }
 
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
+       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& parameter, bool adding) CXX11_OVERRIDE
        {
                if (!IS_LOCAL(source))
                {
@@ -86,30 +89,6 @@ class User_r : public ModeHandler
        }
 };
 
-/** Channel mode +R - unidentified users cannot join
- */
-class AChannel_R : public SimpleChannelModeHandler
-{
- public:
-       AChannel_R(Module* Creator) : SimpleChannelModeHandler(Creator, "reginvite", 'R') { }
-};
-
-/** User mode +R - unidentified users cannot message
- */
-class AUser_R : public SimpleUserModeHandler
-{
- public:
-       AUser_R(Module* Creator) : SimpleUserModeHandler(Creator, "regdeaf", 'R') { }
-};
-
-/** Channel mode +M - unidentified users cannot message channel
- */
-class AChannel_M : public SimpleChannelModeHandler
-{
- public:
-       AChannel_M(Module* Creator) : SimpleChannelModeHandler(Creator, "regmoderated", 'M') { }
-};
-
 class AccountExtItemImpl : public AccountExtItem
 {
        Events::ModuleEventProvider eventprov;
@@ -121,7 +100,7 @@ class AccountExtItemImpl : public AccountExtItem
        {
        }
 
-       void unserialize(SerializeFormat format, Extensible* container, const std::string& value)
+       void unserialize(SerializeFormat format, Extensible* container, const std::string& value) CXX11_OVERRIDE
        {
                User* user = static_cast<User*>(container);
 
@@ -152,9 +131,9 @@ class AccountExtItemImpl : public AccountExtItem
 class ModuleServicesAccount : public Module, public Whois::EventListener
 {
        CheckExemption::EventProvider exemptionprov;
-       AChannel_R m1;
-       AChannel_M m2;
-       AUser_R m3;
+       SimpleChannelModeHandler m1;
+       SimpleChannelModeHandler m2;
+       SimpleUserModeHandler m3;
        Channel_r m4;
        User_r m5;
        AccountExtItemImpl accountname;
@@ -163,7 +142,11 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
        ModuleServicesAccount()
                : Whois::EventListener(this)
                , exemptionprov(this)
-               , m1(this), m2(this), m3(this), m4(this), m5(this)
+               , m1(this, "reginvite", 'R')
+               , m2(this, "regmoderated", 'M')
+               , m3(this, "regdeaf", 'R')
+               , m4(this)
+               , m5(this)
                , accountname(this)
                , checking_ban(false)
        {
@@ -210,13 +193,12 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
                if (target_type == TYPE_CHANNEL)
                {
                        Channel* c = (Channel*)dest;
-                       ModResult res;
-                       FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "regmoderated"));
+                       ModResult res = CheckExemption::Call(exemptionprov, user, c, "regmoderated");
 
                        if (c->IsModeSet(m2) && !is_registered && res != MOD_RES_ALLOW)
                        {
                                // user messaging a +M channel and is not registered
-                               user->WriteNumeric(477, c->name, "You need to be identified to a registered account to message this channel");
+                               user->WriteNumeric(ERR_NEEDREGGEDNICK, c->name, "You need to be identified to a registered account to message this channel");
                                return MOD_RES_DENY;
                        }
                }
@@ -227,7 +209,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
                        if (u->IsModeSet(m3) && !is_registered)
                        {
                                // user messaging a +R user and is not registered
-                               user->WriteNumeric(477, u->nick, "You need to be identified to a registered account to message this user");
+                               user->WriteNumeric(ERR_NEEDREGGEDNICK, u->nick, "You need to be identified to a registered account to message this user");
                                return MOD_RES_DENY;
                        }
                }
@@ -282,7 +264,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
                                if (!is_registered)
                                {
                                        // joining a +R channel and not identified
-                                       user->WriteNumeric(477, chan->name, "You need to be identified to a registered account to join this channel");
+                                       user->WriteNumeric(ERR_NEEDREGGEDNICK, chan->name, "You need to be identified to a registered account to join this channel");
                                        return MOD_RES_DENY;
                                }
                        }