X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fmodules.h;h=b428a5f8d3b14720c8507da74ed7ec01dd242ed0;hb=2cb47dd7920355b11edd664f7399ca69e0d5d0b4;hp=4f60d55e4a48761026449004b30544fc713fb1b2;hpb=c2ec183ffe0fd0db4fe3c06874a888f84738f49c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/modules.h b/include/modules.h index 4f60d55e4..b428a5f8d 100644 --- a/include/modules.h +++ b/include/modules.h @@ -1,18 +1,30 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2009-2010 Daniel De Graaf + * Copyright (C) 2006-2007, 2009 Dennis Friis + * Copyright (C) 2003-2008 Craig Edwards + * Copyright (C) 2008 Thomas Stagner + * Copyright (C) 2007 Robin Burchell + * Copyright (C) 2006-2007 Oliver Lupton + * Copyright (C) 2003 randomdan * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#ifndef __MODULES_H -#define __MODULES_H + +#ifndef MODULES_H +#define MODULES_H #include "dynamic.h" #include "base.h" @@ -94,10 +106,17 @@ struct ModResult { } }; -/** If you change the module API in any way, increment this value. - * This MUST be a pure integer, with no parenthesis +/** InspIRCd major version. + * 1.2 -> 102; 2.1 -> 201; 2.12 -> 212 */ -#define API_VERSION 141 +#define INSPIRCD_VERSION_MAJ 200 +/** InspIRCd API version. + * If you change any API elements, increment this value. This counter should be + * reset whenever the major version is changed. Modules can use these two values + * and numerical comparisons in preprocessor macros if they wish to support + * multiple versions of InspIRCd in one file. + */ +#define INSPIRCD_VERSION_API 1 /** * This #define allows us to call a method in all @@ -169,12 +188,8 @@ do { \ /** Holds a module's Version information. * The members (set by the constructor only) indicate details as to the version number * of a module. A class of type Version is returned by the GetVersion method of the Module class. - * - * The core provides only one implementation of the template, causing a run-time linking - * error when attempting to load a module compiled against a different API_VERSION. */ -template -class CoreExport VersionBase +class CoreExport Version { public: /** Module description @@ -189,19 +204,14 @@ class CoreExport VersionBase const std::string link_data; /** Simple module version */ - VersionBase(const std::string &desc, int flags = VF_NONE); + Version(const std::string &desc, int flags = VF_NONE); /** Complex version information, including linking compatability data */ - VersionBase(const std::string &desc, int flags, const std::string& linkdata); + Version(const std::string &desc, int flags, const std::string& linkdata); - virtual ~VersionBase() {} - - /** Return true if the module can link (default is identity comparison) */ - virtual bool CanLink(const std::string& other_data); + virtual ~Version() {} }; -typedef VersionBase Version; - /** The Request class is a unicast message directed at a given module. * When this class is properly instantiated it may be sent to a module * using the Send() method, which will call the given module's OnRequest @@ -287,6 +297,7 @@ class CoreExport dynamic_reference_base : public interfacebase void SetProvider(const std::string& newname); void lookup(); operator bool(); + static void reset_all(); }; template @@ -305,7 +316,7 @@ class dynamic_reference : public dynamic_reference_base /** Priority types which can be used by Module::Prioritize() */ -enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFORE, PRIORITY_AFTER }; +enum Priority { PRIORITY_FIRST, PRIORITY_LAST, PRIORITY_BEFORE, PRIORITY_AFTER }; /** Implementation-specific flags which may be set in Module::Implements() */ @@ -327,7 +338,7 @@ enum Implementation I_OnPostOper, I_OnSyncNetwork, I_OnSetAway, I_OnPostCommand, I_OnPostJoin, I_OnWhoisLine, I_OnBuildNeighborList, I_OnGarbageCollect, I_OnSetConnectClass, I_OnText, I_OnPassCompare, I_OnRunTestSuite, I_OnNamesListItem, I_OnNumeric, I_OnHookIO, - I_OnPreRehash, I_OnModuleRehash, I_OnSendWhoLine, I_OnChangeIdent, I_OnChannelRestrictionApply, + I_OnPreRehash, I_OnModuleRehash, I_OnSendWhoLine, I_OnChangeIdent, I_END }; @@ -1274,16 +1285,9 @@ class CoreExport Module : public classbase, public usecountbase * @param source The user running the /WHO query * @param params The parameters to the /WHO query * @param user The user that this line of the query is about - * @param channel The channel being queried (or NULL if not a channel query) * @param line The raw line to send; modifiable, if empty no line will be returned. */ - virtual void OnSendWhoLine(User* source, const std::vector& params, User* user, Channel* channel, std::string& line); - - /** Called to check whether a channel restriction mode applies to a user on it - * @return MOD_RES_DENY to apply the restriction, MOD_RES_ALLOW to bypass - * the restriction, or MOD_RES_PASSTHRU to check restriction status normally - */ - virtual ModResult OnChannelRestrictionApply(User* user, Channel* chan, const char* restriction); + virtual void OnSendWhoLine(User* source, const std::vector& params, User* user, std::string& line); }; @@ -1498,9 +1502,6 @@ class CoreExport ModuleManager /** List of data services keyed by name */ std::multimap DataProviders; - /** List of all dynamic references that are currently active */ - std::vector ActiveDynrefs; - /** Simple, bog-standard, boring constructor. */ ModuleManager(); @@ -1521,16 +1522,17 @@ class CoreExport ModuleManager * PRIO_FIRST to set the event to be first called, PRIO_LAST to * set it to be the last called, or PRIO_BEFORE and PRIORITY_AFTER * to set it to be before or after one or more other modules. - * @param modules If PRIO_BEFORE or PRIORITY_AFTER is set in parameter 's', - * then this contains a list of one or more modules your module must be - * placed before or after. Your module will be placed before the highest - * priority module in this list for PRIO_BEFORE, or after the lowest - * priority module in this list for PRIORITY_AFTER. - * @param sz The number of modules being passed for PRIO_BEFORE and PRIORITY_AFTER. - * Defaults to 1, as most of the time you will only want to prioritize your module - * to be before or after one other module. + * @param which If PRIO_BEFORE or PRIORITY_AFTER is set in parameter 's', + * then this contains a the module that your module must be placed before + * or after. */ - bool SetPriority(Module* mod, Implementation i, Priority s, Module** modules = NULL, size_t sz = 1); + bool SetPriority(Module* mod, Implementation i, Priority s, Module* which = NULL); + + /** Backwards compat interface */ + inline bool SetPriority(Module* mod, Implementation i, Priority s, Module** dptr) + { + return SetPriority(mod, i, s, *dptr); + } /** Change the priority of all events in a module. * @param mod The module to set the priority of @@ -1620,6 +1622,9 @@ class CoreExport ModuleManager /** Register a service provided by a module */ void AddService(ServiceProvider&); + /** Unregister a service provided by a module */ + void DelService(ServiceProvider&); + inline void AddServices(ServiceProvider** list, int count) { for(int i=0; i < count; i++) @@ -1651,9 +1656,9 @@ class CoreExport ModuleManager #define MODULE_INIT_STR MODULE_INIT_STR_FN_2(MODULE_INIT_SYM) #define MODULE_INIT_STR_FN_2(x) MODULE_INIT_STR_FN_1(x) #define MODULE_INIT_STR_FN_1(x) #x -#define MODULE_INIT_SYM MODULE_INIT_SYM_FN_2(API_VERSION) -#define MODULE_INIT_SYM_FN_2(x) MODULE_INIT_SYM_FN_1(x) -#define MODULE_INIT_SYM_FN_1(x) inspircd_module_ ## x +#define MODULE_INIT_SYM MODULE_INIT_SYM_FN_2(INSPIRCD_VERSION_MAJ, INSPIRCD_VERSION_API) +#define MODULE_INIT_SYM_FN_2(x,y) MODULE_INIT_SYM_FN_1(x,y) +#define MODULE_INIT_SYM_FN_1(x,y) inspircd_module_ ## x ## _ ## y #ifdef PURE_STATIC @@ -1672,8 +1677,11 @@ struct AllModuleList { }; #define MODULE_INIT(x) static Module* MK_ ## x() { return new x; } \ - static const AllModuleList PREP_ ## x(&MK_ ## x, #x); + static const AllModuleList PREP_ ## x(&MK_ ## x, MODNAMESTR); +#define MODNAMESTR MODNAMESTR_FN_2(MODNAME) +#define MODNAMESTR_FN_2(x) MODNAMESTR_FN_1(x) +#define MODNAMESTR_FN_1(x) #x #else