diff options
| author | Adam <Adam@anope.org> | 2010-11-30 03:02:33 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2010-12-12 19:37:02 -0500 |
| commit | 0ba566491ea246fcc895862d0ef80bdf4ee43b4b (patch) | |
| tree | 9852671d32476ddad58e264a8e074c41fef9f69f /include | |
| parent | 2a4d57a1cacd22084abea5dd21c87dc733a7b5bf (diff) | |
Allowing adding hostmasks to channel access lists
Diffstat (limited to 'include')
| -rw-r--r-- | include/extern.h | 5 | ||||
| -rw-r--r-- | include/language.h | 6 | ||||
| -rw-r--r-- | include/modules.h | 14 | ||||
| -rw-r--r-- | include/regchannel.h | 37 | ||||
| -rw-r--r-- | include/services.h | 3 |
5 files changed, 42 insertions, 23 deletions
diff --git a/include/extern.h b/include/extern.h index de51742ab..24f12a84f 100644 --- a/include/extern.h +++ b/include/extern.h @@ -63,8 +63,6 @@ E Channel *findchan(const Anope::string &chan); E User *nc_on_chan(Channel *c, const NickCore *nc); -E int get_access_level(ChannelInfo *ci, NickAlias *na); -E int get_access_level(ChannelInfo *ci, NickCore *nc); E Anope::string get_xop_level(int level); E void do_cmode(const Anope::string &source, const Anope::string &channel, const Anope::string &modes, const Anope::string &ts); @@ -91,7 +89,7 @@ E void get_chanserv_stats(long *nrec, long *memuse); E void reset_levels(ChannelInfo *ci); E void cs_init(); E void expire_chans(); -E void cs_remove_nick(const NickCore *nc); +E void cs_remove_nick(NickCore *nc); E void check_modes(Channel *c); E int check_valid_admin(User *user, Channel *chan, int servermode); @@ -100,7 +98,6 @@ E int check_valid_op(User *user, Channel *chan, int servermode); E ChannelInfo *cs_findchan(const Anope::string &chan); E int check_access(User *user, ChannelInfo *ci, int what); E bool IsFounder(User *user, ChannelInfo *ci); -E int get_access(User *user, ChannelInfo *ci); E void update_cs_lastseen(User *user, ChannelInfo *ci); E int get_idealban(ChannelInfo *ci, User *u, Anope::string &ret); diff --git a/include/language.h b/include/language.h index 0b880a2f5..4b04028f9 100644 --- a/include/language.h +++ b/include/language.h @@ -392,7 +392,6 @@ enum LanguageString CHAN_XOP_NOT_AVAILABLE, CHAN_QOP_SYNTAX, CHAN_QOP_DISABLED, - CHAN_QOP_NICKS_ONLY, CHAN_QOP_ADDED, CHAN_QOP_MOVED, CHAN_QOP_NO_SUCH_ENTRY, @@ -406,7 +405,6 @@ enum LanguageString CHAN_QOP_CLEAR, CHAN_AOP_SYNTAX, CHAN_AOP_DISABLED, - CHAN_AOP_NICKS_ONLY, CHAN_AOP_ADDED, CHAN_AOP_MOVED, CHAN_AOP_NO_SUCH_ENTRY, @@ -420,7 +418,6 @@ enum LanguageString CHAN_AOP_CLEAR, CHAN_HOP_SYNTAX, CHAN_HOP_DISABLED, - CHAN_HOP_NICKS_ONLY, CHAN_HOP_ADDED, CHAN_HOP_MOVED, CHAN_HOP_NO_SUCH_ENTRY, @@ -434,7 +431,6 @@ enum LanguageString CHAN_HOP_CLEAR, CHAN_SOP_SYNTAX, CHAN_SOP_DISABLED, - CHAN_SOP_NICKS_ONLY, CHAN_SOP_ADDED, CHAN_SOP_MOVED, CHAN_SOP_NO_SUCH_ENTRY, @@ -448,7 +444,6 @@ enum LanguageString CHAN_SOP_CLEAR, CHAN_VOP_SYNTAX, CHAN_VOP_DISABLED, - CHAN_VOP_NICKS_ONLY, CHAN_VOP_ADDED, CHAN_VOP_MOVED, CHAN_VOP_NO_SUCH_ENTRY, @@ -466,7 +461,6 @@ enum LanguageString CHAN_ACCESS_DISABLED, CHAN_ACCESS_LEVEL_NONZERO, CHAN_ACCESS_LEVEL_RANGE, - CHAN_ACCESS_NICKS_ONLY, CHAN_ACCESS_REACHED_LIMIT, CHAN_ACCESS_LEVEL_UNCHANGED, CHAN_ACCESS_LEVEL_CHANGED, diff --git a/include/modules.h b/include/modules.h index 12e7884f8..c96c1ae27 100644 --- a/include/modules.h +++ b/include/modules.h @@ -723,25 +723,23 @@ class CoreExport Module : public Extensible /** Called when access is deleted from a channel * @param ci The channel * @param u The user who removed the access - * @param nc The user who was deleted + * @param access The access entry being removed */ - virtual void OnAccessDel(ChannelInfo *ci, User *u, NickCore *nc) { } + virtual void OnAccessDel(ChannelInfo *ci, User *u, ChanAccess *access) { } /** Called when access is changed * @param ci The channel * @param u The user who changed the access - * @param nc The nick whos access was changed - * @param level The level of the new access + * @param u access The access changed */ - virtual void OnAccessChange(ChannelInfo *ci, User *u, NickCore *nc, int level) { } + virtual void OnAccessChange(ChannelInfo *ci, User *u, ChanAccess *access) { } /** Called when access is added * @param ci The channel * @param u The user who added the access - * @para nc The nick who was added to access - * @param level The level they were added at + * @param access The access changed */ - virtual void OnAccessAdd(ChannelInfo *ci, User *u, NickCore *nc, int level) { } + virtual void OnAccessAdd(ChannelInfo *ci, User *u, ChanAccess *access) { } /** Called when the access list is cleared * @param ci The channel diff --git a/include/regchannel.h b/include/regchannel.h index 760a91f5f..71deb1ce7 100644 --- a/include/regchannel.h +++ b/include/regchannel.h @@ -132,14 +132,15 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag, /** Add an entry to the channel access list * - * @param nc The NickCore of the user that the access entry should be tied to + * @param mask The mask of the access entry * @param level The channel access level the user has on the channel * @param creator The user who added the access * @param last_seen When the user was last seen within the channel + * @return The new access class * * Creates a new access list entry and inserts it into the access list. */ - void AddAccess(NickCore *nc, int16 level, const Anope::string &creator, int32 last_seen = 0); + ChanAccess *AddAccess(const Anope::string &mask, int16 level, const Anope::string &creator, int32 last_seen = 0); /** Get an entry from the channel access list by index * @@ -150,15 +151,35 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag, */ ChanAccess *GetAccess(unsigned index); + /** Get an entry from the channel access list by User + * + * @param u The User to find within the access list vector + * @param level Optional channel access level to compare the access entries to + * @return A ChanAccess struct corresponding to the User, or NULL if not found + * + * Retrieves an entry from the access list that matches the given User, optionally also matching a certain level. + */ + ChanAccess *GetAccess(User *u, int16 level = 0); + /** Get an entry from the channel access list by NickCore * - * @param nc The NickCore to find within the access list vector + * @param u The NickCore to find within the access list vector * @param level Optional channel access level to compare the access entries to * @return A ChanAccess struct corresponding to the NickCore, or NULL if not found * * Retrieves an entry from the access list that matches the given NickCore, optionally also matching a certain level. */ - ChanAccess *GetAccess(const NickCore *nc, int16 level = 0); + ChanAccess *GetAccess(NickCore *nc, int16 level = 0); + + /** Get an entry from the channel access list by mask + * + * @param u The mask to find within the access list vector + * @param level Optional channel access level to compare the access entries to + * @return A ChanAccess struct corresponding to the mask, or NULL if not found + * + * Retrieves an entry from the access list that matches the given mask, optionally also matching a certain level. + */ + ChanAccess *GetAccess(const Anope::string &mask, int16 level = 0); /** Get the size of the accss vector for this channel * @return The access vector size @@ -173,6 +194,14 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag, */ void EraseAccess(unsigned index); + /** Erase an entry from the channel access list + * + * @param access The access to remove + * + * Clears the memory used by the given access entry and removes it from the vector. + */ + void EraseAccess(ChanAccess *access); + /** Clear the entire channel access list * * Clears the entire access list by deleting every item and then clearing the vector. diff --git a/include/services.h b/include/services.h index 16be4ebc7..2b4c13f7c 100644 --- a/include/services.h +++ b/include/services.h @@ -571,7 +571,8 @@ enum AccessLevel struct ChanAccess { int16 level; - NickCore *nc; /* Guaranteed to be non-NULL if in use, NULL if not */ + Anope::string mask; /* Mask of the access entry */ + NickCore *nc; /* NC of the entry, if the entry is a valid nickcore */ time_t last_seen; Anope::string creator; }; |
