summaryrefslogtreecommitdiff
path: root/src/modes
diff options
context:
space:
mode:
Diffstat (limited to 'src/modes')
-rw-r--r--src/modes/cmode_b.cpp179
-rw-r--r--src/modes/cmode_k.cpp99
-rw-r--r--src/modes/cmode_l.cpp47
-rw-r--r--src/modes/cmode_o.cpp70
-rw-r--r--src/modes/cmode_v.cpp70
-rw-r--r--src/modes/umode_o.cpp54
-rw-r--r--src/modes/umode_s.cpp72
7 files changed, 0 insertions, 591 deletions
diff --git a/src/modes/cmode_b.cpp b/src/modes/cmode_b.cpp
deleted file mode 100644
index e45f191f7..000000000
--- a/src/modes/cmode_b.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * InspIRCd -- Internet Relay Chat Daemon
- *
- * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
- * Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
- *
- * This file is part of InspIRCd. InspIRCd is free software: you can
- * redistribute it and/or modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation, version 2.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "inspircd.h"
-#include <string>
-#include <vector>
-#include "inspircd_config.h"
-#include "configreader.h"
-#include "hash_map.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modules.h"
-#include "inspstring.h"
-#include "hashcomp.h"
-#include "modes/cmode_b.h"
-
-ModeChannelBan::ModeChannelBan() : ModeHandler(NULL, "ban", 'b', PARAM_ALWAYS, MODETYPE_CHANNEL)
-{
- list = true;
-}
-
-ModeAction ModeChannelBan::OnModeChange(User* source, User*, Channel* channel, std::string &parameter, bool adding)
-{
- int status = channel->GetPrefixValue(source);
- /* Call the correct method depending on wether we're adding or removing the mode */
- if (adding)
- {
- this->AddBan(source, parameter, channel, status);
- }
- else
- {
- this->DelBan(source, parameter, channel, status);
- }
- /* If the method above 'ate' the parameter by reducing it to an empty string, then
- * it won't matter wether we return ALLOW or DENY here, as an empty string overrides
- * the return value and is always MODEACTION_DENY if the mode is supposed to have
- * a parameter.
- */
- return MODEACTION_ALLOW;
-}
-
-void ModeChannelBan::RemoveMode(Channel* channel, irc::modestacker* stack)
-{
- BanList copy;
-
- for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++)
- {
- copy.push_back(*i);
- }
-
- for (BanList::iterator i = copy.begin(); i != copy.end(); i++)
- {
- if (stack)
- {
- stack->Push(this->GetModeChar(), i->data);
- }
- else
- {
- std::vector<std::string> parameters; parameters.push_back(channel->name); parameters.push_back("-b"); parameters.push_back(i->data);
- ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
- }
- }
-}
-
-void ModeChannelBan::RemoveMode(User*, irc::modestacker* stack)
-{
-}
-
-void ModeChannelBan::DisplayList(User* user, Channel* channel)
-{
- /* Display the channel banlist */
- for (BanList::reverse_iterator i = channel->bans.rbegin(); i != channel->bans.rend(); ++i)
- {
- user->WriteServ("367 %s %s %s %s %lu",user->nick.c_str(), channel->name.c_str(), i->data.c_str(), i->set_by.c_str(), (unsigned long)i->set_time);
- }
- user->WriteServ("368 %s %s :End of channel ban list",user->nick.c_str(), channel->name.c_str());
- return;
-}
-
-void ModeChannelBan::DisplayEmptyList(User* user, Channel* channel)
-{
- user->WriteServ("368 %s %s :End of channel ban list",user->nick.c_str(), channel->name.c_str());
-}
-
-std::string& ModeChannelBan::AddBan(User *user, std::string &dest, Channel *chan, int)
-{
- if ((!user) || (!chan))
- {
- ServerInstance->Logs->Log("MODE",DEFAULT,"*** BUG *** AddBan was given an invalid parameter");
- dest.clear();
- return dest;
- }
-
- /* Attempt to tidy the mask */
- ModeParser::CleanMask(dest);
- /* If the mask was invalid, we exit */
- if (dest.empty() || dest.length() > 250)
- return dest;
-
- long maxbans = chan->GetMaxBans();
- if (IS_LOCAL(user) && ((unsigned)chan->bans.size() >= (unsigned)maxbans))
- {
- user->WriteServ("478 %s %s :Channel ban list for %s is full (maximum entries for this channel is %ld)",user->nick.c_str(), chan->name.c_str(), chan->name.c_str(), maxbans);
- dest.clear();
- return dest;
- }
-
- ModResult MOD_RESULT;
- FIRST_MOD_RESULT(OnAddBan, MOD_RESULT, (user,chan,dest));
- if (MOD_RESULT == MOD_RES_DENY)
- {
- dest.clear();
- return dest;
- }
-
- for (BanList::iterator i = chan->bans.begin(); i != chan->bans.end(); i++)
- {
- if (i->data == dest)
- {
- /* dont allow a user to set the same ban twice */
- dest.clear();
- return dest;
- }
- }
-
- b.set_time = ServerInstance->Time();
- b.data.assign(dest, 0, MAXBUF);
- b.set_by.assign(user->nick, 0, 64);
- chan->bans.push_back(b);
- return dest;
-}
-
-std::string& ModeChannelBan::DelBan(User *user, std::string& dest, Channel *chan, int)
-{
- if ((!user) || (!chan))
- {
- ServerInstance->Logs->Log("MODE",DEFAULT,"*** BUG *** TakeBan was given an invalid parameter");
- dest.clear();
- return dest;
- }
-
- for (BanList::iterator i = chan->bans.begin(); i != chan->bans.end(); i++)
- {
- if (!strcasecmp(i->data.c_str(), dest.c_str()))
- {
- ModResult MOD_RESULT;
- FIRST_MOD_RESULT(OnDelBan, MOD_RESULT, (user, chan, dest));
- if (MOD_RESULT == MOD_RES_DENY)
- {
- dest.clear();
- return dest;
- }
- dest = i->data;
- chan->bans.erase(i);
- return dest;
- }
- }
- dest.clear();
- return dest;
-}
-
diff --git a/src/modes/cmode_k.cpp b/src/modes/cmode_k.cpp
deleted file mode 100644
index 400333fce..000000000
--- a/src/modes/cmode_k.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * InspIRCd -- Internet Relay Chat Daemon
- *
- * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
- * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
- * Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
- *
- * This file is part of InspIRCd. InspIRCd is free software: you can
- * redistribute it and/or modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation, version 2.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/cmode_k.h"
-
-ModeChannelKey::ModeChannelKey() : ModeHandler(NULL, "key", 'k', PARAM_ALWAYS, MODETYPE_CHANNEL)
-{
-}
-
-void ModeChannelKey::RemoveMode(Channel* channel, irc::modestacker* stack)
-{
- /** +k needs a parameter when being removed,
- * so we have a special-case RemoveMode here for it
- */
-
- if (channel->IsModeSet('k'))
- {
- if (stack)
- {
- stack->Push('k', channel->GetModeParameter('k'));
- }
- else
- {
- std::vector<std::string> parameters;
- parameters.push_back(channel->name);
- parameters.push_back("-k");
- parameters.push_back(channel->GetModeParameter('k'));
- ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
- }
- }
-}
-
-void ModeChannelKey::RemoveMode(User*, irc::modestacker* stack)
-{
-}
-
-ModeAction ModeChannelKey::OnModeChange(User* source, User*, Channel* channel, std::string &parameter, bool adding)
-{
- bool exists = channel->IsModeSet('k');
- if (IS_LOCAL(source))
- {
- if (exists == adding)
- return MODEACTION_DENY;
- if (exists && (parameter != channel->GetModeParameter('k')))
- {
- /* Key is currently set and the correct key wasnt given */
- return MODEACTION_DENY;
- }
- } else {
- if (exists && adding && parameter == channel->GetModeParameter('k'))
- {
- /* no-op, don't show */
- return MODEACTION_DENY;
- }
- }
-
- /* invalid keys */
- if (!parameter.length())
- return MODEACTION_DENY;
-
- if (parameter.rfind(' ') != std::string::npos)
- return MODEACTION_DENY;
-
- if (adding)
- {
- std::string ckey;
- ckey.assign(parameter, 0, 32);
- parameter = ckey;
- channel->SetModeParam('k', parameter);
- }
- else
- {
- channel->SetModeParam('k', "");
- }
- return MODEACTION_ALLOW;
-}
diff --git a/src/modes/cmode_l.cpp b/src/modes/cmode_l.cpp
deleted file mode 100644
index 001d058bb..000000000
--- a/src/modes/cmode_l.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * InspIRCd -- Internet Relay Chat Daemon
- *
- * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
- * Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
- *
- * This file is part of InspIRCd. InspIRCd is free software: you can
- * redistribute it and/or modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation, version 2.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/cmode_l.h"
-
-ModeChannelLimit::ModeChannelLimit() : ParamChannelModeHandler(NULL, "limit", 'l')
-{
-}
-
-bool ModeChannelLimit::ResolveModeConflict(std::string &their_param, const std::string &our_param, Channel*)
-{
- /* When TS is equal, the higher channel limit wins */
- return (atoi(their_param.c_str()) < atoi(our_param.c_str()));
-}
-
-bool ModeChannelLimit::ParamValidate(std::string &parameter)
-{
- int limit = atoi(parameter.c_str());
-
- if (limit < 0)
- return false;
-
- parameter = ConvToStr(limit);
- return true;
-}
diff --git a/src/modes/cmode_o.cpp b/src/modes/cmode_o.cpp
deleted file mode 100644
index 0a13b39ce..000000000
--- a/src/modes/cmode_o.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * InspIRCd -- Internet Relay Chat Daemon
- *
- * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
- * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
- * Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
- *
- * This file is part of InspIRCd. InspIRCd is free software: you can
- * redistribute it and/or modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation, version 2.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "inspircd.h"
-#include "configreader.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modules.h"
-#include "modes/cmode_o.h"
-
-ModeChannelOp::ModeChannelOp() : ModeHandler(NULL, "op", 'o', PARAM_ALWAYS, MODETYPE_CHANNEL)
-{
- list = true;
- prefix = '@';
- levelrequired = OP_VALUE;
- m_paramtype = TR_NICK;
-}
-
-unsigned int ModeChannelOp::GetPrefixRank()
-{
- return OP_VALUE;
-}
-
-void ModeChannelOp::RemoveMode(Channel* channel, irc::modestacker* stack)
-{
- const UserMembList* clist = channel->GetUsers();
-
- for (UserMembCIter i = clist->begin(); i != clist->end(); i++)
- {
- if (stack)
- stack->Push(this->GetModeChar(), i->first->nick);
- else
- {
- std::vector<std::string> parameters;
- parameters.push_back(channel->name);
- parameters.push_back("-o");
- parameters.push_back(i->first->nick);
- ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
- }
- }
-}
-
-void ModeChannelOp::RemoveMode(User*, irc::modestacker* stack)
-{
-}
-
-ModeAction ModeChannelOp::OnModeChange(User* source, User*, Channel* channel, std::string &parameter, bool adding)
-{
- return MODEACTION_ALLOW;
-}
diff --git a/src/modes/cmode_v.cpp b/src/modes/cmode_v.cpp
deleted file mode 100644
index 4a00f60f1..000000000
--- a/src/modes/cmode_v.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * InspIRCd -- Internet Relay Chat Daemon
- *
- * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
- * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
- * Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
- *
- * This file is part of InspIRCd. InspIRCd is free software: you can
- * redistribute it and/or modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation, version 2.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "inspircd.h"
-#include "configreader.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modules.h"
-#include "modes/cmode_v.h"
-
-ModeChannelVoice::ModeChannelVoice() : ModeHandler(NULL, "voice", 'v', PARAM_ALWAYS, MODETYPE_CHANNEL)
-{
- list = true;
- prefix = '+';
- levelrequired = HALFOP_VALUE;
- m_paramtype = TR_NICK;
-}
-
-unsigned int ModeChannelVoice::GetPrefixRank()
-{
- return VOICE_VALUE;
-}
-
-void ModeChannelVoice::RemoveMode(Channel* channel, irc::modestacker* stack)
-{
- const UserMembList* clist = channel->GetUsers();
-
- for (UserMembCIter i = clist->begin(); i != clist->end(); i++)
- {
- if (stack)
- stack->Push(this->GetModeChar(), i->first->nick);
- else
- {
- std::vector<std::string> parameters;
- parameters.push_back(channel->name);
- parameters.push_back("-v");
- parameters.push_back(i->first->nick);
- ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
- }
- }
-}
-
-void ModeChannelVoice::RemoveMode(User*, irc::modestacker* stack)
-{
-}
-
-ModeAction ModeChannelVoice::OnModeChange(User* source, User*, Channel* channel, std::string &parameter, bool adding)
-{
- return MODEACTION_ALLOW;
-}
diff --git a/src/modes/umode_o.cpp b/src/modes/umode_o.cpp
deleted file mode 100644
index a5f590ba0..000000000
--- a/src/modes/umode_o.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * InspIRCd -- Internet Relay Chat Daemon
- *
- * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
- * Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
- *
- * This file is part of InspIRCd. InspIRCd is free software: you can
- * redistribute it and/or modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation, version 2.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/umode_o.h"
-
-ModeUserOperator::ModeUserOperator() : ModeHandler(NULL, "oper", 'o', PARAM_NONE, MODETYPE_USER)
-{
- oper = true;
-}
-
-ModeAction ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, std::string&, bool adding)
-{
- /* Only opers can execute this class at all */
- if (!ServerInstance->ULine(source->server) && !IS_OPER(source))
- return MODEACTION_DENY;
-
- /* Not even opers can GIVE the +o mode, only take it away */
- if (adding)
- return MODEACTION_DENY;
-
- /* Set the bitfields.
- * Note that oper status is only given in cmd_oper.cpp
- * NOT here. It is impossible to directly set +o without
- * verifying as an oper and getting an opertype assigned
- * to your User!
- */
- char snomask = IS_LOCAL(dest) ? 'o' : 'O';
- ServerInstance->SNO->WriteToSnoMask(snomask, "User %s de-opered (by %s)", dest->nick.c_str(),
- source->nick.empty() ? source->server.c_str() : source->nick.c_str());
- dest->UnOper();
-
- return MODEACTION_ALLOW;
-}
diff --git a/src/modes/umode_s.cpp b/src/modes/umode_s.cpp
deleted file mode 100644
index 1b782ae85..000000000
--- a/src/modes/umode_s.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * InspIRCd -- Internet Relay Chat Daemon
- *
- * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
- * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
- * Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
- *
- * This file is part of InspIRCd. InspIRCd is free software: you can
- * redistribute it and/or modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation, version 2.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/umode_s.h"
-
-ModeUserServerNoticeMask::ModeUserServerNoticeMask() : ModeHandler(NULL, "snomask", 's', PARAM_SETONLY, MODETYPE_USER)
-{
- oper = true;
-}
-
-ModeAction ModeUserServerNoticeMask::OnModeChange(User* source, User* dest, Channel*, std::string &parameter, bool adding)
-{
- /* Set the array fields */
- if (adding)
- {
- /* Fix for bug #310 reported by Smartys */
- if (!dest->modes[UM_SNOMASK])
- dest->snomasks.reset();
-
- dest->modes[UM_SNOMASK] = true;
- parameter = dest->ProcessNoticeMasks(parameter.c_str());
- return MODEACTION_ALLOW;
- }
- else
- {
- if (dest->modes[UM_SNOMASK] != false)
- {
- dest->modes[UM_SNOMASK] = false;
- return MODEACTION_ALLOW;
- }
- }
-
- /* Allow the change */
- return MODEACTION_DENY;
-}
-
-std::string ModeUserServerNoticeMask::GetUserParameter(User* user)
-{
- std::string masks = user->FormatNoticeMasks();
- if (masks.length())
- masks = "+" + masks;
- return masks;
-}
-
-void ModeUserServerNoticeMask::OnParameterMissing(User* user, User* dest, Channel* channel)
-{
- user->WriteServ("NOTICE %s :*** The user mode +s requires a parameter (server notice mask). Please provide a parameter, e.g. '+s +*'.",
- user->nick.c_str());
-}
-