]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/users.h
Remove SpanningTreeProtocolInterface::SendOperNotice - it was translated to a SendSNO...
[user/henk/code/inspircd.git] / include / users.h
index 1fca831ef632013759b1843d3a4b05c7746546d9..229edcfa2564aea295979c9f8c966d3fbbc24bc7 100644 (file)
@@ -18,6 +18,8 @@
 #include "connection.h"
 #include "dns.h"
 
+#include "mode.h"
+
 /** Channel status for a user
  */
 enum ChanStatus {
@@ -207,7 +209,7 @@ public:
         */
        void Update(unsigned int timeout, unsigned int fld, const std::string &hst, unsigned int ping,
                                const std::string &pas, unsigned int thres, unsigned long sendq, unsigned long recvq,
-                               unsigned long maxl, unsigned long maxg, unsigned int maxc, int p, unsigned long limit)
+                               unsigned long maxl, unsigned long maxg, unsigned int maxc, int p, unsigned long llimit)
        {
                if (timeout)
                        registration_timeout = timeout;
@@ -234,7 +236,13 @@ public:
                if (p)
                        port = p;
 
-               this->limit = limit;
+               this->limit = llimit;
+       }
+
+       void Update(const std::string &n, const std::string &hst)
+       {
+               name = n;
+               host = hst;
        }
 
        /** Reference counter. Contains an int as to how many users are connected to this class. :)
@@ -360,9 +368,9 @@ public:
        }
 };
 
-/** Holds a complete list of all channels to which a user has been invited and has not yet joined.
+/** 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<irc::string> InvitedList;
+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)
  */
@@ -455,7 +463,17 @@ class CoreExport User : public connection
 
        std::map<std::string, bool>* AllowedOperCommands;
 
+       /** Allowed user modes from oper classes. */
+       bool* AllowedUserModes;
+
+       /** Allowed channel modes from oper classes. */
+       bool* AllowedChanModes;
+
  public:
+       /** Module responsible for raw i/o
+        */
+       Module* io;
+
        /** 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. :)
         */
@@ -544,6 +562,11 @@ class CoreExport User : public connection
         */
        char awaymsg[MAXAWAY+1];
 
+       /** Time the user last went away.
+        * This is ONLY RELIABLE if user IS_AWAY()!
+        */
+       time_t awaytime;
+
        /** Timestamp of current time + connection class timeout.
         * This user must send USER/NICK before this timestamp is
         * reached or they will be disconnected.
@@ -636,7 +659,7 @@ class CoreExport User : public connection
        /** Get IP string from sockaddr, using static internal buffer
         * @return The IP string
         */
-       const char* GetIPString();
+       const char* GetIPString(bool translate4in6 = true);
 
        /* Write error string
         */
@@ -666,6 +689,10 @@ class CoreExport User : public connection
         */
        User(InspIRCd* Instance, const std::string &uid = "");
 
+       /** Check if the user matches a G or K line, and disconnect them if they do
+        */
+       void CheckLines();
+
        /** Returns the full displayed host of the user
         * This member function returns the hostname of the user as seen by other users
         * on the server, in nick!ident&at;host form.
@@ -736,8 +763,9 @@ class CoreExport User : public connection
 
        /** Adds a channel to a users invite list (invites them to a channel)
         * @param channel A channel name to add
+        * @param timeout When the invite should expire (0 == never)
         */
-       virtual void InviteTo(const irc::string &channel);
+       virtual void InviteTo(const irc::string &channel, time_t timeout);
 
        /** Removes a channel from a users invite list.
         * This member function is called on successfully joining an invite only channel
@@ -754,6 +782,15 @@ class CoreExport User : public connection
         */
        bool HasPermission(const std::string &command);
 
