]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_invisible.cpp
Remove useless vector copy
[user/henk/code/inspircd.git] / src / modules / m_invisible.cpp
index 6a1dd700db91d4949429c045f15f6c1098220fe8..d471b44d974f87d37869b1480d5a6b12c82ef3b2 100644 (file)
@@ -2,8 +2,8 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
@@ -55,29 +55,8 @@ class InvisibleMode : public ModeHandler
 
        ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
        {
-               if (source != dest)
-                       return MODEACTION_DENY;
-
                if (dest->IsModeSet('Q') != adding)
                {
-                       bool ok = false;
-
-                       for (int j = 0; j < conf->Enumerate("type"); j++)
-                       {
-                               std::string opertype = conf->ReadValue("type","name",j);
-                               if (opertype == source->oper)
-                               {
-                                       ok = conf->ReadFlag("type", "canquiet", j);
-                                       break;
-                               }
-                       }
-
-                       if (!ok)
-                       {
-                               source->WriteNumeric(481, "%s :Permission Denied - You do not have access to become invisible via user mode +Q", source->nick.c_str());
-                               return MODEACTION_DENY;
-                       }
-
                        dest->SetMode('Q', adding);
 
                        /* Fix for bug #379 reported by stealth. On +/-Q make m_watch think the user has signed on/off */
@@ -116,7 +95,7 @@ class InvisibleMode : public ModeHandler
                                }
                        }
 
-                       ServerInstance->SNO->WriteToSnoMask('A', "\2NOTICE\2: Oper %s has become %svisible (%sQ)", dest->GetFullHost().c_str(), adding ? "in" : "", adding ? "+" : "-");
+                       ServerInstance->SNO->WriteToSnoMask('a', "\2NOTICE\2: Oper %s has become %svisible (%cQ)", dest->GetFullHost().c_str(), adding ? "in" : "", adding ? '+' : '-');
                        return MODEACTION_ALLOW;
                }
                else
@@ -128,10 +107,8 @@ class InvisibleMode : public ModeHandler
 
 class InvisibleDeOper : public ModeWatcher
 {
- private:
-       InspIRCd* Srv;
  public:
-       InvisibleDeOper(InspIRCd* Instance) : ModeWatcher(Instance, 'o', MODETYPE_USER), Srv(Instance)
+       InvisibleDeOper(InspIRCd* Instance) : ModeWatcher(Instance, 'o', MODETYPE_USER)
        {
        }
 
@@ -153,38 +130,34 @@ class InvisibleDeOper : public ModeWatcher
 class ModuleInvisible : public Module
 {
  private:
-       InvisibleMode* qm;
-       InvisibleDeOper* ido;
+       InvisibleMode qm;
+       InvisibleDeOper ido;
  public:
        ModuleInvisible(InspIRCd* Me)
-               : Module(Me)
+               : Module(Me), qm(Me), ido(Me)
        {
                conf = new ConfigReader(ServerInstance);
-               qm = new InvisibleMode(ServerInstance);
-               if (!ServerInstance->Modes->AddMode(qm))
+               if (!ServerInstance->Modes->AddMode(&qm))
                        throw ModuleException("Could not add new modes!");
-               ido = new InvisibleDeOper(ServerInstance);
-               if (!ServerInstance->Modes->AddModeWatcher(ido))
+               if (!ServerInstance->Modes->AddModeWatcher(&ido))
                        throw ModuleException("Could not add new mode watcher on usermode +o!");
 
                /* Yeah i know people can take this out. I'm not about to obfuscate code just to be a pain in the ass. */
                ServerInstance->Users->ServerNoticeAll("*** m_invisible.so has just been loaded on this network. For more information, please visit http://inspircd.org/wiki/Modules/invisible");
-               Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserJoin, I_OnUserPart, I_OnUserQuit, I_OnRehash };
-               ServerInstance->Modules->Attach(eventlist, this, 6);
+               Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserJoin, I_OnUserPart, I_OnUserQuit, I_OnRehash, I_OnHostCycle };
+               ServerInstance->Modules->Attach(eventlist, this, 7);
        };
 
        virtual ~ModuleInvisible()
        {
-               ServerInstance->Modes->DelMode(qm);
-               ServerInstance->Modes->DelModeWatcher(ido);
-               delete qm;
-               delete ido;
+               ServerInstance->Modes->DelMode(&qm);
+               ServerInstance->Modes->DelModeWatcher(&ido);
                delete conf;
        };
 
        virtual Version GetVersion();
-       virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent);
-       virtual void OnRehash(User* user, const std::string &parameter);
+       virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent, bool created);
+       virtual void OnRehash(User* user);
        void OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent);
        void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message);
        bool OnHostCycle(User* user);
@@ -200,18 +173,18 @@ Version ModuleInvisible::GetVersion()
        return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
 }
 
-void ModuleInvisible::OnUserJoin(User* user, Channel* channel, bool sync, bool &silent)
+void ModuleInvisible::OnUserJoin(User* user, Channel* channel, bool sync, bool &silent, bool created)
 {
        if (user->IsModeSet('Q'))
        {
                silent = true;
                /* Because we silenced the event, make sure it reaches the user whos joining (but only them of course) */
                this->WriteCommonFrom(user, channel, "JOIN %s", channel->name.c_str());
-               ServerInstance->SNO->WriteToSnoMask('A', "\2NOTICE\2: Oper %s has joined %s invisibly (+Q)", user->GetFullHost().c_str(), channel->name.c_str());
+               ServerInstance->SNO->WriteToSnoMask('a', "\2NOTICE\2: Oper %s has joined %s invisibly (+Q)", user->GetFullHost().c_str(), channel->name.c_str());
        }
 }
 
-void ModuleInvisible::OnRehash(User* user, const std::string &parameter)
+void ModuleInvisible::OnRehash(User* user)
 {
        delete conf;
        conf = new ConfigReader(ServerInstance);