X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules.cpp;h=52a25d37cc8e0a43001776e402675eaf450364a1;hb=f1c95ba9301178017542afe9262a3f2f0528afd5;hp=22628ff0f1c5edc144527e3abcb203961d1e1e78;hpb=4b6bdeccb537b6f8030172c37afa7dc324e26765;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules.cpp b/src/modules.cpp index 22628ff0f..52a25d37c 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -99,8 +99,8 @@ ModResult Module::OnKill(User*, User*, const std::string&) { return MOD_RES_PASS void Module::OnLoadModule(Module*) { } void Module::OnUnloadModule(Module*) { } void Module::OnBackgroundTimer(time_t) { } -ModResult Module::OnPreCommand(std::string&, std::vector&, User *, bool, const std::string&) { return MOD_RES_PASSTHRU; } -void Module::OnPostCommand(const std::string&, const std::vector&, User *, CmdResult, const std::string&) { } +ModResult Module::OnPreCommand(std::string&, std::vector&, LocalUser*, bool, const std::string&) { return MOD_RES_PASSTHRU; } +void Module::OnPostCommand(const std::string&, const std::vector&, LocalUser*, CmdResult, const std::string&) { } ModResult Module::OnCheckReady(LocalUser*) { return MOD_RES_PASSTHRU; } ModResult Module::OnUserRegister(LocalUser*) { return MOD_RES_PASSTHRU; } ModResult Module::OnUserPreKick(User*, Membership*, const std::string&) { return MOD_RES_PASSTHRU; } @@ -155,13 +155,14 @@ ModResult Module::OnUserList(User*, Channel*) { return MOD_RES_PASSTHRU; } ModResult Module::OnWhoisLine(User*, User*, int&, std::string&) { return MOD_RES_PASSTHRU; } void Module::OnBuildNeighborList(User*, UserChanList&, std::map&) { } void Module::OnGarbageCollect() { } +ModResult Module::OnSetConnectClass(LocalUser* user, ConnectClass* myclass) { return MOD_RES_PASSTHRU; } 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(StreamSocket*, ListenSocket*) { } ModResult Module::OnAcceptConnection(int, ListenSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { return MOD_RES_PASSTHRU; } -void Module::OnSendWhoLine(User*, User*, Channel*, std::string&) { } +void Module::OnSendWhoLine(User*, const std::vector&, User*, Channel*, std::string&) { } ModResult Module::OnChannelRestrictionApply(User*, Channel*, const char*) { return MOD_RES_PASSTHRU; } ModuleManager::ModuleManager() : ModCount(0) @@ -175,7 +176,7 @@ ModuleManager::~ModuleManager() bool ModuleManager::Attach(Implementation i, Module* mod) { if (Modules.find(mod->ModuleSourceFile) == Modules.end()) - ServerInstance->Logs->Log("MODULE", ERROR, "Module %s is attaching to hook %d in constructor; this does not handle exceptions correctly!", mod->ModuleSourceFile.c_str(), i); + ServerInstance->Logs->Log("MODULE", DEFAULT, "Module is attaching to hook %d in constructor; this does not handle exceptions correctly!", i); if (std::find(EventHandlers[i].begin(), EventHandlers[i].end(), mod) != EventHandlers[i].end()) return false; @@ -424,7 +425,7 @@ void ModuleManager::AddService(ServiceProvider& item) { Module* owner = item.creator; if (Modules.find(owner->ModuleSourceFile) == Modules.end()) - ServerInstance->Logs->Log("MODULE", ERROR, "Module %s is registering item %s in constructor; this does not handle exceptions correctly!", owner->ModuleSourceFile.c_str(), item.name.c_str()); + ServerInstance->Logs->Log("MODULE", DEFAULT, "Module is registering item %s in constructor; this does not handle exceptions correctly!", item.name.c_str()); switch (item.service) { @@ -524,6 +525,14 @@ void InspIRCd::SendMode(const std::vector& parameters, User *user) this->Modes->Process(parameters, user); } + +void InspIRCd::SendGlobalMode(const std::vector& parameters, User *user) +{ + Modes->Process(parameters, user); + if (!Modes->GetLastParse().empty()) + this->PI->SendMode(parameters[0], Modes->GetLastParseParams(), Modes->GetLastParseTranslate()); +} + bool InspIRCd::AddResolver(Resolver* r, bool cached) { if (!cached) @@ -558,6 +567,8 @@ const std::vector ModuleManager::GetAllModuleNames(int filter) ConfigReader::ConfigReader() { this->error = 0; + ServerInstance->Logs->Log("MODULE", DEBUG, "ConfigReader is deprecated in 2.0; " + "use ServerInstance->Config->ConfValue(\"key\") or ->ConfTags(\"key\") instead"); } @@ -675,13 +686,27 @@ void FileReader::CalcSize() void FileReader::LoadFile(const std::string &filename) { - file_cache c; - c.clear(); - if (ServerInstance->Config->ReadFile(c,filename.c_str())) + std::map::iterator file = ServerInstance->Config->Files.find(filename); + if (file != ServerInstance->Config->Files.end()) + { + this->fc = file->second; + } + else { - this->fc = c; - this->CalcSize(); + fc.clear(); + FILE* f = fopen(filename.c_str(), "r"); + if (!f) + return; + char linebuf[MAXBUF*10]; + while (fgets(linebuf, sizeof(linebuf), f)) + { + int len = strlen(linebuf); + if (len) + fc.push_back(std::string(linebuf, len - 1)); + } + fclose(f); } + CalcSize(); }