summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/channels.h127
-rw-r--r--include/membership.h39
-rw-r--r--include/mode.h10
-rw-r--r--include/modules.h10
-rw-r--r--include/users.h15
5 files changed, 52 insertions, 149 deletions
diff --git a/include/channels.h b/include/channels.h
index dfbe06c27..ec52661d6 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -14,6 +14,8 @@
#ifndef __CHANNELS_H__
#define __CHANNELS_H__
+#include "membership.h"
+
/** RFC1459 channel modes
*/
enum ChannelModes {
@@ -61,23 +63,10 @@ class BanItem : public HostItem
*/
typedef std::list<BanItem> BanList;
-/** A list of users on a channel
- */
-typedef std::map<User*,std::string> CUList;
-
-/** Shorthand for CUList::iterator
- */
-typedef CUList::iterator CUListIter;
-
-/** Shorthand for CUList::const_iterator
- */
-typedef CUList::const_iterator CUListConstIter;
-
/** A list of custom modes parameters on a channel
*/
typedef std::map<char,std::string> CustomModeList;
-
/** used to hold a channel and a users modes on that channel, e.g. +v, +h, +o
*/
enum UserChannelModes {
@@ -86,18 +75,6 @@ enum UserChannelModes {
UCMODE_HOP = 4 /* Halfopped user */
};
-/** A stored prefix and its rank
- */
-typedef std::pair<char, unsigned int> prefixtype;
-
-/** A list of prefixes set on a user in a channel
- */
-typedef std::vector<prefixtype> pfxcontainer;
-
-/** A list of users with zero or more prefixes set on them
- */
-typedef std::map<User*, std::vector<prefixtype> > prefixlist;
-
/** Holds all relevent information for a channel.
* This class represents a channel, and contains its name, modes, topic, topic set time,
* etc, and an instance of the BanList type.
@@ -118,11 +95,6 @@ class CoreExport Channel : public Extensible
*/
void SetDefaultModes();
- /** A list of prefixes associated with each user in the channel
- * (e.g. &%+ etc)
- */
- prefixlist prefixes;
-
/** Maximum number of bans (cached)
*/
int maxbans;
@@ -149,33 +121,9 @@ class CoreExport Channel : public Extensible
*/
std::bitset<64> modes;
- /** User lists.
- * There are four user lists, one for
- * all the users, one for the ops, one for
- * the halfops and another for the voices.
- */
- CUList internal_userlist;
-
- /** Opped users.
- * There are four user lists, one for
- * all the users, one for the ops, one for
- * the halfops and another for the voices.
- */
- CUList internal_op_userlist;
-
- /** Halfopped users.
- * There are four user lists, one for
- * all the users, one for the ops, one for
- * the halfops and another for the voices.
- */
- CUList internal_halfop_userlist;
-
- /** Voiced users.
- * There are four user lists, one for
- * all the users, one for the ops, one for
- * the halfops and another for the voices.
+ /** User list.
*/
- CUList internal_voice_userlist;
+ UserMembList userlist;
/** Parameters for custom modes.
* One for each custom mode letter.
@@ -256,22 +204,7 @@ class CoreExport Channel : public Extensible
* an arbitary pointer compared to other users by its memory address,
* as this is a very fast 32 or 64 bit integer comparison.
*/
- void AddUser(User* user);
-
- /** Add a user pointer to the internal reference list of opped users
- * @param user The user to add
- */
- void AddOppedUser(User* user);
-
- /** Add a user pointer to the internal reference list of halfopped users
- * @param user The user to add
- */
- void AddHalfoppedUser(User* user);
-
- /** Add a user pointer to the internal reference list of voiced users
- * @param user The user to add
- */
- void AddVoicedUser(User* user);
+ Membership* AddUser(User* user);
/** Delete a user pointer to the internal reference list
* @param user The user to delete
@@ -279,21 +212,6 @@ class CoreExport Channel : public Extensible
*/
unsigned long DelUser(User* user);
- /** Delete a user pointer to the internal reference list of opped users
- * @param user The user to delete
- */
- void DelOppedUser(User* user);
-
- /** Delete a user pointer to the internal reference list of halfopped users
- * @param user The user to delete
- */
- void DelHalfoppedUser(User* user);
-
- /** Delete a user pointer to the internal reference list of voiced users
- * @param user The user to delete
- */
- void DelVoicedUser(User* user);
-
/** Obtain the internal reference list
* The internal reference list contains a list of User*.
* These are used for rapid comparison to determine
@@ -303,22 +221,7 @@ class CoreExport Channel : public Extensible
*
* @return This function returns pointer to a map of User pointers (CUList*).
*/
- CUList* GetUsers();
-
- /** Obtain the internal reference list of opped users
- * @return This function returns pointer to a map of User pointers (CUList*).
- */
- CUList* GetOppedUsers();
-
- /** Obtain the internal reference list of halfopped users
- * @return This function returns pointer to a map of User pointers (CUList*).
- */
- CUList* GetHalfoppedUsers();
-
- /** Obtain the internal reference list of voiced users
- * @return This function returns pointer to a map of User pointers (CUList*).
- */
- CUList* GetVoicedUsers();
+ const UserMembList* GetUsers();
/** Returns true if the user given is on the given channel.
* @param The user to look for
@@ -326,6 +229,8 @@ class CoreExport Channel : public Extensible
*/
bool HasUser(User* user);
+ Membership* GetUser(User* user);
+
/** Make src kick user from this channel with the given reason.
* @param src The source of the kick
* @param user The user being kicked (must be on this channel)
@@ -448,28 +353,14 @@ class CoreExport Channel : public Extensible
/** Spool the NAMES list for this channel to the given user
* @param user The user to spool the NAMES list to
- * @param ulist The user list to send, NULL to use the
- * channel's default names list of everyone
*/
- void UserList(User *user, CUList* ulist = NULL);
+ void UserList(User *user);
/** Get the number of invisible users on this channel
* @return Number of invisible users
*/
int CountInvisible();
- /** Get a users status on this channel
- * @param user The user to look up
- * @return One of STATUS_OP, STATUS_HOP, STATUS_VOICE, or zero.
- */
- int GetStatus(User *user);
-
- /** Get a users status on this channel in a bitmask
- * @param user The user to look up
- * @return A bitmask containing zero or more of STATUS_OP, STATUS_HOP, STATUS_VOICE
- */
- int GetStatusFlags(User *user);
-
/** Get a users prefix on this channel in a string.
* @param user The user to look up
* @return A character array containing the prefix string.
diff --git a/include/membership.h b/include/membership.h
new file mode 100644
index 000000000..95267915c
--- /dev/null
+++ b/include/membership.h
@@ -0,0 +1,39 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * 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.
+ *
+ * ---------------------------------------------------
+ */
+
+#ifndef __MEMBERSHIP_H__
+#define __MEMBERSHIP_H__
+
+class User;
+class Channel;
+
+struct Membership : public Extensible
+{
+ User* const user;
+ Channel* const chan;
+ // mode list, sorted by prefix rank, higest first
+ std::string modes;
+ Membership(User* u, Channel* c) : user(u), chan(c) {}
+ inline bool hasMode(char m) const
+ {
+ return modes.find(m) != std::string::npos;
+ }
+};
+
+typedef std::map<User*, Membership*> UserMembList;
+typedef UserMembList::iterator UserMembIter;
+typedef UserMembList::const_iterator UserMembCIter;
+
+typedef std::set<User*> CUList;
+
+#endif
diff --git a/include/mode.h b/include/mode.h
index a6b10475d..7f3ef34a7 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -478,12 +478,6 @@ class CoreExport ModeParser : public classbase
* for example, should 'user A' be able to 'op' on 'channel B'.
*/
User* SanityChecks(User *user,const char *dest,Channel *chan,int status);
- /** Grant a built in privilage (e.g. ops, halfops, voice) to a user on a channel
- */
- const char* Grant(User *d,Channel *chan,int MASK);
- /** Revoke a built in privilage (e.g. ops, halfops, voice) to a user on a channel
- */
- const char* Revoke(User *d,Channel *chan,int MASK);
/** Tidy a banmask. This makes a banmask 'acceptable' if fields are left out.
* E.g.
*
@@ -581,9 +575,7 @@ class CoreExport ModeParser : public classbase
*/
std::string GiveModeList(ModeMasks m);
- /** Used by this class internally during std::sort and 005 generation
- */
- static bool PrefixComparison(prefixtype one, prefixtype two);
+ static bool PrefixComparison(ModeHandler* one, ModeHandler* two);
/** This returns the PREFIX=(ohv)@%+ section of the 005 numeric.
*/
diff --git a/include/modules.h b/include/modules.h
index 9e9686ad2..89de183b7 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -1365,14 +1365,8 @@ class CoreExport Module : public Extensible
* return 0.
* @param The user requesting the NAMES list
* @param Ptr The channel the NAMES list is requested for
- * @param userlist The user list for the channel (you may change this pointer.
- * If you want to change the values, take a copy first, and change the copy, then
- * point the pointer at your copy)
- * @return 1 to prevent the user list being sent to the client, 0 to allow it.
- * Returning -1 allows the names list, but bypasses any checks which check for
- * channel membership before sending the names list.
- */
- virtual ModResult OnUserList(User* user, Channel* Ptr, CUList* &userlist);
+ */
+ virtual ModResult OnUserList(User* user, Channel* Ptr);
/** Called whenever a line of WHOIS output is sent to a user.
* You may change the numeric and the text of the output by changing
diff --git a/include/users.h b/include/users.h
index a6c36b7fd..f91280139 100644
--- a/include/users.h
+++ b/include/users.h
@@ -18,19 +18,6 @@
#include "dns.h"
#include "mode.h"
-/** Channel status for a user
- */
-enum ChanStatus {
- /** Op */
- STATUS_OP = 4,
- /** Halfop */
- STATUS_HOP = 2,
- /** Voice */
- STATUS_VOICE = 1,
- /** None */
- STATUS_NORMAL = 0
-};
-
/** connect class types
*/
enum ClassTypes {
@@ -208,7 +195,7 @@ typedef std::vector<ConnectClass*> ClassVector;
/** Typedef for the list of user-channel records for a user
*/
-typedef std::map<Channel*, char> UserChanList;
+typedef std::set<Channel*> UserChanList;
/** Shorthand for an iterator into a UserChanList
*/