]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Move OnSync{Channel,Network,User} to ServerEventListener.
authorPeter Powell <petpow@saberuk.com>
Wed, 22 Nov 2017 12:37:20 +0000 (12:37 +0000)
committerPeter Powell <petpow@saberuk.com>
Sun, 3 Dec 2017 13:58:10 +0000 (13:58 +0000)
include/modules.h
include/modules/server.h
src/modules.cpp
src/modules/m_filter.cpp
src/modules/m_spanningtree/netburst.cpp

index ce2402964c4516a1f065f7b0d8a0255f53965017..5dee6bfb63c8293df7f26ca3fbeb2305bd8b157b 100644 (file)
@@ -230,8 +230,8 @@ enum Implementation
        I_OnUserConnect, I_OnUserQuit, I_OnUserDisconnect, I_OnUserJoin, I_OnUserPart,
        I_OnSendSnotice, I_OnUserPreJoin, I_OnUserPreKick, I_OnUserKick, I_OnOper, I_OnInfo,
        I_OnUserPreInvite, I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNick,
-       I_OnUserMessage, I_OnMode, I_OnSyncUser,
-       I_OnSyncChannel, I_OnDecodeMetaData, I_OnAcceptConnection, I_OnUserInit,
+       I_OnUserMessage, I_OnMode,
+       I_OnDecodeMetaData, I_OnAcceptConnection, I_OnUserInit,
        I_OnChangeHost, I_OnChangeName, I_OnAddLine, I_OnDelLine, I_OnExpireLine,
        I_OnUserPostNick, I_OnPreMode, I_On005Numeric, I_OnKill, I_OnLoadModule,
        I_OnUnloadModule, I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite,
@@ -239,7 +239,7 @@ enum Implementation
        I_OnStats, I_OnChangeLocalUserHost, I_OnPreTopicChange,
        I_OnPostTopicChange, I_OnPostConnect,
        I_OnChangeLocalUserGECOS, I_OnUserRegister, I_OnChannelPreDelete, I_OnChannelDelete,
-       I_OnPostOper, I_OnSyncNetwork, I_OnSetAway, I_OnPostCommand, I_OnPostJoin,
+       I_OnPostOper, I_OnSetAway, I_OnPostCommand, I_OnPostJoin,
        I_OnBuildNeighborList, I_OnGarbageCollect, I_OnSetConnectClass,
        I_OnText, I_OnPassCompare, I_OnNamesListItem, I_OnNumeric,
        I_OnPreRehash, I_OnModuleRehash, I_OnSendWhoLine, I_OnChangeIdent, I_OnSetUserIP,
@@ -581,40 +581,11 @@ class CoreExport Module : public classbase, public usecountbase
         */
        virtual void OnMode(User* user, User* usertarget, Channel* chantarget, const Modes::ChangeList& changelist, ModeParser::ModeProcessFlag processflags, const std::string& output_mode);
 
-       /** Allows modules to synchronize data which relates to users during a netburst.
-        * When this function is called, it will be called from the module which implements
-        * the linking protocol. This currently is m_spanningtree.so.
-        * This function will be called for every user visible on your side
-        * of the burst, allowing you to for example set modes, etc.
-        * @param user The user being syncronized
-        * @param server The target of the burst
-        */
-       virtual void OnSyncUser(User* user, ProtocolServer& server);
-
-       /** Allows modules to synchronize data which relates to channels during a netburst.
-        * When this function is called, it will be called from the module which implements
-        * the linking protocol. This currently is m_spanningtree.so.
-        * This function will be called for every channel visible on your side of the burst,
-        * allowing you to for example set modes, etc.
-        *
-        * @param chan The channel being syncronized
-        * @param server The target of the burst
-        */
-       virtual void OnSyncChannel(Channel* chan, ProtocolServer& server);
-
-       /** Allows modules to syncronize metadata not related to users or channels, over the network during a netburst.
-        * When the linking module has finished sending all data it wanted to send during a netburst, then
-        * this method is called. You should use the SendMetaData() function after you've
-        * correctly decided how the data should be represented, to send the data.
-        * @param server The target of the burst
-        */
-       virtual void OnSyncNetwork(ProtocolServer& server);
-
        /** Allows module data, sent via ProtoSendMetaData, to be decoded again by a receiving module.
         * Please see src/modules/m_swhois.cpp for a working example of how to use this method call.
         * @param target The Channel* or User* that data should be added to
         * @param extname The extension name which is being sent
-        * @param extdata The extension data, encoded at the other end by an identical module through OnSyncChannelMetaData or OnSyncUserMetaData
+        * @param extdata The extension data, encoded at the other end by an identical module
         */
        virtual void OnDecodeMetaData(Extensible* target, const std::string &extname, const std::string &extdata);
 
