]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_services.cpp
Update $ModDep lines so that these properly depend on their headers in the makefile
[user/henk/code/inspircd.git] / src / modules / m_services.cpp
index 0a7e3adff18b58259a0d300dbc0c04b1f37ce035..b746f64924ae5d203a64ac60a7cf4fb4671da0b7 100644 (file)
 
 using namespace std;
 
-#include <stdio.h>
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
-#include <string>
-
-#include "commands.h"
-#include "hashcomp.h"
 #include "inspircd.h"
 
 static bool kludgeme = false;
 
 /* $ModDesc: Povides support for services +r user/chan modes and more */
 
-
-
+/** Channel mode +r - mark a channel as identified
+ */
 class Channel_r : public ModeHandler
 {
        
@@ -56,6 +51,8 @@ class Channel_r : public ModeHandler
        }
 };
 
+/** User mode +r - mark a user as identified
+ */
 class User_r : public ModeHandler
 {
        
@@ -66,9 +63,13 @@ class User_r : public ModeHandler
        {
                if ((kludgeme) || (ServerInstance->ULine(source->nick)) || (ServerInstance->ULine(source->server)) || (!*source->server || (strchr(source->nick,'.'))))
                {
-                       ServerInstance->Log(DEBUG,"Allowing umode +r, server and nick are: '%s','%s'",source->nick,source->server);
-                       dest->SetMode('r',adding);
-                       return MODEACTION_ALLOW;
+                       if ((adding && !dest->IsModeSet('r')) || (!adding && dest->IsModeSet('r')))
+                       {
+                               ServerInstance->Log(DEBUG,"Allowing umode +r, server and nick are: '%s','%s'",source->nick,source->server);
+                               dest->SetMode('r',adding);
+                               return MODEACTION_ALLOW;
+                       }
+                       return MODEACTION_DENY;
                }
                else
                {
@@ -79,6 +80,8 @@ class User_r : public ModeHandler
        }
 };
 
+/** Channel mode +R - registered users only
+ */
 class Channel_R : public ModeHandler
 {
  public:
@@ -107,6 +110,8 @@ class Channel_R : public ModeHandler
        }
 };
 
+/** User mode +R - only allow PRIVMSG and NOTICE from registered users
+ */
 class User_R : public ModeHandler
 {
  public:
@@ -135,6 +140,8 @@ class User_R : public ModeHandler
        }
 };
 
+/** Channel mode +M - only allow privmsg and notice to channel from registered users
+ */
 class Channel_M : public ModeHandler
 {
  public:
@@ -154,7 +161,7 @@ class Channel_M : public ModeHandler
                {
                        if (channel->IsModeSet('M'))
                        {
-                               channel->SetMode('M',true);
+                               channel->SetMode('M',false);
                                return MODEACTION_ALLOW;
                        }
                }
@@ -163,6 +170,8 @@ class Channel_M : public ModeHandler
        }
 };
 
+/** Dreamnforge-like services support
+ */
 class ModuleServices : public Module
 {
        
@@ -189,24 +198,19 @@ class ModuleServices : public Module
                kludgeme = false;
        }
 
-       virtual void On005Numeric(std::string &output)
-       {
-               ServerInstance->Modes->InsertMode(output, "rRM", 4);
-       }
-
        /* <- :stitch.chatspike.net 307 w00t w00t :is a registered nick */
        virtual void OnWhois(userrec* source, userrec* dest)
        {
                if (dest->IsModeSet('r'))
                {
                        /* user is registered */
-                       source->WriteServ("307 %s %s :is a registered nick", source->nick, dest->nick);
+                       ServerInstance->SendWhoisLine(source, dest, 307, "%s %s :is a registered nick", source->nick, dest->nick);
                }
        }
 
        void Implements(char* List)
        {
-               List[I_OnWhois] = List[I_OnUserPostNick] = List[I_OnUserPreMessage] = List[I_On005Numeric] = List[I_OnUserPreNotice] = List[I_OnUserPreJoin] = 1;
+               List[I_OnWhois] = List[I_OnUserPostNick] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnUserPreJoin] = 1;
        }
 
        virtual void OnUserPostNick(userrec* user, const std::string &oldnick)
@@ -223,7 +227,7 @@ class ModuleServices : public Module
                }
        }
        
-       virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
+       virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
        {
                if (target_type == TYPE_CHANNEL)
                {
@@ -243,7 +247,7 @@ class ModuleServices : public Module
                if (target_type == TYPE_USER)
                {
                        userrec* u = (userrec*)dest;
-                       if ((u->IsModeSet('R')) && (user->IsModeSet('r')))
+                       if ((u->IsModeSet('R')) && (!user->IsModeSet('r')))
                        {
                                if ((ServerInstance->ULine(user->nick)) || (ServerInstance->ULine(user->server)))
                                {
@@ -258,18 +262,18 @@ class ModuleServices : public Module
                return 0;
        }
        
-       virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
+       virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
        {
-               return OnUserPreMessage(user,dest,target_type,text,status);
+               return OnUserPreMessage(user,dest,target_type,text,status, exempt_list);
        }
        
-       virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
+       virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs)
        {
                if (chan)
                {
                        if (chan->IsModeSet('R'))
                        {
-                               if (user->IsModeSet('r'))
+                               if (!user->IsModeSet('r'))
                                {
                                        if ((ServerInstance->ULine(user->nick)) || (ServerInstance->ULine(user->server)))
                                        {
@@ -287,6 +291,12 @@ class ModuleServices : public Module
 
        virtual ~ModuleServices()
        {
+               kludgeme = true;
+               ServerInstance->Modes->DelMode(m1);
+               ServerInstance->Modes->DelMode(m2);
+               ServerInstance->Modes->DelMode(m3);
+               ServerInstance->Modes->DelMode(m4);
+               ServerInstance->Modes->DelMode(m5);
                DELETE(m1);
                DELETE(m2);
                DELETE(m3);
@@ -296,7 +306,7 @@ class ModuleServices : public Module
        
        virtual Version GetVersion()
        {
-               return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
+               return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
        }
 };