]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/users.h
Move MODENOTICE command to a command module
[user/henk/code/inspircd.git] / include / users.h
index fa56abc0e9bdcc5a424b91027a41569611cee5e4..ed649f1b9758c7d5d6e166d34edc4b03b694e11d 100644 (file)
@@ -56,11 +56,11 @@ enum RegistrationState {
        REG_ALL = 7             /* REG_NICKUSER plus next bit along */
 };
 
-/* Required forward declaration */
-class Channel;
-class UserResolver;
-struct ConfigTag;
-class OperInfo;
+enum UserType {
+       USERTYPE_LOCAL = 1,
+       USERTYPE_REMOTE = 2,
+       USERTYPE_SERVER = 3
+};
 
 /** Holds information relevent to <connect allow> and <connect deny> tags in the config file.
  */
@@ -208,26 +208,6 @@ struct CoreExport ConnectClass : public refcountbase
        }
 };
 
-/** 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;
-
-/** Holds a complete list of all allow and deny tags from the configuration file (connection classes)
- */
-typedef std::vector<reference<ConnectClass> > ClassVector;
-
-/** Typedef for the list of user-channel records for a user
- */
-typedef std::set<Channel*> UserChanList;
-
-/** Shorthand for an iterator into a UserChanList
- */
-typedef UserChanList::iterator UCListIter;
-
-/* Required forward declaration
- */
-class User;
-
 /** Holds all information about a user
  * This class stores all information about a user connected to the irc server. Everything about a
  * connection is stored here primarily, from the user's socket ID (file descriptor) through to the
@@ -297,7 +277,7 @@ class CoreExport User : public StreamSocket
        /** The user's unique identifier.
         * This is the unique identifier which the user has across the network.
         */
-       std::string uuid;
+       const std::string uuid;
 
        /** The users ident reply.
         * Two characters are added to the user-defined limit to compensate for the tilde etc.
@@ -336,7 +316,7 @@ class CoreExport User : public StreamSocket
 
        /** The server the user is connected to.
         */
-       std::string server;
+       const std::string server;
 
        /** The user's away message.
         * If this string is empty, the user is not marked as away.
@@ -383,6 +363,9 @@ class CoreExport User : public StreamSocket
         */
        unsigned int lastping:1;
 
+       /** What type of user is this? */
+       const unsigned int usertype:2;
+
        /** Get client IP string from sockaddr, using static internal buffer
         * @return The IP string
         */
@@ -390,19 +373,17 @@ class CoreExport User : public StreamSocket
 
        /** Get CIDR mask, using default range, for this user
         */
-       irc::string GetCIDRMask();
+       irc::sockets::cidr_mask GetCIDRMask();
 
        /** Sets the client IP for this user
         * @return true if the conversion was successful
         */
        bool SetClientIP(const char* sip);
 
-       /** Default constructor
+       /** Constructor
         * @throw CoreException if the UID allocated to the user already exists
-        * @param Instance Creator instance
-        * @param uid User UUID, or empty to allocate one automatically
         */
-       User(const std::string &uid);
+       User(const std::string &uid, const std::string& srv, int objtype);
 
        /** Check if the user matches a G or K line, and disconnect them if they do.
         * @param doZline True if ZLines should be checked (if IP has changed since initial connect)
@@ -415,7 +396,7 @@ class CoreExport User : public StreamSocket
         * on the server, in nick!ident&at;host form.
         * @return The full masked host of the user
         */
-       virtual const std::string GetFullHost();
+       virtual const std::string& GetFullHost();
 
        /** Returns the full real host of the user
         * This member function returns the hostname of the user as seen by other users
@@ -423,7 +404,7 @@ class CoreExport User : public StreamSocket
         * e.g. through a module, then this method will ignore it and return the true hostname.
         * @return The full real host of the user
         */
-       virtual const std::string GetFullRealHost();
+       virtual const std::string& GetFullRealHost();
 
        /** This clears any cached results that are used for GetFullRealHost() etc.
         * The results of these calls are cached as generating them can be generally expensive.
@@ -733,14 +714,6 @@ class CoreExport User : public StreamSocket
        virtual CullResult cull();
 };
 
-/** Represents a non-local user.
- * (in fact, any FD less than -1 does)
- */
-#define FD_MAGIC_NUMBER -42
-/** Represents a fake user (i.e. a server)
- */
-#define FD_FAKEUSER_NUMBER -7
-
 class CoreExport LocalUser : public User
 {
        /** A list of channels the user has a pending invite to.
@@ -750,7 +723,7 @@ class CoreExport LocalUser : public User
        InvitedList invites;
 
  public:
-       LocalUser();
+       LocalUser(int fd, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
        CullResult cull();
 
        /** Stats counter for bytes inbound
@@ -891,9 +864,8 @@ class CoreExport LocalUser : public User
 class CoreExport RemoteUser : public User
 {
  public:
-       RemoteUser(const std::string& uid) : User(uid)
+       RemoteUser(const std::string& uid, const std::string& srv) : User(uid, srv, USERTYPE_REMOTE)
        {
-               SetFd(FD_MAGIC_NUMBER);
        }
        virtual void SendText(const std::string& line);
 };
@@ -901,32 +873,32 @@ class CoreExport RemoteUser : public User
 class CoreExport FakeUser : public User
 {
  public:
-       FakeUser(const std::string &uid) : User(uid)
+       FakeUser(const std::string &uid, const std::string& srv) : User(uid, srv, USERTYPE_SERVER)
        {
-               SetFd(FD_FAKEUSER_NUMBER);
+               nick = srv;
        }
 
+       virtual CullResult cull();
        virtual void SendText(const std::string& line);
-       virtual const std::string GetFullHost();
-       virtual const std::string GetFullRealHost();
-       void SetFakeServer(std::string name);
+       virtual const std::string& GetFullHost();
+       virtual const std::string& GetFullRealHost();
 };
 
 /* Faster than dynamic_cast */
 /** Is a local user */
 inline LocalUser* IS_LOCAL(User* u)
 {
-       return u->GetFd() > -1 ? static_cast<LocalUser*>(u) : NULL;
+       return u->usertype == USERTYPE_LOCAL ? static_cast<LocalUser*>(u) : NULL;
 }
 /** Is a remote user */
 inline RemoteUser* IS_REMOTE(User* u)
 {
-       return u->GetFd() == FD_MAGIC_NUMBER ? static_cast<RemoteUser*>(u) : NULL;
+       return u->usertype == USERTYPE_REMOTE ? static_cast<RemoteUser*>(u) : NULL;
 }
 /** Is a server fakeuser */
 inline FakeUser* IS_SERVER(User* u)
 {
-       return u->GetFd() == FD_FAKEUSER_NUMBER ? static_cast<FakeUser*>(u) : NULL;
+       return u->usertype == USERTYPE_SERVER ? static_cast<FakeUser*>(u) : NULL;
 }
 /** Is an oper */
 #define IS_OPER(x) (x->oper)