]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/modules.h
Added VF_ module flags as discussed with Craig
[user/henk/code/inspircd.git] / include / modules.h
index dc17b99c0b90129a2915c60c6ce4f229e02de3e3..9b2118472b15307c689a8d0e7c66da6a6905c4eb 100644 (file)
 #define AC_INVITE 7            // a user is being invited
 #define AC_GENERAL_MODE 8      // a user channel mode is being changed
 
+// used to define a set of behavior bits for a module
+
+#define VF_STATIC              1       // module is static, cannot be /unloadmodule'd
+#define VF_VENDOR              2       // module is a vendor module (came in the original tarball, not 3rd party)
+#define VF_SERVICEPROVIDER     4       // module provides a service to other modules (can be a dependency)
+#define VF_COMMON              8       // module needs to be common on all servers in a mesh to link
+
 #include "dynamic.h"
 #include "base.h"
 #include "ctables.h"
@@ -284,12 +291,18 @@ class Module : public classbase
         * check user->server before taking any action (including returning nonzero from the method).
         * If your method returns nonzero, the nickchange is silently forbidden, and it is down to your
         * module to generate some meaninful output.
-        * You may alter the message text as you wish before relinquishing control to the next module
-        * in the chain, and if no other modules block the text this altered form of the text will be sent out
-        * to the user and possibly to other servers.
         */
        virtual int OnUserPreNick(userrec* user, std::string newnick);
        
+       /** Called after any nickchange, local or remote. This can be used to track users after nickchanges
+        * have been applied. Please note that although you can see remote nickchanges through this function, you should
+         * NOT make any changes to the userrec if the user is a remote user as this may cause a desnyc.
+         * check user->server before taking any action (including returning nonzero from the method).
+        * Because this method is called after the nickchange is taken place, no return values are possible
+        * to indicate forbidding of the nick change. Use OnUserPreNick for this.
+         */
+       virtual void OnUserPostNick(userrec* user, std::string oldnick);
+
        /** Called before an action which requires a channel privilage check.
         * This function is called before many functions which check a users status on a channel, for example
         * before opping a user, deopping a user, kicking a user, etc.
@@ -326,6 +339,34 @@ class Module : public classbase
         * multiple commands in the string_list.
         */
        virtual string_list OnChannelSync(chanrec* chan);
+
+       /** Called when a 005 numeric is about to be output.
+        * The module should modify the 005 numeric if needed to indicate its features.
+        */
+       virtual void On005Numeric(std::string &output);
+
+       /** Called when a client is disconnected by KILL.
+        * If a client is killed by a server, e.g. a nickname collision or protocol error,
+        * source is NULL.
+        * Return 1 from this function to prevent the kill, and 0 from this function to allow
+        * it as normal. If you prevent the kill no output will be sent to the client, it is
+        * down to your module to generate this information.
+        * NOTE: It is NOT advisable to stop kills which originate from servers. If you do
+        * so youre risking race conditions, desyncs and worse!
+        */
+       virtual int OnKill(userrec* source, userrec* dest, std::string reason);
+
+       /** Called whenever a module is loaded.
+        * mod will contain a pointer to the module, and string will contain its name,
+        * for example m_widgets.so. This function is primary for dependency checking,
+        * your module may decide to enable some extra features if it sees that you have
+        * for example loaded "m_killwidgets.so" with "m_makewidgets.so". It is highly
+        * recommended that modules do *NOT* bail if they cannot satisfy dependencies,
+        * but instead operate under reduced functionality, unless the dependency is
+        * absolutely neccessary (e.g. a module that extends the features of another
+        * module).
+        */
+       virtual void OnLoadModule(Module* mod,std::string name);
 };
 
 
@@ -647,6 +688,7 @@ class ConfigReader : public classbase
         * (such as comments) stripped from it.
         */
        std::stringstream *cache;
+       std::stringstream *errorlog;
        /** Used to store errors
         */
        bool readerror;
@@ -703,6 +745,13 @@ class ConfigReader : public classbase
         * file does not exist or could not be opened.
         */
        bool Verify();
+       /** Dumps the list of errors in a config file to an output location. If bail is true,
+        * then the program will abort. If bail is false and user points to a valid user
+        * record, the error report will be spooled to the given user by means of NOTICE.
+        * if bool is false AND user is false, the error report will be spooled to all opers
+        * by means of a NOTICE to all opers.
+        */
+       void DumpErrors(bool bail,userrec* user);
 
        /** Returns the number of items within a tag.
         * For example if the tag was <test tag="blah" data="foo"> then this