X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules.cpp;h=23aceb3e11e442c524e5eb8f15ce44e2ef619eba;hb=282138ad0e9ef483ec2a1606376fc5cb6d5f4cbc;hp=388a579050281169c6d9deae313aab9a2d28ad26;hpb=58d7827bb1bd3d90f38a1c199f6f41ae9f24885c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules.cpp b/src/modules.cpp index 388a57905..23aceb3e1 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -25,7 +25,6 @@ #include -#include #include "inspircd.h" #include "xline.h" #include "socket.h" @@ -133,12 +132,10 @@ void Module::OnPostConnect(User*) { DetachEvent(I_OnPostConnect); } void Module::OnUserMessage(User*, void*, int, const std::string&, char, const CUList&, MessageType) { DetachEvent(I_OnUserMessage); } void Module::OnUserInvite(User*, User*, Channel*, time_t) { DetachEvent(I_OnUserInvite); } void Module::OnPostTopicChange(User*, Channel*, const std::string&) { DetachEvent(I_OnPostTopicChange); } -void Module::OnGetServerDescription(const std::string&, std::string&) { DetachEvent(I_OnGetServerDescription); } -void Module::OnSyncUser(User*, Module*, void*) { DetachEvent(I_OnSyncUser); } -void Module::OnSyncChannel(Channel*, Module*, void*) { DetachEvent(I_OnSyncChannel); } -void Module::OnSyncNetwork(Module*, void*) { DetachEvent(I_OnSyncNetwork); } +void Module::OnSyncUser(User*, ProtocolInterface::Server&) { DetachEvent(I_OnSyncUser); } +void Module::OnSyncChannel(Channel*, ProtocolInterface::Server&) { DetachEvent(I_OnSyncChannel); } +void Module::OnSyncNetwork(ProtocolInterface::Server&) { DetachEvent(I_OnSyncNetwork); } void Module::OnDecodeMetaData(Extensible*, const std::string&, const std::string&) { DetachEvent(I_OnDecodeMetaData); } -void Module::ProtoSendMetaData(void*, Extensible*, const std::string&, const std::string&) { } void Module::OnChangeHost(User*, const std::string&) { DetachEvent(I_OnChangeHost); } void Module::OnChangeName(User*, const std::string&) { DetachEvent(I_OnChangeName); } void Module::OnChangeIdent(User*, const std::string&) { DetachEvent(I_OnChangeIdent); } @@ -391,18 +388,23 @@ void ModuleManager::DoSafeUnload(Module* mod) std::vector > items; ServerInstance->Extensions.BeginUnregister(modfind->second, items); /* Give the module a chance to tidy out all its metadata */ - for (chan_hash::iterator c = ServerInstance->chanlist->begin(); c != ServerInstance->chanlist->end(); c++) + for (chan_hash::iterator c = ServerInstance->chanlist->begin(); c != ServerInstance->chanlist->end(); ) { - mod->OnCleanup(TYPE_CHANNEL,c->second); - c->second->doUnhookExtensions(items); - const UserMembList* users = c->second->GetUsers(); + Channel* chan = c->second; + ++c; + mod->OnCleanup(TYPE_CHANNEL, chan); + chan->doUnhookExtensions(items); + const UserMembList* users = chan->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++) + for (user_hash::iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); ) { - mod->OnCleanup(TYPE_USER,u->second); - u->second->doUnhookExtensions(items); + User* user = u->second; + // The module may quit the user (e.g. SSL mod unloading) and that will remove it from the container + ++u; + mod->OnCleanup(TYPE_USER, user); + user->doUnhookExtensions(items); } for(char m='A'; m <= 'z'; m++) { @@ -552,6 +554,8 @@ void ModuleManager::LoadAll() } } + this->NewServices = NULL; + if (!PrioritizeHooks()) ServerInstance->Exit(EXIT_STATUS_MODULE); } @@ -709,47 +713,3 @@ Module* ModuleManager::Find(const std::string &name) else return modfind->second; } - -FileReader::FileReader(const std::string& filename) -{ - Load(filename); -} - -void FileReader::Load(const std::string& filename) -{ - // If the file is stored in the file cache then we used that version instead. - std::string realName = ServerInstance->Config->Paths.PrependConfig(filename); - ConfigFileCache::iterator it = ServerInstance->Config->Files.find(realName); - if (it != ServerInstance->Config->Files.end()) - { - this->lines = it->second; - } - else - { - lines.clear(); - - std::ifstream stream(realName.c_str()); - if (!stream.is_open()) - throw CoreException(filename + " does not exist or is not readable!"); - - std::string line; - while (std::getline(stream, line)) - { - lines.push_back(line); - totalSize += line.size() + 2; - } - - stream.close(); - } -} - -std::string FileReader::GetString() -{ - std::string buffer; - for (file_cache::iterator it = this->lines.begin(); it != this->lines.end(); ++it) - { - buffer.append(*it); - buffer.append("\r\n"); - } - return buffer; -}