summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_dccallow.cpp40
-rw-r--r--src/modules/m_showwhois.cpp25
2 files changed, 28 insertions, 37 deletions
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp
index c6cb09645..99952342b 100644
--- a/src/modules/m_dccallow.cpp
+++ b/src/modules/m_dccallow.cpp
@@ -51,12 +51,16 @@ typedef std::vector<DCCAllow> dccallowlist;
dccallowlist* dl;
typedef std::vector<BannedFileList> bannedfilelist;
bannedfilelist bfl;
-SimpleExtItem<dccallowlist>* ext;
+typedef SimpleExtItem<dccallowlist> DCCAllowExt;
class CommandDccallow : public Command
{
+ DCCAllowExt& ext;
+
public:
- CommandDccallow(Module* parent) : Command(parent, "DCCALLOW", 0)
+ CommandDccallow(Module* parent, DCCAllowExt& Ext)
+ : Command(parent, "DCCALLOW", 0)
+ , ext(Ext)
{
syntax = "{[+|-]<nick> <time>|HELP|LIST}";
/* XXX we need to fix this so it can work with translation stuff (i.e. move +- into a seperate param */
@@ -106,7 +110,7 @@ class CommandDccallow : public Command
if (action == '-')
{
// check if it contains any entries
- dl = ext->get(user);
+ dl = ext.get(user);
if (dl)
{
for (dccallowlist::iterator i = dl->begin(); i != dl->end(); ++i)
@@ -129,11 +133,11 @@ class CommandDccallow : public Command
return CMD_FAILURE;
}
- dl = ext->get(user);
+ dl = ext.get(user);
if (!dl)
{
dl = new dccallowlist;
- ext->set(user, dl);
+ ext.set(user, dl);
// add this user to the userlist
ul.push_back(user);
}
@@ -228,7 +232,7 @@ class CommandDccallow : public Command
// display current DCCALLOW list
user->WriteNumeric(990, "%s :Users on your DCCALLOW list:", user->nick.c_str());
- dl = ext->get(user);
+ dl = ext.get(user);
if (dl)
{
for (dccallowlist::const_iterator c = dl->begin(); c != dl->end(); ++c)
@@ -244,24 +248,19 @@ class CommandDccallow : public Command
class ModuleDCCAllow : public Module
{
+ DCCAllowExt ext;
CommandDccallow cmd;
public:
ModuleDCCAllow()
- : cmd(this)
- {
- ext = NULL;
- }
-
- void init() CXX11_OVERRIDE
+ : ext("dccallow", this)
+ , cmd(this, ext)
{
- ext = new SimpleExtItem<dccallowlist>("dccallow", this);
- ServerInstance->Modules->AddService(*ext);
}
void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message) CXX11_OVERRIDE
{
- dccallowlist* udl = ext->get(user);
+ dccallowlist* udl = ext.get(user);
// remove their DCCALLOW list if they have one
if (udl)
@@ -303,7 +302,7 @@ class ModuleDCCAllow : public Module
if (strncmp(text.c_str(), "\1DCC ", 5) == 0)
{
- dl = ext->get(u);
+ dl = ext.get(u);
if (dl && dl->size())
{
for (dccallowlist::const_iterator iter = dl->begin(); iter != dl->end(); ++iter)
@@ -372,7 +371,7 @@ class ModuleDCCAllow : public Module
for (userlist::iterator iter = ul.begin(); iter != ul.end();)
{
User* u = (User*)(*iter);
- dl = ext->get(u);
+ dl = ext.get(u);
if (dl)
{
if (dl->size())
@@ -406,7 +405,7 @@ class ModuleDCCAllow : public Module
for (userlist::iterator iter = ul.begin(); iter != ul.end();)
{
User *u = (User*)(*iter);
- dl = ext->get(u);
+ dl = ext.get(u);
if (dl)
{
if (dl->size())
@@ -459,11 +458,6 @@ class ModuleDCCAllow : public Module
}
}
- ~ModuleDCCAllow()
- {
- delete ext;
- }
-
Version GetVersion() CXX11_OVERRIDE
{
return Version("Provides support for the /DCCALLOW command", VF_COMMON | VF_VENDOR);
diff --git a/src/modules/m_showwhois.cpp b/src/modules/m_showwhois.cpp
index bedaf6236..96d8d90cf 100644
--- a/src/modules/m_showwhois.cpp
+++ b/src/modules/m_showwhois.cpp
@@ -28,9 +28,14 @@
class SeeWhois : public SimpleUserModeHandler
{
public:
- SeeWhois(Module* Creator, bool IsOpersOnly) : SimpleUserModeHandler(Creator, "showwhois", 'W')
+ SeeWhois(Module* Creator)
+ : SimpleUserModeHandler(Creator, "showwhois", 'W')
{
- oper = IsOpersOnly;
+ }
+
+ void SetOperOnly(bool operonly)
+ {
+ oper = operonly;
}
};
@@ -67,13 +72,13 @@ class WhoisNoticeCmd : public Command
class ModuleShowwhois : public Module
{
bool ShowWhoisFromOpers;
- SeeWhois* sw;
+ SeeWhois sw;
WhoisNoticeCmd cmd;
public:
ModuleShowwhois()
- : sw(NULL), cmd(this)
+ : sw(this), cmd(this)
{
}
@@ -81,16 +86,8 @@ class ModuleShowwhois : public Module
{
ConfigTag* tag = ServerInstance->Config->ConfValue("showwhois");
- bool OpersOnly = tag->getBool("opersonly", true);
+ sw.SetOperOnly(tag->getBool("opersonly", true));
ShowWhoisFromOpers = tag->getBool("showfromopers", true);
-
- sw = new SeeWhois(this, OpersOnly);
- ServerInstance->Modules->AddService(*sw);
- }
-
- ~ModuleShowwhois()
- {
- delete sw;
}
Version GetVersion() CXX11_OVERRIDE
@@ -100,7 +97,7 @@ class ModuleShowwhois : public Module
void OnWhois(User* source, User* dest) CXX11_OVERRIDE
{
- if (!dest->IsModeSet(*sw) || source == dest)
+ if (!dest->IsModeSet(sw) || source == dest)
return;
if (!ShowWhoisFromOpers && source->IsOper())