]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/users.h
Make classbase and refcountbase uncopyable; expand comments on their indended uses
[user/henk/code/inspircd.git] / include / users.h
index 76337b2c337edfec83f3c7a5e0ea27b5db7b69c6..0ce9f59ab681639b7f0ec801f31b321bb9d2fcbd 100644 (file)
@@ -59,11 +59,13 @@ enum RegistrationState {
 /* Required forward declaration */
 class Channel;
 class UserResolver;
+class ConfigTag;
 
 /** Holds information relevent to <connect allow> and <connect deny> tags in the config file.
  */
-struct CoreExport ConnectClass : public classbase
+struct CoreExport ConnectClass : public refcountbase
 {
+       reference<ConfigTag> config;
        /** Type of line, either CC_ALLOW or CC_DENY
         */
        char type;
@@ -127,18 +129,12 @@ struct CoreExport ConnectClass : public classbase
         */
        unsigned long limit;
 
-       /** Reference counter.
-        * This will be 1 if no users are connected, as long as it is a valid connect block
-        * When it reaches 0, the object should be deleted
-        */
-       unsigned long RefCount;
-
        /** Create a new connect class with no settings.
         */
-       ConnectClass(char type, const std::string& mask);
+       ConnectClass(ConfigTag* tag, char type, const std::string& mask);
        /** Create a new connect class with inherited settings.
         */
-       ConnectClass(char type, const std::string& mask, const ConnectClass& parent);
+       ConnectClass(ConfigTag* tag, char type, const std::string& mask, const ConnectClass& parent);
        
        /** Update the settings in this block to match the given block */
        void Update(const ConnectClass* newSettings);
@@ -202,19 +198,19 @@ struct CoreExport ConnectClass : public classbase
 
 /** Holds a complete list of all channels to which a user has been invited and has not yet joined, and the time at which they'll expire.
  */
-typedef std::vector< std::pair<irc::string, time_t> > InvitedList;
+CoreExport typedef std::vector< std::pair<irc::string, time_t> > InvitedList;
 
 /** Holds a complete list of all allow and deny tags from the configuration file (connection classes)
  */
-typedef std::vector<ConnectClass*> ClassVector;
+CoreExport typedef std::vector<reference<ConnectClass> > ClassVector;
 
 /** Typedef for the list of user-channel records for a user
  */
-typedef std::set<Channel*> UserChanList;
+CoreExport typedef std::set<Channel*> UserChanList;
 
 /** Shorthand for an iterator into a UserChanList
  */
-typedef UserChanList::iterator UCListIter;
+CoreExport typedef UserChanList::iterator UCListIter;
 
 /* Required forward declaration
  */
@@ -270,13 +266,9 @@ class CoreExport User : public StreamSocket
        std::bitset<64> AllowedChanModes;
 
  public:
-       static LocalIntExt NICKForced;
-       static LocalStringExt OperQuit;
-
        /** Contains a pointer to the connect class a user is on from - this will be NULL for remote connections.
-        * The pointer is guarenteed to *always* be valid. :)
         */
-       ConnectClass *MyClass;
+       reference<ConnectClass> MyClass;
 
        /** Hostname of connection.
         * This should be valid as per RFC1035.
@@ -299,16 +291,6 @@ class CoreExport User : public StreamSocket
         */
        int cmds_out;
 
-       /** True if user has authenticated, false if otherwise
-        */
-       bool haspassed;
-
-       /** Used by User to indicate the registration status of the connection
-        * It is a bitfield of the REG_NICK, REG_USER and REG_ALL bits to indicate
-        * the connection state.
-        */
-       char registered;
-
        /** Time the connection was last pinged
         */
        time_t lastping;
@@ -389,7 +371,7 @@ class CoreExport User : public StreamSocket
 
        /** The server the user is connected to.
         */
-       const char* server;
+       std::string server;
 
        /** The user's away message.
         * If this string is empty, the user is not marked as away.
@@ -408,28 +390,43 @@ class CoreExport User : public StreamSocket
         */
        std::string oper;
 
-       /** True when DNS lookups are completed.
-        * The UserResolver classes res_forward and res_reverse will
-        * set this value once they complete.
-        */
-       bool dns_done;
-
        /** Password specified by the user when they registered.
         * This is stored even if the <connect> block doesnt need a password, so that
         * modules may check it.
         */
        std::string password;
 
+       /** This value contains how far into the penalty threshold the user is. Once its over
+        * the penalty threshold then commands are held and processed on-timer.
+        */
+       int Penalty;
+
+       /** Used by User to indicate the registration status of the connection
+        * It is a bitfield of the REG_NICK, REG_USER and REG_ALL bits to indicate
+        * the connection state.
+        */
+       unsigned int registered:3;
+
+       /** True when DNS lookups are completed.
+        * The UserResolver classes res_forward and res_reverse will
+        * set this value once they complete.
+        */
+       unsigned int dns_done:1;
+
        /** Whether or not to send an snotice about this user's quitting
         */
-       bool quietquit;
+       unsigned int quietquit:1;
 
        /** If this is set to true, then all socket operations for the user
         * are dropped into the bit-bucket.
         * This value is set by QuitUser, and is not needed seperately from that call.
         * Please note that setting this value alone will NOT cause the user to quit.
         */
-       bool quitting;
+       unsigned int quitting:1;
+
+       /** This is true if the user matched an exception (E:Line). It is used to save time on ban checks.
+        */
+       unsigned int exempt:1;
 
        /** Server address and port that this user is connected to.
         * If unknown, address family is AF_UNKNOWN
@@ -451,10 +448,6 @@ class CoreExport User : public StreamSocket
         * @return The port number of this user.
         */
        int GetServerPort();
-       /**
-        * @return The server IP address
-        */
-       std::string GetServerIP();
 
        /** Get client IP string from sockaddr, using static internal buffer
         * @return The IP string
@@ -470,15 +463,6 @@ class CoreExport User : public StreamSocket
         */
        const char *GetCIDRMask(int range);
 
-       /** This is true if the user matched an exception (E:Line). It is used to save time on ban checks.
-        */
-       bool exempt;
-
-       /** This value contains how far into the penalty threshold the user is. Once its over
-        * the penalty threshold then commands are held and processed on-timer.
-        */
-       int Penalty;
-
        /** Default constructor
         * @throw CoreException if the UID allocated to the user already exists
         * @param Instance Creator instance
@@ -726,7 +710,7 @@ class CoreExport User : public StreamSocket
        /** Write to all users that can see this user (including this user in the list), appending CR/LF
         * @param text A std::string to send to the users
         */
-       void WriteCommon(const std::string &text);
+       void WriteCommonRaw(const std::string &line, bool include_self = true);
 
        /** Write to all users that can see this user (including this user in the list), appending CR/LF
         * @param text The format string for text to send to the users
@@ -740,11 +724,6 @@ class CoreExport User : public StreamSocket
         */
        void WriteCommonExcept(const char* text, ...) CUSTOM_PRINTF(2, 3);
 
-       /** Write to all users that can see this user (not including this user in the list), appending CR/LF
-        * @param text A std::string to send to the users
-        */
-       void WriteCommonExcept(const std::string &text);
-
        /** Write a quit message to all common users, as in User::WriteCommonExcept but with a specific
         * quit message for opers only.
         * @param normal_text Normal user quit message
@@ -869,7 +848,7 @@ class CoreExport User : public StreamSocket
        /** Default destructor
         */
        virtual ~User();
-       virtual void cull();
+       virtual CullResult cull();
 };
 
 /** Derived from Resolver, and performs user forward/reverse lookups.