]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_permchannels.cpp
Remove VF_COMMON from mode-provider modules (no longer needed due to better CAPAB...
[user/henk/code/inspircd.git] / src / modules / m_permchannels.cpp
index a0b2adea2faa4b5e02c308c1084f161a8b87400f..fbbd38c151c61721184cb7a36fbdbe64f890db49 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
  * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
@@ -110,7 +110,7 @@ static bool WriteDatabase()
 class PermChannel : public ModeHandler
 {
  public:
-       PermChannel(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'P', PARAM_NONE, MODETYPE_CHANNEL) { }
+       PermChannel(Module* Creator) : ModeHandler(Creator, "permanent", 'P', PARAM_NONE, MODETYPE_CHANNEL) { }
 
        ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
        {
@@ -135,7 +135,7 @@ class PermChannel : public ModeHandler
                {
                        if (channel->IsModeSet('P'))
                        {
-                               if (channel->GetUserCounter() == 0 && !IS_FAKE(source))
+                               if (channel->GetUserCounter() == 0 && !IS_SERVER(source))
                                {
                                        /*
                                         * ugh, ugh, UGH!
@@ -175,19 +175,18 @@ class ModulePermanentChannels : public Module
        PermChannel p;
 public:
 
-       ModulePermanentChannels(InspIRCd* Me) : Module(Me), p(Me, this)
+       ModulePermanentChannels() : p(this)
        {
                if (!ServerInstance->Modes->AddMode(&p))
                        throw ModuleException("Could not add new modes!");
-               Implementation eventlist[] = { I_OnChannelPreDelete, I_OnPostTopicChange, I_OnRawMode };
-               ServerInstance->Modules->Attach(eventlist, this, 3);
+               Implementation eventlist[] = { I_OnChannelPreDelete, I_OnPostTopicChange, I_OnRawMode, I_OnRehash };
+               ServerInstance->Modules->Attach(eventlist, this, 4);
 
                OnRehash(NULL);
        }
 
-       virtual ~ModulePermanentChannels()
+       CullResult cull()
        {
-               ServerInstance->Modes->DelMode(&p);
                /*
                 * DelMode can't remove the +P mode on empty channels, or it will break
                 * merging modes with remote servers. Remove the empty channels now as
@@ -201,12 +200,15 @@ public:
                        {
                                chan_hash::iterator at = iter;
                                iter++;
+                               FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(c));
                                ServerInstance->chanlist->erase(at);
-                               delete c;
+                               ServerInstance->GlobalCulls.AddItem(c);
                        }
                        else
                                iter++;
                }
+               ServerInstance->Modes->DelMode(&p);
+               return Module::cull();
        }
 
        virtual void OnRehash(User *user)
@@ -215,7 +217,7 @@ public:
                 * Process config-defined list of permanent channels.
                 * -- w00t
                 */
-               ConfigReader MyConf(ServerInstance);
+               ConfigReader MyConf;
 
                permchannelsconf = MyConf.ReadValue("permchanneldb", "filename", "", 0, false);
 
@@ -235,7 +237,7 @@ public:
 
                        if (!c)
                        {
-                               c = new Channel(ServerInstance, channel, ServerInstance->Time());
+                               c = new Channel(channel, ServerInstance->Time());
                                if (!topic.empty())
                                {
                                        c->SetTopic(NULL, topic, true);
@@ -293,7 +295,7 @@ public:
 
        virtual Version GetVersion()
        {
-               return Version("$Id$",VF_COMMON|VF_VENDOR,API_VERSION);
+               return Version("Provides support for channel mode +P to provide permanent channels",VF_VENDOR);
        }
 
        virtual ModResult OnChannelPreDelete(Channel *c)