- ServerInstance->BuildISupport();
- return true;
-}
-
-bool ModuleManager::Unload(const char* filename)
-{
- std::string filename_str(filename);
- std::map<std::string, Module*>::iterator modfind = Modules.find(filename);
-
- if (modfind != Modules.end())
- {
- if (modfind->second->GetVersion().Flags & VF_STATIC)
- {
- LastModuleError = "Module " + filename_str + " not unloadable (marked static)";
- ServerInstance->Logs->Log("MODULE", DEFAULT, LastModuleError);
- return false;
- }
- std::pair<int,std::string> intercount = GetInterfaceInstanceCount(modfind->second);
- if (intercount.first > 0)
- {
- LastModuleError = "Failed to unload module " + filename_str + ", being used by " + ConvToStr(intercount.first) + " other(s) via interface '" + intercount.second + "'";
- ServerInstance->Logs->Log("MODULE", DEFAULT, LastModuleError);
- return false;
- }
-
- std::vector<ExtensionItem*> items = Extensible::BeginUnregister(modfind->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->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->OnCleanup(TYPE_USER,u->second);
- u->second->doUnhookExtensions(items);
- }
-
- /* Tidy up any dangling resolvers */
- ServerInstance->Res->CleanResolvers(modfind->second);