/** 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. A pointer to this module
- * is given in Module* proto, so that you may call its methods such as ProtoSendMode
- * (see below). This function will be called for every user visible on your side
- * of the burst, allowing you to for example set modes, etc. Do not use this call to
- * synchronize data which you have stored using class Extensible -- There is a specialist
- * function OnSyncUserMetaData and OnSyncChannelMetaData for this!
+ * 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 proto A pointer to the module handling network protocol
- * @param opaque An opaque pointer set by the protocol module, should not be modified!
+ * @param server The target of the burst
*/
- virtual void OnSyncUser(User* user, Module* proto, void* opaque);
+ 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. A pointer to this module
- * is given in Module* proto, so that you may call its methods such as ProtoSendMode
- * (see below). This function will be called for every user visible on your side
- * of the burst, allowing you to for example set modes, etc.
+ * 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 proto A pointer to the module handling network protocol
- * @param opaque An opaque pointer set by the protocol module, should not be modified!
+ * @param server The target of the burst
*/
- virtual void OnSyncChannel(Channel* chan, Module* proto, void* opaque);
+ virtual void OnSyncChannel(Channel* chan, ProtocolServer& server);
- /* Allows modules to syncronize metadata not related to users or channels, over the network during a netburst.
- * Whenever the linking module wants to send out data, but doesnt know what the data
- * represents (e.g. it is Extensible metadata, added to a User or Channel by a module) then
- * this method is called. You should use the ProtoSendMetaData function after you've
- * correctly decided how the data should be represented, to send the metadata on its way if
- * if it belongs to your module.
- * @param proto A pointer to the module handling network protocol
- * @param opaque An opaque pointer set by the protocol module, should not be modified!
- * @param displayable If this value is true, the data is going to be displayed to a user,
- * and not sent across the network. Use this to determine wether or not to show sensitive data.
+ /** 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(Module* proto, void* opaque);
+ 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.
*/
virtual void OnDecodeMetaData(Extensible* target, const std::string &extname, const std::string &extdata);
- /** Implemented by modules which provide the ability to link servers.
- * These modules will implement this method, which allows transparent sending of servermodes
- * down the network link as a broadcast, without a module calling it having to know the format
- * of the MODE command before the actual mode string.
- *
- * @param opaque An opaque pointer set by the protocol module, should not be modified!
- * @param target_type The type of item to decode data for, TYPE_USER or TYPE_CHANNEL
- * @param target The Channel* or User* that modes should be sent for
- * @param modeline The modes and parameters to be sent
- * @param translate The translation types of the mode parameters
- */
- virtual void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::vector<std::string> &modeline, const std::vector<TranslateType> &translate);
-
- /** Implemented by modules which provide the ability to link servers.
- * These modules will implement this method, which allows metadata (extra data added to
- * user and channel records using class Extensible, Extensible::Extend, etc) to be sent
- * to other servers on a netburst and decoded at the other end by the same module on a
- * different server.
- *
- * More documentation to follow soon. Please see src/modules/m_swhois.cpp for example of
- * how to use this function.
- * @param opaque An opaque pointer set by the protocol module, should not be modified!
- * @param target The Channel* or User* that metadata should be sent for
- * @param extname The extension name to send metadata for
- * @param extdata Encoded data for this extension name, which will be encoded at the oppsite end by an identical module using OnDecodeMetaData
- */
- virtual void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata);
-
/** Called whenever a user's hostname is changed.
* This event triggers after the host has been set.
* @param user The user whos host is being changed
*/
class CoreExport ModuleManager
{
+ public:
+ typedef std::vector<ServiceProvider*> ServiceList;
+
private:
/** Holds a string describing the last module error to occur
*/
/** Internal unload module hook */
bool CanUnload(Module*);
+ /** Loads all core modules (cmd_*)
+ */
+ void LoadCoreModules(std::map<std::string, ServiceList>& servicemap);
+
+ /** Calls the Prioritize() method in all loaded modules
+ * @return True if all went well, false if a dependency loop was detected
+ */
+ bool PrioritizeHooks();
+
public:
typedef std::map<std::string, Module*> ModuleMap;
/** List of data services keyed by name */
std::multimap<std::string, ServiceProvider*> DataProviders;
+ /** A list of ServiceProviders waiting to be registered.
+ * Non-NULL when constructing a Module, NULL otherwise.
+ * When non-NULL ServiceProviders add themselves to this list on creation and the core
+ * automatically registers them (that is, call AddService()) after the Module is constructed,
+ * and before Module::init() is called.
+ * If a service is created after the construction of the Module (for example in init()) it
+ * has to be registered manually.
+ */
+ ServiceList* NewServices;
+
/** Simple, bog-standard, boring constructor.
*/
ModuleManager();
/** Unregister a service provided by a module */
void DelService(ServiceProvider&);
+ /** Register all services in a given ServiceList
+ * @param list The list containing the services to register
+ */
+ void AddServices(const ServiceList& list);
+
inline void AddServices(ServiceProvider** list, int count)
{
for(int i=0; i < count; i++)
{ \
return new y; \
} \
- extern "C" const char inspircd_src_version[] = VERSION " " REVISION;
+ extern "C" DllExport const char inspircd_src_version[] = VERSION " " REVISION;
#endif
#define COMMAND_INIT(c) MODULE_INIT(CommandModule<c>)