index 8e64a3b35f06217ce2677613526fcc14ff474ce1..99bd2ee1d26ecb44f2b6f8c2826fb45802016a36 100644 (file)
@@ -38,4 +38,24 @@ class ServerEventListener : public Events::ModuleEventListener
          * @param server Server that split
          */
        virtual void OnServerSplit(const Server* server) { }
+
+       /** Allows modules to synchronize user metadata during a netburst. This will
+        * be called for every user visible on your side of the burst.
+        * @param user The user being synchronized.
+        * @param server The target of the burst.
+        */
+       virtual void OnSyncUser(User* user, ProtocolServer& server) { }
+
+       /** Allows modules to synchronize channel metadata during a netburst. This will
+        * be called for every channel visible on your side of the burst.
+        * @param chan The channel being synchronized.
+        * @param server The target of the burst.
+        */
+       virtual void OnSyncChannel(Channel* chan, ProtocolServer& server) { }
+
+       /** Allows modules to synchronize network metadata during a netburst.
+        * @param server The target of the burst.
+        */
+       virtual void OnSyncNetwork(ProtocolServer& server) { }
+       
 };
index 65e0a53ca5a68e4bd31cf4e45e606831624b0eeb..f204f3fc1b1ae2a576e9c1afc8415fc0a23a6971 100644 (file)
@@ -116,9 +116,6 @@ 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, unsigned int, CUList&) { DetachEvent(I_OnUserInvite); }
 void           Module::OnPostTopicChange(User*, Channel*, const std::string&) { DetachEvent(I_OnPostTopicChange); }
-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::OnChangeHost(User*, const std::string&) { DetachEvent(I_OnChangeHost); }
 void           Module::OnChangeName(User*, const std::string&) { DetachEvent(I_OnChangeName); }
index 8e43d276755078620d738d726bfad1eb296bd7e8..27c511c1697b587da75fe05d87166b77c7e7e7f3 100644 (file)
@@ -23,6 +23,7 @@
 #include "inspircd.h"
 #include "xline.h"
 #include "modules/regex.h"
+#include "modules/server.h"
 
 enum FilterFlags
 {
@@ -154,7 +155,7 @@ class CommandFilter : public Command
        }
 };
 
-class ModuleFilter : public Module
+class ModuleFilter : public Module, public ServerEventListener
 {
        typedef insp::flat_set<std::string, irc::insensitive_swo> ExemptTargetSet;
 
@@ -292,7 +293,10 @@ bool ModuleFilter::AppliesToMe(User* user, FilterResult* filter, int iflags)
 }
 
 ModuleFilter::ModuleFilter()
-       : initing(true), filtcommand(this), RegexEngine(this, "regex")
+       : ServerEventListener(this)
+       , initing(true)
+       , filtcommand(this)
+       , RegexEngine(this, "regex")
 {
 }
 
index cdafa9dedfbb86361e8005815f32a1ca11db5ae1..5115c7aa8a670b1566acebf1e91ee2e8ebeeea1d 100644 (file)
@@ -27,6 +27,7 @@
 #include "treeserver.h"
 #include "main.h"
 #include "commands.h"
+#include "modules/server.h"
 
 /**
  * Creates FMODE messages, used only when syncing channels
@@ -122,7 +123,7 @@ void TreeSocket::DoBurst(TreeServer* s)
 
        // Send all xlines
        this->SendXLines();
-       FOREACH_MOD(OnSyncNetwork, (bs.server));
+       FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), ServerEventListener, OnSyncNetwork, (bs.server));
        this->WriteLine(CmdBuilder("ENDBURST"));
        ServerInstance->SNO->WriteToSnoMask('l',"Finished bursting to \2"+ s->GetName()+"\2.");
 
@@ -261,7 +262,7 @@ void TreeSocket::SyncChannel(Channel* chan, BurstState& bs)
                        this->WriteLine(CommandMetadata::Builder(chan, item->name, value));
        }
 
-       FOREACH_MOD(OnSyncChannel, (chan, bs.server));
+       FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), ServerEventListener, OnSyncChannel, (chan, bs.server));
 }
 
 void TreeSocket::SyncChannel(Channel* chan)
@@ -273,8 +274,6 @@ void TreeSocket::SyncChannel(Channel* chan)
 /** Send all users and their state, including oper and away status and global metadata */
 void TreeSocket::SendUsers(BurstState& bs)
 {
-       ProtocolInterface::Server& piserver = bs.server;
-
        const user_hash& users = ServerInstance->Users->GetUsers();
        for (user_hash::const_iterator u = users.begin(); u != users.end(); ++u)
        {
@@ -299,6 +298,6 @@ void TreeSocket::SendUsers(BurstState& bs)
                                this->WriteLine(CommandMetadata::Builder(user, item->name, value));
                }
 
-               FOREACH_MOD(OnSyncUser, (user, piserver));
+               FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), ServerEventListener, OnSyncUser, (user, bs.server));
        }
 }