]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_delayjoin.cpp
Add initial query support to m_mysql [patch by Athenon]
[user/henk/code/inspircd.git] / src / modules / m_delayjoin.cpp
index 90d193cd3a1d572cb07a67bd0c1054272c273055..9ccb89167a0690c07485c11bc12b486b67668e68 100644 (file)
@@ -3,7 +3,7 @@
  *       +------------------------------------+
  *
  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *         the file COPYING for details.
@@ -18,23 +18,21 @@ class DelayJoinMode : public ModeHandler
 {
  private:
        CUList empty;
-       Module* Creator;
  public:
-       DelayJoinMode(InspIRCd* Instance, Module* Parent) : ModeHandler(Instance, 'D', 0, 0, false, MODETYPE_CHANNEL, false, '@', '@'), Creator(Parent) {};
+       DelayJoinMode(InspIRCd* Instance, Module* Parent) : ModeHandler(Instance, Parent, 'D', 0, 0, false, MODETYPE_CHANNEL, false, 0, '@') {};
 
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool);
+       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding);
 };
 
 class ModuleDelayJoin : public Module
 {
  private:
-       DelayJoinMode* djm;
+       DelayJoinMode djm;
        CUList nl;
  public:
-       ModuleDelayJoin(InspIRCd* Me) : Module(Me)
+       ModuleDelayJoin(InspIRCd* Me) : Module(Me), djm(Me, this)
        {
-               djm = new DelayJoinMode(ServerInstance, this);
-               if (!ServerInstance->Modes->AddMode(djm))
+               if (!ServerInstance->Modes->AddMode(&djm))
                        throw ModuleException("Could not add new modes!");
                Implementation eventlist[] = { I_OnUserJoin, I_OnUserPart, I_OnUserKick, I_OnUserQuit, I_OnNamesListItem, I_OnText, I_OnHostCycle };
                ServerInstance->Modules->Attach(eventlist, this, 7);
@@ -42,9 +40,9 @@ class ModuleDelayJoin : public Module
        virtual ~ModuleDelayJoin();
        virtual Version GetVersion();
        virtual void OnNamesListItem(User* issuer, User* user, Channel* channel, std::string &prefixes, std::string &nick);
-       virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent);
+       virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent, bool created);
        void CleanUser(User* user);
-       bool OnHostCycle(User* user);
+       ModResult OnHostCycle(User* user);
        void OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent);
        void OnUserKick(User* source, User* user, Channel* chan, const std::string &reason, bool &silent);
        void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message);
@@ -54,7 +52,7 @@ class ModuleDelayJoin : public Module
 
 /* $ModDesc: Allows for delay-join channels (+D) where users dont appear to join until they speak */
 
-ModeAction DelayJoinMode::OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
+ModeAction DelayJoinMode::OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
 {
        /* no change */
        if (channel->IsModeSet('D') == adding)
@@ -68,7 +66,7 @@ ModeAction DelayJoinMode::OnModeChange(User* source, User* dest, Channel* channe
                 */
                CUList* names = channel->GetUsers();
                for (CUListIter n = names->begin(); n != names->end(); ++n)
-                       Creator->OnText(n->first, channel, TYPE_CHANNEL, "", 0, empty);
+                       creator->OnText(n->first, channel, TYPE_CHANNEL, "", 0, empty);
        }
        channel->SetMode('D', adding);
        return MODEACTION_ALLOW;
@@ -76,8 +74,7 @@ ModeAction DelayJoinMode::OnModeChange(User* source, User* dest, Channel* channe
 
 ModuleDelayJoin::~ModuleDelayJoin()
 {
-       ServerInstance->Modes->DelMode(djm);
-       delete djm;
+       ServerInstance->Modes->DelMode(&djm);
 }
 
 Version ModuleDelayJoin::GetVersion()
@@ -102,7 +99,7 @@ void ModuleDelayJoin::OnNamesListItem(User* issuer, User* user, Channel* channel
                nick.clear();
 }
 
-void ModuleDelayJoin::OnUserJoin(User* user, Channel* channel, bool sync, bool &silent)
+void ModuleDelayJoin::OnUserJoin(User* user, Channel* channel, bool sync, bool &silent, bool created)
 {
        if (channel->IsModeSet('D'))
        {
@@ -161,9 +158,9 @@ void ModuleDelayJoin::OnUserKick(User* source, User* user, Channel* chan, const
        }
 }
 
-bool ModuleDelayJoin::OnHostCycle(User* user)
+ModResult ModuleDelayJoin::OnHostCycle(User* user)
 {
-       return user->GetExt("delayjoin");
+       return user->GetExt("delayjoin") ? MOD_RES_DENY : MOD_RES_PASSTHRU;
 }
 
 void ModuleDelayJoin::OnUserQuit(User* user, const std::string &reason, const std::string &oper_message)
@@ -232,10 +229,6 @@ void ModuleDelayJoin::WriteCommonFrom(User *user, Channel* channel, const char*
                if (user == i->first)
                        continue;
 
-               /* Users with a visibility state that hides them dont appear */
-               if (user->Visibility && !user->Visibility->VisibleTo(i->first))
-                       continue;
-
                i->first->Write(std::string(tb));
        }
 }