summaryrefslogtreecommitdiff
path: root/src/chanserv.c
diff options
context:
space:
mode:
authorrburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864>2009-06-10 22:29:59 +0000
committerrburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864>2009-06-10 22:29:59 +0000
commit695644d0c479228feb92e2cd9501d15819778c24 (patch)
treeec3389db1a9fa7a957618d1a02765a4df3c79aa0 /src/chanserv.c
parentc8c89c7af098ad8825309dea4e118413b368a1d6 (diff)
New timer infrastructure, can be used inside modules. Replaces old ENFORCE/COLLIDE/inhabit timers, too. Patch by Adam.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2317 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/chanserv.c')
-rw-r--r--src/chanserv.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/chanserv.c b/src/chanserv.c
index 91432defe..abebb6f61 100644
--- a/src/chanserv.c
+++ b/src/chanserv.c
@@ -127,6 +127,28 @@ void moduleAddChanServCmds() {
/* *INDENT-ON* */
/*************************************************************************/
+
+class ChanServTimer : public Timer
+{
+ private:
+ std::string channel;
+
+ public:
+ ChanServTimer(long delay, const std::string &chan) : Timer(delay), channel(chan)
+ {
+ }
+
+ void Tick(time_t ctime)
+ {
+ ChannelInfo *ci = cs_findchan(channel.c_str());
+
+ if (ci)
+ ci->flags &= ~CI_INHABIT;
+
+ ircdproto->SendPart(findbot(s_ChanServ), channel.c_str(), NULL);
+ }
+};
+
/*************************************************************************/
/* Returns modes for mlock in a nice way. */
@@ -1083,21 +1105,6 @@ int check_should_protect(User * user, char *chan)
/*************************************************************************/
-/* Tiny helper routine to get ChanServ out of a channel after it went in. */
-
-static void timeout_leave(Timeout * to)
-{
- const char *chan = static_cast<const char *>(to->data);
- ChannelInfo *ci = cs_findchan(chan);
-
- if (ci) /* Check cos the channel may be dropped in the meantime */
- ci->flags &= ~CI_INHABIT;
-
- ircdproto->SendPart(findbot(s_ChanServ), chan, NULL);
- delete [] static_cast<const char *>(to->data);
-}
-
-
/* Check whether a user is permitted to be on a channel. If so, return 0;
* else, kickban the user with an appropriate message (could be either
* AKICK or restricted access) and return 1. Note that this is called
@@ -1118,7 +1125,7 @@ int check_kick(User * user, const char *chan, time_t chants)
char buf[BUFSIZE];
char mask[BUFSIZE];
const char *reason;
- Timeout *t;
+ ChanServTimer *t;
if (!ci)
return 0;
@@ -1207,8 +1214,8 @@ int check_kick(User * user, const char *chan, time_t chants)
{
ircdproto->SendMode(findbot(s_ChanServ), chan, "+ntsi");
}
- t = add_timeout(CSInhabit, timeout_leave, 0);
- t->data = sstrdup(chan);
+
+ t = new ChanServTimer(CSInhabit, chan);
ci->flags |= CI_INHABIT;
}