]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/modules.h
Move more stuff into userrec
[user/henk/code/inspircd.git] / include / modules.h
index 88fe81adc207332a2540e8a5054db960cc122a47..b0d249c7c73d8d52060a11cec5f500c338acba0c 100644 (file)
 #ifndef __MODULES_H
 #define __MODULES_H
 
-/** log levels
- */
-enum DebugLevels { DEBUG, VERBOSE, DEFAULT, SPARSE, NONE };
-
 /** Used with OnAccessCheck() method of modules
  */
 enum AccessControlType {
@@ -84,11 +80,6 @@ class Module;
 typedef std::deque<std::string> file_cache;
 typedef file_cache string_list;
 
-/** Holds a list of users in a channel
- */
-typedef std::deque<userrec*> chanuserlist;
-
-
 /** Holds a list of 'published features' for modules.
  */
 typedef std::map<std::string,Module*> featurelist;
@@ -98,9 +89,9 @@ typedef std::map<std::string,Module*> featurelist;
  * loaded modules in a readable simple way, e.g.:
  * 'FOREACH_MOD(I_OnXonnwxr,OnConnect(user));'
  */
-#define FOREACH_MOD(y,x) if (Config->global_implementation[y] > 0) { \
+#define FOREACH_MOD(y,x) if (ServerInstance->Config->global_implementation[y] > 0) { \
        for (int _i = 0; _i <= MODCOUNT; _i++) { \
-       if (Config->implement_lists[_i][y]) \
+       if (ServerInstance->Config->implement_lists[_i][y]) \
                try \
                { \
                        modules[_i]->x ; \
@@ -112,15 +103,28 @@ typedef std::map<std::string,Module*> featurelist;
        } \
   }
 
+#define FOREACH_MOD_I(z,y,x) if (z->Config->global_implementation[y] > 0) { \
+       for (int _i = 0; _i <= MODCOUNT; _i++) { \
+               if (z->Config->implement_lists[_i][y]) \
+               try \
+               { \
+                       modules[_i]->x ; \
+               } \
+               catch (ModuleException& modexcept) \
+               { \
+                       log(DEBUG,"Module exception caught: %s",modexcept.GetReason()); \
+               } \
+       } \
+}
 /**
  *  This define is similar to the one above but returns a result in MOD_RESULT.
  * The first module to return a nonzero result is the value to be accepted,
  * and any modules after are ignored.
  */
-#define FOREACH_RESULT(y,x) { if (Config->global_implementation[y] > 0) { \
+#define FOREACH_RESULT(y,x) { if (ServerInstance->Config->global_implementation[y] > 0) { \
                        MOD_RESULT = 0; \
                        for (int _i = 0; _i <= MODCOUNT; _i++) { \
-                       if (Config->implement_lists[_i][y]) {\
+                       if (ServerInstance->Config->implement_lists[_i][y]) { \
                                try \
                                { \
                                        int res = modules[_i]->x ; \
@@ -138,6 +142,27 @@ typedef std::map<std::string,Module*> featurelist;
        } \
  }
 
+#define FOREACH_RESULT_I(z,y,x) { if (z->Config->global_implementation[y] > 0) { \
+                       MOD_RESULT = 0; \
+                       for (int _i = 0; _i <= MODCOUNT; _i++) { \
+                       if (z->Config->implement_lists[_i][y]) { \
+                               try \
+                               { \
+                                       int res = modules[_i]->x ; \
+                                       if (res != 0) { \
+                                               MOD_RESULT = res; \
+                                               break; \
+                                       } \
+                               } \
+                               catch (ModuleException& modexcept) \
+                               { \
+                                       log(DEBUG,"Module exception cought: %s",modexcept.GetReason()); \
+                               } \
+                       } \
+               } \
+       } \
+}
+
 #define FD_MAGIC_NUMBER -42
 
 // useful macros
@@ -1192,7 +1217,7 @@ class Module : public Extensible
         * @param Number of characters to write
         * @return Number of characters actually written or 0 if you didn't handle the operation
         */
-       virtual int OnRawSocketWrite(int fd, char* buffer, int count);
+       virtual int OnRawSocketWrite(int fd, const char* buffer, int count);
 
        /** Called immediately before any socket is closed. When this event is called, shutdown()
         * has not yet been called on the socket.
@@ -1327,28 +1352,11 @@ class Server : public Extensible
         */
        virtual void Log(int level, const std::string &s);
 
