X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_kicknorejoin.cpp;h=16def4d7986f1cb291e59c380c85a106596d3bcf;hb=8e89fe75f9467969bce1dc6930befc6ef273edf6;hp=4bb9f9dc1adfdc6353d6af0ef1aa4dfc4a1bf959;hpb=76bf72f8c2c5b1524bf20a523fe1cf0d79d29742;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index 4bb9f9dc1..16def4d79 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * InspIRCd: (C) 2002-2008 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see @@ -11,19 +11,10 @@ * --------------------------------------------------- */ -#include -#include -#include -#include -#include "users.h" -#include "channels.h" -#include "modules.h" #include "inspircd.h" /* $ModDesc: Provides channel mode +J (delay rejoin after kick) */ - - inline int strtoint(const std::string &str) { std::istringstream ss(str); @@ -32,7 +23,7 @@ inline int strtoint(const std::string &str) return result; } -typedef std::map delaylist; +typedef std::map delaylist; /** Handles channel mode +J */ @@ -41,21 +32,21 @@ class KickRejoin : public ModeHandler public: KickRejoin(InspIRCd* Instance) : ModeHandler(Instance, 'J', 1, 0, false, MODETYPE_CHANNEL, false) { } - ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) - { - if (channel->IsModeSet('J')) - return std::make_pair(true, channel->GetModeParameter('J')); - else - return std::make_pair(false, parameter); - } + ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) + { + if (channel->IsModeSet('J')) + return std::make_pair(true, channel->GetModeParameter('J')); + else + return std::make_pair(false, parameter); + } - bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel) + bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, Channel* channel) { /* When TS is equal, the alphabetically later one wins */ return (their_param < our_param); } - ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) + ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, bool) { if (!adding) { @@ -64,7 +55,7 @@ class KickRejoin : public ModeHandler if (channel->GetExt("norejoinusers", dl)) { - DELETE(dl); + delete dl; channel->Shrink("norejoinusers"); } @@ -129,22 +120,24 @@ class ModuleKickNoRejoin : public Module public: ModuleKickNoRejoin(InspIRCd* Me) - : Module::Module(Me) + : Module(Me) { kr = new KickRejoin(ServerInstance); - if (!ServerInstance->AddMode(kr, 'J')) + if (!ServerInstance->Modes->AddMode(kr)) throw ModuleException("Could not add new modes!"); + Implementation eventlist[] = { I_OnCleanup, I_OnChannelDelete, I_OnUserPreJoin, I_OnUserKick }; + ServerInstance->Modules->Attach(eventlist, this, 4); } - virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs) + virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven) { if (chan) { delaylist* dl; if (chan->GetExt("norejoinusers", dl)) { - std::vector itemstoremove; + std::vector itemstoremove; for (delaylist::iterator iter = dl->begin(); iter != dl->end(); iter++) { @@ -169,7 +162,7 @@ public: if (!dl->size()) { // Now it's empty.. - DELETE(dl); + delete dl; chan->Shrink("norejoinusers"); } } @@ -177,7 +170,7 @@ public: return 0; } - virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason) + virtual void OnUserKick(User* source, User* user, Channel* chan, const std::string &reason, bool &silent) { if (chan->IsModeSet('J') && (source != user)) { @@ -191,13 +184,13 @@ public: } } - virtual void OnChannelDelete(chanrec* chan) + virtual void OnChannelDelete(Channel* chan) { delaylist* dl; if (chan->GetExt("norejoinusers", dl)) { - DELETE(dl); + delete dl; chan->Shrink("norejoinusers"); } } @@ -205,48 +198,21 @@ public: virtual void OnCleanup(int target_type, void* item) { if(target_type == TYPE_CHANNEL) - OnChannelDelete((chanrec*)item); + OnChannelDelete((Channel*)item); } - virtual void Implements(char* List) - { - List[I_OnCleanup] = List[I_OnChannelDelete] = List[I_OnUserPreJoin] = List[I_OnUserKick] = 1; - } virtual ~ModuleKickNoRejoin() { ServerInstance->Modes->DelMode(kr); - DELETE(kr); + delete kr; } virtual Version GetVersion() { - return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION); + return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION); } }; -class ModuleKickNoRejoinFactory : public ModuleFactory -{ - public: - ModuleKickNoRejoinFactory() - { - } - - ~ModuleKickNoRejoinFactory() - { - } - - virtual Module * CreateModule(InspIRCd* Me) - { - return new ModuleKickNoRejoin(Me); - } - -}; - - -extern "C" void * init_module( void ) -{ - return new ModuleKickNoRejoinFactory; -} - +MODULE_INIT(ModuleKickNoRejoin)