Remove OnAddBan and OnDelBan hooks

This commit is contained in:
attilamolnar 2013-04-08 21:55:53 +02:00
parent 745378a329
commit 9fc218c005
4 changed files with 35 additions and 37 deletions

View File

@ -333,8 +333,8 @@ enum Implementation
I_OnUnloadModule, I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite,
I_OnRawMode, I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnCheckChannelBan, I_OnExtBanCheck,
I_OnStats, I_OnChangeLocalUserHost, I_OnPreTopicChange,
I_OnPostTopicChange, I_OnEvent, I_OnGlobalOper, I_OnPostConnect, I_OnAddBan,
I_OnDelBan, I_OnChangeLocalUserGECOS, I_OnUserRegister, I_OnChannelPreDelete, I_OnChannelDelete,
I_OnPostTopicChange, I_OnEvent, I_OnGlobalOper, I_OnPostConnect,
I_OnChangeLocalUserGECOS, I_OnUserRegister, I_OnChannelPreDelete, I_OnChannelDelete,
I_OnPostOper, I_OnSyncNetwork, I_OnSetAway, I_OnPostCommand, I_OnPostJoin,
I_OnWhoisLine, I_OnBuildNeighborList, I_OnGarbageCollect, I_OnSetConnectClass,
I_OnText, I_OnPassCompare, I_OnRunTestSuite, I_OnNamesListItem, I_OnNumeric, I_OnHookIO,
@ -1152,24 +1152,6 @@ class CoreExport Module : public classbase, public usecountbase
*/
virtual void OnPostConnect(User* user);
/** Called whenever a ban is added to a channel's list.
* Return a non-zero value to 'eat' the mode change and prevent the ban from being added.
* @param source The user adding the ban
* @param channel The channel the ban is being added to
* @param banmask The ban mask being added
* @return 1 to block the ban, 0 to continue as normal
*/
virtual ModResult OnAddBan(User* source, Channel* channel,const std::string &banmask);
/** Called whenever a ban is removed from a channel's list.
* Return a non-zero value to 'eat' the mode change and prevent the ban from being removed.
* @param source The user deleting the ban
* @param channel The channel the ban is being deleted from
* @param banmask The ban mask being deleted
* @return 1 to block the unban, 0 to continue as normal
*/
virtual ModResult OnDelBan(User* source, Channel* channel,const std::string &banmask);
/** Called to install an I/O hook on an event handler
* @param user The socket to possibly install the I/O hook on
* @param via The port that the user connected on

View File

@ -135,8 +135,6 @@ void Module::OnRequest(Request&) { }
ModResult Module::OnPassCompare(Extensible* ex, const std::string &password, const std::string &input, const std::string& hashtype) { return MOD_RES_PASSTHRU; }
void Module::OnGlobalOper(User*) { }
void Module::OnPostConnect(User*) { }
ModResult Module::OnAddBan(User*, Channel*, const std::string &) { return MOD_RES_PASSTHRU; }
ModResult Module::OnDelBan(User*, Channel*, const std::string &) { return MOD_RES_PASSTHRU; }
void Module::OnStreamSocketAccept(StreamSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { }
int Module::OnStreamSocketWrite(StreamSocket*, std::string&) { return -1; }
void Module::OnStreamSocketClose(StreamSocket*) { }

View File

@ -152,8 +152,6 @@ static void checkall(Module* noimpl)
CHK(OnEvent);
CHK(OnGlobalOper);
CHK(OnPostConnect);
CHK(OnAddBan);
CHK(OnDelBan);
CHK(OnChangeLocalUserGECOS);
CHK(OnUserRegister);
CHK(OnChannelPreDelete);

View File

@ -114,27 +114,22 @@ found:
}
};
class ModuleTimedBans : public Module
class BanWatcher : public ModeWatcher
{
CommandTban cmd;
public:
ModuleTimedBans()
: cmd(this)
BanWatcher(Module* parent)
: ModeWatcher(parent, 'b', MODETYPE_CHANNEL)
{
}
void init()
void AfterMode(User* source, User* dest, Channel* chan, const std::string& banmask, bool adding, ModeType type)
{
ServerInstance->Modules->AddService(cmd);
Implementation eventlist[] = { I_OnDelBan, I_OnBackgroundTimer };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
if (adding)
return;
virtual ModResult OnDelBan(User* source, Channel* chan, const std::string &banmask)
{
irc::string listitem = banmask.c_str();
irc::string thischan = chan->name.c_str();
for (timedbans::iterator i = TimedBanList.begin(); i != TimedBanList.end(); i++)
for (timedbans::iterator i = TimedBanList.begin(); i != TimedBanList.end(); ++i)
{
irc::string target = i->mask.c_str();
irc::string tchan = i->channel.c_str();
@ -144,7 +139,32 @@ class ModuleTimedBans : public Module
break;
}
}
return MOD_RES_PASSTHRU;
}
};
class ModuleTimedBans : public Module
{
CommandTban cmd;
BanWatcher banwatcher;
public:
ModuleTimedBans()
: cmd(this)
, banwatcher(this)
{
}
void init()
{
ServerInstance->Modules->AddService(cmd);
Implementation eventlist[] = { I_OnBackgroundTimer };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
ServerInstance->Modes->AddModeWatcher(&banwatcher);
}
~ModuleTimedBans()
{
ServerInstance->Modes->DelModeWatcher(&banwatcher);
}
virtual void OnBackgroundTimer(time_t curtime)