-       /** Returns true if two users share a common channel.
-        * This method is used internally by the NICK and QUIT commands, and the Server::SendCommon
-        * method.
-        */
-       virtual bool CommonChannels(userrec* u1, userrec* u2);
-
-       /** Sends a WALLOPS message.
-        * This method writes a WALLOPS message to all users with the +w flag, originating from the
-        * specified user.
-        */
-       virtual void SendWallops(userrec* User, const std::string &text);
-
        /** Returns true if a nick is valid.
         * Nicks for unregistered connections will return false.
         */
        virtual bool IsNick(const std::string &nick);
 
-       /** Returns a count of the number of users on a channel.
-        * This will NEVER be 0, as if the chanrec exists, it will have at least one user in the channel.
-        */
-       virtual int CountUsers(chanrec* c);
-
        /** Adds an InspTimer which will trigger at a future time
         */
        virtual void AddTimer(InspTimer* T);
@@ -1442,21 +1450,7 @@ class Server : public Extensible
         */
 
        virtual void SendMode(const char **parameters, int pcnt, userrec *user);
-       
-       /** Sends to all users matching a mode mask
-        * You must specify one or more usermodes as the first parameter. These can be RFC specified modes such as +i,
-        * or module provided modes, including ones provided by your own module.
-        * In the second parameter you must place a flag value which indicates wether the modes you have given will be
-        * logically ANDed or OR'ed. You may use one of either WM_AND or WM_OR.
-        * for example, if you were to use:
-        *
-        * Serv->SendToModeMask("xi", WM_OR, "m00");
-        *
-        * Then the text 'm00' will be sent to all users with EITHER mode x or i. Conversely if you used WM_AND, the
-        * user must have both modes set to receive the message.
-        */
-       virtual void SendToModeMask(const std::string &modes, int flags, const std::string &text);
-       
+
        /**  Matches text against a glob pattern.
         * Uses the ircd's internal matching function to match string against a globbing pattern, e.g. *!*@*.com
         * Returns true if the literal successfully matches the pattern, false if otherwise.
@@ -1484,20 +1478,6 @@ class Server : public Extensible
         */
        virtual bool IsValidModuleCommand(const std::string &commandname, int pcnt, userrec* user);
        
-       /** Change displayed hostname of a user.
-        * You should always call this method to change a user's host rather than writing directly to the
-        * dhost member of userrec, as any change applied via this method will be propogated to any
-        * linked servers.
-        */     
-       virtual void ChangeHost(userrec* user, const std::string &host);
-       
-       /** Change GECOS (fullname) of a user.
-        * You should always call this method to change a user's GECOS rather than writing directly to the
-        * fullname member of userrec, as any change applied via this method will be propogated to any
-        * linked servers.
-        */     
-       virtual void ChangeGECOS(userrec* user, const std::string &gecos);
-       
        /** Returns true if the servername you give is ulined.
         * ULined servers have extra privilages. They are allowed to change nicknames on remote servers,
         * change modes of clients which are on remote servers and set modes of channels where there are
@@ -1505,27 +1485,6 @@ class Server : public Extensible
         */
        virtual bool IsUlined(const std::string &server);
        
-       /** Fetches the userlist of a channel. This function must be here and not a member of userrec or
-        * chanrec due to include constraints.
-        */
-       virtual chanuserlist GetUsers(chanrec* chan);
-
-       /** Remove a user's connection to the irc server, but leave their client in existence in the
-        * user hash. When you call this function, the user's file descriptor will be replaced with the
-        * value of FD_MAGIC_NUMBER and their old file descriptor will be closed. This idle client will
-        * remain until it is restored with a valid file descriptor, or is removed from IRC by an operator
-        * After this call, the pointer to user will be invalid.
-        */
-       virtual bool UserToPseudo(userrec* user, const std::string &message);
-
-       /** This user takes one user, and switches their file descriptor with another user, so that one user
-        * "becomes" the other. The user in 'alive' is booted off the server with the given message. The user
-        * referred to by 'zombie' should have previously been locked with Server::UserToPseudo, otherwise
-        * stale sockets and file descriptor leaks can occur. After this call, the pointer to alive will be
-        * invalid, and the pointer to zombie will be equivalent in effect to the old pointer to alive.
-        */
-       virtual bool PseudoToUser(userrec* alive, userrec* zombie, const std::string &message);
-
        /** Adds a G-line
         * The G-line is propogated to all of the servers in the mesh and enforced as soon as it is added.
         * The duration must be in seconds, however you can use the Server::CalcDuration method to convert