]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Added OnLoadModule and OnUnloadModule (OnLoadModule was not triggering)
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 1 Jun 2005 16:38:00 +0000 (16:38 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 1 Jun 2005 16:38:00 +0000 (16:38 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1586 e03df62e-2008-0410-955e-edbf42e46eb7

include/modules.h
src/inspircd.cpp
src/modules.cpp

index 0737f9e17ba5c70ddd6b2d767a382a1631e60433..91f9604e550f7769f96d37e538b918925a927338 100644 (file)
@@ -491,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
index 4d7c933c6c53a9e133f134b8cce71f900e3b3e3c..9523e13ca0c5abfa7f522506fef9d7c7445a95c9 100644 (file)
@@ -2480,6 +2480,7 @@ bool UnloadModule(const char* filename)
                                snprintf(MODERR,MAXBUF,"Module not unloadable (marked static)");
                                return false;
                        }
+                       FOREACH_MOD OnUnloadModule(modules[j],module_names[j]);
                        // found the module
                        log(DEBUG,"Deleting module...");
                        erase_module(j);
@@ -2541,6 +2542,7 @@ bool LoadModule(const char* filename)
                 {
                        Module* m = factory[MODCOUNT+1]->factory->CreateModule();
                         modules[MODCOUNT+1] = m;
+                       FOREACH_MOD OnLoadModule(m,filename_str);
                         /* save the module and the module's classfactory, if
                          * this isnt done, random crashes can occur :/ */
                         module_names.push_back(filename);
index 6f2fc82ec444eae7abd10c862f191b5fac81e09d..35372a71edd45e11ff61beb3b9831d1925e5a518 100644 (file)
@@ -330,6 +330,7 @@ string_list Module::OnChannelSync(chanrec* chan) { string_list empty; return emp
 void           Module::On005Numeric(std::string &output) { };
 int            Module::OnKill(userrec* source, userrec* dest, std::string reason) { return 0; };
 void           Module::OnLoadModule(Module* mod,std::string name) { };
+void           Module::OnUnloadModule(Module* mod,std::string name) { };
 void           Module::OnBackgroundTimer(time_t curtime) { };
 void           Module::OnSendList(userrec* user, chanrec* channel, char mode) { };
 int            Module::OnPreCommand(std::string command, char **parameters, int pcnt, userrec *user) { return 0; };