From 0376f1d8be09a242befe207be4fa9e809d098557 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 1 May 2008 19:56:16 +0000 Subject: Convert to SimpleUserModeHandler and SimpleChannelModeHandler git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9599 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modes/cmode_i.cpp | 14 +------------- src/modes/cmode_m.cpp | 15 +-------------- src/modes/cmode_n.cpp | 15 +-------------- src/modes/cmode_p.cpp | 14 +------------- src/modes/cmode_s.cpp | 14 +------------- src/modes/umode_i.cpp | 19 +------------------ src/modes/umode_s.cpp | 19 +------------------ src/modes/umode_w.cpp | 19 +------------------ 8 files changed, 8 insertions(+), 121 deletions(-) (limited to 'src/modes') diff --git a/src/modes/cmode_i.cpp b/src/modes/cmode_i.cpp index 57dbe75b2..17c89c24a 100644 --- a/src/modes/cmode_i.cpp +++ b/src/modes/cmode_i.cpp @@ -17,19 +17,7 @@ #include "users.h" #include "modes/cmode_i.h" -ModeChannelInviteOnly::ModeChannelInviteOnly(InspIRCd* Instance) : ModeHandler(Instance, 'i', 0, 0, false, MODETYPE_CHANNEL, false) +ModeChannelInviteOnly::ModeChannelInviteOnly(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'i') { } -ModeAction ModeChannelInviteOnly::OnModeChange(User*, User*, Channel* channel, std::string&, bool adding, bool servermode) -{ - if (channel->modes[CM_INVITEONLY] != adding) - { - channel->modes[CM_INVITEONLY] = adding; - return MODEACTION_ALLOW; - } - else - { - return MODEACTION_DENY; - } -} diff --git a/src/modes/cmode_m.cpp b/src/modes/cmode_m.cpp index ab8ed80a1..0714b4e01 100644 --- a/src/modes/cmode_m.cpp +++ b/src/modes/cmode_m.cpp @@ -17,20 +17,7 @@ #include "users.h" #include "modes/cmode_m.h" -ModeChannelModerated::ModeChannelModerated(InspIRCd* Instance) : ModeHandler(Instance, 'm', 0, 0, false, MODETYPE_CHANNEL, false) +ModeChannelModerated::ModeChannelModerated(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'm') { } -ModeAction ModeChannelModerated::OnModeChange(User*, User*, Channel* channel, std::string&, bool adding, bool servermode) -{ - if (channel->modes[CM_MODERATED] != adding) - { - channel->modes[CM_MODERATED] = adding; - return MODEACTION_ALLOW; - } - else - { - return MODEACTION_DENY; - } -} - diff --git a/src/modes/cmode_n.cpp b/src/modes/cmode_n.cpp index 0f3607566..e8ede5976 100644 --- a/src/modes/cmode_n.cpp +++ b/src/modes/cmode_n.cpp @@ -17,20 +17,7 @@ #include "users.h" #include "modes/cmode_n.h" -ModeChannelNoExternal::ModeChannelNoExternal(InspIRCd* Instance) : ModeHandler(Instance, 'n', 0, 0, false, MODETYPE_CHANNEL, false) +ModeChannelNoExternal::ModeChannelNoExternal(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'n') { } -ModeAction ModeChannelNoExternal::OnModeChange(User*, User*, Channel* channel, std::string&, bool adding, bool servermode) -{ - if (channel->modes[CM_NOEXTERNAL] != adding) - { - channel->modes[CM_NOEXTERNAL] = adding; - return MODEACTION_ALLOW; - } - else - { - return MODEACTION_DENY; - } -} - diff --git a/src/modes/cmode_p.cpp b/src/modes/cmode_p.cpp index b83980a11..c9efee2e0 100644 --- a/src/modes/cmode_p.cpp +++ b/src/modes/cmode_p.cpp @@ -17,19 +17,7 @@ #include "users.h" #include "modes/cmode_p.h" -ModeChannelPrivate::ModeChannelPrivate(InspIRCd* Instance) : ModeHandler(Instance, 'p', 0, 0, false, MODETYPE_CHANNEL, false) +ModeChannelPrivate::ModeChannelPrivate(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'p') { } -ModeAction ModeChannelPrivate::OnModeChange(User*, User*, Channel* channel, std::string&, bool adding, bool servermode) -{ - if (channel->modes[CM_PRIVATE] != adding) - { - channel->modes[CM_PRIVATE] = adding; - return MODEACTION_ALLOW; - } - else - { - return MODEACTION_DENY; - } -} diff --git a/src/modes/cmode_s.cpp b/src/modes/cmode_s.cpp index ab1365536..92fa4ea94 100644 --- a/src/modes/cmode_s.cpp +++ b/src/modes/cmode_s.cpp @@ -17,19 +17,7 @@ #include "users.h" #include "modes/cmode_s.h" -ModeChannelSecret::ModeChannelSecret(InspIRCd* Instance) : ModeHandler(Instance, 's', 0, 0, false, MODETYPE_CHANNEL, false) +ModeChannelSecret::ModeChannelSecret(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 's') { } -ModeAction ModeChannelSecret::OnModeChange(User*, User*, Channel* channel, std::string&, bool adding, bool servermode) -{ - if (channel->modes[CM_SECRET] != adding) - { - channel->modes[CM_SECRET] = adding; - return MODEACTION_ALLOW; - } - else - { - return MODEACTION_DENY; - } -} diff --git a/src/modes/umode_i.cpp b/src/modes/umode_i.cpp index 493687ea7..e7a4a8e11 100644 --- a/src/modes/umode_i.cpp +++ b/src/modes/umode_i.cpp @@ -17,27 +17,10 @@ #include "users.h" #include "modes/umode_i.h" -ModeUserInvisible::ModeUserInvisible(InspIRCd* Instance) : ModeHandler(Instance, 'i', 0, 0, false, MODETYPE_USER, false) +ModeUserInvisible::ModeUserInvisible(InspIRCd* Instance) : SimpleUserModeHandler(Instance, 'i') { } -ModeAction ModeUserInvisible::OnModeChange(User* source, User* dest, Channel*, std::string&, bool adding, bool servermode) -{ - /* Only opers can change other users modes */ - if ((source != dest) && (!*source->oper)) - return MODEACTION_DENY; - - /* Set the bitfields */ - if (dest->modes[UM_INVISIBLE] != adding) - { - dest->modes[UM_INVISIBLE] = adding; - return MODEACTION_ALLOW; - } - - /* Allow the change */ - return MODEACTION_DENY; -} - unsigned int ModeUserInvisible::GetCount() { return count; diff --git a/src/modes/umode_s.cpp b/src/modes/umode_s.cpp index 4e5fba8e0..6b6e521eb 100644 --- a/src/modes/umode_s.cpp +++ b/src/modes/umode_s.cpp @@ -17,27 +17,10 @@ #include "users.h" #include "modes/umode_s.h" -ModeUserServerNotice::ModeUserServerNotice(InspIRCd* Instance) : ModeHandler(Instance, 's', 0, 0, false, MODETYPE_USER, false) +ModeUserServerNotice::ModeUserServerNotice(InspIRCd* Instance) : SimpleUserModeHandler(Instance, 's') { } -ModeAction ModeUserServerNotice::OnModeChange(User* source, User* dest, Channel*, std::string&, bool adding, bool servermode) -{ - /* Only opers can change other users modes */ - if ((source != dest) && (!*source->oper)) - return MODEACTION_DENY; - - /* Set the bitfields */ - if (dest->modes[UM_SERVERNOTICE] != adding) - { - dest->modes[UM_SERVERNOTICE] = adding; - return MODEACTION_ALLOW; - } - - /* Allow the change */ - return MODEACTION_DENY; -} - unsigned int ModeUserServerNotice::GetCount() { return count; diff --git a/src/modes/umode_w.cpp b/src/modes/umode_w.cpp index 32fbe9e76..fe4ba8ccd 100644 --- a/src/modes/umode_w.cpp +++ b/src/modes/umode_w.cpp @@ -17,27 +17,10 @@ #include "users.h" #include "modes/umode_w.h" -ModeUserWallops::ModeUserWallops(InspIRCd* Instance) : ModeHandler(Instance, 'w', 0, 0, false, MODETYPE_USER, false) +ModeUserWallops::ModeUserWallops(InspIRCd* Instance) : SimpleUserModeHandler(Instance, 'w') { } -ModeAction ModeUserWallops::OnModeChange(User* source, User* dest, Channel*, std::string&, bool adding, bool servermode) -{ - /* Only opers can change other users modes */ - if ((source != dest) && (!*source->oper)) - return MODEACTION_DENY; - - /* Set the bitfields */ - if (dest->modes[UM_WALLOPS] != adding) - { - dest->modes[UM_WALLOPS] = adding; - return MODEACTION_ALLOW; - } - - /* Allow the change */ - return MODEACTION_DENY; -} - unsigned int ModeUserWallops::GetCount() { return count; -- cgit v1.2.3