+       /** Returns true or false if a user can set a privileged user or channel mode.
+        * This is done by looking up their oper type from User::oper, then referencing
+        * this to their oper classes, and checking the modes they can set.
+        * @param mode The mode the check
+        * @param type ModeType (MODETYPE_CHANNEL or MODETYPE_USER).
+        * @return True if the user can set or unset this mode.
+        */
+       bool HasModePermission(unsigned char mode, ModeType type);
+
        /** Calls read() to read some data for this user using their fd.
         * @param buffer The buffer to read into
         * @param size The size of data to read
@@ -851,14 +888,6 @@ class CoreExport User : public connection
         */
        void CloseSocket();
 
-       /** Disconnect a user gracefully
-        * @param user The user to remove
-        * @param r The quit reason to show to normal users
-        * @param oreason The quit reason to show to opers
-        * @return Although this function has no return type, on exit the user provided will no longer exist.
-        */
-       static void QuitUser(InspIRCd* Instance, User *user, const std::string &r, const char* oreason = "");
-
        /** Add the user to WHOWAS system
         */
        void AddToWhoWas();
@@ -909,7 +938,7 @@ class CoreExport User : public connection
         * @param text The format string for text to send to the user
         * @param ... POD-type format arguments
         */
-       void Write(const char *text, ...);
+       void Write(const char *text, ...) CUSTOM_PRINTF(2, 3);
 
        /** Write text to this user, appending CR/LF and prepending :server.name
         * @param text A std::string to send to the user
@@ -920,7 +949,11 @@ class CoreExport User : public connection
         * @param text The format string for text to send to the user
         * @param ... POD-type format arguments
         */
-       void WriteServ(const char* text, ...);
+       void WriteServ(const char* text, ...) CUSTOM_PRINTF(2, 3);
+
+       void WriteNumeric(unsigned int numeric, const char* text, ...) CUSTOM_PRINTF(3, 4);
+
+       void WriteNumeric(unsigned int numeric, const std::string &text);
 
        /** Write text to this user, appending CR/LF and prepending :nick!user@host of the user provided in the first parameter.
         * @param user The user to prepend the :nick!user@host of
@@ -933,7 +966,7 @@ class CoreExport User : public connection
         * @param text The format string for text to send to the user
         * @param ... POD-type format arguments
         */
-       void WriteFrom(User *user, const char* text, ...);
+       void WriteFrom(User *user, const char* text, ...) CUSTOM_PRINTF(3, 4);
 
        /** Write text to the user provided in the first parameter, appending CR/LF, and prepending THIS user's :nick!user@host.
         * @param dest The user to route the message to
@@ -946,7 +979,7 @@ class CoreExport User : public connection
         * @param text The format string for text to send to the user
         * @param ... POD-type format arguments
         */
-       void WriteTo(User *dest, const char *data, ...);
+       void WriteTo(User *dest, const char *data, ...) CUSTOM_PRINTF(3, 4);
 
        /** 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
@@ -957,13 +990,13 @@ class CoreExport User : public connection
         * @param text The format string for text to send to the users
         * @param ... POD-type format arguments
         */
-       void WriteCommon(const char* text, ...);
+       void WriteCommon(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 The format string for text to send to the users
         * @param ... POD-type format arguments
         */
-       void WriteCommonExcept(const char* text, ...);
+       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
@@ -982,7 +1015,7 @@ class CoreExport User : public connection
         * @param text The format string to send in the WALLOPS message
         * @param ... Format arguments
         */
-       void WriteWallOps(const char* text, ...);
+       void WriteWallOps(const char* text, ...) CUSTOM_PRINTF(2, 3);
 
        /** Write a WALLOPS message from this user to all local opers.
         * If this user is not opered, the function will return without doing anything.
@@ -1032,7 +1065,7 @@ class CoreExport User : public connection
         * @param text The text format string to send
         * @param ... Format arguments
         */
-       void SendAll(const char* command, char* text, ...);
+       void SendAll(const char* command, const char* text, ...) CUSTOM_PRINTF(3, 4);
 
        /** Compile a channel list for this user, and send it to the user 'source'
         * Used internally by WHOIS