X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fbuiltinmodes.h;h=a77734ae3cfeba10eb6aabc14cf88a354ab1f9b4;hb=2f64744dd81cd956780160e8568a42cf952df6c8;hp=a4a9509221ad0bac156b4df04a145e64dc160f66;hpb=ebe5b201aab71cf2ead1e068889be736314fbb73;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/builtinmodes.h b/include/builtinmodes.h index a4a950922..a77734ae3 100644 --- a/include/builtinmodes.h +++ b/include/builtinmodes.h @@ -35,133 +35,76 @@ class ModeChannelBan : public ListModeBase } }; -/** Channel mode +i - */ -class ModeChannelInviteOnly : public SimpleChannelModeHandler -{ - public: - ModeChannelInviteOnly() : SimpleChannelModeHandler(NULL, "inviteonly", 'i') - { - } -}; - /** Channel mode +k */ -class ModeChannelKey : public ModeHandler +class ModeChannelKey : public ParamMode { + static const std::string::size_type maxkeylen = 32; public: ModeChannelKey(); ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding); - void RemoveMode(Channel* channel, irc::modestacker* stack = NULL); - void RemoveMode(User* user, irc::modestacker* stack = NULL); + void SerializeParam(Channel* chan, const std::string* key, std::string& out); + ModeAction OnSet(User* source, Channel* chan, std::string& param); }; - /** Channel mode +l */ -class ModeChannelLimit : public ParamChannelModeHandler +class ModeChannelLimit : public ParamMode { public: ModeChannelLimit(); - bool ParamValidate(std::string& parameter); bool ResolveModeConflict(std::string &their_param, const std::string &our_param, Channel* channel); -}; - -/** Channel mode +m - */ -class ModeChannelModerated : public SimpleChannelModeHandler -{ - public: - ModeChannelModerated() : SimpleChannelModeHandler(NULL, "moderated", 'm') - { - } -}; - -/** Channel mode +n - */ -class ModeChannelNoExternal : public SimpleChannelModeHandler -{ - public: - ModeChannelNoExternal() : SimpleChannelModeHandler(NULL, "noextmsg", 'n') - { - } + void SerializeParam(Channel* chan, intptr_t n, std::string& out); + ModeAction OnSet(User* source, Channel* channel, std::string& parameter); }; /** Channel mode +o */ -class ModeChannelOp : public ModeHandler +class ModeChannelOp : public PrefixMode { - private: public: - ModeChannelOp(); - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding); - unsigned int GetPrefixRank(); - void RemoveMode(Channel* channel, irc::modestacker* stack = NULL); - void RemoveMode(User* user, irc::modestacker* stack = NULL); -}; - -/** Channel mode +p - */ -class ModeChannelPrivate : public SimpleChannelModeHandler -{ - public: - ModeChannelPrivate() : SimpleChannelModeHandler(NULL, "private", 'p') - { - } -}; - -/** Channel mode +s - */ -class ModeChannelSecret : public SimpleChannelModeHandler -{ - public: - ModeChannelSecret() : SimpleChannelModeHandler(NULL, "secret", 's') - { - } -}; - -/** Channel mode +t - */ -class ModeChannelTopicOps : public SimpleChannelModeHandler -{ - public: - ModeChannelTopicOps() : SimpleChannelModeHandler(NULL, "topiclock", 't') + ModeChannelOp() + : PrefixMode(NULL, "op", 'o', OP_VALUE, '@') { + levelrequired = OP_VALUE; } }; /** Channel mode +v */ -class ModeChannelVoice : public ModeHandler -{ - private: - public: - ModeChannelVoice(); - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding); - unsigned int GetPrefixRank(); - void RemoveMode(User* user, irc::modestacker* stack = NULL); - void RemoveMode(Channel* channel, irc::modestacker* stack = NULL); -}; - -/** User mode +i - */ -class ModeUserInvisible : public SimpleUserModeHandler +class ModeChannelVoice : public PrefixMode { public: - ModeUserInvisible() : SimpleUserModeHandler(NULL, "invisible", 'i') + ModeChannelVoice() + : PrefixMode(NULL, "voice", 'v', VOICE_VALUE, '+') { + levelrequired = HALFOP_VALUE; } }; -/** User mode +n +/** User mode +s */ class ModeUserServerNoticeMask : public ModeHandler { + /** Process a snomask modifier string, e.g. +abc-de + * @param user The target user + * @param input A sequence of notice mask characters + * @return The cleaned mode sequence which can be output, + * e.g. in the above example if masks c and e are not + * valid, this function will return +ab-d + */ + std::string ProcessNoticeMasks(User* user, const std::string& input); + public: ModeUserServerNoticeMask(); ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding); void OnParameterMissing(User* user, User* dest, Channel* channel); - std::string GetUserParameter(User* user); + + /** Create a displayable mode string of the snomasks set on a given user + * @param user The user whose notice masks to format + * @return The notice mask character sequence + */ + std::string GetUserParameter(const User* user) const CXX11_OVERRIDE; }; /** User mode +o @@ -172,13 +115,3 @@ class ModeUserOperator : public ModeHandler ModeUserOperator(); ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding); }; - -/** User mode +w - */ -class ModeUserWallops : public SimpleUserModeHandler -{ - public: - ModeUserWallops() : SimpleUserModeHandler(NULL, "wallops", 'w') - { - } -};