]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modes/cmode_v.cpp
ModResult conversion: Change return type of all module functions
[user/henk/code/inspircd.git] / src / modes / cmode_v.cpp
index 66e58a479bca670b4cc32e2d3cf1a8fa8611803b..03dbb5a33f0027ed38262a9cdfa51bb3ea26263b 100644 (file)
@@ -1,9 +1,10 @@
+
 /*       +------------------------------------+
  *       | 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.
@@ -19,7 +20,7 @@
 #include "modules.h"
 #include "modes/cmode_v.h"
 
-ModeChannelVoice::ModeChannelVoice(InspIRCd* Instance) : ModeHandler(Instance, 'v', 1, 1, true, MODETYPE_CHANNEL, false, '+')
+ModeChannelVoice::ModeChannelVoice(InspIRCd* Instance) : ModeHandler(Instance, NULL, 'v', 1, 1, true, MODETYPE_CHANNEL, false, '+', '%', TR_NICK)
 {
 }
 
@@ -45,13 +46,12 @@ ModePair ModeChannelVoice::ModeSet(User*, User*, Channel* channel, const std::st
        return std::make_pair(false, parameter);
 }
 
-void ModeChannelVoice::RemoveMode(Channel* channel)
+void ModeChannelVoice::RemoveMode(Channel* channel, irc::modestacker* stack)
 {
-       CUList* list = channel->GetVoicedUsers();
+       CUList* clist = channel->GetVoicedUsers();
        CUList copy;
-       char moderemove[MAXBUF];
 
-       for (CUList::iterator i = list->begin(); i != list->end(); i++)
+       for (CUList::iterator i = clist->begin(); i != clist->end(); i++)
        {
                User* n = i->first;
                copy.insert(std::make_pair(n,n->nick));
@@ -59,13 +59,17 @@ void ModeChannelVoice::RemoveMode(Channel* channel)
 
        for (CUList::iterator i = copy.begin(); i != copy.end(); i++)
        {
-               sprintf(moderemove,"-%c",this->GetModeChar());
-               const char* parameters[] = { channel->name, moderemove, i->first->nick };
-               ServerInstance->SendMode(parameters, 3, ServerInstance->FakeClient);
+               if (stack)
+                       stack->Push(this->GetModeChar(), i->first->nick);
+               else
+               {
+                       std::vector<std::string> parameters; parameters.push_back(channel->name); parameters.push_back("-v"); parameters.push_back(i->first->nick);
+                       ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
+               }
        }
 }
 
-void ModeChannelVoice::RemoveMode(User*)
+void ModeChannelVoice::RemoveMode(User*, irc::modestacker* stack)
 {
 }
 
@@ -101,16 +105,16 @@ std::string ModeChannelVoice::AddVoice(User *user,const char* dest,Channel *chan
        {
                if (IS_LOCAL(user))
                {
-                       int MOD_RESULT = 0;
-                       FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_VOICE));
+                       ModResult MOD_RESULT;
+                       FIRST_MOD_RESULT(ServerInstance, OnAccessCheck, MOD_RESULT, (user,d,chan,AC_VOICE));
 
-                       if (MOD_RESULT == ACR_DENY)
+                       if (MOD_RESULT == MOD_RES_DENY)
                                return "";
-                       if (MOD_RESULT == ACR_DEFAULT)
+                       if (MOD_RESULT == MOD_RES_PASSTHRU)
                        {
                                if ((status < STATUS_HOP) && (!ServerInstance->ULine(user->server)))
                                {
-                                       user->WriteServ("482 %s %s :You're not a channel (half)operator",user->nick, chan->name);
+                                       user->WriteServ("482 %s %s :You're not a channel (half)operator",user->nick.c_str(), chan->name.c_str());
                                        return "";
                                }
                        }
@@ -129,16 +133,16 @@ std::string ModeChannelVoice::DelVoice(User *user,const char *dest,Channel *chan
        {
                if (IS_LOCAL(user))
                {
-                       int MOD_RESULT = 0;
-                       FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_DEVOICE));
+                       ModResult MOD_RESULT;
+                       FIRST_MOD_RESULT(ServerInstance, OnAccessCheck, MOD_RESULT, (user,d,chan,AC_DEVOICE));
 
-                       if (MOD_RESULT == ACR_DENY)
+                       if (MOD_RESULT == MOD_RES_DENY)
                                return "";
-                       if (MOD_RESULT == ACR_DEFAULT)
+                       if (MOD_RESULT == MOD_RES_PASSTHRU)
                        {
                                if ((status < STATUS_HOP) && (!ServerInstance->ULine(user->server)))
                                {
-                                       user->WriteServ("482 %s %s :You are not a channel (half)operator",user->nick, chan->name);
+                                       user->WriteServ("482 %s %s :You are not a channel (half)operator",user->nick.c_str(), chan->name.c_str());
                                        return "";
                                }
                        }