]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules.cpp
Change the syntax of FOREACH macros to be less dumb.
[user/henk/code/inspircd.git] / src / modules.cpp
index 871bb94995cc696ac9e316a4bf4c134aa058f1e3..26e91f87694f1f383bda1699a080563bb004c785 100644 (file)
@@ -58,22 +58,11 @@ Version::Version(const std::string &desc, int flags, const std::string& linkdata
 {
 }
 
-Request::Request(Module* src, Module* dst, const char* idstr)
-: id(idstr), source(src), dest(dst)
-{
-}
-
-void Request::Send()
-{
-       if (dest)
-               dest->OnRequest(*this);
-}
-
 Event::Event(Module* src, const std::string &eventid) : source(src), id(eventid) { }
 
 void Event::Send()
 {
-       FOREACH_MOD(I_OnEvent,OnEvent(*this));
+       FOREACH_MOD(OnEvent, (*this));
 }
 
 // These declarations define the behavours of the base class Module (which does nothing at all)
@@ -98,7 +87,7 @@ void          Module::OnPreRehash(User*, const std::string&) { }
 void           Module::OnModuleRehash(User*, const std::string&) { }
 void           Module::OnRehash(User*) { }
 ModResult      Module::OnUserPreJoin(LocalUser*, Channel*, const std::string&, std::string&, const std::string&) { return MOD_RES_PASSTHRU; }
-void           Module::OnMode(User*, void*, int, const std::vector<std::string>&, const std::vector<TranslateType>&) { }
+void           Module::OnMode(User*, User*, Channel*, const std::vector<std::string>&, const std::vector<TranslateType>&) { }
 void           Module::OnOper(User*, const std::string&) { }
 void           Module::OnPostOper(User*, const std::string&, const std::string &) { }
 void           Module::OnInfo(User*) { }
@@ -114,7 +103,7 @@ void                Module::OnLoadModule(Module*) { }
 void           Module::OnUnloadModule(Module*) { }
 void           Module::OnBackgroundTimer(time_t) { }
 ModResult      Module::OnPreCommand(std::string&, std::vector<std::string>&, LocalUser*, bool, const std::string&) { return MOD_RES_PASSTHRU; }
-void           Module::OnPostCommand(const std::string&, const std::vector<std::string>&, LocalUser*, CmdResult, const std::string&) { }
+void           Module::OnPostCommand(Command*, const std::vector<std::string>&, LocalUser*, CmdResult, const std::string&) { }
 void           Module::OnUserInit(LocalUser*) { }
 ModResult      Module::OnCheckReady(LocalUser*) { return MOD_RES_PASSTHRU; }
 ModResult      Module::OnUserRegister(LocalUser*) { return MOD_RES_PASSTHRU; }
@@ -132,17 +121,10 @@ ModResult Module::OnChangeLocalUserHost(LocalUser*, const std::string&) { return
 ModResult      Module::OnChangeLocalUserGECOS(LocalUser*, const std::string&) { return MOD_RES_PASSTHRU; }
 ModResult      Module::OnPreTopicChange(User*, Channel*, const std::string&) { return MOD_RES_PASSTHRU; }
 void           Module::OnEvent(Event&) { }
-void           Module::OnRequest(Request&) { }
 ModResult      Module::OnPassCompare(Extensible* ex, const std::string &password, const std::string &input, const std::string& hashtype) { return MOD_RES_PASSTHRU; }
 void           Module::OnGlobalOper(User*) { }
 void           Module::OnPostConnect(User*) { }
-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&, MessageType) { }
-void           Module::OnRemoteKill(User*, User*, const std::string&, const std::string&) { }
 void           Module::OnUserInvite(User*, User*, Channel*, time_t) { }
 void           Module::OnPostTopicChange(User*, Channel*, const std::string&) { }
 void           Module::OnGetServerDescription(const std::string&, std::string&) { }
@@ -152,7 +134,6 @@ void                Module::OnSyncNetwork(Module*, void*) { }
 void           Module::ProtoSendMode(void*, TargetTypeFlags, void*, const std::vector<std::string>&, const std::vector<TranslateType>&) { }
 void           Module::OnDecodeMetaData(Extensible*, const std::string&, const std::string&) { }
 void           Module::ProtoSendMetaData(void*, Extensible*, const std::string&, const std::string&) { }
-void           Module::OnWallops(User*, const std::string&) { }
 void           Module::OnChangeHost(User*, const std::string&) { }
 void           Module::OnChangeName(User*, const std::string&) { }
 void           Module::OnChangeIdent(User*, const std::string&) { }
@@ -348,7 +329,7 @@ void ModuleManager::DoSafeUnload(Module* mod)
        // First, notify all modules that a module is about to be unloaded, so in case
        // they pass execution to the soon to be unloaded module, it will happen now,
        // i.e. before we unregister the services of the module being unloaded
-       FOREACH_MOD(I_OnUnloadModule,OnUnloadModule(mod));
+       FOREACH_MOD(OnUnloadModule, (mod));
 
        std::map<std::string, Module*>::iterator modfind = Modules.find(mod->ModuleSourceFile);
 
@@ -434,11 +415,14 @@ void ModuleManager::AddService(ServiceProvider& item)
                                throw ModuleException("Command "+std::string(item.name)+" already exists.");
                        return;
                case SERVICE_MODE:
-                       if (!ServerInstance->Modes->AddMode(static_cast<ModeHandler*>(&item)))
+               {
+                       ModeHandler* mh = static_cast<ModeHandler*>(&item);
+                       if (!ServerInstance->Modes->AddMode(mh))
                                throw ModuleException("Mode "+std::string(item.name)+" already exists.");
-                       DataProviders.insert(std::make_pair("mode/" + item.name, &item));
+                       DataProviders.insert(std::make_pair((mh->GetModeType() == MODETYPE_CHANNEL ? "mode/" : "umode/") + item.name, &item));
                        dynamic_reference_base::reset_all();
                        return;
+               }
                case SERVICE_METADATA:
                        if (!ServerInstance->Extensions.Register(static_cast<ExtensionItem*>(&item)))
                                throw ModuleException("Extension " + std::string(item.name) + " already exists.");
@@ -446,8 +430,8 @@ void ModuleManager::AddService(ServiceProvider& item)
                case SERVICE_DATA:
                case SERVICE_IOHOOK:
                {
-                       if (item.name.substr(0, 5) == "mode/")
-                               throw ModuleException("The \"mode/\" service name prefix is reserved.");
+                       if ((item.name.substr(0, 5) == "mode/") || (item.name.substr(0, 6) == "umode/"))
+                               throw ModuleException("The \"mode/\" and the \"umode\" service name prefixes are reserved.");
 
                        DataProviders.insert(std::make_pair(item.name, &item));
                        std::string::size_type slash = item.name.find('/');
@@ -552,13 +536,6 @@ void dynamic_reference_base::resolve()
                value = NULL;
 }
 
-void InspIRCd::SendGlobalMode(const std::vector<std::string>& parameters, User *user)
-{
-       Modes->Process(parameters, user);
-       if (!Modes->GetLastParse().empty())
-               this->PI->SendMode(parameters[0], Modes->GetLastParseParams(), Modes->GetLastParseTranslate());
-}
-
 Module* ModuleManager::Find(const std::string &name)
 {
        std::map<std::string, Module*>::iterator modfind = Modules.find(name);