]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/modules.h
Added OnLoadModule and OnUnloadModule (OnLoadModule was not triggering)
[user/henk/code/inspircd.git] / include / modules.h
index 78cc2553d882b43da9997eb256a967fa92df717f..91f9604e550f7769f96d37e538b918925a927338 100644 (file)
@@ -76,7 +76,7 @@ typedef std::deque<userrec*> chanuserlist;
 // loaded modules in a readable simple way, e.g.:
 // 'FOREACH_MOD OnConnect(user);'
 
-#define FOREACH_MOD for (int i = 0; i <= MODCOUNT; i++) modules[i]->
+#define FOREACH_MOD for (int _i = 0; _i <= MODCOUNT; _i++) modules[_i]->
 
 // 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,
@@ -85,8 +85,8 @@ typedef std::deque<userrec*> chanuserlist;
 // *********************************************************************************************
 
 #define FOREACH_RESULT(x) { MOD_RESULT = 0; \
-                       for (int i = 0; i <= MODCOUNT; i++) { \
-                       int res = modules[i]->x ; \
+                       for (int _i = 0; _i <= MODCOUNT; _i++) { \
+                       int res = modules[_i]->x ; \
                        if (res != 0) { \
                                MOD_RESULT = res; \
                                break; \
@@ -144,6 +144,7 @@ class ModuleMessage : public classbase
         /** This class is pure virtual and must be inherited.
          */
         virtual char* Send() = 0;
+       virtual ~ModuleMessage() {};
 };
 
 /** The Request class is a unicast message directed at a given module.
@@ -490,6 +491,18 @@ class Module : public classbase
         */
        virtual void OnLoadModule(Module* mod,std::string name);
 
+       /** Called whenever a module is unloaded.
+         * 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 OnUnloadModule(Module* mod,std::string name);
+
        /** Called once every five seconds for background processing.
         * This timer can be used to control timed features. Its period is not accurate
         * enough to be used as a clock, but it is gauranteed to be called at least once in
@@ -641,6 +654,48 @@ class Module : public classbase
         */
        virtual void OnGlobalConnect(userrec* user);
 
+       /** Called whenever a ban is added to a channel's list.
+        * Return a non-zero value to 'eat' the mode change and prevent the ban from being added.
+        */
+       virtual int OnAddBan(userrec* source, chanrec* channel,std::string banmask);
+
+       /** Called whenever a ban is removed from a channel's list.
+        * Return a non-zero value to 'eat' the mode change and prevent the ban from being removed.
+        */
+       virtual int OnDelBan(userrec* source, chanrec* channel,std::string banmask);
+
+       /** Called immediately after any  connection is accepted. This is intended for raw socket
+        * processing (e.g. modules which wrap the tcp connection within another library) and provides
+        * no information relating to a user record as the connection has not been assigned yet.
+        * There are no return values from this call as all modules get an opportunity if required to
+        * process the connection.
+        */
+       virtual void OnRawSocketAccept(int fd, std::string ip, int localport);
+
+       /** Called immediately before any write() operation on a user's socket in the core. Because
+        * this event is a low level event no user information is associated with it. It is intended
+        * for use by modules which may wrap connections within another API such as SSL for example.
+        * return a non-zero result if you have handled the write operation, in which case the core
+        * will not call write().
+        */
+       virtual int OnRawSocketWrite(int fd, 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.
+        */
+       virtual void OnRawSocketClose(int fd);
+
+       /** Called immediately before any read() operation on a client socket in the core.
+        * This occurs AFTER the select() or poll() so there is always data waiting to be read
+        * when this event occurs.
+        * Your event should return 1 if it has handled the reading itself, which prevents the core
+        * just using read(). You should place any data read into buffer, up to but NOT GREATER THAN
+        * the value of count. The value of readresult must be identical to an actual result that might
+        * be returned from the read() system call, for example, number of bytes read upon success,
+        * 0 upon EOF or closed socket, and -1 for error. If your function returns a nonzero value,
+        * you MUST set readresult.
+        */
+       virtual int OnRawSocketRead(int fd, char* buffer, unsigned int count, int &readresult);
 };
 
 
@@ -680,6 +735,10 @@ class Server : public classbase
         * as used by numerics (see RFC 1459)
         */
        virtual void SendServ(int Socket, std::string s);
+       /** Writes text to a channel, but from a server, including all.
+        * This can be used to send server notices to a group of users.
+        */
+       virtual void SendChannelServerNotice(std::string ServName, chanrec* Channel, std::string text);
        /** Sends text from a user to a socket.
         * This method writes a line of text to an established socket, with the given user's nick/ident
         * /host combination prepended, as used in PRIVSG etc commands (see RFC 1459)
@@ -738,6 +797,10 @@ class Server : public classbase
         * This function will return NULL if the nick does not exist.
         */
        virtual userrec* FindNick(std::string nick);
+       /** Attempts to look up a nick using the file descriptor associated with that nick.
+        * This function will return NULL if the file descriptor is not associated with a valid user.
+        */
+       virtual userrec* FindDescriptor(int socket);
        /** Attempts to look up a channel and return a pointer to it.
         * This function will return NULL if the channel does not exist.
         */
@@ -757,6 +820,9 @@ class Server : public classbase
        /** Returns the network name, global to all linked servers.
         */
        virtual std::string GetNetworkName();
+       /** Returns the server description string of the local server
+        */
+       virtual std::string GetServerDescription();
        /** Returns the information of the server as returned by the /ADMIN command.
         * See the Admin class for further information of the return value. The members
         * Admin::Nick, Admin::Email and Admin::Name contain the information for the