]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/mode.cpp
namespace fix0rz
[user/henk/code/inspircd.git] / src / mode.cpp
index 1a26a69416c1df8ac341a3423336e95e7a77c424..c3946af2e1b18c8fcc41dccd90509b8fed146664 100644 (file)
@@ -11,7 +11,7 @@
  * ---------------------------------------------------
  */
 
-/* $Core: libIRCDmode */
+/* $Core */
 /* $ExtraDeps: $(RELCPPFILES) */
 /* $ExtraObjects: modes/modeclasses.a */
 /* $ExtraBuild: @${MAKE} -C "modes" DIRNAME="src/modes" CC="$(CC)" $(MAKEARGS) CPPFILES="$(CPPFILES)" */
 #include "modes/cmode_h.h"
 /* +v (channel voice) */
 #include "modes/cmode_v.h"
-/* +s (server notices) */
-#include "modes/umode_s.h"
 /* +w (see wallops) */
 #include "modes/umode_w.h"
 /* +i (invisible) */
 #include "modes/umode_i.h"
 /* +o (operator) */
 #include "modes/umode_o.h"
-/* +n (notice mask - our implementation of snomasks) */
-#include "modes/umode_n.h"
+/* +s (server notice masks) */
+#include "modes/umode_s.h"
 
 ModeHandler::ModeHandler(InspIRCd* Instance, char modeletter, int parameters_on, int parameters_off, bool listmode, ModeType type, bool operonly, char mprefix, char prefixrequired)
        : ServerInstance(Instance), mode(modeletter), n_params_on(parameters_on), n_params_off(parameters_off), list(listmode), m_type(type), oper(operonly), prefix(mprefix), count(0), prefixneeded(prefixrequired)
@@ -119,6 +117,11 @@ char ModeHandler::GetModeChar()
        return mode;
 }
 
+std::string ModeHandler::GetUserParameter(User* user)
+{
+       return "";
+}
+
 ModeAction ModeHandler::OnModeChange(User*, User*, Channel*, std::string&, bool, bool)
 {
        return MODEACTION_DENY;
@@ -144,6 +147,10 @@ void ModeHandler::DisplayEmptyList(User*, Channel*)
 {
 }
 
+void ModeHandler::OnParameterMissing(User* user, User* dest, Channel* channel)
+{
+}
+
 bool ModeHandler::CheckTimeStamp(time_t theirs, time_t ours, const std::string&, const std::string&, Channel*)
 {
        return (ours < theirs);
@@ -330,7 +337,7 @@ void ModeParser::DisplayCurrentModes(User *user, User* targetuser, Channel* targ
        {
                if (targetuser->Visibility && !targetuser->Visibility->VisibleTo(user))
                {
-                       user->WriteNumeric(RPL_NOSUCHNICK, "%s %s :No such nick/channel",user->nick.c_str(), text);
+                       user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel",user->nick.c_str(), text);
                        return;
                }
 
@@ -573,6 +580,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
                                                                else
                                                                {
                                                                        /* No parameter, continue to the next mode */
+                                                                       modehandlers[handler_id]->OnParameterMissing(user, targetuser, targetchannel);
                                                                        continue;
                                                                }
 
@@ -641,6 +649,17 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
                                                        if (abort)
                                                                continue;
 
+                                                       /* If it's disabled, they have to be an oper.
+                                                        */
+                                                       if (IS_LOCAL(user) && !IS_OPER(user) && ((type == MODETYPE_CHANNEL ? ServerInstance->Config->DisabledCModes : ServerInstance->Config->DisabledUModes)[modehandlers[handler_id]->GetModeChar() - 'A']))
+                                                       {
+                                                               user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - %s mode %c has been locked by the administrator",
+                                                                               user->nick.c_str(),
+                                                                               type == MODETYPE_CHANNEL ? "channel" : "user",
+                                                                               modehandlers[handler_id]->GetModeChar());
+                                                               continue;
+                                                       }
+
                                                        /* It's an oper only mode, check if theyre an oper. If they arent,
                                                         * eat any parameter that  came with the mode, and continue to next
                                                         */
@@ -1191,7 +1210,6 @@ ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance)
                new ModeChannelOp(Instance),
                new ModeChannelHalfOp(Instance),
                new ModeChannelVoice(Instance),
-               new ModeUserServerNotice(Instance),
                new ModeUserWallops(Instance),
                new ModeUserInvisible(Instance),
                new ModeUserOperator(Instance),
@@ -1210,5 +1228,5 @@ ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance)
                this->AddMode(modes[index]);
 
        seq = 0;
-       memset(&sent, 0, 256);
+       memset(&sent, 0, sizeof(sent));
 }