X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fchannels.h;h=6080cda98182cb4e82fbe279434184f1c04d1a33;hb=3ffb95a12391eac5cf89549af9e790362fbfc075;hp=9f97c3b8b9c3e99c8cdd86f616b6ae34cfa6326b;hpb=abdb186046bcdd83aefbc4171a00bd1ad7ec963c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/channels.h b/include/channels.h index 9f97c3b8b..6080cda98 100644 --- a/include/channels.h +++ b/include/channels.h @@ -1,12 +1,24 @@ -/* - - -*/ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * Inspire is copyright (C) 2002-2004 ChatSpike-Dev. + * E-mail: + * + * + * + * Written by Craig Edwards, Craig McLure, and others. + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ #include "inspircd_config.h" #include "base.h" #include #include +#include #ifndef __CHANNELS_H__ #define __CHANNELS_H__ @@ -51,6 +63,18 @@ class InviteItem : public HostItem }; +/** Holds a custom parameter to a module-defined channel mode + * e.g. for +L this would hold the channel name. + */ + +class ModeParameter : public classbase +{ + public: + char mode; + char parameter[MAXBUF]; + char channel[CHANMAX]; +}; + /** Holds a complete ban list */ typedef std::vector BanList; @@ -67,7 +91,7 @@ typedef std::vector InviteList; * This class represents a channel, and contains its name, modes, time created, topic, topic set time, * etc, and an instance of the BanList type. */ -class chanrec : public classbase +class chanrec : public Extensible { public: /** The channels name. @@ -77,6 +101,16 @@ class chanrec : public classbase * Plugins may use this field in any way they see fit. */ char custom_modes[MAXMODES]; /* modes handled by modules */ + + /** Count of users on the channel used for fast user counting + */ + long users; + + /** User list (casted to char*'s to stop forward declaration stuff) + * (chicken and egg scenario!) + */ + std::vector internal_userlist; + /** Channel topic. * If this is an empty string, no channel topic is set. */ @@ -141,6 +175,64 @@ class chanrec : public classbase */ void SetCustomModeParam(char mode,char* parameter,bool mode_on); + /** Returns true if a custom mode is set on a channel + */ + bool IsCustomModeSet(char mode); + + /** Returns the parameter for a custom mode on a channel. + * For example if "+L #foo" is set, and you pass this method + * 'L', it will return '#foo'. If the mode is not set on the + * channel, or the mode has no parameters associated with it, + * it will return an empty string. + */ + std::string GetModeParameter(char mode); + + /** Increment the channel "user counter" + * The channel user counter is a reference counter which + * holds the number of users on the channel. If it decremented + * to 0 then the channel is removed from the system. + */ + void IncUserCounter(); + + /** Decrement the channel "user counter" + * The channel user counter is a reference counter which + * holds the number of users on the channel. If it decremented + * to 0 then the channel is removed from the system. + * Modules may alter the reference count to hold channels open + * which have no users and would normally be deleted once empty. + */ + void DecUserCounter(); + + /** Obtain the channel "user counter" + * This returns the channel reference counter, which is initialized + * to 0 when the channel is created and incremented/decremented + * upon joins, parts quits and kicks. + */ + long GetUserCounter(); + + /** Add a user pointer to the internal reference list + * The data inserted into the reference list is a table as it is + * 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(char* castuser); + + /** Delete a user pointer to the internal reference list + * The data removed from the reference list is a table as it is + * an arbitary pointer compared to other users by its memory address, + * as this is a very fast 32 or 64 bit integer comparison. + */ + void DelUser(char* castuser); + + /** Obrain the internal reference list + * The internal reference list contains a list of userrec* + * cast to char*. These are used for rapid comparison to determine + * channel membership for PRIVMSG, NOTICE, QUIT, PART etc. + * The resulting pointer to the vector should be considered + * readonly and only modified via AddUser and DelUser. + */ + std::vector *GetUsers(); + /** Creates a channel record and initialises it with default values */ chanrec();