]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules.cpp
Update svn:ignore and .gitignore
[user/henk/code/inspircd.git] / src / modules.cpp
index 48b477658b99382180fcf71daf0bcbde63396f12..67c90b128b401e3dbd045f11dd3564d62ef08cf5 100644 (file)
@@ -28,7 +28,7 @@
 
 // version is a simple class for holding a modules version number
 Version::Version(const std::string &modv, int flags, int api_ver, const std::string& rev)
-: version(modv + " - " + rev), Flags(flags), API(api_ver)
+: description(modv), version(rev), Flags(flags), API(api_ver)
 {
 }
 
@@ -90,7 +90,7 @@ Module* Event::GetSource()
        return this->source;
 }
 
-char* Event::Send(InspIRCd* SI)
+char* Event::Send()
 {
        FOREACH_MOD(I_OnEvent,OnEvent(this));
        return NULL;
@@ -104,7 +104,7 @@ std::string Event::GetEventID()
 
 // These declarations define the behavours of the base class Module (which does nothing at all)
 
-Module::Module(InspIRCd*) { }
+Module::Module() { }
 Module::~Module() { }
 
 ModResult      Module::OnSendSnotice(char &snomask, std::string &type, const std::string &message) { return MOD_RES_PASSTHRU; }
@@ -119,7 +119,6 @@ void                Module::OnModuleRehash(User*, const std::string&) { }
 void           Module::OnRehash(User*) { }
 ModResult      Module::OnUserPreJoin(User*, Channel*, const char*, std::string&, const std::string&) { return MOD_RES_PASSTHRU; }
 void           Module::OnMode(User*, void*, int, const std::vector<std::string>&, const std::vector<TranslateType>&) { }
-Version                Module::GetVersion() { return Version("Misconfigured", VF_VENDOR, -1); }
 void           Module::OnOper(User*, const std::string&) { }
 void           Module::OnPostOper(User*, const std::string&, const std::string &) { }
 void           Module::OnInfo(User*) { }
@@ -159,11 +158,11 @@ void              Module::OnGlobalOper(User*) { }
 void           Module::OnPostConnect(User*) { }
 ModResult      Module::OnAddBan(User*, Channel*, const std::string &) { return MOD_RES_PASSTHRU; }
 ModResult      Module::OnDelBan(User*, Channel*, const std::string &) { return MOD_RES_PASSTHRU; }
-void           Module::OnRawSocketAccept(int, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { }
-int            Module::OnRawSocketWrite(int, const char*, int) { return 0; }
-void           Module::OnRawSocketClose(int) { }
-void           Module::OnRawSocketConnect(int) { }
-int            Module::OnRawSocketRead(int, char*, unsigned int, int&) { return 0; }
+void           Module::OnStreamSocketAccept(StreamSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { }
+int            Module::OnStreamSocketWrite(StreamSocket*, std::string&) { return -1; }
+void           Module::OnStreamSocketClose(StreamSocket*) { }
+void           Module::OnStreamSocketConnect(StreamSocket*) { }
+int            Module::OnStreamSocketRead(StreamSocket*, std::string&) { return -1; }
 void           Module::OnUserMessage(User*, void*, int, const std::string&, char, const CUList&) { }
 void           Module::OnUserNotice(User*, void*, int, const std::string&, char, const CUList&) { }
 void           Module::OnRemoteKill(User*, User*, const std::string&, const std::string&) { }
@@ -191,12 +190,11 @@ ModResult Module::OnUserList(User*, Channel*) { return MOD_RES_PASSTHRU; }
 ModResult      Module::OnWhoisLine(User*, User*, int&, std::string&) { return MOD_RES_PASSTHRU; }
 void           Module::OnBuildExemptList(MessageType, Channel*, User*, char, CUList&, const std::string&) { }
 void           Module::OnGarbageCollect() { }
-void           Module::OnBufferFlushed(User*) { }
 void           Module::OnText(User*, void*, int, const std::string&, char, CUList&) { }
 void           Module::OnRunTestSuite() { }
 void           Module::OnNamesListItem(User*, Membership*, std::string&, std::string&) { }
 ModResult      Module::OnNumeric(User*, unsigned int, const std::string&) { return MOD_RES_PASSTHRU; }
-void           Module::OnHookIO(EventHandler*, ListenSocketBase*) { }
+void           Module::OnHookIO(StreamSocket*, ListenSocketBase*) { }
 ModResult      Module::OnHostCycle(User*) { return MOD_RES_PASSTHRU; }
 void           Module::OnSendWhoLine(User*, User*, Channel*, std::string&) { }
 
@@ -427,7 +425,7 @@ bool ModuleManager::Load(const char* filename)
                /* This will throw a CoreException if there's a problem loading
                 * the module file or getting a pointer to the init_module symbol.
                 */
-               newhandle = new ircd_module(ServerInstance, modfile, "init_module");
+               newhandle = new ircd_module(modfile, "init_module");
                newmod = newhandle->CallInit();
 
                if (newmod)
@@ -495,7 +493,7 @@ bool ModuleManager::Load(const char* filename)
        }
 
        this->ModCount++;
-       FOREACH_MOD_I(ServerInstance,I_OnLoadModule,OnLoadModule(newmod, filename_str));
+       FOREACH_MOD(I_OnLoadModule,OnLoadModule(newmod, filename_str));
 
        /* We give every module a chance to re-prioritize when we introduce a new one,
         * not just the one thats loading, as the new module could affect the preference
@@ -538,26 +536,30 @@ bool ModuleManager::Unload(const char* filename)
                        return false;
                }
 
+               std::vector<ExtensionItem*> items = Extensible::BeginUnregister(modfind->second.second);
                /* Give the module a chance to tidy out all its metadata */
                for (chan_hash::iterator c = ServerInstance->chanlist->begin(); c != ServerInstance->chanlist->end(); c++)
                {
                        modfind->second.second->OnCleanup(TYPE_CHANNEL,c->second);
+                       c->second->doUnhookExtensions(items);
+                       const UserMembList* users = c->second->GetUsers();
+                       for(UserMembCIter mi = users->begin(); mi != users->end(); mi++)
+                               mi->second->doUnhookExtensions(items);
                }
                for (user_hash::iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++)
                {
                        modfind->second.second->OnCleanup(TYPE_USER,u->second);
+                       u->second->doUnhookExtensions(items);
                }
 
                /* Tidy up any dangling resolvers */
                ServerInstance->Res->CleanResolvers(modfind->second.second);
 
-
-               FOREACH_MOD_I(ServerInstance,I_OnUnloadModule,OnUnloadModule(modfind->second.second, modfind->first));
+               FOREACH_MOD(I_OnUnloadModule,OnUnloadModule(modfind->second.second, modfind->first));
 
                this->DetachAll(modfind->second.second);
 
                ServerInstance->Parser->RemoveCommands(modfind->second.second);
-               Extensible::UnRegister(modfind->second.second);
 
                delete modfind->second.second;
                delete modfind->second.first;
@@ -874,7 +876,7 @@ const std::vector<std::string> ModuleManager::GetAllModuleNames(int filter)
        return retval;
 }
 
-ConfigReader::ConfigReader(InspIRCd* Instance)
+ConfigReader::ConfigReader()
 {
        this->error = 0;
 }
@@ -954,12 +956,12 @@ int ConfigReader::EnumerateValues(const std::string &tag, int index)
        return ServerInstance->Config->ConfVarEnum(tag, index);
 }
 
-FileReader::FileReader(InspIRCd* Instance, const std::string &filename)
+FileReader::FileReader(const std::string &filename)
 {
        LoadFile(filename);
 }
 
-FileReader::FileReader(InspIRCd* Instance)
+FileReader::FileReader()
 {
 }