summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/configreader.cpp19
-rw-r--r--src/mode.cpp8
-rw-r--r--src/modules/m_halfop.cpp (renamed from src/modes/cmode_h.cpp)41
3 files changed, 37 insertions, 31 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 9e0aa2031..348554584 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -30,7 +30,6 @@
#include "xline.h"
#include "exitcodes.h"
#include "commands/cmd_whowas.h"
-#include "modes/cmode_h.h"
#include "configparser.h"
ServerConfig::ServerConfig()
@@ -749,9 +748,6 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
ServerInstance->Exit(EXIT_STATUS_CONFIG);
}
- if (ConfValue("options")->getBool("allowhalfop"))
- ServerInstance->Modes->AddMode(new ModeChannelHalfOp);
-
return;
}
@@ -768,18 +764,6 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
void ServerConfig::ApplyModules(User* user)
{
- bool AllowHalfOp = ConfValue("options")->getBool("allowhalfop");
- ModeHandler* mh = ServerInstance->Modes->FindMode('h', MODETYPE_CHANNEL);
- if (AllowHalfOp && !mh) {
- ServerInstance->Logs->Log("CONFIG", DEFAULT, "Enabling halfop mode.");
- mh = new ModeChannelHalfOp;
- ServerInstance->Modes->AddMode(mh);
- } else if (!AllowHalfOp && mh) {
- ServerInstance->Logs->Log("CONFIG", DEFAULT, "Disabling halfop mode.");
- ServerInstance->Modes->DelMode(mh);
- delete mh;
- }
-
Module* whowas = ServerInstance->Modules->Find("cmd_whowas.so");
if (whowas)
WhowasRequest(NULL, whowas, WhowasRequest::WHOWAS_PRUNE).Send();
@@ -802,6 +786,9 @@ void ServerConfig::ApplyModules(User* user)
}
}
+ if (ConfValue("options")->getBool("allowhalfop") && removed_modules.erase("m_halfop.so") == 0)
+ added_modules.push_back("m_halfop.so");
+
for (std::set<std::string>::iterator removing = removed_modules.begin(); removing != removed_modules.end(); removing++)
{
// Don't remove cmd_*.so, just remove m_*.so
diff --git a/src/mode.cpp b/src/mode.cpp
index fd2517dce..9c3b75101 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -34,8 +34,6 @@
#include "modes/cmode_l.h"
/* +o (channel op) */
#include "modes/cmode_o.h"
-/* +h (channel halfop) */
-#include "modes/cmode_h.h"
/* +v (channel voice) */
#include "modes/cmode_v.h"
/* +w (see wallops) */
@@ -981,10 +979,4 @@ ModeParser::ModeParser()
ModeParser::~ModeParser()
{
- ModeHandler* mh = FindMode('h', MODETYPE_CHANNEL);
- if (mh)
- {
- mh->cull();
- delete mh;
- }
}
diff --git a/src/modes/cmode_h.cpp b/src/modules/m_halfop.cpp
index 0b0f0b700..4ddf083d9 100644
--- a/src/modes/cmode_h.cpp
+++ b/src/modules/m_halfop.cpp
@@ -12,14 +12,18 @@
*/
#include "inspircd.h"
-#include "configreader.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modules.h"
-#include "modes/cmode_h.h"
-ModeChannelHalfOp::ModeChannelHalfOp() : ModeHandler(NULL, "halfop", 'h', PARAM_ALWAYS, MODETYPE_CHANNEL)
+class ModeChannelHalfOp : public ModeHandler
+{
+ public:
+ ModeChannelHalfOp(Module* parent);
+ ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding);
+ unsigned int GetPrefixRank();
+ void RemoveMode(Channel* channel, irc::modestacker* stack = NULL);
+ void RemoveMode(User* user, irc::modestacker* stack = NULL);
+};
+
+ModeChannelHalfOp::ModeChannelHalfOp(Module* parent) : ModeHandler(parent, "halfop", 'h', PARAM_ALWAYS, MODETYPE_CHANNEL)
{
list = true;
prefix = '%';
@@ -62,3 +66,26 @@ ModeAction ModeChannelHalfOp::OnModeChange(User* source, User*, Channel* channel
{
return MODEACTION_ALLOW;
}
+
+class ModuleHalfop : public Module
+{
+ ModeChannelHalfOp mh;
+ public:
+ ModuleHalfop() : mh(this)
+ {
+ if (!ServerInstance->Modes->AddMode(&mh))
+ throw ModuleException("Could not add new modes!");
+ }
+
+ ~ModuleHalfop()
+ {
+ ServerInstance->Modes->DelMode(&mh);
+ }
+
+ Version GetVersion()
+ {
+ return Version("Channel half-operator mode provider", VF_VENDOR|VF_COMMON);
+ }
+};
+
+MODULE_INIT(ModuleHalfop)